use of org.apache.jmeter.testelement.property.PropertyIterator in project jmeter by apache.
the class AnchorModifier method modifyArgument.
private void modifyArgument(Argument arg, Arguments args) {
if (log.isDebugEnabled()) {
log.debug("Modifying argument: " + arg);
}
List<Argument> possibleReplacements = new ArrayList<>();
PropertyIterator iter = args.iterator();
Argument replacementArg;
while (iter.hasNext()) {
replacementArg = (Argument) iter.next().getObjectValue();
try {
if (HtmlParsingUtils.isArgumentMatched(replacementArg, arg)) {
possibleReplacements.add(replacementArg);
}
} catch (Exception ex) {
log.error("Problem adding Argument", ex);
}
}
if (!possibleReplacements.isEmpty()) {
replacementArg = possibleReplacements.get(ThreadLocalRandom.current().nextInt(possibleReplacements.size()));
arg.setName(replacementArg.getName());
arg.setValue(replacementArg.getValue());
if (log.isDebugEnabled()) {
log.debug("Just set argument to values: " + arg.getName() + " = " + arg.getValue());
}
args.removeArgument(replacementArg);
}
}
Aggregations