use of org.javarosa.core.util.UnregisteredLocaleException in project javarosa by opendatakit.
the class LocalizerTest method testNullArgs.
public void testNullArgs() {
Localizer l = new Localizer();
l.addAvailableLocale("test");
TableLocaleSource table = new TableLocaleSource();
try {
l.addAvailableLocale(null);
fail("addAvailableLocale: Did not get expected null pointer exception");
} catch (NullPointerException npe) {
// expected
}
if (l.hasLocale(null)) {
fail("Localizer reports it contains null locale");
}
try {
l.registerLocaleResource(null, new TableLocaleSource());
fail("setLocaleData: Did not get expected null pointer exception");
} catch (NullPointerException npe) {
// expected
}
try {
l.registerLocaleResource("test", null);
fail("setLocaleData: Did not get expected null pointer exception");
} catch (NullPointerException npe) {
// expected
}
if (l.getLocaleData(null) != null) {
fail("getLocaleData: Localizer returns mappings for null locale");
}
try {
l.getLocaleMap(null);
fail("getLocaleMap: Did not get expected exception");
} catch (UnregisteredLocaleException nsee) {
// expected
}
try {
table.setLocaleMapping(null, "text");
fail("setLocaleMapping: Did not get expected null pointer exception");
} catch (NullPointerException npe) {
// expected
}
try {
table.setLocaleMapping(null, null);
fail("setLocaleMapping: Did not get expected null pointer exception");
} catch (NullPointerException npe) {
// expected
}
try {
l.hasMapping(null, "textID");
fail("hasMapping: Did not get expected exception");
} catch (UnregisteredLocaleException nsee) {
// expected
}
if (l.hasMapping("test", null)) {
fail("Localization reports it contains null mapping");
}
try {
l.destroyLocale(null);
fail("destroyLocale: Did not get expected null pointer exception");
} catch (NullPointerException npe) {
// expected
}
try {
l.getText("textID", (String) null);
fail("getText: Did not get expected exception");
} catch (UnregisteredLocaleException nsee) {
// expected
}
try {
l.getText(null, "test");
fail("getText: Did not get expected null pointer exception");
} catch (NullPointerException npe) {
// expected
}
}
use of org.javarosa.core.util.UnregisteredLocaleException in project javarosa by opendatakit.
the class LocalizerTest method testGetTextNoCurrentLocale.
public void testGetTextNoCurrentLocale() {
Localizer l = new Localizer();
TableLocaleSource table = new TableLocaleSource();
l.addAvailableLocale("test");
l.setDefaultLocale("test");
table.setLocaleMapping("textID", "text");
l.registerLocaleResource("test", table);
try {
l.getText("textID");
fail("Retrieved current locale text when current locale not set");
} catch (UnregisteredLocaleException nsee) {
// expected
}
}
Aggregations