Search in sources :

Example 16 with ConfigTestElement

use of org.apache.jmeter.config.ConfigTestElement in project jmeter by apache.

the class HttpDefaultsGui method modifyTestElement.

/**
     * Modifies a given TestElement to mirror the data in the gui components.
     *
     * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
     */
@Override
public void modifyTestElement(TestElement config) {
    ConfigTestElement cfg = (ConfigTestElement) config;
    ConfigTestElement el = (ConfigTestElement) urlConfigGui.createTestElement();
    cfg.clear();
    cfg.addConfigElement(el);
    super.configureTestElement(config);
    if (retrieveEmbeddedResources.isSelected()) {
        config.setProperty(new BooleanProperty(HTTPSamplerBase.IMAGE_PARSER, true));
    } else {
        config.removeProperty(HTTPSamplerBase.IMAGE_PARSER);
    }
    enableConcurrentDwn(retrieveEmbeddedResources.isSelected());
    if (concurrentDwn.isSelected()) {
        config.setProperty(new BooleanProperty(HTTPSamplerBase.CONCURRENT_DWN, true));
    } else {
        // The default is false, so we can remove the property to simplify JMX files
        // This also allows HTTPDefaults to work for this checkbox
        config.removeProperty(HTTPSamplerBase.CONCURRENT_DWN);
    }
    if (!StringUtils.isEmpty(concurrentPool.getText())) {
        config.setProperty(new StringProperty(HTTPSamplerBase.CONCURRENT_POOL, concurrentPool.getText()));
    } else {
        config.setProperty(new StringProperty(HTTPSamplerBase.CONCURRENT_POOL, String.valueOf(HTTPSamplerBase.CONCURRENT_POOL_SIZE)));
    }
    if (useMD5.isSelected()) {
        config.setProperty(new BooleanProperty(HTTPSamplerBase.MD5, true));
    } else {
        config.removeProperty(HTTPSamplerBase.MD5);
    }
    if (!StringUtils.isEmpty(embeddedRE.getText())) {
        config.setProperty(new StringProperty(HTTPSamplerBase.EMBEDDED_URL_RE, embeddedRE.getText()));
    } else {
        config.removeProperty(HTTPSamplerBase.EMBEDDED_URL_RE);
    }
    if (!StringUtils.isEmpty(sourceIpAddr.getText())) {
        config.setProperty(new StringProperty(HTTPSamplerBase.IP_SOURCE, sourceIpAddr.getText()));
        config.setProperty(new IntegerProperty(HTTPSamplerBase.IP_SOURCE_TYPE, sourceIpType.getSelectedIndex()));
    } else {
        config.removeProperty(HTTPSamplerBase.IP_SOURCE);
        config.removeProperty(HTTPSamplerBase.IP_SOURCE_TYPE);
    }
    config.setProperty(HTTPSamplerBase.PROXYHOST, proxyHost.getText(), "");
    config.setProperty(HTTPSamplerBase.PROXYPORT, proxyPort.getText(), "");
    config.setProperty(HTTPSamplerBase.PROXYUSER, proxyUser.getText(), "");
    config.setProperty(HTTPSamplerBase.PROXYPASS, String.valueOf(proxyPass.getPassword()), "");
    config.setProperty(HTTPSamplerBase.IMPLEMENTATION, httpImplementation.getSelectedItem().toString(), "");
    config.setProperty(HTTPSamplerBase.CONNECT_TIMEOUT, connectTimeOut.getText());
    config.setProperty(HTTPSamplerBase.RESPONSE_TIMEOUT, responseTimeOut.getText());
}
Also used : IntegerProperty(org.apache.jmeter.testelement.property.IntegerProperty) BooleanProperty(org.apache.jmeter.testelement.property.BooleanProperty) StringProperty(org.apache.jmeter.testelement.property.StringProperty) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement)

Example 17 with ConfigTestElement

use of org.apache.jmeter.config.ConfigTestElement 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 18 with ConfigTestElement

use of org.apache.jmeter.config.ConfigTestElement 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)

Example 19 with ConfigTestElement

use of org.apache.jmeter.config.ConfigTestElement in project jmeter by apache.

