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