[logback-dev] svn commit: r995 - in logback/trunk/logback-core/src: main/java/ch/qos/logback/core/util test/java/ch/qos/logback/core/util

noreply.ceki at qos.ch noreply.ceki at qos.ch
Thu Nov 23 16:10:06 CET 2006


Author: ceki
Date: Thu Nov 23 16:10:05 2006
New Revision: 995

Modified:
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/Duration.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/DurationTest.java

Log:
- accept 'seconde' as a valid way of specifying seconds
- test parsing of durations where the init is specified in upper case 

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/Duration.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/Duration.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/Duration.java	Thu Nov 23 16:10:05 2006
@@ -30,7 +30,7 @@
   private final static String DOUBLE_PART = "([0-9]*(.[0-9]+)?)";
   private final static int DOUBLE_GROUP = 1;
 
-  private final static String UNIT_PART = "(|millisecond|second|minute|hour|day)s?";
+  private final static String UNIT_PART = "(|millisecond|second(e)?|minute|hour|day)s?";
   private final static int UNIT_GROUP = 3;
 
   private static final Pattern DURATION_PATTERN = Pattern.compile(DOUBLE_PART
@@ -85,7 +85,7 @@
       double doubleValue = Double.valueOf(doubleStr);
       if (unitStr.equalsIgnoreCase("millisecond") || unitStr.length() == 0) {
         return buildByMilliseconds(doubleValue);
-      } else if (unitStr.equalsIgnoreCase("second")) {
+      } else if (unitStr.equalsIgnoreCase("second") || unitStr.equalsIgnoreCase("seconde")) {
         return buildBySeconds(doubleValue);
       } else if (unitStr.equalsIgnoreCase("minute")) {
         return buildByMinutes(doubleValue);

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/DurationTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/DurationTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/DurationTest.java	Thu Nov 23 16:10:05 2006
@@ -46,9 +46,24 @@
     }
     
     {
-      Duration d = Duration.valueOf("10 seconds");
+      Duration d = Duration.valueOf("10 SECOnds");
       assertEquals(10 * 1000, d.getMilliseconds());
     }
+
+    {
+      Duration d = Duration.valueOf("12seconde");
+      assertEquals(12 * 1000, d.getMilliseconds());
+    }
+
+    {
+      Duration d = Duration.valueOf("14 SECONDES");
+      assertEquals(14 * 1000, d.getMilliseconds());
+    }
+    
+    {
+      Duration d = Duration.valueOf("12second");
+      assertEquals(12 * 1000, d.getMilliseconds());
+    }
     
     {
       Duration d = Duration.valueOf("10.7 seconds");



More information about the logback-dev mailing list