Search in sources :

Example 56 with TestElement

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

the class TestRandomController method testRandomOrder.

@Test
public void testRandomOrder() {
    testLog.debug("Testing RandomController");
    RandomController roc = new RandomController();
    roc.addTestElement(new TestSampler("zero"));
    roc.addTestElement(new TestSampler("one"));
    roc.addTestElement(new TestSampler("two"));
    roc.addTestElement(new TestSampler("three"));
    TestElement sampler = null;
    List<String> usedSamplers = new ArrayList<>();
    roc.initialize();
    while ((sampler = roc.next()) != null) {
        String samplerName = sampler.getName();
        if (usedSamplers.contains(samplerName)) {
            assertTrue("Duplicate sampler returned from next()", false);
        }
        usedSamplers.add(samplerName);
    }
    assertEquals(1, usedSamplers.size());
    assertTrue(Arrays.asList("zero", "one", "two", "three").contains(usedSamplers.get(0)));
}
Also used : ArrayList(java.util.ArrayList) TestSampler(org.apache.jmeter.junit.stubs.TestSampler) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 57 with TestElement

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

the class TestRandomOrderController method testRandomOrderOneElement.

@Test
public void testRandomOrderOneElement() {
    RandomOrderController roc = new RandomOrderController();
    roc.addTestElement(new TestSampler("zero"));
    TestElement sampler = null;
    List<String> usedSamplers = new ArrayList<>();
    roc.initialize();
    while ((sampler = roc.next()) != null) {
        String samplerName = sampler.getName();
        if (usedSamplers.contains(samplerName)) {
            assertTrue("Duplicate sampler returned from next()", false);
        }
        usedSamplers.add(samplerName);
    }
    assertEquals("All samplers were returned", 1, usedSamplers.size());
}
Also used : ArrayList(java.util.ArrayList) TestSampler(org.apache.jmeter.junit.stubs.TestSampler) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 58 with TestElement

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

the class TestRandomOrderController method testRandomOrder.

@Test
public void testRandomOrder() {
    testLog.debug("Testing RandomOrderController");
    RandomOrderController roc = new RandomOrderController();
    roc.addTestElement(new TestSampler("zero"));
    roc.addTestElement(new TestSampler("one"));
    roc.addTestElement(new TestSampler("two"));
    roc.addTestElement(new TestSampler("three"));
    TestElement sampler = null;
    List<String> usedSamplers = new ArrayList<>();
    roc.initialize();
    while ((sampler = roc.next()) != null) {
        String samplerName = sampler.getName();
        if (usedSamplers.contains(samplerName)) {
            assertTrue("Duplicate sampler returned from next()", false);
        }
        usedSamplers.add(samplerName);
    }
    assertEquals("All samplers were returned", 4, usedSamplers.size());
}
Also used : ArrayList(java.util.ArrayList) TestSampler(org.apache.jmeter.junit.stubs.TestSampler) TestElement(org.apache.jmeter.testelement.TestElement) Test(org.junit.Test)

Example 59 with TestElement

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

the class TestValueReplacer method testReplaceStringWithBackslash.

@Test
public void testReplaceStringWithBackslash() throws Exception {
    ValueReplacer replacer = new ValueReplacer();
    replacer.setUserDefinedVariables(variables.getUserDefinedVariables());
    TestElement element = new ConfigTestElement();
    String input = "\\${server} \\ \\\\ \\\\\\ \\, ";
    element.setProperty(new StringProperty("domain", input));
    replacer.replaceValues(element);
    element.setRunningVersion(true);
    assertEquals(input, element.getPropertyAsString("domain"));
}
Also used : StringProperty(org.apache.jmeter.testelement.property.StringProperty) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) TestElement(org.apache.jmeter.testelement.TestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) Test(org.junit.Test)

Example 60 with TestElement

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

the class TestValueReplacer method testReplaceFunctionWithBackslash.

/*
         * This test should be compared with the one above.
         * Here, the string contains a valid variable reference, so all
         * backslashes are also processed.
         * 
         * See https://bz.apache.org/bugzilla/show_bug.cgi?id=53534
         */
@Test
public void testReplaceFunctionWithBackslash() throws Exception {
    ValueReplacer replacer = new ValueReplacer();
    replacer.setUserDefinedVariables(variables.getUserDefinedVariables());
    TestElement element = new ConfigTestElement();
    String input = "${server} \\ \\\\ \\\\\\ \\, ";
    element.setProperty(new StringProperty("domain", input));
    replacer.replaceValues(element);
    element.setRunningVersion(true);
    assertEquals("jakarta.apache.org \\ \\ \\\\ , ", element.getPropertyAsString("domain"));
}
Also used : StringProperty(org.apache.jmeter.testelement.property.StringProperty) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) TestElement(org.apache.jmeter.testelement.TestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) Test(org.junit.Test)

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