diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-03-12 10:26:06 -0800 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-03-12 10:26:06 -0800 |
commit | 24875de6bd864fa7082e1c96bf8aebe9950c3e54 (patch) | |
tree | 458533c92b11a2ed96c11109393dd0c4437adb52 | |
parent | 2ae9a85045915a38af2c300aa1874304fd8ea17b (diff) | |
download | jgit-24875de6bd864fa7082e1c96bf8aebe9950c3e54.tar.gz jgit-24875de6bd864fa7082e1c96bf8aebe9950c3e54.zip |
Fix NLS to build under Java 5
The tests were using a Locale.ROOT constant which was introduced
in Java 6. However, we need to retain Java 5 support.
Change-Id: I75c5648fcfc728a9aea2e839d2ad0320f5cf742f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
CC: Sasa Zivkov <sasa.zivkov@sap.com>
3 files changed, 18 insertions, 17 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestNLS.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestNLS.java index b6377c9203..a01ed4e923 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestNLS.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestNLS.java @@ -53,9 +53,9 @@ import junit.framework.TestCase; 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 class TestNLS extends TestCase { } 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 class TestNLS extends TestCase { } } - NLS.setLocale(Locale.ROOT); + NLS.setLocale(NLS.ROOT_LOCALE); GermanTranslatedBundle mainThreadsBundle = GermanTranslatedBundle.get(); T t = new T(); t.start(); @@ -126,7 +126,7 @@ public class TestNLS extends TestCase { } } - 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 class TestNLS extends TestCase { 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()); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestTranslationBundle.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestTranslationBundle.java index 58b42c9d4a..7d713f2c1a 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestTranslationBundle.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/nls/TestTranslationBundle.java @@ -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 class TestTranslationBundle extends TestCase { 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); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java b/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java index ece20bdb36..f2e379e136 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/nls/NLS.java @@ -68,6 +68,7 @@ import org.eclipse.jgit.errors.TranslationStringMissingException; * </pre> */ public class NLS { + static final Locale ROOT_LOCALE = new Locale("", "", ""); private static final InheritableThreadLocal<NLS> local = new InheritableThreadLocal<NLS>() { protected NLS initialValue() { |