Search in sources :

Example 16 with NullProperty

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

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

the class PackageTest method testRecovery.

@Test
public void testRecovery() throws Exception {
    ConfigTestElement config = new ConfigTestElement();
    config.addProperty(new StringProperty("name", "config"));
    config.setRunningVersion(true);
    LoginConfig loginConfig = new LoginConfig();
    loginConfig.setUsername("user1");
    loginConfig.setPassword("pass1");
    assertTrue(config.getProperty("login") instanceof NullProperty);
    // This test should work whether or not all Nulls are equal
    assertEquals(new NullProperty("login"), config.getProperty("login"));
    config.addProperty(new TestElementProperty("login", loginConfig));
    assertEquals(loginConfig.toString(), config.getPropertyAsString("login"));
    config.recoverRunningVersion();
    assertTrue(config.getProperty("login") instanceof NullProperty);
    assertEquals(new NullProperty("login"), config.getProperty("login"));
}
Also used : NullProperty(org.apache.jmeter.testelement.property.NullProperty) TestElementProperty(org.apache.jmeter.testelement.property.TestElementProperty) LoginConfig(org.apache.jmeter.config.LoginConfig) StringProperty(org.apache.jmeter.testelement.property.StringProperty) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) Test(org.junit.Test)

Example 18 with NullProperty

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

the class VariableThroughputTimer method getRPSForSecond.

/**
 * @param durationSinceStartOfTestSec Elapsed time since start of test in seconds
 * @return double RPS at that second or -1 if we're out of schedule
 */
public Pair<Double, Long> getRPSForSecond(final double elapsedSinceStartOfTestSec) {
    JMeterProperty data = getData();
    if (data instanceof NullProperty) {
        return Pair.of(-1.0, 0L);
    }
    CollectionProperty rows = (CollectionProperty) data;
    PropertyIterator scheduleIT = rows.iterator();
    double newSec = elapsedSinceStartOfTestSec;
    double result = -1;
    boolean resultComputed = false;
    long totalDuration = 0;
    while (scheduleIT.hasNext()) {
        @SuppressWarnings("unchecked") List<Object> curProp = (List<Object>) scheduleIT.next().getObjectValue();
        int duration = getIntValue(curProp, DURATION_FIELD_NO);
        totalDuration += duration;
        if (!resultComputed) {
            double fromRps = getDoubleValue(curProp, FROM_FIELD_NO);
            double toRps = getDoubleValue(curProp, TO_FIELD_NO);
            if (newSec - duration <= 0) {
                result = fromRps + newSec * (toRps - fromRps) / (double) duration;
                resultComputed = true;
            } else {
                // We're not yet in the slot
                newSec -= duration;
            }
        }
    }
    return Pair.of(result, totalDuration);
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) NullProperty(org.apache.jmeter.testelement.property.NullProperty) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator) List(java.util.List)

Example 19 with NullProperty

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

the class FirefoxDriverConfig method setPreferences.

private void setPreferences(FirefoxProfile profile) {
    JMeterProperty property = getProperty(PREFERENCES);
    if (property instanceof NullProperty) {
        return;
    }
    CollectionProperty rows = (CollectionProperty) property;
    for (int i = 0; i < rows.size(); i++) {
        ArrayList row = (ArrayList) rows.get(i).getObjectValue();
        String name = ((JMeterProperty) row.get(0)).getStringValue();
        String value = ((JMeterProperty) row.get(1)).getStringValue();
        switch(value) {
            case "true":
                profile.setPreference(name, true);
                break;
            case "false":
                profile.setPreference(name, false);
                break;
            default:
                profile.setPreference(name, value);
                break;
        }
    }
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) NullProperty(org.apache.jmeter.testelement.property.NullProperty) ArrayList(java.util.ArrayList)

Example 20 with NullProperty

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

the class AbstractMonitoringVisualizer method configure.

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

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