ICU-5077 Make ICU4J Tests work on JDK 1.3
X-SVN-Rev: 19240
This commit is contained in:
parent
1576a34ce3
commit
77f7720c75
@ -1,6 +1,7 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -26,7 +27,9 @@ import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.Random;
|
||||
|
||||
//#ifdef FOUNDATION
|
||||
//## import com.ibm.icu.impl.Utility;
|
||||
//#endif
|
||||
/**
|
||||
* TestFmwk is a base class for tests that can be run conveniently from the
|
||||
* command line as well as under the Java test harness.
|
||||
@ -60,7 +63,11 @@ public class TestFmwk extends AbstractTestLog {
|
||||
}
|
||||
}
|
||||
protected void handleException(Throwable e){
|
||||
//#ifndef FOUNDATION
|
||||
Throwable ex = e.getCause();
|
||||
//#else
|
||||
//## Throwable ex = null;
|
||||
//#endif
|
||||
if(ex==null){
|
||||
ex = e;
|
||||
}
|
||||
@ -1008,7 +1015,12 @@ public class TestFmwk extends AbstractTestLog {
|
||||
}
|
||||
|
||||
public static TestParams create(String arglist, PrintWriter log) {
|
||||
//#ifndef FOUNDATION
|
||||
return create(arglist.split("\\s"), log);
|
||||
//#else
|
||||
//## return create(Utility.split(arglist, '\u0020'), log);
|
||||
//#endif
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,7 @@
|
||||
//##header
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2001-2004, International Business Machines Corporation and *
|
||||
* Copyright (C) 2001-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -11,6 +12,7 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.File;
|
||||
|
||||
public final class TestUtil {
|
||||
/**
|
||||
@ -61,9 +63,13 @@ public final class TestUtil {
|
||||
} catch (Throwable t) {
|
||||
IOException ex =
|
||||
new IOException("data resource '" + name + "' not found");
|
||||
//#ifndef FOUNDATION
|
||||
//initCause API was introduced in JDK 1.4
|
||||
ex.initCause(t);
|
||||
//t.printStackTrace();
|
||||
//#else
|
||||
//## t.printStackTrace();
|
||||
//#endif
|
||||
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
@ -231,4 +237,16 @@ public final class TestUtil {
|
||||
|
||||
lock.go();
|
||||
}
|
||||
public static BufferedReader openUTF8Reader(String dir, String filename) throws IOException {
|
||||
return openReader(dir,filename,"UTF-8");
|
||||
}
|
||||
public static BufferedReader openReader(String dir, String filename, String encoding) throws IOException {
|
||||
File file = new File(dir + filename);
|
||||
return new BufferedReader(
|
||||
new InputStreamReader(
|
||||
new FileInputStream(file),
|
||||
encoding),
|
||||
4*1024);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
//##header
|
||||
/**
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2005-2006, International Business Machines Corporation and *
|
||||
@ -16,6 +17,9 @@ import com.ibm.icu.dev.test.TestFmwk;
|
||||
import com.ibm.icu.impl.UTF32;
|
||||
import com.ibm.icu.text.*;
|
||||
import com.ibm.icu.util.VersionInfo;
|
||||
//#ifdef FOUNDATION
|
||||
//##import com.ibm.icu.impl.Utility;
|
||||
//#endif
|
||||
|
||||
import javax.xml.parsers.*;
|
||||
import org.w3c.dom.*;
|
||||
@ -56,9 +60,13 @@ public class TestCharsetDetector extends TestFmwk
|
||||
throw new Exception();
|
||||
}
|
||||
catch (Exception e) {
|
||||
//#ifndef FOUNDATION
|
||||
StackTraceElement failPoint = e.getStackTrace()[1];
|
||||
msg = "Test failure in file " + failPoint.getFileName() +
|
||||
" at line " + failPoint.getLineNumber();
|
||||
//#else
|
||||
//## msg = "Test failure " + e.getMessage() ;
|
||||
//#endif
|
||||
}
|
||||
errln(msg);
|
||||
}
|
||||
@ -117,7 +125,11 @@ public class TestCharsetDetector extends TestFmwk
|
||||
private void checkEncoding(String testString, String encoding, String id)
|
||||
{
|
||||
String enc = null, lang = null;
|
||||
//#ifndef FOUNDATION
|
||||
String[] split = encoding.split("/");
|
||||
//#else
|
||||
//## String[] split = Utility.split(encoding,'/');
|
||||
//#endif
|
||||
|
||||
enc = split[0];
|
||||
|
||||
@ -343,7 +355,11 @@ public class TestCharsetDetector extends TestFmwk
|
||||
|
||||
// Process test text with each encoding / language pair.
|
||||
String testString = testText.toString();
|
||||
//#ifndef FOUNDATION
|
||||
String[] encodingList = encodings.split(" ");
|
||||
//#else
|
||||
//## String[] encodingList = Utility.split(encodings, ' ');
|
||||
//#endif
|
||||
|
||||
for (int e = 0; e < encodingList.length; e += 1) {
|
||||
checkEncoding(testString, encodingList[e], id);
|
||||
|
@ -1,11 +1,13 @@
|
||||
//##header
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2002-2005, International Business Machines
|
||||
* Copyright (c) 2002-2006, International Business Machines
|
||||
* Corporation and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Author: Mark Davis
|
||||
**********************************************************************
|
||||
*/
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.cldr;
|
||||
|
||||
import java.io.File;
|
||||
@ -559,4 +561,5 @@ public class TestCLDRVsICU extends TestFmwk {
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
@ -1,11 +1,11 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.collator;
|
||||
|
||||
|
||||
@ -292,3 +292,5 @@ public class RandomCollator extends TestFmwk {
|
||||
};
|
||||
*/
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -40,7 +41,9 @@ public class TestAll extends TestGroup {
|
||||
"CollationMiscTest",
|
||||
"CollationChineseTest",
|
||||
"CollationServiceTest",
|
||||
//#ifndef FOUNDATION
|
||||
"RandomCollator",
|
||||
//#endif
|
||||
"UCAConformanceTest",
|
||||
// don't test Search API twice!
|
||||
//"com.ibm.icu.dev.test.search.SearchTest"
|
||||
|
@ -1,7 +1,7 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2004-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2004-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -14,7 +14,6 @@ import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
import com.ibm.icu.dev.test.util.BagFormatter;
|
||||
import com.ibm.icu.text.DateFormat;
|
||||
import com.ibm.icu.text.DateFormatSymbols;
|
||||
import com.ibm.icu.text.SimpleDateFormat;
|
||||
|
@ -1,9 +1,11 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2004, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.timezone;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -416,3 +418,5 @@ public class TimeZoneAliasTest extends TestFmwk {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#endif
|
||||
|
@ -1,9 +1,11 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -320,3 +322,4 @@ public class BNF {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
@ -1,9 +1,11 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -1083,3 +1085,4 @@ public class BagFormatter {
|
||||
this.fixName = fixName;
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
@ -1,9 +1,11 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.util;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -502,4 +504,5 @@ public final class CollectionUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
@ -1,9 +1,11 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.util;
|
||||
|
||||
import java.io.DataInput;
|
||||
@ -229,4 +231,5 @@ public final class DataInputCompressor implements ObjectInput {
|
||||
}
|
||||
return valuesList;
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
@ -1,9 +1,11 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.util;
|
||||
|
||||
import java.io.DataOutput;
|
||||
@ -208,4 +210,6 @@ public final class DataOutputCompressor implements ObjectOutput {
|
||||
if (object_index != null) object_index.put(s, new Integer(i++));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#endif
|
||||
|
@ -1,10 +1,14 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
package com.ibm.icu.dev.test.util;import java.io.BufferedReader;
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
@ -71,4 +75,5 @@ public class FileUtilities {
|
||||
public static String anchorize(String source) {
|
||||
return source.toLowerCase(Locale.ENGLISH).replaceAll("\\P{L}", "_");
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
@ -1,10 +1,11 @@
|
||||
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2004, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -412,4 +413,5 @@ public class ICUPropertyFactory extends UnicodeProperty.Factory {
|
||||
return Arrays.asList(names);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
@ -1,9 +1,11 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2004, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.util;
|
||||
|
||||
import java.util.Random;
|
||||
@ -237,4 +239,6 @@ public class TestBNF {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//#endif
|
||||
|
@ -1,9 +1,11 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2004, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.util;
|
||||
|
||||
// TODO integrate this into the test framework
|
||||
@ -240,4 +242,5 @@ public class TestBagFormatter {
|
||||
System.out.println(bf.showSetNames(propAlias + "with " + pattern, stuff));
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
@ -1,9 +1,11 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.util;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
@ -464,4 +466,5 @@ public class TestUtilities extends TestFmwk {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
@ -1,9 +1,11 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2004, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#ifndef FOUNDATION
|
||||
package com.ibm.icu.dev.test.util;
|
||||
|
||||
import java.text.ParsePosition;
|
||||
@ -315,4 +317,6 @@ public class Tokenizer {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#endif
|
||||
|
@ -1,6 +1,7 @@
|
||||
//##header
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2002-2005, International Business Machines Corporation and *
|
||||
* Copyright (C) 2002-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -11,6 +12,8 @@ import java.io.IOException;
|
||||
|
||||
import com.ibm.icu.text.Transliterator;
|
||||
|
||||
import com.ibm.icu.dev.test.TestUtil;
|
||||
|
||||
public class TransliteratorUtilities {
|
||||
public static boolean DEBUG = false;
|
||||
|
||||
@ -42,7 +45,11 @@ public class TransliteratorUtilities {
|
||||
Transliterator.registerInstance(t);
|
||||
if (DEBUG) System.out.println("Registered new Transliterator: " + id + ", " + rid);
|
||||
} catch (IOException e) {
|
||||
//#ifndef FOUNDATION
|
||||
throw (IllegalArgumentException) new IllegalArgumentException("Can't open " + dir + ", " + id).initCause(e);
|
||||
//#else
|
||||
//## throw (IllegalArgumentException) new IllegalArgumentException("Can't open " + dir + ", " + id+" "+ e.getMessage());
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +57,11 @@ public class TransliteratorUtilities {
|
||||
*
|
||||
*/
|
||||
public static String getFileContents(String dir, String filename) throws IOException {
|
||||
//#ifndef FOUNDATION
|
||||
BufferedReader br = BagFormatter.openUTF8Reader(dir, filename);
|
||||
//#else
|
||||
//## BufferedReader br = TestUtil.openUTF8Reader(dir, filename);
|
||||
//#endif
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
while (true) {
|
||||
String line = br.readLine();
|
||||
@ -60,6 +71,7 @@ public class TransliteratorUtilities {
|
||||
}
|
||||
br.close();
|
||||
return buffer.toString();
|
||||
|
||||
}
|
||||
|
||||
private static final String BASE_RULES =
|
||||
@ -137,4 +149,4 @@ the double-quote character (") as """.
|
||||
"any-html", HTML_RULES_ASCII, Transliterator.FORWARD);
|
||||
public static final Transliterator fromHTML = Transliterator.createFromRules(
|
||||
"html-any", HTML_RULES, Transliterator.REVERSE);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user