001: /*
002: ******************************************************************************
003: * Copyright (C) 2005, International Business Machines Corporation and *
004: * others. All Rights Reserved. *
005: ******************************************************************************
006: */
007: package com.ibm.icu.tests;
008:
009: import junit.framework.TestCase;
010: import com.ibm.icu.dev.test.TestAll;
011: import com.ibm.icu.dev.test.TestFmwk;
012: import com.ibm.icu.dev.test.TestFmwk.TestParams;
013:
014: //import com.ibm.icu.text.DateFormat;
015: //import com.ibm.icu.util.Calendar;
016: //import com.ibm.icu.util.GregorianCalendar;
017: //import com.ibm.icu.util.TimeZone;
018: //import com.ibm.icu.util.ULocale;
019:
020: public class UnitTest extends TestCase {
021:
022: public void testCalendar() throws Exception {
023: runUtility("Calendar");
024: }
025:
026: public void testCollator() throws Exception {
027: runUtility("Collator");
028: }
029:
030: public void testCompression() throws Exception {
031: runUtility("Compression");
032: }
033:
034: public void testDiagBigDecimal() throws Exception {
035: runUtility("DiagBigDecimal");
036: }
037:
038: public void testFormat() throws Exception {
039: runUtility("Format");
040: }
041:
042: public void testImpl() throws Exception {
043: runUtility("Impl");
044: }
045:
046: public void testNormalizer() throws Exception {
047: runUtility("Normalizer");
048: }
049:
050: public void testProperty() throws Exception {
051: runUtility("Property");
052: }
053:
054: public void testRBBI() throws Exception {
055: runUtility("RBBI");
056: }
057:
058: public void testSearchTest() throws Exception {
059: runUtility("SearchTest");
060: }
061:
062: public void testStringPrep() throws Exception {
063: runUtility("StringPrep");
064: }
065:
066: public void testTestCharsetDetector() throws Exception {
067: runUtility("TestCharsetDetector");
068: }
069:
070: public void testTestUCharacterIterator() throws Exception {
071: runUtility("TestUCharacterIterator");
072: }
073:
074: public void testTimeScale() throws Exception {
075: runUtility("TimeScale");
076: }
077:
078: public void testTimeZone() throws Exception {
079: runUtility("TimeZone");
080: }
081:
082: public void testTranslit() throws Exception {
083: runUtility("Translit");
084: }
085:
086: public void testUtil() throws Exception {
087: runUtility("Util");
088: }
089:
090: public void runUtility(String testname) throws Exception {
091: TestParams params = TestParams.create("-n", null);
092: TestFmwk test = new TestAll();
093: test.resolveTarget(params, testname).run();
094: if (params.errorCount > 0) {
095: fail(params.errorSummary.toString());
096: }
097: }
098:
099: // sample tests from ICU4J test suite
100:
101: // Calendar
102: // public void testCalendarSimple() throws Exception {
103: // TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
104: // GregorianCalendar gc = new GregorianCalendar(tz);
105: // gc.set(2005,9,17,14,15,33);
106: // Date time = gc.getTime();
107: //
108: // final String[] calendars = {
109: // "buddhist", "chinese", "coptic", "ethiopic", "gregorian",
110: // "hebrew", "islamic", "islamic-civil", "japanese"
111: // };
112: // final String[] ustimes = {
113: // "Monday, October 17, 2548 BE 2:15:33 PM PDT",
114: // "Monday 22x78-9-15 2:15:33 PM PDT",
115: // "Monday, Baba 7, 1722 2:15:33 PM PDT",
116: // "Monday, Tekemt 7, 1998 2:15:33 PM PDT",
117: // "Monday, October 17, 2005 2:15:33 PM PDT",
118: // "Monday, Tishri 14, 5766 2:15:33 PM PDT",
119: // "Monday, Ramadan 14, 1426 2:15:33 PM PDT",
120: // "Monday, Ramadan 14, 1426 2:15:33 PM PDT",
121: // "Monday, October 17, 17 Heisei 2:15:33 PM PDT",
122: // };
123: // final String[] detimes = {
124: // "Montag, Oktober 17, 2548 BE 2:15:33 nachm. GMT-07:00",
125: // "Montag 22x78-9-15 2:15:33 nachm. GMT-07:00",
126: // "Montag, 7. Baba 1722 14:15 Uhr GMT-07:00",
127: // "Montag, 7. Tekemt 1998 14:15 Uhr GMT-07:00",
128: // "Montag, 17. Oktober 2005 14:15 Uhr GMT-07:00",
129: // "Montag, 14. Tishri 5766 14:15 Uhr GMT-07:00",
130: // "Montag, 14. Ramadan 1426 14:15 Uhr GMT-07:00",
131: // "Montag, 14. Ramadan 1426 14:15 Uhr GMT-07:00",
132: // "Montag, Oktober 17, 17 Heisei 2:15:33 nachm. GMT-07:00",
133: // };
134: //
135: // ULocale[] locales = {ULocale.US, ULocale.GERMANY };
136: // String[][] times = { ustimes, detimes };
137: // for (int j = 0; j < locales.length; ++j) {
138: // ULocale ul = new ULocale("en_US");
139: // for (int i = 0; i < calendars.length; ++i) {
140: // ul = ul.setKeywordValue("calendar", calendars[i]);
141: // Calendar cal = Calendar.getInstance(ul);
142: // DateFormat fmt = cal.getDateTimeFormat(DateFormat.FULL, DateFormat.FULL, locales[j]);
143: // String result = fmt.format(time);
144: // System.out.println(calendars[i] + ": " + result);
145: // if (!result.equals(times[j][i])) {
146: // fail("calendar: " + calendars[i]);
147: // }
148: // }
149: // }
150: // }
151: }
|