commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject svn commit: r307279 - in /jakarta/commons/proper/lang/trunk/src: java/org/apache/commons/lang/LocaleUtils.java test/org/apache/commons/lang/LocaleUtilsTest.java
Date Sat, 08 Oct 2005 09:55:30 GMT
Author: scolebourne
Date: Sat Oct  8 02:55:25 2005
New Revision: 307279

URL: http://svn.apache.org/viewcvs?rev=307279&view=rev
Log:
Handle differences between JDK1.3 and JDK1.4

Modified:
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/LocaleUtilsTest.java

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java?rev=307279&r1=307278&r2=307279&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java (original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/LocaleUtils.java Sat
Oct  8 02:55:25 2005
@@ -70,11 +70,15 @@
      * locale object from it.</p>
      *
      * <pre>
-     *   LocaleUtils.toLocale("en")     = new Locale("en", "")
-     *   LocaleUtils.toLocale("en_GB")  = new Locale("en", "GB")
-     *   LocaleUtils.toLocale("en_GB_xxx")  = new Locale("en", "GB", "xxx")
+     *   LocaleUtils.toLocale("en")         = new Locale("en", "")
+     *   LocaleUtils.toLocale("en_GB")      = new Locale("en", "GB")
+     *   LocaleUtils.toLocale("en_GB_xxx")  = new Locale("en", "GB", "xxx")   (#)
      * </pre>
-     * 
+     *
+     * <p>(#) The behaviour of the JDK variant constructor changed between JDK1.3 and
JDK1.4.
+     * In JDK1.3, the constructor upper cases the variant, in JDK1.4, it doesn't.
+     * Thus, the result from getVariant() may vary depending on your JDK.</p>
+     *
      * <p>This method validates the input strictly.
      * The language code must be lowercase.
      * The country code must be uppercase.

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/LocaleUtilsTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/LocaleUtilsTest.java?rev=307279&r1=307278&r2=307279&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/LocaleUtilsTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/LocaleUtilsTest.java
Sat Oct  8 02:55:25 2005
@@ -220,9 +220,16 @@
      * Test toLocale() method.
      */
     public void testToLocale_3Part() {
-        assertValidToLocale("us_EN_a", "us", "EN", "a");
         assertValidToLocale("us_EN_A", "us", "EN", "A");
-        assertValidToLocale("us_EN_SFsafdFDsdfF", "us", "EN", "SFsafdFDsdfF");
+        // this isn't pretty, but was caused by a jdk bug it seems
+        // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4210525
+        if (SystemUtils.isJavaVersionAtLeast(1.4f)) {
+            assertValidToLocale("us_EN_a", "us", "EN", "a");
+            assertValidToLocale("us_EN_SFsafdFDsdfF", "us", "EN", "SFsafdFDsdfF");
+        } else {
+            assertValidToLocale("us_EN_a", "us", "EN", "A");
+            assertValidToLocale("us_EN_SFsafdFDsdfF", "us", "EN", "SFSAFDFDSDFF");
+        }
         
         try {
             LocaleUtils.toLocale("us_EN-a");
@@ -272,7 +279,7 @@
             new Locale[] {
                 LOCALE_EN_US_ZZZZ,
                 LOCALE_EN_US,
-                new Locale("en", "")});
+                LOCALE_EN});
     }        
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message