0
votes

I have set up a Test Plan using Jmeter with XMPP plugin and openfire (as my server) . When I run my test (using the Jmeter GUI) for each: XMPP Collect Packages Sample I am getting a response data as number of packets received along with packets itself, I need to get the subSample result .

IN BeanShell Sampler I have

import org.apache.jmeter.samplers.SampleResult;

System.out.println( "myData-->"+SampleResult subResult : 
SampleResult.getSubResults());

I keep getting this error:

 Typed variable declaration : Cannot reach instance method: getSubResults() from static context: org.apache.jmeter.samplers.SampleResult

From GUI when I click on the message from collectPackage sampler itself I see:

<message id='Q93Ww-102' to='user0@n-dev-xyz' from='user0@n-dev-xyz/jmeter'><body>Hello, it&apos;s user1</body></message>

enter image description here

1

1 Answers

0
votes
  1. You cannot do this from the Beanshell Sampler itself, in order to be able to work with the XMPP Sampler sub-results you need:

    • Add Beanshell Post-Processor as a child of the XMPP Sampler. You will be able to access the parent sampler result using prev shorthand like:

      SampleResult [] subResults = prev.getSubResults();
      
    • If you still want to use Beanshell Sampler you need to place it after the XMPP Sampler and use ctx shorthand to access previous sampler result like:

      SampleResult [] subResults = ctx.getPreviousResult().getSubResults();
      
  2. Be aware that starting from JMeter 3.1 it is strongly recommended to use JSR223 Test Elements and Groovy language for any form of scripting mainly because Groovy performance is much better comparing to Beanshell so I would suggest migrating to JSR223 Post-Processor and Groovy on next available opportunity.