Search in sources :

Example 6 with TestElementProperty

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

the class UrlConfigTest method setUp.

@Before
public void setUp() {
    Arguments args = new Arguments();
    args.addArgument("username", "mstover");
    args.addArgument("password", "pass");
    args.addArgument("action", "login");
    config = new HTTPNullSampler();
    config.setName("Full Config");
    config.setProperty(HTTPSamplerBase.DOMAIN, "www.lazer.com");
    config.setProperty(HTTPSamplerBase.PATH, "login.jsp");
    config.setProperty(HTTPSamplerBase.METHOD, HTTPConstants.POST);
    config.setProperty(new TestElementProperty(HTTPSamplerBase.ARGUMENTS, args));
    defaultConfig = new HTTPNullSampler();
    defaultConfig.setName("default");
    defaultConfig.setProperty(HTTPSamplerBase.DOMAIN, "www.xerox.com");
    defaultConfig.setProperty(HTTPSamplerBase.PATH, "default.html");
    partialConfig = new HTTPNullSampler();
    partialConfig.setProperty(HTTPSamplerBase.PATH, "main.jsp");
    partialConfig.setProperty(HTTPSamplerBase.METHOD, HTTPConstants.GET);
}
Also used : HTTPNullSampler(org.apache.jmeter.protocol.http.sampler.HTTPNullSampler) TestElementProperty(org.apache.jmeter.testelement.property.TestElementProperty) Arguments(org.apache.jmeter.config.Arguments) Before(org.junit.Before)

Example 7 with TestElementProperty

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

the class PackageTest method testArguments.

@Test
public void testArguments() throws Exception {
    Arguments args = new Arguments();
    args.addArgument("arg1", "val1", "=");
    TestElementProperty prop = new TestElementProperty("args", args);
    ConfigTestElement te = new ConfigTestElement();
    te.addProperty(prop);
    te.setRunningVersion(true);
    Arguments config = new Arguments();
    config.addArgument("config1", "configValue", "=");
    TestElementProperty configProp = new TestElementProperty("args", config);
    ConfigTestElement te2 = new ConfigTestElement();
    te2.addProperty(configProp);
    te.addTestElement(te2);
    assertEquals(2, args.getArgumentCount());
    assertEquals("config1=configValue", args.getArgument(1).toString());
    te.recoverRunningVersion();
    te.addTestElement(te2);
    assertEquals(2, args.getArgumentCount());
    assertEquals("config1=configValue", args.getArgument(1).toString());
}
Also used : TestElementProperty(org.apache.jmeter.testelement.property.TestElementProperty) Arguments(org.apache.jmeter.config.Arguments) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) Test(org.junit.Test)

Example 8 with TestElementProperty

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

the class GuiPackage method getTestElementCheckSum.

/**
     * Compute checksum of TestElement to detect changes
     * the method calculates properties checksum to detect testelement
     * modifications
     * TODO would be better to override hashCode for TestElement, but I decided not to touch it
     *
     * @param el {@link TestElement}
     * @return int checksum
     */
private int getTestElementCheckSum(TestElement el) {
    int ret = el.getClass().hashCode();
    PropertyIterator it = el.propertyIterator();
    while (it.hasNext()) {
        JMeterProperty obj = it.next();
        if (obj instanceof TestElementProperty) {
            ret ^= getTestElementCheckSum(((TestElementProperty) obj).getElement());
        } else {
            ret ^= obj.getName().hashCode();
            String stringValue = obj.getStringValue();
            if (stringValue != null) {
                ret ^= stringValue.hashCode();
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("obj.getStringValue() returned null for test element:" + el.getName() + " at property:" + obj.getName());
                }
            }
        }
    }
    return ret;
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) TestElementProperty(org.apache.jmeter.testelement.property.TestElementProperty) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Example 9 with TestElementProperty

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

the class MailerResultCollector method clear.

/** {@inheritDoc} */
@Override
public void clear() {
    super.clear();
    setProperty(new TestElementProperty(MAILER_MODEL, new MailerModel()));
}
Also used : TestElementProperty(org.apache.jmeter.testelement.property.TestElementProperty)

Example 10 with TestElementProperty

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

the class DNSCacheManager method isStaticHost.

private boolean isStaticHost(String host) {
    JMeterProperty p = getProperty(HOSTS);
    if (p instanceof NullProperty) {
        removeProperty(HOSTS);
        return false;
    }
    CollectionProperty property = (CollectionProperty) p;
    PropertyIterator iterator = property.iterator();
    while (iterator.hasNext()) {
        TestElementProperty possibleEntry = (TestElementProperty) iterator.next();
        if (log.isDebugEnabled()) {
            log.debug("Look for {} at {}: {}", host, possibleEntry.getObjectValue(), possibleEntry.getObjectValue().getClass());
        }
        StaticHost entry = (StaticHost) possibleEntry.getObjectValue();
        if (entry.getName().equalsIgnoreCase(host)) {
            if (log.isDebugEnabled()) {
                log.debug("Found static host: {} => {}", host, entry.getAddress());
            }
            return true;
        }
    }
    log.debug("No static host found for {}", host);
    return false;
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) NullProperty(org.apache.jmeter.testelement.property.NullProperty) TestElementProperty(org.apache.jmeter.testelement.property.TestElementProperty) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Aggregations

TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)22 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)5 TestElement (org.apache.jmeter.testelement.TestElement)4 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)4 Arguments (org.apache.jmeter.config.Arguments)3 NullProperty (org.apache.jmeter.testelement.property.NullProperty)3 StringProperty (org.apache.jmeter.testelement.property.StringProperty)3 HeaderManager (org.apache.jmeter.protocol.http.control.HeaderManager)2 BooleanProperty (org.apache.jmeter.testelement.property.BooleanProperty)2 PropertyIterator (org.apache.jmeter.testelement.property.PropertyIterator)2 Test (org.junit.Test)2 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 LoginConfig (org.apache.jmeter.config.LoginConfig)1 AuthManager (org.apache.jmeter.protocol.http.control.AuthManager)1 Authorization (org.apache.jmeter.protocol.http.control.Authorization)1 DNSCacheManager (org.apache.jmeter.protocol.http.control.DNSCacheManager)1 Header (org.apache.jmeter.protocol.http.control.Header)1 HTTPNullSampler (org.apache.jmeter.protocol.http.sampler.HTTPNullSampler)1 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)1