Search in sources :

Example 11 with PropertyIterator

use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.

the class AbstractTestElement method getSearchableTokens.

/**
 * {@inheritDoc}}
 */
@Override
public List<String> getSearchableTokens() {
    List<String> result = new ArrayList<>(25);
    PropertyIterator iterator = propertyIterator();
    while (iterator.hasNext()) {
        JMeterProperty jMeterProperty = iterator.next();
        result.add(jMeterProperty.getName());
        result.add(jMeterProperty.getStringValue());
    }
    return result;
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) ArrayList(java.util.ArrayList) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Example 12 with PropertyIterator

use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.

the class AbstractTestElement method clone.

@Override
public Object clone() {
    try {
        TestElement clonedElement = this.getClass().getDeclaredConstructor().newInstance();
        PropertyIterator iter = propertyIterator();
        while (iter.hasNext()) {
            clonedElement.setProperty(iter.next().clone());
        }
        clonedElement.setRunningVersion(runningVersion);
        return clonedElement;
    } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException e) {
        // clone should never return null
        throw new AssertionError(e);
    }
}
Also used : PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Example 13 with PropertyIterator

use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.

the class AbstractTestElement method setRunningVersion.

/**
 * Sets the runningVersion.
 *
 * @param runningVersion
 *            the runningVersion to set
 */
@Override
public void setRunningVersion(boolean runningVersion) {
    this.runningVersion = runningVersion;
    PropertyIterator iter = propertyIterator();
    while (iter.hasNext()) {
        iter.next().setRunningVersion(runningVersion);
    }
}
Also used : PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Example 14 with PropertyIterator

use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.

the class TestTreeCloner method testCloning.

@Test
public void testCloning() throws Exception {
    ListedHashTree original = new ListedHashTree();
    GenericController controller = new GenericController();
    controller.setName("controller");
    Arguments args = new Arguments();
    args.setName("args");
    TestPlan plan = new TestPlan();
    plan.addParameter("server", "jakarta");
    original.add(controller, args);
    original.add(plan);
    ResultCollector listener = new ResultCollector();
    listener.setName("Collector");
    original.add(controller, listener);
    TreeCloner cloner = new TreeCloner();
    original.traverse(cloner);
    ListedHashTree newTree = cloner.getClonedTree();
    assertTrue(original != newTree);
    assertEquals(original.size(), newTree.size());
    assertEquals(original.getTree(original.getArray()[0]).size(), newTree.getTree(newTree.getArray()[0]).size());
    assertTrue(original.getArray()[0] != newTree.getArray()[0]);
    assertEquals(((GenericController) original.getArray()[0]).getName(), ((GenericController) newTree.getArray()[0]).getName());
    assertSame(original.getTree(original.getArray()[0]).getArray()[1], newTree.getTree(newTree.getArray()[0]).getArray()[1]);
    TestPlan clonedTestPlan = (TestPlan) newTree.getArray()[1];
    clonedTestPlan.setRunningVersion(true);
    clonedTestPlan.recoverRunningVersion();
    assertTrue(!plan.getUserDefinedVariablesAsProperty().isRunningVersion());
    assertTrue(clonedTestPlan.getUserDefinedVariablesAsProperty().isRunningVersion());
    Arguments vars = (Arguments) plan.getUserDefinedVariablesAsProperty().getObjectValue();
    PropertyIterator iter = ((CollectionProperty) vars.getProperty(Arguments.ARGUMENTS)).iterator();
    while (iter.hasNext()) {
        JMeterProperty argProp = iter.next();
        assertTrue(!argProp.isRunningVersion());
        assertTrue(argProp.getObjectValue() instanceof Argument);
        Argument arg = (Argument) argProp.getObjectValue();
        arg.setValue("yahoo");
        assertEquals("yahoo", arg.getValue());
    }
    vars = (Arguments) clonedTestPlan.getUserDefinedVariablesAsProperty().getObjectValue();
    iter = vars.propertyIterator();
    while (iter.hasNext()) {
        assertTrue(iter.next().isRunningVersion());
    }
}
Also used : ListedHashTree(org.apache.jorphan.collections.ListedHashTree) CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) Argument(org.apache.jmeter.config.Argument) TestPlan(org.apache.jmeter.testelement.TestPlan) Arguments(org.apache.jmeter.config.Arguments) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator) GenericController(org.apache.jmeter.control.GenericController) ResultCollector(org.apache.jmeter.reporters.ResultCollector) Test(org.junit.jupiter.api.Test)

Example 15 with PropertyIterator

use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.

the class TestElementTest method checkElementCloning.

private static void checkElementCloning(TestElement item) {
    TestElement clonedItem = (TestElement) item.clone();
    cloneTesting(item, clonedItem);
    PropertyIterator iter2 = item.propertyIterator();
    while (iter2.hasNext()) {
        JMeterProperty item2 = iter2.next();
        assertEquals(item2.getStringValue(), clonedItem.getProperty(item2.getName()).getStringValue());
        assertTrue(item2 != clonedItem.getProperty(item2.getName()));
    }
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Aggregations

PropertyIterator (org.apache.jmeter.testelement.property.PropertyIterator)36 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)12 CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)8 ArrayList (java.util.ArrayList)4 Argument (org.apache.jmeter.config.Argument)4 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)3 Test (org.junit.jupiter.api.Test)3 BasicAttribute (javax.naming.directory.BasicAttribute)2 ModificationItem (javax.naming.directory.ModificationItem)2 NameValuePair (org.apache.http.NameValuePair)2 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)2 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)2 Customizer (java.beans.Customizer)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 Charset (java.nio.charset.Charset)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1