Search in sources :

Example 96 with JMeterProperty

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

the class TestElementConverter method marshal.

/**
 * {@inheritDoc}
 */
@Override
public void marshal(Object arg0, HierarchicalStreamWriter writer, MarshallingContext context) {
    TestElement el = (TestElement) arg0;
    ConversionHelp.saveSpecialProperties(el, writer);
    PropertyIterator iter = el.propertyIterator();
    while (iter.hasNext()) {
        JMeterProperty jmp = iter.next();
        // Skip special properties if required
        if (!ConversionHelp.isSpecialProperty(jmp.getName())) {
            // Don't save empty comments - except for the TestPlan (to maintain compatibility)
            if (!(TestElement.COMMENTS.equals(jmp.getName()) && jmp.getStringValue().length() == 0 && !el.getClass().equals(TestPlan.class))) {
                writeCompleteItem(jmp, context, writer);
            }
        }
    }
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator) TestElement(org.apache.jmeter.testelement.TestElement)

Example 97 with JMeterProperty

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

the class AbstractTestElement method addProperty.

/**
 * Add property to test element
 * @param property {@link JMeterProperty} to add to current Test Element
 * @param clone clone property
 */
protected void addProperty(JMeterProperty property, boolean clone) {
    JMeterProperty propertyToPut = property;
    if (clone) {
        propertyToPut = property.clone();
    }
    if (isRunningVersion()) {
        setTemporary(propertyToPut);
    } else {
        clearTemporary(property);
    }
    JMeterProperty prop = getProperty(property.getName());
    if (prop instanceof NullProperty || (prop instanceof StringProperty && prop.getStringValue().isEmpty())) {
        propMap.put(property.getName(), propertyToPut);
    } else {
        prop.mergeIn(propertyToPut);
    }
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) NullProperty(org.apache.jmeter.testelement.property.NullProperty) StringProperty(org.apache.jmeter.testelement.property.StringProperty)

Example 98 with JMeterProperty

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

the class AbstractTestElement method recoverRunningVersion.

/**
 * {@inheritDoc}
 */
@Override
public void recoverRunningVersion() {
    Iterator<Map.Entry<String, JMeterProperty>> iter = propMap.entrySet().iterator();
    while (iter.hasNext()) {
        Map.Entry<String, JMeterProperty> entry = iter.next();
        JMeterProperty prop = entry.getValue();
        if (isTemporary(prop)) {
            iter.remove();
            clearTemporary(prop);
        } else {
            prop.recoverRunningVersion(this);
        }
    }
    emptyTemporary();
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 99 with JMeterProperty

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

the class AbstractTestElement method mergeIn.

/**
 * Add to this the properties of element (by reference)
 * @param element {@link TestElement}
 */
protected void mergeIn(TestElement element) {
    PropertyIterator iter = element.propertyIterator();
    while (iter.hasNext()) {
        JMeterProperty prop = iter.next();
        addProperty(prop, false);
    }
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Example 100 with JMeterProperty

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

the class AbstractTestElement method logProperties.

/**
 * Log the properties of the test element
 *
 * @see TestElement#setProperty(JMeterProperty)
 */
protected void logProperties() {
    if (log.isDebugEnabled()) {
        PropertyIterator iter = propertyIterator();
        while (iter.hasNext()) {
            JMeterProperty prop = iter.next();
            log.debug("Property {} is temp? {} and is a {}", prop.getName(), isTemporary(prop), prop.getObjectValue());
        }
    }
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Aggregations

JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)126 CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)30 NullProperty (org.apache.jmeter.testelement.property.NullProperty)26 Test (org.junit.Test)26 StringProperty (org.apache.jmeter.testelement.property.StringProperty)24 ArrayList (java.util.ArrayList)17 Argument (org.apache.jmeter.config.Argument)13 PropertyIterator (org.apache.jmeter.testelement.property.PropertyIterator)13 Arguments (org.apache.jmeter.config.Arguments)11 File (java.io.File)9 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)9 HTTPFileArg (org.apache.jmeter.protocol.http.util.HTTPFileArg)8 TestElement (org.apache.jmeter.testelement.TestElement)8 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)6 Test (org.junit.jupiter.api.Test)6 IOException (java.io.IOException)5 List (java.util.List)5 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 MalformedURLException (java.net.MalformedURLException)4