Author: milamber
Date: Mon Oct 11 21:27:39 2010
New Revision: 1021512
URL: http://svn.apache.org/viewvc?rev=1021512&view=rev
Log:
Bug 50032 - Last_Sample_Ok along with other controllers doesnt work correctly
when the threadgroup has multiple loops
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/GenericController.java
jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/IfController.java
jakarta/jmeter/trunk/test/src/org/apache/jmeter/control/TestIfController.java
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/GenericController.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/GenericController.java?rev=1021512&r1=1021511&r2=1021512&view=diff
==============================================================================
---
jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/GenericController.java
(original)
+++
jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/GenericController.java
Mon Oct 11 21:27:39 2010
@@ -216,6 +216,28 @@ public class GenericController extends A
}
/**
+ * Called to re-initialize a index of controller's elements (Bug 50032)
+ *
+ * @return Sampler
+ */
+ protected Sampler reInitializeSubController() {
+ Sampler returnValue = null;
+ try {
+ TestElement currentElement = getCurrentElement();
+ if (currentElement != null) {
+ if (currentElement instanceof Sampler) {
+ returnValue = nextIsASampler((Sampler) currentElement);
+ } else { // must be a controller
+ returnValue = nextIsAController((Controller)
currentElement);
+ reInitializeSubController();
+ }
+ }
+ } catch (NextIsNullException e) {
+ }
+ return returnValue;
+ }
+
+ /**
* If the controller is done, remove it from the list,
* otherwise increment to next entry in list.
*
Modified:
jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/IfController.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/IfController.java?rev=1021512&r1=1021511&r2=1021512&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/IfController.java
(original)
+++ jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/IfController.java
Mon Oct 11 21:27:39 2010
@@ -169,6 +169,7 @@ public class IfController extends Generi
return super.next();
}
try {
+ super.reInitializeSubController(); // Bug 50032 - reinitialize
current index element for all sub controller
return nextIsNull();
} catch (NextIsNullException e1) {
return null;
Modified:
jakarta/jmeter/trunk/test/src/org/apache/jmeter/control/TestIfController.java
URL:
http://svn.apache.org/viewvc/jakarta/jmeter/trunk/test/src/org/apache/jmeter/control/TestIfController.java?rev=1021512&r1=1021511&r2=1021512&view=diff
==============================================================================
---
jakarta/jmeter/trunk/test/src/org/apache/jmeter/control/TestIfController.java
(original)
+++
jakarta/jmeter/trunk/test/src/org/apache/jmeter/control/TestIfController.java
Mon Oct 11 21:27:39 2010
@@ -19,7 +19,8 @@
package org.apache.jmeter.control;
import org.apache.jmeter.junit.JMeterTestCase;
-//import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.junit.stubs.TestSampler;
+import org.apache.jmeter.samplers.Sampler;
public class TestIfController extends JMeterTestCase {
public TestIfController(String name) {
@@ -71,4 +72,105 @@ public class TestIfController extends JM
// + sampler.getName());
// }
}
+
+ public void testProcessingTrue() throws Exception {
+ LoopController controller = new LoopController();
+ controller.setLoops(2);
+ controller.addTestElement(new TestSampler("Sample1"));
+ IfController ifCont = new IfController("true==true");
+ ifCont.setEvaluateAll(true);
+ ifCont.addTestElement(new TestSampler("Sample2"));
+ TestSampler sample3 = new TestSampler("Sample3");
+ ifCont.addTestElement(sample3);
+ controller.addTestElement(ifCont);
+
+ String[] order = new String[] { "Sample1", "Sample2", "Sample3",
+ "Sample1", "Sample2", "Sample3" };
+ int counter = 0;
+ controller.setRunningVersion(true);
+ ifCont.setRunningVersion(true);
+
+ Sampler sampler = null;
+ while ((sampler = controller.next()) != null) {
+ sampler.sample(null);
+ assertEquals(order[counter], sampler.getName());
+ counter++;
+ }
+ assertEquals(counter, 6);
+ }
+
+ /**
+ * Test false return on sample3 (sample4 doesn't execute)
+ * @throws Exception
+ */
+ public void testEvaluateAllChildrenWithoutSubController() throws
Exception {
+ LoopController controller = new LoopController();
+ controller.setLoops(2);
+ controller.addTestElement(new TestSampler("Sample1"));
+ IfController ifCont = new IfController("true==true");
+ ifCont.setEvaluateAll(true);
+ controller.addTestElement(ifCont);
+
+ ifCont.addTestElement(new TestSampler("Sample2"));
+ TestSampler sample3 = new TestSampler("Sample3");
+ ifCont.addTestElement(sample3);
+ TestSampler sample4 = new TestSampler("Sample4");
+ ifCont.addTestElement(sample4);
+
+ String[] order = new String[] { "Sample1", "Sample2", "Sample3",
+ "Sample1", "Sample2", "Sample3" };
+ int counter = 0;
+ controller.setRunningVersion(true);
+ ifCont.setRunningVersion(true);
+
+ Sampler sampler = null;
+ while ((sampler = controller.next()) != null) {
+ sampler.sample(null);
+ if (sampler.getName().equals("Sample3")) {
+ ifCont.setCondition("true==false");
+ }
+ assertEquals(order[counter], sampler.getName());
+ counter++;
+ }
+ assertEquals(counter, 6);
+ }
+
+ /**
+ * test 2 loops with a sub generic controller (sample4 doesn't execute)
+ * @throws Exception
+ */
+ public void testEvaluateAllChildrenWithSubController() throws
Exception {
+ LoopController controller = new LoopController();
+ controller.setLoops(2);
+ controller.addTestElement(new TestSampler("Sample1"));
+ IfController ifCont = new IfController("true==true");
+ ifCont.setEvaluateAll(true);
+ controller.addTestElement(ifCont);
+ ifCont.addTestElement(new TestSampler("Sample2"));
+
+ GenericController genericCont = new GenericController();
+ TestSampler sample3 = new TestSampler("Sample3");
+ genericCont.addTestElement(sample3);
+ TestSampler sample4 = new TestSampler("Sample4");
+ genericCont.addTestElement(sample4);
+ ifCont.addTestElement(genericCont);
+
+ String[] order = new String[] { "Sample1", "Sample2", "Sample3",
+ "Sample1", "Sample2", "Sample3" };
+ int counter = 0;
+ controller.setRunningVersion(true);
+ ifCont.setRunningVersion(true);
+ genericCont.setRunningVersion(true);
+
+ Sampler sampler = null;
+ while ((sampler = controller.next()) != null) {
+ sampler.sample(null);
+ if (sampler.getName().equals("Sample3")) {
+ ifCont.setCondition("true==false");
+ }
+ assertEquals(order[counter], sampler.getName());
+ counter++;
+ }
+ assertEquals(counter, 6);
+ }
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]