Am 14.11.2016 14:47, schrieb Epp, Jeremiah W (Contractor):
While working on our load automation tooling, I've had to figure out a
lot
of obscure and relatively undocumented things about the JMeter
internals.
One of the more bizarre things I've run into is a bunch of setter
methods
that apparently just don't work, forcing you to use setProperty() in a
bunch
of places instead. It's really annoying.
Example:
JSR223PostProcessor jsr = new JSR223PostProcessor();
jsr. setScriptLanguage("beanshell"); // This doesn't actually do
anything.
jsr. setProperty("scriptLanguage", "beanshell"); // We have to use
this.
I have attached a test case that models this, with the only downside,
that it works with current trunk.
Which version of JMeter do you use? And is the test broken with your
sources?
I realised last Friday (after hitting two more) that I should probably
be
reporting these, but I wanted to check on the list first about how we
want
them in Bugzilla. Should each method have a bug? Each class? Should
there
be a tracking bug for them? A bz Keyword? Please advise.
If you think the api doesn't work as it should, you could first try to
discuss it here on the mailing list, or if it is really a no-brainer,
submit a bug. It would be superb, if you could provide a test case
showing the error.
On the scope of the bug. Judge yourself. I prefer to have simple bug
reports.
Regards,
Felix
Regards,
Wyatt
Confidentiality Notice: This electronic message transmission,
including any attachment(s), may contain confidential, proprietary, or
privileged information from Chemical Abstracts Service ("CAS"), a
division of the American Chemical Society ("ACS"). If you have
received this transmission in error, be advised that any disclosure,
copying, distribution, or use of the contents of this information is
strictly prohibited. Please destroy all copies of the message and
contact the sender immediately by either replying to this message or
calling 614-447-3600.
package org.apache.jmeter.extractor;
import static org.junit.Assert.assertThat;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.JMeterVariables;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
public class JSR223PostProcessorTest {
@Test
public void testGetScriptLanguage() {
JSR223PostProcessor processor = new JSR223PostProcessor();
processor.setScriptLanguage("JavaScript");
assertThat(processor.getScriptLanguage(),
CoreMatchers.is("JavaScript"));
processor.setScriptLanguage("BeanShell");
assertThat(processor.getScriptLanguage(), CoreMatchers.is("BeanShell"));
}
@Test
public void testProcessDefaultLanguage() throws Exception {
JSR223PostProcessor processor = new JSR223PostProcessor();
processor.setScript("def answer = 1+2+3+5+7+11+13; vars.put('result',
''+answer)");
processor.setThreadContext(initialContext());
processor.process();
assertThat(processor.getThreadContext().getVariables().get("result"),
CoreMatchers.is("42"));
}
@Test
public void testProcessJS() throws Exception {
JSR223PostProcessor processor = new JSR223PostProcessor();
processor.setScriptLanguage("JavaScript");
processor.setScript("var answer = 1+2+3+5+7+11+13; vars.put('result',
''+answer)");
processor.setThreadContext(initialContext());
processor.process();
assertThat(processor.getThreadContext().getVariables().get("result"),
CoreMatchers.is("42"));
}
private JMeterContext initialContext() {
JMeterContext context = JMeterContextService.getContext();
context.setPreviousResult(new SampleResult());
context.setVariables(new JMeterVariables());
return context;
}
}