jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1444568 - /jmeter/trunk/test/src/org/apache/jmeter/control/TestLoopController.java
Date Sun, 10 Feb 2013 17:14:11 GMT
Author: pmouawad
Date: Sun Feb 10 17:14:11 2013
New Revision: 1444568

URL: http://svn.apache.org/r1444568
Log:
Bug 54467 - Loop controller Controller check conditions each request
Add Test
Bugzilla Id: 54467

Modified:
    jmeter/trunk/test/src/org/apache/jmeter/control/TestLoopController.java

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=1444568&r1=1444567&r2=1444568&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:14:11
2013
@@ -18,9 +18,20 @@
 
 package org.apache.jmeter.control;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.jmeter.engine.util.CompoundVariable;
+import org.apache.jmeter.engine.util.ReplaceStringWithFunctions;
 import org.apache.jmeter.junit.JMeterTestCase;
 import org.apache.jmeter.junit.stubs.TestSampler;
+import org.apache.jmeter.samplers.Sampler;
 import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.testelement.property.JMeterProperty;
+import org.apache.jmeter.testelement.property.StringProperty;
+import org.apache.jmeter.threads.JMeterContext;
+import org.apache.jmeter.threads.JMeterContextService;
+import org.apache.jmeter.threads.JMeterVariables;
 
 public class TestLoopController extends JMeterTestCase {
         public TestLoopController(String name) {
@@ -79,4 +90,27 @@ public class TestLoopController extends 
                 assertNotNull(loop.next());
             }
         }
+            
+        public void testBug54467() throws Exception {
+            JMeterContext jmctx = JMeterContextService.getContext();
+            LoopController loop = new LoopController();
+            Map<String, String> variables = new HashMap<String, String>();
+            ReplaceStringWithFunctions transformer = new ReplaceStringWithFunctions(new CompoundVariable(),
variables);
+            jmctx.setVariables(new JMeterVariables());
+
+            StringProperty prop = new StringProperty(LoopController.LOOPS,"${__Random(1,12,)}");
+            JMeterProperty newProp = transformer.transformValue(prop);
+            newProp.setRunningVersion(true);
+            
+            loop.setProperty(newProp);
+            loop.addTestElement(new TestSampler("random run"));
+            loop.setRunningVersion(true);
+            loop.initialize();
+            int loops = loop.getLoops();
+            for (int i = 0; i < loops; i++) {
+                Sampler s = loop.next();
+                assertNotNull(s);
+            }
+            assertNull(loop.next());    
+        }
 }
\ No newline at end of file



Mime
View raw message