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);
}
}
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"));
}
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);
}
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;
}
}
}
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");
}
}
Aggregations