assertEquals(mylocale2, null);
}
@Test
public void testLocaleProviderFromString() {
LocaleProvider lp = new LocaleProvider();
boolean illegaleArugmentOccured = false;
assertEquals("en_UK", lp.fromString("en-uk;q = .7").toString());
assertEquals("us__slang", lp.fromString("us-slang").toString());
assertEquals("en_UK_cockney", lp.fromString("en-uk-cockney").toString());
// only 2 letter language tags are allowed
try {
lp.fromString("abc-oaeu");
} catch (IllegalArgumentException e) {
illegaleArugmentOccured = true;
}
assertTrue(illegaleArugmentOccured);
illegaleArugmentOccured = false;
// the first sub-tag must not be longer than 8 chars
try {
lp.fromString("ab-abcdefghij");
} catch (IllegalArgumentException e) {
illegaleArugmentOccured = true;
}
assertTrue(illegaleArugmentOccured);
illegaleArugmentOccured = false;
// the first sub-tag must not be shorter than 2 chars
try {
lp.fromString("ab-a");
} catch (IllegalArgumentException e) {
illegaleArugmentOccured = true;
}
assertTrue(illegaleArugmentOccured);
}