ICU-3842 make loading of data files independent of class name
X-SVN-Rev: 20201
This commit is contained in:
parent
cd7d48b2be
commit
208671aabb
@ -8,6 +8,7 @@
|
||||
package com.ibm.icu.dev.test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
@ -79,6 +80,7 @@ class ResourceModule implements TestDataModule {
|
||||
res = (ICUResourceBundle) UResourceBundle.getBundleInstance(baseName, localeName);
|
||||
info = getFromTable(res, INFO, ICUResourceBundle.TABLE);
|
||||
testData = getFromTable(res, TEST_DATA, ICUResourceBundle.TABLE);
|
||||
|
||||
} catch (MissingResourceException e){
|
||||
throw new DataModuleFormatError("Unable to find resource", e);
|
||||
}
|
||||
@ -232,7 +234,8 @@ class ResourceModule implements TestDataModule {
|
||||
|
||||
static ICUResourceBundle getFromTable(ICUResourceBundle res, String key, int[] expResTypes) throws DataModuleFormatError{
|
||||
assert_is (res != null && key != null && res.getType() == ICUResourceBundle.TABLE);
|
||||
ICUResourceBundle t = res.get(key);
|
||||
ICUResourceBundle t = res.get(key);
|
||||
|
||||
assert_not (t ==null);
|
||||
int type = t.getType();
|
||||
Arrays.sort(expResTypes);
|
||||
@ -298,13 +301,6 @@ class ResourceModule implements TestDataModule {
|
||||
throw new DataModuleFormatError("Unable to find resource", e);
|
||||
}
|
||||
|
||||
try{
|
||||
settings = getFromTable(res, SETTINGS, ICUResourceBundle.ARRAY);
|
||||
info = getFromTable(res, INFO, ICUResourceBundle.TABLE);
|
||||
} catch (MissingResourceException e){
|
||||
// do nothing, left them null;
|
||||
}
|
||||
|
||||
try {
|
||||
// unfortunately, actually, data can be either ARRAY or STRING
|
||||
header = getFromTable(res, HEADER, new int[]{ICUResourceBundle.ARRAY, ICUResourceBundle.STRING});
|
||||
@ -315,6 +311,13 @@ class ResourceModule implements TestDataModule {
|
||||
header = defaultHeader;
|
||||
}
|
||||
}
|
||||
try{
|
||||
settings = getFromTable(res, SETTINGS, ICUResourceBundle.ARRAY);
|
||||
info = getFromTable(res, INFO, ICUResourceBundle.TABLE);
|
||||
} catch (MissingResourceException e){
|
||||
// do nothing, left them null;
|
||||
settings = data;
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -361,22 +364,24 @@ class ResourceModule implements TestDataModule {
|
||||
}
|
||||
return t;
|
||||
}
|
||||
public Object getObject(String key) {
|
||||
|
||||
return res.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
private static class UArrayResource implements DataMap{
|
||||
private Map theMap;
|
||||
UArrayResource(ICUResourceBundle theHeader, ICUResourceBundle theData) throws DataModuleFormatError{
|
||||
assert_is (theHeader != null && theData != null);
|
||||
String[] header;
|
||||
String[] data;
|
||||
|
||||
String[] header;
|
||||
|
||||
header = getStringArrayHelper(theHeader);
|
||||
data = getStringArrayHelper(theData);
|
||||
if (data.length != header.length)
|
||||
if (theData.getSize() != header.length)
|
||||
throw new DataModuleFormatError("The count of Header and Data is mismatch.");
|
||||
theMap = new HashMap();
|
||||
for (int i = 0; i < header.length; i++) {
|
||||
theMap.put(header[i], data[i]);
|
||||
theMap.put(header[i], theData.get(i));
|
||||
}
|
||||
|
||||
}
|
||||
@ -384,5 +389,8 @@ class ResourceModule implements TestDataModule {
|
||||
public String getString(String key) {
|
||||
return (String)theMap.get(key);
|
||||
}
|
||||
public Object getObject(String key) {
|
||||
return theMap.get(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public interface TestDataModule {
|
||||
public interface DataMap {
|
||||
// public abstract boolean isDefined(String key);
|
||||
//
|
||||
// public abstract Object getObject(String key);
|
||||
public abstract Object getObject(String key);
|
||||
public abstract String getString(String key);
|
||||
// public abstract char getChar(String key);
|
||||
// public abstract int getInt(String key);
|
||||
|
@ -163,6 +163,7 @@ public class CollationTest extends ModuleTest{
|
||||
// ok i have to be careful here since it seems like we can have
|
||||
// multiple locales for each test
|
||||
String locale = settings.getString("TestLocale");
|
||||
|
||||
if (locale != null) {
|
||||
// this is a case where we have locale
|
||||
try {
|
||||
|
@ -16,7 +16,7 @@ public class ModuleTestSample extends ModuleTest {
|
||||
super("com/ibm/icu/dev/data/testdata/", "Test");
|
||||
}
|
||||
|
||||
// // standard loop, settings and cases
|
||||
// standard loop, settings and cases
|
||||
// public void Test01() {
|
||||
// while (nextSettings()) {
|
||||
// logln("--------");
|
||||
|
Loading…
Reference in New Issue
Block a user