Search in sources :

Example 1 with NullProperty

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

the class TestBeanHelper method unwrapProperty.

private static Object unwrapProperty(PropertyDescriptor desc, JMeterProperty jprop, Class<?> type) {
    Object value;
    if (jprop instanceof TestElementProperty) {
        TestElement te = ((TestElementProperty) jprop).getElement();
        if (te instanceof TestBean) {
            prepare(te);
        }
        value = te;
    } else if (jprop instanceof MultiProperty) {
        value = unwrapCollection((MultiProperty) jprop, (String) desc.getValue(TableEditor.CLASSNAME));
    } else // value was not provided, and this is allowed
    if (jprop instanceof NullProperty && // use negative condition so missing (null) value is treated as FALSE
    !Boolean.TRUE.equals(desc.getValue(GenericTestBeanCustomizer.NOT_UNDEFINED))) {
        value = null;
    } else {
        value = Converter.convert(jprop.getStringValue(), type);
    }
    return value;
}
Also used : NullProperty(org.apache.jmeter.testelement.property.NullProperty) TestElementProperty(org.apache.jmeter.testelement.property.TestElementProperty) MultiProperty(org.apache.jmeter.testelement.property.MultiProperty) TestElement(org.apache.jmeter.testelement.TestElement)

Example 2 with NullProperty

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

the class UrlConfigTest method testOverRide.

@Test
public void testOverRide() {
    JMeterProperty jmp = partialConfig.getProperty(HTTPSamplerBase.DOMAIN);
    assertTrue(jmp instanceof NullProperty);
    assertEquals(jmp, new NullProperty(HTTPSamplerBase.DOMAIN));
    partialConfig.addTestElement(defaultConfig);
    assertEquals(partialConfig.getPropertyAsString(HTTPSamplerBase.DOMAIN), "www.xerox.com");
    assertEquals(partialConfig.getPropertyAsString(HTTPSamplerBase.PATH), "main.jsp");
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) NullProperty(org.apache.jmeter.testelement.property.NullProperty) Test(org.junit.Test)

Example 3 with NullProperty

use of org.apache.jmeter.testelement.property.NullProperty 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)

Example 4 with NullProperty

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

the class DNSCacheManager method fromStaticHost.

private InetAddress[] fromStaticHost(String host) {
    JMeterProperty p = getProperty(HOSTS);
    if (p instanceof NullProperty) {
        removeProperty(HOSTS);
        return new InetAddress[0];
    }
    CollectionProperty property = (CollectionProperty) p;
    PropertyIterator iterator = property.iterator();
    while (iterator.hasNext()) {
        StaticHost entry = (StaticHost) ((TestElementProperty) iterator.next()).getObjectValue();
        if (entry.getName().equals(host)) {
            List<InetAddress> addresses = new ArrayList<>();
            for (String address : Arrays.asList(entry.getAddress().split("\\s*,\\s*"))) {
                try {
                    addresses.addAll(Arrays.asList(requestLookup(address)));
                } catch (UnknownHostException e) {
                    log.warn("Couldn't resolve static address {} for host {}", address, host, e);
                }
            }
            return addresses.toArray(new InetAddress[addresses.size()]);
        }
    }
    return new InetAddress[0];
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) NullProperty(org.apache.jmeter.testelement.property.NullProperty) UnknownHostException(java.net.UnknownHostException) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator) ArrayList(java.util.ArrayList) InetAddress(java.net.InetAddress)

Example 5 with NullProperty

use of org.apache.jmeter.testelement.property.NullProperty in project jmeter-plugins by undera.

the class JMXMonGui method configure.

@Override
public void configure(TestElement te) {
    super.configure(te);
    JMXMonCollector dmte = (JMXMonCollector) te;
    JMeterProperty jmxmonValues = dmte.getSamplerSettings();
    if (!(jmxmonValues instanceof NullProperty)) {
        JMeterPluginsUtils.collectionPropertyToTableModelRows((CollectionProperty) jmxmonValues, tableModel, columnClasses);
    } else {
        log.warn("Received null property instead of collection");
    }
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) NullProperty(org.apache.jmeter.testelement.property.NullProperty) JMXMonCollector(kg.apc.jmeter.jmxmon.JMXMonCollector)

Aggregations

NullProperty (org.apache.jmeter.testelement.property.NullProperty)26 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)24 CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)13 ArrayList (java.util.ArrayList)4 PropertyIterator (org.apache.jmeter.testelement.property.PropertyIterator)3 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)3 List (java.util.List)2 TestElement (org.apache.jmeter.testelement.TestElement)2 StringProperty (org.apache.jmeter.testelement.property.StringProperty)2 Test (org.junit.Test)2 FirefoxDriverConfig (com.googlecode.jmeter.plugins.webdriver.config.FirefoxDriverConfig)1 File (java.io.File)1 IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 UnknownHostException (java.net.UnknownHostException)1 DbMonCollector (kg.apc.jmeter.dbmon.DbMonCollector)1 JMXMonCollector (kg.apc.jmeter.jmxmon.JMXMonCollector)1 PerfMonCollector (kg.apc.jmeter.perfmon.PerfMonCollector)1 CorrectedResultCollector (kg.apc.jmeter.vizualizers.CorrectedResultCollector)1 MonitoringResultsCollector (kg.apc.jmeter.vizualizers.MonitoringResultsCollector)1