the class PropertyControlGui method createTestElement.

@Override
public TestElement createTestElement() {
    TestElement el = new ConfigTestElement();
    modifyTestElement(el);
    return el;
}
Also used : TestElement(org.apache.jmeter.testelement.TestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement)

Example 20 with ConfigTestElement

use of org.apache.jmeter.config.ConfigTestElement in project jmeter by apache.

the class TestElementPropertyConverter method unmarshal.

/*
     * TODO - convert to work more like upgrade.properties/NameUpdater.java
     *
     * Special processing is carried out for the Header Class The String
     * property TestElement.name is converted to Header.name for example:
     * <elementProp name="User-Agent"
     * elementType="org.apache.jmeter.protocol.http.control.Header"> <stringProp
     * name="Header.value">Mozilla%2F4.0+%28compatible%3B+MSIE+5.5%3B+Windows+98%29</stringProp>
     * <stringProp name="TestElement.name">User-Agent</stringProp>
     * </elementProp> becomes <elementProp name="User-Agent"
     * elementType="org.apache.jmeter.protocol.http.control.Header"> <stringProp
     * name="Header.value">Mozilla%2F4.0+%28compatible%3B+MSIE+5.5%3B+Windows+98%29</stringProp>
     * <stringProp name="Header.name">User-Agent</stringProp> </elementProp>
     */
/** {@inheritDoc} */
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    try {
        TestElementProperty prop = (TestElementProperty) createCollection(context.getRequiredType());
        prop.setName(ConversionHelp.decode(reader.getAttribute(ConversionHelp.ATT_NAME)));
        String element = reader.getAttribute(ConversionHelp.ATT_ELEMENT_TYPE);
        boolean isHeader = HEADER_CLASSNAME.equals(element);
        // Always decode
        prop.setObjectValue(mapper().realClass(element).newInstance());
        TestElement te = (TestElement) prop.getObjectValue();
        // No need to check version, just process the attributes if present
        ConversionHelp.restoreSpecialProperties(te, reader);
        while (reader.hasMoreChildren()) {
            reader.moveDown();
            JMeterProperty subProp = (JMeterProperty) readItem(reader, context, prop);
            if (subProp != null) {
                // could be null if it has been deleted via NameUpdater
                if (isHeader) {
                    String name = subProp.getName();
                    if (TestElement.NAME.equals(name)) {
                        // $NON-NLS-1$
                        subProp.setName("Header.name");
                    // Must be same as Header.HNAME - but that is built
                    // later
                    }
                }
                prop.addProperty(subProp);
            }
            reader.moveUp();
        }
        return prop;
    } catch (InstantiationException | IllegalAccessException e) {
        log.error("Couldn't unmarshall TestElementProperty", e);
        // $NON-NLS-1$
        return new TestElementProperty("ERROR", new ConfigTestElement());
    }
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) TestElementProperty(org.apache.jmeter.testelement.property.TestElementProperty) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) TestElement(org.apache.jmeter.testelement.TestElement) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement)

Aggregations

ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)22 TestElement (org.apache.jmeter.testelement.TestElement)7 Test (org.junit.Test)6 StringProperty (org.apache.jmeter.testelement.property.StringProperty)5 Arguments (org.apache.jmeter.config.Arguments)3 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)3 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)2 Collection (java.util.Collection)1 LinkedList (java.util.LinkedList)1 Assertion (org.apache.jmeter.assertions.Assertion)1 LoginConfig (org.apache.jmeter.config.LoginConfig)1 Controller (org.apache.jmeter.control.Controller)1 GenericController (org.apache.jmeter.control.GenericController)1 TransactionController (org.apache.jmeter.control.TransactionController)1 TransactionSampler (org.apache.jmeter.control.TransactionSampler)1 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)1 PostProcessor (org.apache.jmeter.processor.PostProcessor)1 PreProcessor (org.apache.jmeter.processor.PreProcessor)1 HttpDefaultsGui (org.apache.jmeter.protocol.http.config.gui.HttpDefaultsGui)1 Authorization (org.apache.jmeter.protocol.http.control.Authorization)1