changeset 884:f78b47850aa8

bugfix
author Devel 1
date Fri, 23 Mar 2018 11:03:24 +0100
parents 9cc298ac7305
children 64dbae6be412
files stress-tester/src/main/java/com/passus/st/utils/PeriodFormatter.java stress-tester/src/test/java/com/passus/st/utils/PeriodFormatterTest.java
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/utils/PeriodFormatter.java	Mon Feb 05 17:04:15 2018 +0100
+++ b/stress-tester/src/main/java/com/passus/st/utils/PeriodFormatter.java	Fri Mar 23 11:03:24 2018 +0100
@@ -1,7 +1,6 @@
 package com.passus.st.utils;
 
 import com.passus.commons.ConversionException;
-import java.text.ParseException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Locale;
@@ -56,6 +55,14 @@
         map.put("secs", "s");
         map.put("second", "s");
         map.put("seconds", "s");
+
+        // milliseconds
+        map.put("ms", "ms");
+        map.put("milli", "ms");
+        map.put("millis", "ms");
+        map.put("millisecond", "ms");
+        map.put("milliseconds", "ms");
+
         ALIAS = Collections.unmodifiableMap(map);
     }
 
@@ -68,7 +75,7 @@
     };
 
     private static final long[] CUMULATIVE = {
-        0L, 1000L, 60L * 1000L, 60L * 60L * 1000L, 24L * 60L * 60L * 1000L, 7L * 24L * 60L * 60L * 1000L
+        1L, 1000L, 60L * 1000L, 60L * 60L * 1000L, 24L * 60L * 60L * 1000L, 7L * 24L * 60L * 60L * 1000L
     };
 
     private final boolean printMillis;
--- a/stress-tester/src/test/java/com/passus/st/utils/PeriodFormatterTest.java	Mon Feb 05 17:04:15 2018 +0100
+++ b/stress-tester/src/test/java/com/passus/st/utils/PeriodFormatterTest.java	Fri Mar 23 11:03:24 2018 +0100
@@ -39,12 +39,14 @@
             assertEquals(instance.transform("0day", null), new Long(0), "Zero time with long unit description");
             assertEquals(instance.transform("0week", null), new Long(0), "Zero time with long unit description");
 
+            assertEquals(instance.transform("1ms", null), new Long(1), "String with short unit description.");
             assertEquals(instance.transform("1s", null), new Long(1 * 1000), "String with short unit description.");
             assertEquals(instance.transform("1m", null), new Long(1 * 60 * 1000), "String with short unit description.");
             assertEquals(instance.transform("1h", null), new Long(1 * 60 * 60 * 1000), "String with short unit description.");
             assertEquals(instance.transform("1d", null), new Long(1 * 24 * 60 * 60 * 1000), "String with short unit description.");
             assertEquals(instance.transform("1w", null), new Long(1 * 7L * 24L * 60L * 60L * 1000L), "String with short unit description.");
 
+            assertEquals(instance.transform("1milli", null), new Long(1), "String with long unit description.");
             assertEquals(instance.transform("1sec", null), new Long(1 * 1000), "String with long unit description.");
             assertEquals(instance.transform("1min", null), new Long(1 * 60 * 1000), "String with long unit description.");
             assertEquals(instance.transform("1hrs", null), new Long(1 * 60 * 60 * 1000), "String with long unit description.");
@@ -57,6 +59,7 @@
             assertEquals(instance.transform("86400000", null), new Long(1L * 24 * 60 * 60 * 1000), "String without time unit");
             assertEquals(instance.transform("604800000", null), new Long(1L * 7L * 24L * 60L * 60L * 1000L), "String without time unit");
 
+            assertEquals(instance.transform("59s 123ms", null), new Long(59123L));
             assertEquals(instance.transform("1h 59m 59s", null), new Long(2 * 60L * 60L * 1000L - 1000L));
 
             assertEquals(instance.transform("61s", null), new Long(61L * 1000L), "Exceeded time units");