On 24.08.2010 12:41, Stephen Colebourne wrote:
Thats Bad. All the locale cases should be dealt with by a
setup/teardown of the locale, or try finally.

If you want to save me some time, you're welcome to look at the source
code and figure out whats up. The locale part is working in a lot of
other places. I don't expect to be able to fix this myself
immediately.

Stephen
Hi Stephen,

after digging into the code, it wasn't all that bad.

Some tests assumed the system's default locale to be set to english, as they pass "null" as the locale to some formatting routines. I fixed these spots. Find a small patch attached.

Do you have a few minutes of spare time to apply this to the trunk?

Best regards

Ansgar
Index: src/test/java/org/joda/time/TestLocalDateTime_Basics.java
===================================================================
--- src/test/java/org/joda/time/TestLocalDateTime_Basics.java   (revision 1410)
+++ src/test/java/org/joda/time/TestLocalDateTime_Basics.java   (revision )
@@ -38,6 +38,8 @@
 import org.joda.time.format.DateTimeFormat;
 import org.joda.time.format.DateTimeFormatter;
 
+import static java.util.Locale.ENGLISH;
+
 /**
  * This class is a Junit unit test for LocalDate.
  *
@@ -85,6 +87,8 @@
 
     private DateTimeZone zone = null;
 
+    private Locale systemDefaultLocale = null;
+
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
@@ -101,12 +105,16 @@
         DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW_UTC);
         zone = DateTimeZone.getDefault();
         DateTimeZone.setDefault(LONDON);
+        systemDefaultLocale = Locale.getDefault();
+        Locale.setDefault(ENGLISH);
     }
 
     protected void tearDown() throws Exception {
         DateTimeUtils.setCurrentMillisSystem();
         DateTimeZone.setDefault(zone);
         zone = null;
+        Locale.setDefault(systemDefaultLocale);
+        systemDefaultLocale = null;
     }
 
     //-----------------------------------------------------------------------
@@ -966,9 +974,9 @@
     //-----------------------------------------------------------------------
     public void testToString_String_Locale() {
         LocalDateTime test = new LocalDateTime(1970, 6, 9, 10, 20, 30, 40);
-        assertEquals("Tue 9/6", test.toString("EEE d/M", Locale.ENGLISH));
+        assertEquals("Tue 9/6", test.toString("EEE d/M", ENGLISH));
         assertEquals("mar. 9/6", test.toString("EEE d/M", Locale.FRENCH));
-        assertEquals("1970-06-09T10:20:30.040", test.toString(null, 
Locale.ENGLISH));
+        assertEquals("1970-06-09T10:20:30.040", test.toString(null, ENGLISH));
         assertEquals("Tue 9/6", test.toString("EEE d/M", null));
         assertEquals("1970-06-09T10:20:30.040", test.toString(null, null));
     }
Index: src/test/java/org/joda/time/TestLocalDateTime_Properties.java
===================================================================
--- src/test/java/org/joda/time/TestLocalDateTime_Properties.java       
(revision 1085)
+++ src/test/java/org/joda/time/TestLocalDateTime_Properties.java       
(revision )
@@ -22,6 +22,8 @@
 
 import org.joda.time.chrono.CopticChronology;
 
+import static java.util.Locale.ENGLISH;
+
 /**
  * This class is a Junit unit test for LocalDateTime.
  *
@@ -54,6 +56,8 @@
 
     private DateTimeZone zone = null;
 
+    private Locale systemDefaultLocale = null;
+
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
@@ -70,12 +74,16 @@
         DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
         zone = DateTimeZone.getDefault();
         DateTimeZone.setDefault(DateTimeZone.UTC);
+        systemDefaultLocale = Locale.getDefault();
+        Locale.setDefault(ENGLISH);
     }
 
     protected void tearDown() throws Exception {
         DateTimeUtils.setCurrentMillisSystem();
         DateTimeZone.setDefault(zone);
         zone = null;
+        Locale.setDefault(systemDefaultLocale);
+        systemDefaultLocale = null;
     }
 
     //-----------------------------------------------------------------------
Index: src/test/java/org/joda/time/TestLocalDate_Basics.java
===================================================================
--- src/test/java/org/joda/time/TestLocalDate_Basics.java       (revision 1556)
+++ src/test/java/org/joda/time/TestLocalDate_Basics.java       (revision )
@@ -40,6 +40,8 @@
 import org.joda.time.format.DateTimeFormat;
 import org.joda.time.format.DateTimeFormatter;
 
+import static java.util.Locale.ENGLISH;
+
 /**
  * This class is a Junit unit test for LocalDate.
  *
@@ -85,6 +87,8 @@
         
     private DateTimeZone zone = null;
 
+    private Locale systemDefaultLocale = null;
+
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
@@ -101,12 +105,16 @@
         DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
         zone = DateTimeZone.getDefault();
         DateTimeZone.setDefault(LONDON);
+        systemDefaultLocale = Locale.getDefault();
+        Locale.setDefault(ENGLISH);
     }
 
     protected void tearDown() throws Exception {
         DateTimeUtils.setCurrentMillisSystem();
         DateTimeZone.setDefault(zone);
         zone = null;
+        Locale.setDefault(systemDefaultLocale);
+        systemDefaultLocale = null;
     }
 
     //-----------------------------------------------------------------------
@@ -1098,9 +1106,9 @@
     //-----------------------------------------------------------------------
     public void testToString_String_Locale() {
         LocalDate test = new LocalDate(1970, 6, 9);
-        assertEquals("Tue 9/6", test.toString("EEE d/M", Locale.ENGLISH));
+        assertEquals("Tue 9/6", test.toString("EEE d/M", ENGLISH));
         assertEquals("mar. 9/6", test.toString("EEE d/M", Locale.FRENCH));
-        assertEquals("1970-06-09", test.toString(null, Locale.ENGLISH));
+        assertEquals("1970-06-09", test.toString(null, ENGLISH));
         assertEquals("Tue 9/6", test.toString("EEE d/M", null));
         assertEquals("1970-06-09", test.toString(null, null));
     }
Index: src/test/java/org/joda/time/TestYearMonthDay_Properties.java
===================================================================
--- src/test/java/org/joda/time/TestYearMonthDay_Properties.java        
(revision 1139)
+++ src/test/java/org/joda/time/TestYearMonthDay_Properties.java        
(revision )
@@ -24,6 +24,8 @@
 import org.joda.time.chrono.LenientChronology;
 import org.joda.time.chrono.StrictChronology;
 
+import static java.util.Locale.ENGLISH;
+
 /**
  * This class is a Junit unit test for YearMonthDay.
  *
@@ -49,6 +51,8 @@
         
     private DateTimeZone zone = null;
 
+    private Locale systemDefaultLocale = null;
+
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
@@ -65,12 +69,16 @@
         DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
         zone = DateTimeZone.getDefault();
         DateTimeZone.setDefault(DateTimeZone.UTC);
+        systemDefaultLocale = Locale.getDefault();
+        Locale.setDefault(ENGLISH);
     }
 
     protected void tearDown() throws Exception {
         DateTimeUtils.setCurrentMillisSystem();
         DateTimeZone.setDefault(zone);
         zone = null;
+        Locale.setDefault(systemDefaultLocale);
+        systemDefaultLocale = null;
     }
 
     //-----------------------------------------------------------------------
Index: src/test/java/org/joda/time/TestYearMonth_Properties.java
===================================================================
--- src/test/java/org/joda/time/TestYearMonth_Properties.java   (revision 1414)
+++ src/test/java/org/joda/time/TestYearMonth_Properties.java   (revision )
@@ -24,6 +24,8 @@
 import org.joda.time.chrono.LenientChronology;
 import org.joda.time.chrono.StrictChronology;
 
+import static java.util.Locale.ENGLISH;
+
 /**
  * This class is a Junit unit test for YearMonth.
  *
@@ -49,6 +51,8 @@
         
     private DateTimeZone zone = null;
 
+    private Locale systemDefaultLocale = null;
+
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
@@ -65,12 +69,16 @@
         DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
         zone = DateTimeZone.getDefault();
         DateTimeZone.setDefault(DateTimeZone.UTC);
+        systemDefaultLocale = Locale.getDefault();
+        Locale.setDefault(ENGLISH);
     }
 
     protected void tearDown() throws Exception {
         DateTimeUtils.setCurrentMillisSystem();
         DateTimeZone.setDefault(zone);
         zone = null;
+        Locale.setDefault(systemDefaultLocale);
+        systemDefaultLocale = null;
     }
 
     //-----------------------------------------------------------------------
Index: src/test/java/org/joda/time/TestLocalDate_Properties.java
===================================================================
--- src/test/java/org/joda/time/TestLocalDate_Properties.java   (revision 1139)
+++ src/test/java/org/joda/time/TestLocalDate_Properties.java   (revision )
@@ -24,6 +24,8 @@
 import org.joda.time.chrono.LenientChronology;
 import org.joda.time.chrono.StrictChronology;
 
+import static java.util.Locale.ENGLISH;
+
 /**
  * This class is a Junit unit test for YearMonthDay.
  *
@@ -49,6 +51,8 @@
         
     private DateTimeZone zone = null;
 
+    private Locale systemDefaultLocale = null;
+
     public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
     }
@@ -65,12 +69,16 @@
         DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
         zone = DateTimeZone.getDefault();
         DateTimeZone.setDefault(DateTimeZone.UTC);
+        systemDefaultLocale = Locale.getDefault();
+        Locale.setDefault(ENGLISH);
     }
 
     protected void tearDown() throws Exception {
         DateTimeUtils.setCurrentMillisSystem();
         DateTimeZone.setDefault(zone);
         zone = null;
+        Locale.setDefault(systemDefaultLocale);
+        systemDefaultLocale = null;
     }
 
     //-----------------------------------------------------------------------
------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to