Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk Fauth2014-09-18 20:47:39 +0000
committerDirk Fauth2014-09-19 22:01:02 +0000
commitce9c389022c9affdcda2d97baa44d7216e3a4e2a (patch)
tree6bc2119546c89518ba09701044ab80c92c273eef /bundles/org.eclipse.osgi.tests
parentfbf81a373bf16b4c4a24623c0caa9d9d3922b85f (diff)
downloadrt.equinox.framework-ce9c389022c9affdcda2d97baa44d7216e3a4e2a.tar.gz
rt.equinox.framework-ce9c389022c9affdcda2d97baa44d7216e3a4e2a.tar.xz
rt.equinox.framework-ce9c389022c9affdcda2d97baa44d7216e3a4e2a.zip
Bug 444534 - Parsing of nl parameter will now always return a valid
Locale Change-Id: I24d2deb2ee31aa5fabcbcf87ddd314c765230991 Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
Diffstat (limited to 'bundles/org.eclipse.osgi.tests')
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/eclipseadaptor/LocaleTransformationTest.java127
1 files changed, 127 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/eclipseadaptor/LocaleTransformationTest.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/eclipseadaptor/LocaleTransformationTest.java
new file mode 100644
index 000000000..88a83a14f
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/eclipseadaptor/LocaleTransformationTest.java
@@ -0,0 +1,127 @@
+package org.eclipse.osgi.tests.eclipseadaptor;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Locale;
+import org.eclipse.osgi.internal.framework.EquinoxConfiguration;
+import org.junit.Test;
+
+public class LocaleTransformationTest {
+
+ @Test
+ public void testValidLanguageCountryVariant() {
+ String localeString = "de_DE_EURO";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("de", locale.getLanguage());
+ assertEquals("DE", locale.getCountry());
+ assertEquals("EURO", locale.getVariant());
+ }
+
+ @Test
+ public void testValidLanguageCountry() {
+ String localeString = "de_DE";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("de", locale.getLanguage());
+ assertEquals("DE", locale.getCountry());
+ assertEquals("", locale.getVariant());
+ }
+
+ @Test
+ public void testValidLanguage() {
+ String localeString = "de";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("de", locale.getLanguage());
+ assertEquals("", locale.getCountry());
+ assertEquals("", locale.getVariant());
+ }
+
+ @Test
+ public void testValidCountry() {
+ String localeString = "_DE";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("", locale.getLanguage());
+ assertEquals("DE", locale.getCountry());
+ assertEquals("", locale.getVariant());
+ }
+
+ @Test
+ public void testValidLanguageVariant() {
+ String localeString = "de__EURO";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("de", locale.getLanguage());
+ assertEquals("", locale.getCountry());
+ assertEquals("EURO", locale.getVariant());
+ }
+
+ @Test
+ public void testValidVariant() {
+ String localeString = "__EURO";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("", locale.getLanguage());
+ assertEquals("", locale.getCountry());
+ assertEquals("EURO", locale.getVariant());
+ }
+
+ @Test
+ public void testValidCountryVariant() {
+ String localeString = "_DE_EURO";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("", locale.getLanguage());
+ assertEquals("DE", locale.getCountry());
+ assertEquals("EURO", locale.getVariant());
+ }
+
+ @Test
+ public void testInvalidLanguage() {
+ String localeString = "1234";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("en", locale.getLanguage());
+ assertEquals("", locale.getCountry());
+ assertEquals("", locale.getVariant());
+ }
+
+ @Test
+ public void testInvalidOneLetterLanguage() {
+ String localeString = "a";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("en", locale.getLanguage());
+ assertEquals("", locale.getCountry());
+ assertEquals("", locale.getVariant());
+ }
+
+ @Test
+ public void testThreeLetterValidLanguage() {
+ String localeString = "kok";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("kok", locale.getLanguage());
+ assertEquals("", locale.getCountry());
+ assertEquals("", locale.getVariant());
+ }
+
+ @Test
+ public void testInvalidOneLetterCountry() {
+ String localeString = "_X";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("en", locale.getLanguage());
+ assertEquals("", locale.getCountry());
+ assertEquals("", locale.getVariant());
+ }
+
+ @Test
+ public void testInvalidThreeLetterCountry() {
+ String localeString = "_XXX";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("en", locale.getLanguage());
+ assertEquals("", locale.getCountry());
+ assertEquals("", locale.getVariant());
+ }
+
+ @Test
+ public void testValidNumericAreaCode() {
+ String localeString = "_029";
+ Locale locale = EquinoxConfiguration.toLocale(localeString, Locale.ENGLISH);
+ assertEquals("", locale.getLanguage());
+ assertEquals("029", locale.getCountry());
+ assertEquals("", locale.getVariant());
+ }
+}

Back to the top