1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html#License
3/*****************************************************************************************
4 *
5 *   Copyright (C) 1996-2014, International Business Machines
6 *   Corporation and others.  All Rights Reserved.
7 **/
8
9/**
10 * Port From:   JDK 1.4b1 : java.text.Format.IntlTestDateFormatSymbols
11 * Source File: java/text/format/IntlTestDateFormatSymbols.java
12 **/
13
14/*
15    @test 1.4 98/03/06
16    @summary test International Date Format Symbols
17*/
18
19package com.ibm.icu.dev.test.format;
20
21import java.util.Locale;
22
23import org.junit.Test;
24
25import com.ibm.icu.text.DateFormatSymbols;
26import com.ibm.icu.util.Calendar;
27import com.ibm.icu.util.ULocale;
28
29public class IntlTestDateFormatSymbols extends com.ibm.icu.dev.test.TestFmwk
30{
31    // Test getMonths
32    @Test
33    public void TestGetMonths()
34    {
35        final String[] month;
36        DateFormatSymbols symbol;
37
38        symbol=new DateFormatSymbols(Locale.getDefault());
39
40        month=symbol.getMonths();
41        int cnt = month.length;
42
43        logln("size = " + cnt);
44
45        for (int i=0; i<cnt; ++i)
46        {
47            logln(month[i]);
48        }
49    }
50
51    @Test
52    public void TestGetMonths2()
53    {
54        DateFormatSymbols symbol;
55        symbol=new DateFormatSymbols(Locale.getDefault());
56
57        int[] context = {DateFormatSymbols.STANDALONE, DateFormatSymbols.FORMAT};
58        int[] width = {DateFormatSymbols.WIDE, DateFormatSymbols.ABBREVIATED, DateFormatSymbols.NARROW};
59
60        for (int i = 0; i < context.length; i++) {
61            for (int j = 0; j < width.length; j++) {
62                String[] month =symbol.getMonths(context[i],width[j]);
63                int cnt = month.length;
64
65                logln("size = " + cnt);
66
67                for (int k = 0; k < month.length; k++) {
68                    logln(month[k]);
69                }
70            }
71        }
72    }
73
74    @Test
75    public void TestGetWeekdays2(){
76        DateFormatSymbols symbol;
77        symbol=new DateFormatSymbols(Locale.getDefault());
78
79        int[] context = {DateFormatSymbols.STANDALONE, DateFormatSymbols.FORMAT};
80        int[] width = {DateFormatSymbols.WIDE, DateFormatSymbols.ABBREVIATED, DateFormatSymbols.NARROW};
81
82        for (int i = 0; i < context.length; i++) {
83            for (int j = 0; j < width.length; j++) {
84                String[] wd =symbol.getWeekdays(context[i],width[j]);
85                int cnt = wd.length;
86
87                logln("size = " + cnt);
88
89                for (int k = 0; k < wd.length; k++) {
90                    logln(wd[k]);
91                }
92            }
93        }
94
95    }
96
97    @Test
98    public void TestGetEraNames(){
99        DateFormatSymbols symbol;
100        symbol=new DateFormatSymbols(Locale.getDefault());
101        String[] s = symbol.getEraNames();
102        for (int i = 0; i < s.length; i++) {
103            logln(s[i]);
104        }
105
106    }
107
108    private boolean UnicodeStringsArePrefixes(String[] prefixArray, String[] baseArray){
109        if (prefixArray.length != baseArray.length) {
110            return false;
111        }
112        int i;
113        for (i = 0; i < baseArray.length; i++) {
114            if (!baseArray[i].startsWith(prefixArray[i])) {
115                errln("ERROR: Mismatch example, index " + i + ": expect prefix \"" + prefixArray[i] + "\" of base \"" + baseArray[i] + "\".");
116            	return false;
117            }
118        }
119        return true;
120    }
121
122
123    // Test the API of DateFormatSymbols; primarily a simple get/set set.
124    @Test
125    public void TestSymbols()
126    {
127        DateFormatSymbols fr = new DateFormatSymbols(Locale.FRENCH);
128        DateFormatSymbols fr2 = new DateFormatSymbols(Locale.FRENCH);
129
130        DateFormatSymbols en = new DateFormatSymbols(Locale.ENGLISH);
131
132        DateFormatSymbols zhChiCal = new DateFormatSymbols(new ULocale("zh@calendar=chinese"));
133
134        if(en.equals(fr)) {
135            errln("ERROR: English DateFormatSymbols equal to French");
136        }
137
138        // just do some VERY basic tests to make sure that get/set work
139
140        long count;
141        final String[] eras = en.getEras();
142        fr.setEras(eras);
143        final String[] eras1 = fr.getEras();
144        count = eras.length;
145        if( count != eras1.length) {
146            errln("ERROR: setEras() failed (different size array)");
147        }
148        else {
149            for(int i = 0; i < count; i++) {
150                if(! eras[i].equals(eras1[i])) {
151                    errln("ERROR: setEras() failed (different string values)");
152                }
153            }
154        }
155
156
157        final String[] months = en.getMonths();
158        fr.setMonths(months);
159        final String[] months1 = fr.getMonths();
160        count = months.length;
161        if( count != months1.length) {
162            errln("ERROR: setMonths() failed (different size array)");
163        }
164        else {
165            for(int i = 0; i < count; i++) {
166                if(! months[i].equals(months1[i])) {
167                    errln("ERROR: setMonths() failed (different string values)");
168                }
169            }
170        }
171
172        final String[] shortMonths = en.getShortMonths();
173        fr.setShortMonths(shortMonths);
174        final String[] shortMonths1 = fr.getShortMonths();
175        count = shortMonths.length;
176        if( count != shortMonths1.length) {
177            errln("ERROR: setShortMonths() failed (different size array)");
178        }
179        else {
180            for(int i = 0; i < count; i++) {
181                if(! shortMonths[i].equals(shortMonths1[i])) {
182                    errln("ERROR: setShortMonths() failed (different string values)");
183                }
184            }
185        }
186
187        final String[] wideMonths = en.getMonths(DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
188        fr2.setMonths(wideMonths,DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
189        final String[] wideMonths1 = fr2.getMonths(DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
190        count = wideMonths.length;
191        if( count != wideMonths1.length) {
192            errln("ERROR: setMonths(FORMAT,WIDE) failed (different size array)");
193        }
194        else {
195            for(int i = 0; i < count; i++) {
196                if(! wideMonths[i].equals(wideMonths1[i])) {
197                    errln("ERROR: setMonths(FORMAT,WIDE) failed (different string values)");
198                }
199            }
200        }
201
202        final String[] abbrMonths = en.getMonths(DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
203        fr2.setMonths(abbrMonths,DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
204        final String[] abbrMonths1 = fr2.getMonths(DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
205        count = abbrMonths.length;
206        if( count != abbrMonths1.length) {
207            errln("ERROR: setMonths(FORMAT,ABBREVIATED) failed (different size array)");
208        }
209        else {
210            for(int i = 0; i < count; i++) {
211                if(! abbrMonths[i].equals(abbrMonths1[i])) {
212                    errln("ERROR: setMonths(FORMAT,ABBREVIATED) failed (different string values)");
213                }
214            }
215        }
216
217        final String[] narrowMonths = en.getMonths(DateFormatSymbols.FORMAT,DateFormatSymbols.NARROW);
218        fr.setMonths(narrowMonths,DateFormatSymbols.FORMAT,DateFormatSymbols.NARROW);
219        final String[] narrowMonths1 = fr.getMonths(DateFormatSymbols.FORMAT,DateFormatSymbols.NARROW);
220        count = narrowMonths.length;
221        if( count != narrowMonths1.length) {
222            errln("ERROR: setMonths(FORMAT,NARROW) failed (different size array)");
223        }
224        else {
225            for(int i = 0; i < count; i++) {
226                if(! narrowMonths[i].equals(narrowMonths1[i])) {
227                    errln("ERROR: setMonths(FORMAT,NARROW) failed (different string values)");
228                }
229            }
230        }
231
232        final String[] standaloneMonths = en.getMonths(DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
233        fr.setMonths(standaloneMonths,DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
234        final String[] standaloneMonths1 = fr.getMonths(DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
235        count = standaloneMonths.length;
236        if( count != standaloneMonths1.length) {
237            errln("ERROR: setMonths(STANDALONE,WIDE) failed (different size array)");
238        }
239        else {
240            for(int i = 0; i < count; i++) {
241                if(! standaloneMonths[i].equals(standaloneMonths1[i])) {
242                    errln("ERROR: setMonths(STANDALONE,WIDE) failed (different string values)");
243                }
244            }
245        }
246
247        final String[] standaloneShortMonths = en.getMonths(DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
248        fr.setMonths(standaloneShortMonths,DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
249        final String[] standaloneShortMonths1 = fr.getMonths(DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
250        count = standaloneShortMonths.length;
251        if( count != standaloneShortMonths1.length) {
252            errln("ERROR: setMonths(STANDALONE,ABBREVIATED) failed (different size array)");
253        }
254        else {
255            for(int i = 0; i < count; i++) {
256                if(! standaloneShortMonths[i].equals(standaloneShortMonths1[i])) {
257                    errln("ERROR: setMonths(STANDALONE,ABBREVIATED) failed (different string values)");
258                }
259            }
260        }
261
262        final String[] standaloneNarrowMonths = en.getMonths(DateFormatSymbols.STANDALONE,DateFormatSymbols.NARROW);
263        fr.setMonths(standaloneNarrowMonths,DateFormatSymbols.STANDALONE,DateFormatSymbols.NARROW);
264        final String[] standaloneNarrowMonths1 = fr.getMonths(DateFormatSymbols.STANDALONE,DateFormatSymbols.NARROW);
265        count = standaloneNarrowMonths.length;
266        if( count != standaloneNarrowMonths1.length) {
267            errln("ERROR: setMonths(STANDALONE,NARROW) failed (different size array)");
268        }
269        else {
270            for(int i = 0; i < count; i++) {
271                if(! standaloneNarrowMonths[i].equals(standaloneNarrowMonths1[i])) {
272                    errln("ERROR: setMonths(STANDALONE,NARROW) failed (different string values)");
273                }
274            }
275        }
276
277        final String[] weekdays = en.getWeekdays();
278        fr.setWeekdays(weekdays);
279        final String[] weekdays1 = fr.getWeekdays();
280        count = weekdays.length;
281        if( count != weekdays1.length) {
282            errln("ERROR: setWeekdays() failed (different size array)");
283        }
284        else {
285            for(int i = 0; i < count; i++) {
286                if(! weekdays[i].equals(weekdays1[i])) {
287                    errln("ERROR: setWeekdays() failed (different string values)");
288                }
289            }
290        }
291
292        final String[] shortWeekdays = en.getShortWeekdays();
293        fr.setShortWeekdays(shortWeekdays);
294        final String[] shortWeekdays1 = fr.getShortWeekdays();
295        count = shortWeekdays.length;
296        if( count != shortWeekdays1.length) {
297            errln("ERROR: setShortWeekdays() failed (different size array)");
298        }
299        else {
300            for(int i = 0; i < count; i++) {
301                if(! shortWeekdays[i].equals(shortWeekdays1[i])) {
302                    errln("ERROR: setShortWeekdays() failed (different string values)");
303                }
304            }
305        }
306
307        final String[] wideWeekdays = en.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
308        fr2.setWeekdays(wideWeekdays,DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
309        final String[] wideWeekdays1 = fr2.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
310        count = wideWeekdays.length;
311        if( count != wideWeekdays1.length) {
312            errln("ERROR: setWeekdays(FORMAT,WIDE) failed (different size array)");
313        }
314        else {
315            for(int i = 0; i < count; i++) {
316                if(! wideWeekdays[i].equals(wideWeekdays1[i])) {
317                    errln("ERROR: setWeekdays(FORMAT,WIDE) failed (different string values)");
318                }
319            }
320        }
321
322        final String[] abbrWeekdays = en.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
323        final String[] shorterWeekdays = en.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.SHORT);
324        if ( !UnicodeStringsArePrefixes(shorterWeekdays, abbrWeekdays) ) {
325            errln("ERROR: English format short weekday names don't match prefixes of format abbreviated names");
326        }
327        fr2.setWeekdays(abbrWeekdays,DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
328        final String[] abbrWeekdays1 = fr2.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
329        count = abbrWeekdays.length;
330        if( count != abbrWeekdays1.length) {
331            errln("ERROR: setWeekdays(FORMAT,ABBREVIATED) failed (different size array)");
332        }
333        else {
334            for(int i = 0; i < count; i++) {
335                if(! abbrWeekdays[i].equals(abbrWeekdays1[i])) {
336                    errln("ERROR: setWeekdays(FORMAT,ABBREVIATED) failed (different string values)");
337                }
338            }
339        }
340
341        final String[] narrowWeekdays = en.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.NARROW);
342        fr.setWeekdays(narrowWeekdays,DateFormatSymbols.FORMAT,DateFormatSymbols.NARROW);
343        final String[] narrowWeekdays1 = fr.getWeekdays(DateFormatSymbols.FORMAT,DateFormatSymbols.NARROW);
344        count = narrowWeekdays.length;
345        if( count != narrowWeekdays1.length) {
346            errln("ERROR: setWeekdays(FORMAT,NARROW) failed (different size array)");
347        }
348        else {
349            for(int i = 0; i < count; i++) {
350                if(! narrowWeekdays[i].equals(narrowWeekdays1[i])) {
351                    errln("ERROR: setWeekdays(FORMAT,NARROW) failed (different string values)");
352                }
353            }
354        }
355
356        final String[] standaloneWeekdays = en.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
357        fr.setWeekdays(standaloneWeekdays,DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
358        final String[] standaloneWeekdays1 = fr.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
359        count = standaloneWeekdays.length;
360        if( count != standaloneWeekdays1.length) {
361            errln("ERROR: setWeekdays(STANDALONE,WIDE) failed (different size array)");
362        }
363        else {
364            for(int i = 0; i < count; i++) {
365                if(! standaloneWeekdays[i].equals(standaloneWeekdays1[i])) {
366                    errln("ERROR: setWeekdays(STANDALONE,WIDE) failed (different string values)");
367                }
368            }
369        }
370
371        final String[] standaloneShortWeekdays = en.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
372        final String[] standaloneShorterWeekdays = en.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.SHORT);
373        if ( !UnicodeStringsArePrefixes(standaloneShorterWeekdays, standaloneShortWeekdays) ) {
374            errln("ERROR: English standalone short weekday names don't match prefixes of standalone abbreviated names");
375        }
376        fr.setWeekdays(standaloneShortWeekdays,DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
377        final String[] standaloneShortWeekdays1 = fr.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
378        count = standaloneShortWeekdays.length;
379        if( count != standaloneShortWeekdays1.length) {
380            errln("ERROR: setWeekdays(STANDALONE,ABBREVIATED) failed (different size array)");
381        }
382        else {
383            for(int i = 0; i < count; i++) {
384                if(! standaloneShortWeekdays[i].equals(standaloneShortWeekdays1[i])) {
385                    errln("ERROR: setWeekdays(STANDALONE,ABBREVIATED) failed (different string values)");
386                }
387            }
388        }
389
390        final String[] standaloneNarrowWeekdays = en.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.NARROW);
391        fr.setWeekdays(standaloneNarrowWeekdays,DateFormatSymbols.STANDALONE,DateFormatSymbols.NARROW);
392        final String[] standaloneNarrowWeekdays1 = fr.getWeekdays(DateFormatSymbols.STANDALONE,DateFormatSymbols.NARROW);
393        count = standaloneNarrowWeekdays.length;
394        if( count != standaloneNarrowWeekdays1.length) {
395            errln("ERROR: setWeekdays(STANDALONE,NARROW) failed (different size array)");
396        }
397        else {
398            for(int i = 0; i < count; i++) {
399                if(! standaloneNarrowWeekdays[i].equals(standaloneNarrowWeekdays1[i])) {
400                    errln("ERROR: setWeekdays(STANDALONE,NARROW) failed (different string values)");
401                }
402            }
403        }
404
405        final String[] wideQuarters = en.getQuarters(DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
406        fr2.setQuarters(wideQuarters,DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
407        final String[] wideQuarters1 = fr2.getQuarters(DateFormatSymbols.FORMAT,DateFormatSymbols.WIDE);
408        count = wideQuarters.length;
409        if( count != wideQuarters1.length) {
410            errln("ERROR: setQuarters(FORMAT, WIDE) failed (different size array)");
411        }
412        else {
413            for(int i = 0; i < count; i++) {
414                if(! wideQuarters[i].equals(wideQuarters1[i])) {
415                    errln("ERROR: setQuarters(FORMAT, WIDE) failed (different string values)");
416                }
417            }
418        }
419
420        final String[] abbrQuarters = en.getQuarters(DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
421        fr2.setQuarters(abbrQuarters,DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
422        final String[] abbrQuarters1 = fr2.getQuarters(DateFormatSymbols.FORMAT,DateFormatSymbols.ABBREVIATED);
423        count = abbrQuarters.length;
424        if( count != abbrQuarters1.length) {
425            errln("ERROR: setQuarters(FORMAT, ABBREVIATED) failed (different size array)");
426        }
427        else {
428            for(int i = 0; i < count; i++) {
429                if(! abbrQuarters[i].equals(abbrQuarters1[i])) {
430                    errln("ERROR: setQuarters(FORMAT, ABBREVIATED) failed (different string values)");
431                }
432            }
433        }
434
435        final String[] standaloneQuarters = en.getQuarters(DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
436        fr.setQuarters(standaloneQuarters,DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
437        final String[] standaloneQuarters1 = fr.getQuarters(DateFormatSymbols.STANDALONE,DateFormatSymbols.WIDE);
438        count = standaloneQuarters.length;
439        if( count != standaloneQuarters1.length) {
440            errln("ERROR: setQuarters(STANDALONE, WIDE) failed (different size array)");
441        }
442        else {
443            for(int i = 0; i < count; i++) {
444                if(! standaloneQuarters[i].equals(standaloneQuarters1[i])) {
445                    errln("ERROR: setQuarters(STANDALONE, WIDE) failed (different string values)");
446                }
447            }
448        }
449
450        final String[] standaloneShortQuarters = en.getQuarters(DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
451        fr.setQuarters(standaloneShortQuarters,DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
452        final String[] standaloneShortQuarters1 = fr.getQuarters(DateFormatSymbols.STANDALONE,DateFormatSymbols.ABBREVIATED);
453        count = standaloneShortQuarters.length;
454        if( count != standaloneShortQuarters1.length) {
455            errln("ERROR: setQuarters(STANDALONE, ABBREVIATED) failed (different size array)");
456        }
457        else {
458            for(int i = 0; i < count; i++) {
459                if(! standaloneShortQuarters[i].equals(standaloneShortQuarters1[i])) {
460                    errln("ERROR: setQuarters(STANDALONE, ABBREVIATED) failed (different string values)");
461                }
462            }
463        }
464
465        final String[] ampms = en.getAmPmStrings();
466        fr.setAmPmStrings(ampms);
467        final String[] ampms1 = fr.getAmPmStrings();
468        count = ampms.length;
469        if( count != ampms1.length) {
470            errln("ERROR: setAmPmStrings() failed (different size array)");
471        }
472        else {
473            for(int i = 0; i < count; i++) {
474                if(! ampms[i].equals(ampms1[i])) {
475                    errln("ERROR: setAmPmStrings() failed (different string values)");
476                }
477            }
478        }
479
480        long rowCount = 0, columnCount = 0;
481        final String[][] strings = en.getZoneStrings();
482        fr.setZoneStrings(strings);
483        final String[][] strings1 = fr.getZoneStrings();
484        rowCount = strings.length;
485        for(int i = 0; i < rowCount; i++) {
486            columnCount = strings[i].length;
487            for(int j = 0; j < columnCount; j++) {
488                if( strings[i][j] != strings1[i][j] ) {
489                    errln("ERROR: setZoneStrings() failed");
490                }
491            }
492        }
493
494//        final String pattern = DateFormatSymbols.getPatternChars();
495
496        String localPattern; // pat1, pat2; //The variable is never used
497        localPattern = en.getLocalPatternChars();
498        fr.setLocalPatternChars(localPattern);
499        if(! en.getLocalPatternChars().equals(fr.getLocalPatternChars())) {
500            errln("ERROR: setLocalPatternChars() failed");
501        }
502
503
504        //DateFormatSymbols foo = new DateFormatSymbols(); //The variable is never used
505
506        en = (DateFormatSymbols) fr.clone();
507
508        if(! en.equals(fr)) {
509            errln("ERROR: Clone failed");
510        }
511
512        final String[] shortYearNames = zhChiCal.getYearNames(DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED);
513        final String[] narrowYearNames = zhChiCal.getYearNames(DateFormatSymbols.STANDALONE, DateFormatSymbols.NARROW);
514        if (shortYearNames == null || shortYearNames.length != 60 ||
515                !shortYearNames[0].equals("\u7532\u5B50") || !shortYearNames[59].equals("\u7678\u4EA5")) {
516            errln("ERROR: invalid FORMAT/ABBREVIATED year names from zh@calendar=chinese");
517        }
518        if (narrowYearNames == null || narrowYearNames.length != 60 ||
519                !narrowYearNames[0].equals("\u7532\u5B50") || !narrowYearNames[59].equals("\u7678\u4EA5")) {
520            errln("ERROR: invalid STANDALONE/NARROW year names from zh@calendar=chinese");
521        }
522        final String[] enGregoYearNames = en.getYearNames(DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED);
523        if (enGregoYearNames != null) {
524            errln("ERROR: yearNames not null for en");
525        }
526
527        final String[] shortZodiacNames = zhChiCal.getZodiacNames(DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED);
528        if (shortZodiacNames == null || shortZodiacNames.length != 12 ||
529                !shortZodiacNames[0].equals("\u9F20") || !shortZodiacNames[11].equals("\u732A")) {
530            errln("ERROR: invalid FORMAT/ABBREVIATED zodiac names from zh@calendar=chinese");
531        }
532
533        final String[] newZodiacNames = {"Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat","Monkey","Rooster","Dog","Pig"};
534        zhChiCal.setZodiacNames(newZodiacNames, DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED);
535        final String[] testZodiacNames = zhChiCal.getZodiacNames(DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED);
536        if (testZodiacNames == null || testZodiacNames.length != 12 ||
537                !testZodiacNames[0].equals("Rat") || !testZodiacNames[11].equals("Pig")) {
538            errln("ERROR: setZodiacNames then getZodiacNames not working for zh@calendar=chinese");
539        }
540
541        String leapMonthPatternFmtAbbrev = zhChiCal.getLeapMonthPattern(DateFormatSymbols.FORMAT, DateFormatSymbols.ABBREVIATED);
542        if (leapMonthPatternFmtAbbrev == null || !leapMonthPatternFmtAbbrev.equals("\u95F0{0}")) {
543            errln("ERROR: invalid FORMAT/ABBREVIATED leapMonthPattern from zh@calendar=chinese");
544        }
545    }
546
547    @Test
548    public void TestConstructorWithCalendar() {
549        ULocale[] TestLocales = {
550            new ULocale("en_US@calendar=gregorian"),
551            new ULocale("ja_JP@calendar=japanese"),
552            new ULocale("th_TH@calendar=buddhist"),
553            new ULocale("zh_TW@calendar=roc"),
554            new ULocale("ar_IR@calendar=persian"),
555            new ULocale("ar_EG@calendar=islamic"),
556            new ULocale("he_IL@calendar=hebrew"),
557            new ULocale("zh_CN@calendar=chinese"),
558            new ULocale("hi_IN@calendar=indian"),
559            new ULocale("ar_EG@calendar=coptic"),
560            new ULocale("am_ET@calendar=ethiopic"),
561        };
562
563        int i;
564
565        // calendars
566        Calendar[] calendars = new Calendar[TestLocales.length];
567        for (i = 0; i < TestLocales.length; i++) {
568            calendars[i] = Calendar.getInstance(TestLocales[i]);
569        }
570
571        // Creates an instance from a base locale + calendar
572        DateFormatSymbols[] symbols = new DateFormatSymbols[TestLocales.length];
573        for (i = 0; i < TestLocales.length; i++) {
574            symbols[i] = new DateFormatSymbols(calendars[i], new ULocale(TestLocales[i].getBaseName()));
575        }
576
577        // Compare an instance created from a base locale + calendar
578        // with an instance created from its base locale + calendar class
579        for (i = 0; i < TestLocales.length; i++) {
580            DateFormatSymbols dfs = new DateFormatSymbols(calendars[i].getClass(), new ULocale(TestLocales[i].getBaseName()));
581            if (!dfs.equals(symbols[i])) {
582                errln("FAIL: DateFormatSymbols created from a base locale and calendar instance"
583                        + " is different from one created from the same base locale and calendar class - "
584                        + TestLocales[i]);
585            }
586        }
587
588    }
589}
590