add test for Duration when default locale and formatting locale differ

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/dd5b1335
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/dd5b1335
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/dd5b1335

Branch: refs/heads/master
Commit: dd5b133581c755d46faaa9c0e2350aa1a00f2295
Parents: 9dcaefe
Author: Carl-Eric Menzel <cmen...@apache.org>
Authored: Mon Nov 7 15:06:06 2016 +0100
Committer: Carl-Eric Menzel <cmen...@apache.org>
Committed: Mon Nov 7 15:52:44 2016 +0100

----------------------------------------------------------------------
 .../apache/wicket/util/time/DurationTest.java    | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/dd5b1335/wicket-util/src/test/java/org/apache/wicket/util/time/DurationTest.java
----------------------------------------------------------------------
diff --git 
a/wicket-util/src/test/java/org/apache/wicket/util/time/DurationTest.java 
b/wicket-util/src/test/java/org/apache/wicket/util/time/DurationTest.java
index d9b6392..47f3c4a 100644
--- a/wicket-util/src/test/java/org/apache/wicket/util/time/DurationTest.java
+++ b/wicket-util/src/test/java/org/apache/wicket/util/time/DurationTest.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue;
 
 import java.text.NumberFormat;
 import java.util.Locale;
+import java.util.Locale.Category;
 
 import org.apache.wicket.util.string.StringValueConversionException;
 import org.junit.Test;
@@ -74,6 +75,24 @@ public final class DurationTest
                assertEquals("12 hours", Duration.days(0.5).toString());
        }
 
+       @Test
+       public void formatLocale() throws Exception
+       {
+               final Locale oldFormatLocale = 
Locale.getDefault(Category.FORMAT);
+               final Locale oldDefaultLocale = Locale.getDefault();
+               try
+               {
+                       Locale.setDefault(Locale.US);
+                       Locale.setDefault(Category.FORMAT, Locale.GERMANY);
+                       assertEquals("should take formatting locale into 
account", "1,5 minutes", Duration.seconds(90)
+                                       .toString());
+               } finally
+               {
+                       Locale.setDefault(oldDefaultLocale);
+                       Locale.setDefault(Category.FORMAT, oldFormatLocale);
+               }
+       }
+
        /** */
        @Test
        public void testSleep()

Reply via email to