ASF Bugzilla – Attachment 26151 Details for
Bug 50032
Last_Sample_Ok along with other controllers doesnt work correctly when the threadgroup has multiple loops
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposal patch
bug50032.patch (text/plain), 6.91 KB, created by
Milamber
on 2010-10-09 17:18:40 UTC
(
hide
)
Description:
Proposal patch
Filename:
MIME Type:
Creator:
Milamber
Created:
2010-10-09 17:18:40 UTC
Size:
6.91 KB
patch
obsolete
>Index: test/src/org/apache/jmeter/control/TestIfController.java >=================================================================== >--- test/src/org/apache/jmeter/control/TestIfController.java (revision 1006011) >+++ test/src/org/apache/jmeter/control/TestIfController.java (working copy) >@@ -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 @@ > // + 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 >Index: src/core/org/apache/jmeter/control/GenericController.java >=================================================================== >--- src/core/org/apache/jmeter/control/GenericController.java (revision 1006011) >+++ src/core/org/apache/jmeter/control/GenericController.java (working copy) >@@ -215,6 +215,28 @@ > return null; > } > >+ /** >+ * Called to re-initialize a index of controller's elements >+ * (Bug 50032) >+ * @return Sampler >+ */ >+ public 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. >Index: src/core/org/apache/jmeter/control/IfController.java >=================================================================== >--- src/core/org/apache/jmeter/control/IfController.java (revision 1006011) >+++ src/core/org/apache/jmeter/control/IfController.java (working copy) >@@ -169,6 +169,7 @@ > return super.next(); > } > try { >+ super.reInitializeSubController(); // Bug 50032 - reinitialize current index element for all sub controller > return nextIsNull(); > } catch (NextIsNullException e1) { > return null; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 50032
:
26105
| 26151 |
27486
|
27487
|
27519