Author: sebb
Date: Sat Sep 22 12:33:25 2012
New Revision: 1388787

URL: http://svn.apache.org/viewvc?rev=1388787&view=rev
Log:
LANG-799 Add tests to show ParseException when default Locale is wrong

Modified:
    
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java

Modified: 
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
URL: 
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java?rev=1388787&r1=1388786&r2=1388787&view=diff
==============================================================================
--- 
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
 (original)
+++ 
commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
 Sat Sep 22 12:33:25 2012
@@ -1557,6 +1557,52 @@ public class DateUtilsTest {
                 dateParser.parse("December 2, 2001"));
     }
 
+    @Test
+    public void testLANG799_EN_OK() throws ParseException {
+        Locale dflt = Locale.getDefault();
+        Locale.setDefault(Locale.ENGLISH);
+        try {
+            DateUtils.parseDate("Wed, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM 
yyyy HH:mm:ss zzz");
+        } finally {
+            Locale.setDefault(dflt);            
+        }
+    }
+
+    // Parse German date with English Locale
+    @Test(expected=ParseException.class)
+    public void testLANG799_EN_FAIL() throws ParseException {
+        Locale dflt = Locale.getDefault();
+        Locale.setDefault(Locale.ENGLISH);
+        try {
+            DateUtils.parseDate("Mi, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM 
yyyy HH:mm:ss zzz");
+        } finally {
+            Locale.setDefault(dflt);            
+        }
+    }
+
+    @Test
+    public void testLANG799_DE_OK() throws ParseException {
+        Locale dflt = Locale.getDefault();
+        Locale.setDefault(Locale.GERMAN);
+        try {
+            DateUtils.parseDate("Mi, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM 
yyyy HH:mm:ss zzz");
+        } finally {
+            Locale.setDefault(dflt);            
+        }
+    }
+
+    // Parse English date with German Locale
+    @Test(expected=ParseException.class)
+    public void testLANG799_DE_FAIL() throws ParseException {
+        Locale dflt = Locale.getDefault();
+        Locale.setDefault(Locale.GERMAN);
+        try {
+            DateUtils.parseDate("Wed, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM 
yyyy HH:mm:ss zzz");
+        } finally {
+            Locale.setDefault(dflt);            
+        }
+    }
+
     /**
      * This checks that this is a 7 element iterator of Calendar objects
      * that are dates (no time), and exactly 1 day spaced after each other.


Reply via email to