Merge branch 'stable-0.7'
* stable-0.7: Fix NLS to build under Java 5
This commit is contained in:
commit
ab51665336
|
@ -53,9 +53,9 @@
|
|||
public class TestNLS extends TestCase {
|
||||
|
||||
public void testNLSLocale() {
|
||||
NLS.setLocale(Locale.ROOT);
|
||||
NLS.setLocale(NLS.ROOT_LOCALE);
|
||||
GermanTranslatedBundle bundle = GermanTranslatedBundle.get();
|
||||
assertEquals(Locale.ROOT, bundle.getEffectiveLocale());
|
||||
assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale());
|
||||
|
||||
NLS.setLocale(Locale.GERMAN);
|
||||
bundle = GermanTranslatedBundle.get();
|
||||
|
@ -63,10 +63,10 @@ public void testNLSLocale() {
|
|||
}
|
||||
|
||||
public void testJVMDefaultLocale() {
|
||||
Locale.setDefault(Locale.ROOT);
|
||||
Locale.setDefault(NLS.ROOT_LOCALE);
|
||||
NLS.useJVMDefaultLocale();
|
||||
GermanTranslatedBundle bundle = GermanTranslatedBundle.get();
|
||||
assertEquals(Locale.ROOT, bundle.getEffectiveLocale());
|
||||
assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale());
|
||||
|
||||
Locale.setDefault(Locale.GERMAN);
|
||||
NLS.useJVMDefaultLocale();
|
||||
|
@ -84,7 +84,7 @@ public void run() {
|
|||
}
|
||||
}
|
||||
|
||||
NLS.setLocale(Locale.ROOT);
|
||||
NLS.setLocale(NLS.ROOT_LOCALE);
|
||||
GermanTranslatedBundle mainThreadsBundle = GermanTranslatedBundle.get();
|
||||
T t = new T();
|
||||
t.start();
|
||||
|
@ -126,7 +126,7 @@ public void run() {
|
|||
}
|
||||
}
|
||||
|
||||
T t1 = new T(Locale.ROOT);
|
||||
T t1 = new T(NLS.ROOT_LOCALE);
|
||||
T t2 = new T(Locale.GERMAN);
|
||||
t1.start();
|
||||
t2.start();
|
||||
|
@ -135,7 +135,7 @@ public void run() {
|
|||
|
||||
assertNull("t1 was interrupted or barrier was broken", t1.e);
|
||||
assertNull("t2 was interrupted or barrier was broken", t2.e);
|
||||
assertEquals(Locale.ROOT, t1.bundle.getEffectiveLocale());
|
||||
assertEquals(NLS.ROOT_LOCALE, t1.bundle.getEffectiveLocale());
|
||||
assertEquals(Locale.GERMAN, t2.bundle.getEffectiveLocale());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,23 +54,23 @@ public class TestTranslationBundle extends TestCase {
|
|||
|
||||
public void testMissingPropertiesFile() {
|
||||
try {
|
||||
new NoPropertiesBundle().load(Locale.ROOT);
|
||||
new NoPropertiesBundle().load(NLS.ROOT_LOCALE);
|
||||
fail("Expected TranslationBundleLoadingException");
|
||||
} catch (TranslationBundleLoadingException e) {
|
||||
assertEquals(NoPropertiesBundle.class, e.getBundleClass());
|
||||
assertEquals(Locale.ROOT, e.getLocale());
|
||||
assertEquals(NLS.ROOT_LOCALE, e.getLocale());
|
||||
// pass
|
||||
}
|
||||
}
|
||||
|
||||
public void testMissingString() {
|
||||
try {
|
||||
new MissingPropertyBundle().load(Locale.ROOT);
|
||||
new MissingPropertyBundle().load(NLS.ROOT_LOCALE);
|
||||
fail("Expected TranslationStringMissingException");
|
||||
} catch (TranslationStringMissingException e) {
|
||||
assertEquals("nonTranslatedKey", e.getKey());
|
||||
assertEquals(MissingPropertyBundle.class, e.getBundleClass());
|
||||
assertEquals(Locale.ROOT, e.getLocale());
|
||||
assertEquals(NLS.ROOT_LOCALE, e.getLocale());
|
||||
// pass
|
||||
}
|
||||
}
|
||||
|
@ -78,24 +78,24 @@ public void testMissingString() {
|
|||
public void testNonTranslatedBundle() {
|
||||
NonTranslatedBundle bundle = new NonTranslatedBundle();
|
||||
|
||||
bundle.load(Locale.ROOT);
|
||||
assertEquals(Locale.ROOT, bundle.getEffectiveLocale());
|
||||
bundle.load(NLS.ROOT_LOCALE);
|
||||
assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale());
|
||||
assertEquals("Good morning {0}", bundle.goodMorning);
|
||||
|
||||
bundle.load(Locale.ENGLISH);
|
||||
assertEquals(Locale.ROOT, bundle.getEffectiveLocale());
|
||||
assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale());
|
||||
assertEquals("Good morning {0}", bundle.goodMorning);
|
||||
|
||||
bundle.load(Locale.GERMAN);
|
||||
assertEquals(Locale.ROOT, bundle.getEffectiveLocale());
|
||||
assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale());
|
||||
assertEquals("Good morning {0}", bundle.goodMorning);
|
||||
}
|
||||
|
||||
public void testGermanTranslation() {
|
||||
GermanTranslatedBundle bundle = new GermanTranslatedBundle();
|
||||
|
||||
bundle.load(Locale.ROOT);
|
||||
assertEquals(Locale.ROOT, bundle.getEffectiveLocale());
|
||||
bundle.load(NLS.ROOT_LOCALE);
|
||||
assertEquals(NLS.ROOT_LOCALE, bundle.getEffectiveLocale());
|
||||
assertEquals("Good morning {0}", bundle.goodMorning);
|
||||
|
||||
bundle.load(Locale.GERMAN);
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
* </pre>
|
||||
*/
|
||||
public class NLS {
|
||||
static final Locale ROOT_LOCALE = new Locale("", "", "");
|
||||
|
||||
private static final InheritableThreadLocal<NLS> local = new InheritableThreadLocal<NLS>() {
|
||||
protected NLS initialValue() {
|
||||
|
|
Loading…
Reference in New Issue