Search in sources :

Example 81 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class TestInterleaveControl method testProcessing3.

@Test
public void testProcessing3() throws Exception {
    testLog.debug("Testing Interleave Controller 3");
    GenericController controller = new GenericController();
    InterleaveControl sub_1 = new InterleaveControl();
    sub_1.setStyle(InterleaveControl.USE_SUB_CONTROLLERS);
    sub_1.addTestElement(new TestSampler("one"));
    sub_1.addTestElement(new TestSampler("two"));
    controller.addTestElement(sub_1);
    controller.addTestElement(new TestSampler("three"));
    LoopController sub_2 = new LoopController();
    sub_2.setLoops(3);
    GenericController sub_3 = new GenericController();
    sub_2.addTestElement(new TestSampler("four"));
    sub_3.addTestElement(new TestSampler("five"));
    sub_3.addTestElement(new TestSampler("six"));
    sub_2.addTestElement(sub_3);
    sub_2.addTestElement(new TestSampler("seven"));
    sub_1.addTestElement(sub_2);
    String[] order = new String[] { "one", "three", "two", "three", "four", "five", "six", "seven", "four", "five", "six", "seven", "four", "five", "six", "seven", "three", "one", "three", "two", "three" };
    int counter = 0;
    controller.setRunningVersion(true);
    sub_1.setRunningVersion(true);
    sub_2.setRunningVersion(true);
    sub_3.setRunningVersion(true);
    controller.initialize();
    while (counter < order.length) {
        TestElement sampler = null;
        while ((sampler = controller.next()) != null) {
            assertEquals("failed on" + counter, order[counter], sampler.getName());
            counter++;
        }
    }
}
Also used : TestSampler(org.apache.jmeter.junit.stubs.TestSampler) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 82 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class TestInterleaveControl method testProcessing5.

@Test
public void testProcessing5() throws Exception {
    testLog.debug("Testing Interleave Controller 5");
    GenericController controller = new GenericController();
    InterleaveControl sub_1 = new InterleaveControl();
    sub_1.setStyle(InterleaveControl.USE_SUB_CONTROLLERS);
    controller.addTestElement(sub_1);
    GenericController sub_2 = new GenericController();
    sub_2.addTestElement(new TestSampler("one"));
    sub_2.addTestElement(new TestSampler("two"));
    sub_1.addTestElement(sub_2);
    GenericController sub_3 = new GenericController();
    sub_3.addTestElement(new TestSampler("three"));
    sub_3.addTestElement(new TestSampler("four"));
    sub_1.addTestElement(sub_3);
    String[] order = new String[] { "one", "two", "three", "four" };
    int counter = 0;
    controller.setRunningVersion(true);
    sub_1.setRunningVersion(true);
    sub_2.setRunningVersion(true);
    sub_3.setRunningVersion(true);
    controller.initialize();
    while (counter < order.length) {
        TestElement sampler = null;
        while ((sampler = controller.next()) != null) {
            assertEquals("failed on" + counter, order[counter], sampler.getName());
            counter++;
        }
    }
}
Also used : TestSampler(org.apache.jmeter.junit.stubs.TestSampler) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 83 with TestElement

use of org.apache.jmeter.testelement.TestElement in project jmeter by apache.

the class JMeterTest method GUIComponents2.

/*
     * Test GUI elements - not run for TestBeanGui items
     */
public void GUIComponents2() throws Exception {
    String name = guiItem.getClass().getName();
    // TODO these assertions should be separate tests
    TestElement el = guiItem.createTestElement();
    assertNotNull(name + ".createTestElement should be non-null ", el);
    assertEquals("GUI-CLASS: Failed on " + name, name, el.getPropertyAsString(TestElement.GUI_CLASS));
    assertEquals("NAME: Failed on " + name, guiItem.getName(), el.getName());
    assertEquals("TEST-CLASS: Failed on " + name, el.getClass().getName(), el.getPropertyAsString(TestElement.TEST_CLASS));
    TestElement el2 = guiItem.createTestElement();
    el.setName("hey, new name!:");
    el.setProperty("NOT", "Shouldn't be here");
    if (!(guiItem instanceof UnsharedComponent)) {
        assertEquals("SHARED: Failed on " + name, "", el2.getPropertyAsString("NOT"));
    }
    log.debug("Saving element: {}", el.getClass());
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    SaveService.saveElement(el, bos);
    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    bos.close();
    el = (TestElement) SaveService.loadElement(bis);
    bis.close();
    assertNotNull("Load element failed on: " + name, el);
    guiItem.configure(el);
    assertEquals("CONFIGURE-TEST: Failed on " + name, el.getName(), guiItem.getName());
    guiItem.modifyTestElement(el2);
    assertEquals("Modify Test: Failed on " + name, "hey, new name!:", el2.getName());
}
Also used : UnsharedComponent(org.apache.jmeter.gui.UnsharedComponent) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TestElement(org.apache.jmeter.testelement.TestElement)

Aggregations

TestElement (org.apache.jmeter.testelement.TestElement)83 Test (org.junit.Test)27 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)26 TestSampler (org.apache.jmeter.junit.stubs.TestSampler)21 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)18 TestPlan (org.apache.jmeter.testelement.TestPlan)12 ArrayList (java.util.ArrayList)9 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)9 StringProperty (org.apache.jmeter.testelement.property.StringProperty)7 Controller (org.apache.jmeter.control.Controller)6 JMeterTreeModel (org.apache.jmeter.gui.tree.JMeterTreeModel)6 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)6 TreePath (javax.swing.tree.TreePath)5 GuiPackage (org.apache.jmeter.gui.GuiPackage)5 ActionEvent (java.awt.event.ActionEvent)4 IOException (java.io.IOException)4 LinkedList (java.util.LinkedList)4 Arguments (org.apache.jmeter.config.Arguments)4 WorkBench (org.apache.jmeter.testelement.WorkBench)4 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)4