01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.jmeter.control;
20:
21: import org.apache.jmeter.junit.JMeterTestCase;
22: import org.apache.jmeter.junit.stubs.TestSampler;
23: import org.apache.jmeter.testelement.TestElement;
24:
25: public class TestGenericController extends JMeterTestCase {
26: public TestGenericController(String name) {
27: super (name);
28: }
29:
30: public void testProcessing() throws Exception {
31: testLog.debug("Testing Generic Controller");
32: GenericController controller = new GenericController();
33: GenericController sub_1 = new GenericController();
34: sub_1.addTestElement(new TestSampler("one"));
35: sub_1.addTestElement(new TestSampler("two"));
36: controller.addTestElement(sub_1);
37: controller.addTestElement(new TestSampler("three"));
38: GenericController sub_2 = new GenericController();
39: GenericController sub_3 = new GenericController();
40: sub_2.addTestElement(new TestSampler("four"));
41: sub_3.addTestElement(new TestSampler("five"));
42: sub_3.addTestElement(new TestSampler("six"));
43: sub_2.addTestElement(sub_3);
44: sub_2.addTestElement(new TestSampler("seven"));
45: controller.addTestElement(sub_2);
46: String[] order = new String[] { "one", "two", "three", "four",
47: "five", "six", "seven" };
48: int counter = 7;
49: controller.initialize();
50: for (int i = 0; i < 2; i++) {
51: assertEquals(7, counter);
52: counter = 0;
53: TestElement sampler = null;
54: while ((sampler = controller.next()) != null) {
55: assertEquals(order[counter++], sampler
56: .getPropertyAsString(TestElement.NAME));
57: }
58: }
59: }
60: }
|