Lines 173-176
Link Here
|
173 |
} |
173 |
} |
174 |
assertEquals(counter, 6); |
174 |
assertEquals(counter, 6); |
175 |
} |
175 |
} |
|
|
176 |
|
177 |
/** |
178 |
* Test for Fix of Bug 56160 (Don't step into IfController children if condition is false) |
179 |
*/ |
180 |
public void testNotStepIntoOnFalse() { |
181 |
|
182 |
LoopController controller = new LoopController(); |
183 |
controller.setLoops(2); |
184 |
IfController ifCont = new IfController("false==true"); |
185 |
ifCont.setFirst(true); |
186 |
controller.addTestElement(ifCont); |
187 |
|
188 |
CountingController whileCont = new CountingController(); |
189 |
// whileCont.setCondition("false"); |
190 |
ifCont.addTestElement(whileCont); |
191 |
|
192 |
TestSampler sample = new TestSampler("Placeholder"); |
193 |
whileCont.addTestElement(sample); |
194 |
|
195 |
controller.setRunningVersion(true); |
196 |
ifCont.setRunningVersion(true); |
197 |
whileCont.setRunningVersion(true); |
198 |
|
199 |
Sampler sampler = null; |
200 |
while ((sampler = controller.next()) != null) { |
201 |
System.out.println("sampler name" + sampler.getName()); |
202 |
} |
203 |
|
204 |
assertEquals( |
205 |
"WhileController.next has been evaluated though it's contained in a IfController with condition that is false", |
206 |
0, whileCont.whileNextCalled); |
207 |
} |
208 |
|
209 |
/** |
210 |
* Test that fix of Bug 56160 doesn't break existing code if condition is true |
211 |
*/ |
212 |
public void testStepIntoOnTrue() { |
213 |
|
214 |
LoopController controller = new LoopController(); |
215 |
controller.setLoops(2); |
216 |
IfController ifCont = new IfController("true==true"); |
217 |
ifCont.setFirst(true); |
218 |
controller.addTestElement(ifCont); |
219 |
|
220 |
CountingController whileCont = new CountingController(); |
221 |
// whileCont.setCondition("false"); |
222 |
ifCont.addTestElement(whileCont); |
223 |
|
224 |
TestSampler sample = new TestSampler("Placeholder"); |
225 |
whileCont.addTestElement(sample); |
226 |
|
227 |
controller.setRunningVersion(true); |
228 |
ifCont.setRunningVersion(true); |
229 |
whileCont.setRunningVersion(true); |
230 |
|
231 |
Sampler sampler = null; |
232 |
while ((sampler = controller.next()) != null) { |
233 |
System.out.println("sampler name" + sampler.getName()); |
234 |
} |
235 |
|
236 |
assertTrue("WhileController hasn't been called for ", |
237 |
whileCont.whileNextCalled > 0); |
238 |
} |
239 |
|
240 |
/** |
241 |
* WhileController impl to count the number of invocations of next() |
242 |
*/ |
243 |
private class CountingController extends GenericController { |
244 |
|
245 |
/* generated */ |
246 |
private static final long serialVersionUID = 2752049459477428418L; |
247 |
|
248 |
int whileNextCalled = 0; |
249 |
|
250 |
@Override |
251 |
public Sampler next() { |
252 |
whileNextCalled++; |
253 |
return super.next(); |
254 |
} |
255 |
} |
176 |
} |
256 |
} |