use of org.apache.jmeter.testelement.property.NumberProperty in project jmeter by apache.
the class ValueReplacer method replaceValues.
/**
* Replaces a {@link StringProperty} containing functions with their Function properties equivalent.
* <p>For example:
* <code>${__time()}_${__threadNum()}_${__machineName()}</code> will become a
* {@link org.apache.jmeter.testelement.property.FunctionProperty} of
* a {@link CompoundVariable} containing three functions
* @param iter the {@link PropertyIterator} over all properties, in which the values should be replaced
* @param transform the {@link ValueTransformer}, that should do transformation
* @return a new {@link Collection} with all the transformed {@link JMeterProperty}s
* @throws InvalidVariableException when <code>transform</code> throws an {@link InvalidVariableException} while transforming a value
*/
private Collection<JMeterProperty> replaceValues(PropertyIterator iter, ValueTransformer transform) throws InvalidVariableException {
List<JMeterProperty> props = new ArrayList<>();
while (iter.hasNext()) {
JMeterProperty val = iter.next();
if (log.isDebugEnabled()) {
log.debug("About to replace in property of type: {}: {}", val.getClass(), val);
}
if (val instanceof StringProperty) {
// Must not convert TestElement.gui_class etc
if (!val.getName().equals(TestElement.GUI_CLASS) && !val.getName().equals(TestElement.TEST_CLASS)) {
val = transform.transformValue(val);
log.debug("Replacement result: {}", val);
}
} else if (val instanceof NumberProperty) {
val = transform.transformValue(val);
log.debug("Replacement result: {}", val);
} else if (val instanceof MultiProperty) {
MultiProperty multiVal = (MultiProperty) val;
Collection<JMeterProperty> newValues = replaceValues(multiVal.iterator(), transform);
multiVal.clear();
for (JMeterProperty jmp : newValues) {
multiVal.addProperty(jmp);
}
log.debug("Replacement result: {}", multiVal);
} else {
log.debug("Won't replace {}", val);
}
props.add(val);
}
return props;
}
use of org.apache.jmeter.testelement.property.NumberProperty in project jmeter by apache.
the class TestNumberProperty method testCompareToMinMax.
@Test
public void testCompareToMinMax() {
NumberProperty n1 = new DoubleProperty("n1", Double.MIN_VALUE);
NumberProperty n2 = new DoubleProperty("n2", Double.MAX_VALUE);
assertTrue(n1.compareTo(n2) < 0);
}
use of org.apache.jmeter.testelement.property.NumberProperty in project jmeter by apache.
the class TestNumberProperty method testDZeroCompareToDZero.
@Test
public void testDZeroCompareToDZero() {
NumberProperty n1 = new DoubleProperty("n1", 0.0);
NumberProperty n2 = new DoubleProperty("n2", 0.0);
assertEquals(0, n1.compareTo(n2));
}
use of org.apache.jmeter.testelement.property.NumberProperty in project jmeter by apache.
the class TestNumberProperty method testIZeroCompareToDZero.
@Test
public void testIZeroCompareToDZero() {
NumberProperty n1 = new IntegerProperty("n1", 0);
NumberProperty n2 = new DoubleProperty("n2", 0.0);
assertEquals(0, n1.compareTo(n2));
}
use of org.apache.jmeter.testelement.property.NumberProperty in project jmeter by apache.
the class TestNumberProperty method testCompareToNegative.
@Test
public void testCompareToNegative() {
NumberProperty n1 = new DoubleProperty("n1", -1.0);
NumberProperty n2 = new DoubleProperty("n2", 0.0);
assertTrue(n1.compareTo(n2) < 0);
}
Aggregations