use of org.apache.jmeter.threads.JMeterVariables in project jmeter-plugins by undera.
the class FifoSize method execute.
@Override
public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException {
String fifoName = ((CompoundVariable) values[0]).execute();
int size = FifoMap.getInstance().length(fifoName);
String value = Integer.toString(size);
JMeterVariables vars = getVariables();
if (vars != null && values.length > 1) {
String varName = ((CompoundVariable) values[1]).execute().trim();
vars.put(varName, value);
}
return value;
}
use of org.apache.jmeter.threads.JMeterVariables in project jmeter-plugins by undera.
the class WebDriverSamplerTest method createSampler.
@Before
public void createSampler() {
browser = Mockito.mock(WebDriver.class);
when(browser.getPageSource()).thenReturn("page source");
when(browser.getCurrentUrl()).thenReturn("http://google.com.au");
variables = new JMeterVariables();
variables.putObject(WebDriverConfig.BROWSER, browser);
JMeterContextService.getContext().setVariables(variables);
sampler = new WebDriverSampler();
}
use of org.apache.jmeter.threads.JMeterVariables in project jmeter-plugins by undera.
the class JSONPathExtractorTest method testProcess_default.
@Test
public void testProcess_default() {
System.out.println("process def");
JMeterContext context = JMeterContextService.getContext();
SampleResult res = new SampleResult();
context.setPreviousResult(res);
JSONPathExtractor instance = new JSONPathExtractor();
instance.setDefaultValue("DEFAULT");
instance.setVar("test");
instance.process();
JMeterVariables vars = context.getVariables();
assertEquals("DEFAULT", vars.get("test"));
}
use of org.apache.jmeter.threads.JMeterVariables in project jmeter-plugins by undera.
the class JSONPathExtractorTest method testReported2.
@Ignore
// FIXME: we need to solve this one day
@Test
public void testReported2() {
System.out.println("process reported");
JMeterContext context = JMeterContextService.getContext();
SampleResult res = new SampleResult();
res.setResponseData(json3.getBytes());
context.setPreviousResult(res);
JSONPathExtractor instance = new JSONPathExtractor();
instance.setVar("var");
instance.setJsonPath("$.data[?(@.attr.value>0)][0].attr");
instance.setDefaultValue("NOTFOUND");
instance.process();
JMeterVariables vars = context.getVariables();
assertNotEquals("NOTFOUND", vars.get("var"));
assertEquals("{value=1}", vars.get("var"));
}
use of org.apache.jmeter.threads.JMeterVariables in project jmeter-plugins by undera.
the class JSONPathExtractorTest method testProcess_chinese.
@Test
public void testProcess_chinese() {
JMeterContext context = JMeterContextService.getContext();
SampleResult res = new SampleResult();
String chinese = "{\"carBrandName\":\"大众\"}";
res.setResponseData(chinese.getBytes());
context.setPreviousResult(res);
JSONPathExtractor instance = new JSONPathExtractor();
instance.setDefaultValue("DEFAULT");
instance.setVar("test");
instance.setJsonPath("$.carBrandName");
instance.process();
JMeterVariables vars = context.getVariables();
// freaking "static final" DEFAULT_ENCODING field in SampleResult does not allow us to assert this
// assertEquals("大众", vars.get("test"));
}
Aggregations