use of org.apache.jmeter.testelement.property.JMeterProperty 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 LinkedList<>();
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.JMeterProperty in project jmeter by apache.
the class TestBeanGUI method setValues.
/**
* Get values from element to fill propertyMap and setup customizer
* @param element TestElement
*/
private void setValues(TestElement element) {
// Copy all property values into the map:
for (PropertyIterator jprops = element.propertyIterator(); jprops.hasNext(); ) {
JMeterProperty jprop = jprops.next();
propertyMap.put(jprop.getName(), jprop.getObjectValue());
}
if (customizer != null) {
customizer.setObject(propertyMap);
} else {
if (initialized) {
remove(customizerIndexInPanel);
}
Customizer c = customizers.get(element);
if (c == null) {
c = createCustomizer();
c.setObject(propertyMap);
customizers.put(element, c);
}
add((Component) c, BorderLayout.CENTER);
}
}
use of org.apache.jmeter.testelement.property.JMeterProperty in project jmeter by apache.
the class AbstractTestElement method getSearchableTokens.
/**
* {@inheritDoc}}
*/
@Override
public List<String> getSearchableTokens() {
List<String> result = new ArrayList<>(25);
PropertyIterator iterator = propertyIterator();
while (iterator.hasNext()) {
JMeterProperty jMeterProperty = iterator.next();
result.add(jMeterProperty.getName());
result.add(jMeterProperty.getStringValue());
}
return result;
}
use of org.apache.jmeter.testelement.property.JMeterProperty in project jmeter by apache.
the class AbstractThreadGroup method initialize.
/** {@inheritDoc} */
@Override
public void initialize() {
Controller c = getSamplerController();
JMeterProperty property = c.getProperty(TestElement.NAME);
// Copy our name into that of the controller
property.setObjectValue(getName());
// otherwise name reverts
property.setRunningVersion(property.isRunningVersion());
c.initialize();
}
use of org.apache.jmeter.testelement.property.JMeterProperty 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;
}
Aggregations