You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2012/09/07 08:43:57 UTC

svn commit: r1381904 - in /jmeter/trunk: src/functions/org/apache/jmeter/functions/IntSum.java src/functions/org/apache/jmeter/functions/LongSum.java test/src/org/apache/jmeter/functions/PackageTest.java

Author: pmouawad
Date: Fri Sep  7 06:43:57 2012
New Revision: 1381904

URL: http://svn.apache.org/viewvc?rev=1381904&view=rev
Log:
Rollback StringUtils#isNumeric test (thanks sebb for pointing this ! )
Added 2 tests in JUnit to detect these errors

Modified:
    jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java
    jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java
    jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java

Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java?rev=1381904&r1=1381903&r2=1381904&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/IntSum.java Fri Sep  7 06:43:57 2012
@@ -22,7 +22,6 @@ import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.engine.util.CompoundVariable;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.samplers.Sampler;
@@ -73,17 +72,11 @@ public class IntSum extends AbstractFunc
 
         try {
             // Has chances to be a var
-            if(StringUtils.isNumeric(varName)) {
-                sum += Integer.parseInt(varName);        
-                varName = null; // there is no variable name
-            }
+            sum += Integer.parseInt(varName);        
+            varName = null; // there is no variable name
         } catch(NumberFormatException ignored) {
-            // TODO Should this be a warning ?
-            if(log.isDebugEnabled()) {
-                if(StringUtils.isNumeric(varName)) {
-                    log.debug("Exception parsing "+varName + " as int, value will be considered a variable name and not included in sum");
-                }
-            }
+            // varName keeps its value and sum has not taken 
+            // into account non numeric or overflowing number
         }
 
         String totalString = Integer.toString(sum);

Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java?rev=1381904&r1=1381903&r2=1381904&view=diff
==============================================================================
--- jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java (original)
+++ jmeter/trunk/src/functions/org/apache/jmeter/functions/LongSum.java Fri Sep  7 06:43:57 2012
@@ -22,7 +22,6 @@ import java.util.Collection;
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.engine.util.CompoundVariable;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.samplers.Sampler;
@@ -73,17 +72,11 @@ public class LongSum extends AbstractFun
 
         try {
             // Has chances to be a var
-            if(StringUtils.isNumeric(varName)) {
-                sum += Long.parseLong(varName);
-                varName = null; // there is no variable name
-            }
+            sum += Long.parseLong(varName);
+            varName = null; // there is no variable name
         } catch(NumberFormatException ignored) {
-            // Should this be a warning ?
-            if(log.isDebugEnabled()) {
-                if(StringUtils.isNumeric(varName)) {
-                    log.debug("Exception parsing "+varName + " as long, value will be considered a variable name and not included in sum");
-                }
-            }
+            // varName keeps its value and sum has not taken 
+            // into account non numeric or overflowing number
         }
 
         String totalString = Long.toString(sum);

Modified: jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java?rev=1381904&r1=1381903&r2=1381904&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/functions/PackageTest.java Fri Sep  7 06:43:57 2012
@@ -927,6 +927,7 @@ public class PackageTest extends JMeterT
         checkSumNoVar(is,"3", new String[]{"1","2"});
         checkSum(is,"1", new String[]{"-1","1","1","1","-2","1"});
         checkSumNoVar(is,"1", new String[]{"-1","1","1","1","-2","1"});
+        checkSumNoVar(is,"-1", new String[]{"-1","1","1","1","-2","-1"});
         checkSum(is,maxIntVal, new String[]{maxIntVal,"0"});
         checkSum(is,minIntVal, new String[]{maxIntVal,"1"}); // wrap-round check
         }
@@ -937,6 +938,7 @@ public class PackageTest extends JMeterT
         checkSum(ls,"1", new String[]{"-1","1","1","1","-1","0"});
         checkSumNoVar(ls,"3", new String[]{"1","2"});
         checkSumNoVar(ls,"1", new String[]{"-1","1","1","1","-1","0"});
+        checkSumNoVar(ls,"0", new String[]{"-1","1","1","1","-1","-1"});
         String maxIntVal_1 = Long.toString(1+(long)Integer.MAX_VALUE);
         checkSum(ls,maxIntVal, new String[]{maxIntVal,"0"});
         checkSum(ls,maxIntVal_1, new String[]{maxIntVal,"1"}); // no wrap-round check