use of java.util.MissingResourceException in project robovm by robovm.
the class MissingResourceExceptionTest method test_ConstructorLjava_lang_StringLjava_lang_StringLjava_lang_String.
/**
* java.util.MissingResourceException#MissingResourceException(java.lang.String,
* java.lang.String, java.lang.String)
*/
public void test_ConstructorLjava_lang_StringLjava_lang_StringLjava_lang_String() {
// Test for method java.util.MissingResourceException(java.lang.String,
// java.lang.String, java.lang.String)
assertNotNull(new MissingResourceException("Detail string", "Class name string", "Key string"));
assertNotNull(new MissingResourceException(null, "Class name string", "Key string"));
assertNotNull(new MissingResourceException("Detail string", null, "Key string"));
assertNotNull(new MissingResourceException("Detail string", "Class name string", null));
try {
ResourceBundle.getBundle("Non-ExistentBundle");
} catch (MissingResourceException e) {
return;
}
fail("Failed to generate expected exception");
}
use of java.util.MissingResourceException in project robovm by robovm.
the class Main method testIso3.
/*
* Test that we can set and get an ISO3 language code. Support for this
* is expected by the Android framework.
*/
static void testIso3() {
Locale loc;
loc = new Locale("en", "US");
System.out.println("loc: " + loc);
System.out.println(" iso3=" + loc.getISO3Language());
loc = new Locale("eng", "USA");
System.out.println("loc: " + loc);
try {
System.out.println(" iso3=" + loc.getISO3Language());
} catch (MissingResourceException mre) {
System.err.println("couldn't get iso3 language");
}
}
use of java.util.MissingResourceException in project robovm by robovm.
the class ResourceBundleTest method test_getBundleLjava_lang_StringLjava_util_Locale.
/**
* java.util.ResourceBundle#getBundle(java.lang.String,
* java.util.Locale)
*/
public void test_getBundleLjava_lang_StringLjava_util_Locale() {
ResourceBundle bundle;
String name = "tests.support.Support_TestResource";
Locale defLocale = Locale.getDefault();
Locale.setDefault(new Locale("en", "US"));
bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR", "VAR"));
assertEquals("Wrong bundle fr_FR_VAR", "frFRVARValue4", bundle.getString("parent4"));
bundle = ResourceBundle.getBundle(name, new Locale("fr", "FR", "v1"));
assertEquals("Wrong bundle fr_FR_v1", "frFRValue4", bundle.getString("parent4"));
bundle = ResourceBundle.getBundle(name, new Locale("fr", "US", "VAR"));
assertEquals("Wrong bundle fr_US_var", "frValue4", bundle.getString("parent4"));
bundle = ResourceBundle.getBundle(name, new Locale("de", "FR", "VAR"));
assertEquals("Wrong bundle de_FR_var", "enUSValue4", bundle.getString("parent4"));
Locale.setDefault(new Locale("fr", "FR", "VAR"));
bundle = ResourceBundle.getBundle(name, new Locale("de", "FR", "v1"));
assertEquals("Wrong bundle de_FR_var 2", "frFRVARValue4", bundle.getString("parent4"));
Locale.setDefault(new Locale("de", "US"));
bundle = ResourceBundle.getBundle(name, new Locale("de", "FR", "var"));
assertEquals("Wrong bundle de_FR_var 2", "parentValue4", bundle.getString("parent4"));
try {
ResourceBundle.getBundle(null, Locale.US);
fail("NullPointerException expected");
} catch (NullPointerException ee) {
//expected
}
try {
ResourceBundle.getBundle("blah", (Locale) null);
fail("NullPointerException expected");
} catch (NullPointerException ee) {
//expected
}
try {
ResourceBundle.getBundle("", new Locale("xx", "yy"));
fail("MissingResourceException expected");
} catch (MissingResourceException ee) {
//expected
}
}
use of java.util.MissingResourceException in project robovm by robovm.
the class ResourceBundleTest method test_getBundleLjava_lang_StringLjava_util_LocaleLjava_lang_ClassLoader.
/**
* java.util.ResourceBundle#getBundle(java.lang.String,
* java.util.Locale, java.lang.ClassLoader)
*/
@KnownFailure("It's not allowed to pass null as parent class loader to" + " a new ClassLoader anymore. Maybe we need to change" + " URLClassLoader to allow this? It's not specified.")
public void test_getBundleLjava_lang_StringLjava_util_LocaleLjava_lang_ClassLoader() {
String classPath = System.getProperty("java.class.path");
StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator);
Vector<URL> urlVec = new Vector<URL>();
String resPackage = Support_Resources.RESOURCE_PACKAGE;
try {
while (tok.hasMoreTokens()) {
String path = tok.nextToken();
String url;
if (new File(path).isDirectory())
url = "file:" + path + resPackage + "subfolder/";
else
url = "jar:file:" + path + "!" + resPackage + "subfolder/";
urlVec.addElement(new URL(url));
}
} catch (MalformedURLException e) {
}
URL[] urls = new URL[urlVec.size()];
for (int i = 0; i < urlVec.size(); i++) urls[i] = urlVec.elementAt(i);
URLClassLoader loader = new URLClassLoader(urls, null);
String name = Support_Resources.RESOURCE_PACKAGE_NAME + ".hyts_resource";
ResourceBundle bundle = ResourceBundle.getBundle(name, Locale.getDefault());
assertEquals("Wrong value read", "parent", bundle.getString("property"));
bundle = ResourceBundle.getBundle(name, Locale.getDefault(), loader);
assertEquals("Wrong cached value", "resource", bundle.getString("property"));
try {
ResourceBundle.getBundle(null, Locale.getDefault(), loader);
fail("NullPointerException expected");
} catch (NullPointerException ee) {
//expected
}
try {
ResourceBundle.getBundle(name, null, loader);
fail("NullPointerException expected");
} catch (NullPointerException ee) {
//expected
}
try {
ResourceBundle.getBundle(name, Locale.getDefault(), (ClassLoader) null);
fail("NullPointerException expected");
} catch (NullPointerException ee) {
//expected
}
try {
ResourceBundle.getBundle("", Locale.getDefault(), loader);
fail("MissingResourceException expected");
} catch (MissingResourceException ee) {
//expected
}
// Regression test for Harmony-3823
B bb = new B();
String s = bb.find("nonexistent");
s = bb.find("name");
assertEquals("Wrong property got", "Name", s);
}
use of java.util.MissingResourceException in project robovm by robovm.
the class ResourceBundleTest method test_getBundleLjava_lang_String.
public void test_getBundleLjava_lang_String() {
ResourceBundle bundle;
String name = "tests.support.Support_TestResource";
Locale defLocale = Locale.getDefault();
Locale.setDefault(new Locale("en", "US"));
bundle = ResourceBundle.getBundle(name);
assertEquals("enUSValue4", bundle.getString("parent4"));
Locale.setDefault(new Locale("fr", "FR", "v1"));
bundle = ResourceBundle.getBundle(name);
assertEquals("Wrong bundle fr_FR_v1", "frFRValue4", bundle.getString("parent4"));
Locale.setDefault(new Locale("fr", "US", "VAR"));
bundle = ResourceBundle.getBundle(name);
assertEquals("Wrong bundle fr_US_var", "frValue4", bundle.getString("parent4"));
Locale.setDefault(new Locale("de", "FR", "VAR"));
bundle = ResourceBundle.getBundle(name);
assertEquals("Wrong bundle de_FR_var", "parentValue4", bundle.getString("parent4"));
Locale.setDefault(new Locale("de", "FR", "v1"));
bundle = ResourceBundle.getBundle(name);
assertEquals("Wrong bundle de_FR_var 2", "parentValue4", bundle.getString("parent4"));
Locale.setDefault(new Locale("de", "FR", "var"));
bundle = ResourceBundle.getBundle(name);
assertEquals("Wrong bundle de_FR_var 2", "parentValue4", bundle.getString("parent4"));
try {
ResourceBundle.getBundle(null);
fail("NullPointerException expected");
} catch (NullPointerException ee) {
//expected
}
try {
ResourceBundle.getBundle("");
fail("MissingResourceException expected");
} catch (MissingResourceException ee) {
//expected
}
Locale.setDefault(defLocale);
}
Aggregations