use of org.apache.jmeter.util.BeanShellInterpreter in project jmeter by apache.
the class BeanShellPostProcessor method process.
@Override
public void process() {
JMeterContext jmctx = JMeterContextService.getContext();
SampleResult prev = jmctx.getPreviousResult();
if (prev == null) {
// TODO - should we skip processing here?
return;
}
final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
if (bshInterpreter == null) {
log.error("BeanShell not found");
return;
}
try {
// Add variables for access to context and variables
//$NON-NLS-1$
bshInterpreter.set("data", prev.getResponseData());
processFileOrScript(bshInterpreter);
} catch (JMeterException e) {
if (log.isWarnEnabled()) {
log.warn("Problem in BeanShell script: {}", e.toString());
}
}
}
use of org.apache.jmeter.util.BeanShellInterpreter in project jmeter by apache.
the class BeanShellListener method sampleOccurred.
@Override
public void sampleOccurred(SampleEvent se) {
final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
if (bshInterpreter == null) {
log.error("BeanShell not found");
return;
}
SampleResult samp = se.getResult();
try {
//$NON-NLS-1$
bshInterpreter.set("sampleEvent", se);
//$NON-NLS-1$
bshInterpreter.set("sampleResult", samp);
processFileOrScript(bshInterpreter);
} catch (JMeterException e) {
if (log.isWarnEnabled()) {
log.warn("Problem in BeanShell script. {}", e.toString());
}
}
}
use of org.apache.jmeter.util.BeanShellInterpreter in project jmeter by apache.
the class BeanShell method setParameters.
/** {@inheritDoc} */
@Override
public synchronized void setParameters(Collection<CompoundVariable> parameters) throws InvalidVariableException {
checkParameterCount(parameters, 1, 2);
values = parameters.toArray();
try {
bshInterpreter = new BeanShellInterpreter(JMeterUtils.getProperty(INIT_FILE), log);
} catch (ClassNotFoundException e) {
throw new InvalidVariableException("BeanShell not found", e);
}
}
Aggregations