jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1444571 - in /jmeter/trunk: src/core/org/apache/jmeter/control/LoopController.java src/core/org/apache/jmeter/control/gui/LoopControlPanel.java test/src/org/apache/jmeter/control/TestLoopController.java
Date Sun, 10 Feb 2013 17:37:51 GMT
Author: pmouawad
Date: Sun Feb 10 17:37:50 2013
New Revision: 1444571

URL: http://svn.apache.org/r1444571
Log:
Bug 54467 - Loop controller Controller check conditions each request
Use constant for -1 special value
Bugzilla Id: 54467

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java
    jmeter/trunk/src/core/org/apache/jmeter/control/gui/LoopControlPanel.java
    jmeter/trunk/test/src/org/apache/jmeter/control/TestLoopController.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java?rev=1444571&r1=1444570&r2=1444571&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/control/LoopController.java Sun Feb 10 17:37:50
2013
@@ -31,6 +31,8 @@ import org.apache.jmeter.testelement.pro
  */
 public class LoopController extends GenericController implements Serializable {
 
+    public static final int INFINITE_LOOP_COUNT = -1; // $NON-NLS-1$
+    
     public static final String LOOPS = "LoopController.loops"; // $NON-NLS-1$
 
     private static final long serialVersionUID = 7833960784370272300L;
@@ -67,7 +69,9 @@ public class LoopController extends Gene
     }
 
     public int getLoops() {
-        if(nbLoops==null || nbLoops.intValue()==-1) {
+        // Evaluation occurs when nbLoops is not yet evaluated 
+        // or when nbLoops is equal to special value INFINITE_LOOP_COUNT
+        if(nbLoops==null || nbLoops.intValue()==INFINITE_LOOP_COUNT) {
             try {
                 JMeterProperty prop = getProperty(LOOPS);
                 nbLoops = Integer.valueOf(prop.getStringValue());
@@ -116,7 +120,7 @@ public class LoopController extends Gene
 
     private boolean endOfLoop() {
         final int loops = getLoops();
-        return (loops > -1) && (loopCount >= loops);
+        return (loops > INFINITE_LOOP_COUNT) && (loopCount >= loops);
     }
 
     @Override

Modified: jmeter/trunk/src/core/org/apache/jmeter/control/gui/LoopControlPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/control/gui/LoopControlPanel.java?rev=1444571&r1=1444570&r2=1444571&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/control/gui/LoopControlPanel.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/control/gui/LoopControlPanel.java Sun Feb 10 17:37:50
2013
@@ -126,7 +126,7 @@ public class LoopControlPanel extends Ab
             if (loops.getText().length() > 0) {
                 ((LoopController) lc).setLoops(loops.getText());
             } else {
-                ((LoopController) lc).setLoops(-1);
+                ((LoopController) lc).setLoops(LoopController.INFINITE_LOOP_COUNT);
             }
         }
     }
@@ -238,7 +238,7 @@ public class LoopControlPanel extends Ab
      */
     private void setState(String loopCount) {
         if (loopCount.startsWith("-")) { // $NON-NLS-1$
-            setState(-1);
+            setState(LoopController.INFINITE_LOOP_COUNT);
         } else {
             loops.setText(loopCount);
             infinite.setSelected(false);
@@ -255,7 +255,7 @@ public class LoopControlPanel extends Ab
      *            the number of loops
      */
     private void setState(int loopCount) {
-        if (loopCount <= -1) {
+        if (loopCount <= LoopController.INFINITE_LOOP_COUNT) {
             infinite.setSelected(true);
             loops.setEnabled(false);
             loops.setText(""); // $NON-NLS-1$

Modified: jmeter/trunk/test/src/org/apache/jmeter/control/TestLoopController.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/control/TestLoopController.java?rev=1444571&r1=1444570&r2=1444571&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/control/TestLoopController.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/control/TestLoopController.java Sun Feb 10 17:37:50
2013
@@ -82,7 +82,7 @@ public class TestLoopController extends 
 
         public void testInfiniteLoop() throws Exception {
             LoopController loop = new LoopController();
-            loop.setLoops(-1);
+            loop.setLoops(LoopController.INFINITE_LOOP_COUNT);
             loop.addTestElement(new TestSampler("never run"));
             loop.setRunningVersion(true);
             loop.initialize();



Mime
View raw message