jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepak Shetty <shet...@gmail.com>
Subject Re: error .jmeter.samplers.SampleResult;
Date Tue, 29 Mar 2016 19:03:43 GMT
Hi
whats the complete error ? I tried by spoofing your variables and it worked
fine , so it might not be working for some specific variable conditions -
so add a debug sampler and see what your variables are

(I tried  with
vars.put("comny_id_#","2");
vars.put("stopLooping","1");
vars.put("pathtoinputdata","d:/") ;
vars.put("comny_id_1","dpk");
vars.put("comny_id_2","sh");
vars.put("year_1","1dpk");
vars.put("year_2","1sh"); )

Please also note the following
a. An assertions responsibility is not to write things to file - That is a
listeners responsibility.
b. Look up sample_variables in jmeter documentation - does it solve what
you want to do ?
c. Consider that you might someday need to run this test with multiple
threads - will your code work ?





On Tue, Mar 29, 2016 at 2:09 AM, Srikrishna Dandamraju <
skdandamraju@gmail.com> wrote:

> hi all
>
> i am getting below error  for bean shell assertion issue,
>
> Assertion failure message: org.apache.jorphan.util.JMeterException: Error
> invoking bsh method: eval Sourced file: inline evaluation of: ``import
> org.apache.jmeter.samplers.SampleResult; import org.apache.jmeter.threads .
> . . '' : Typed variable declaration : Object constructor.
>
> i am trying to copy response in to a csv file
> with below  bean  shell assertion code
>
> import org.apache.jmeter.samplers.SampleResult;
> import org.apache.jmeter.threads.JMeterContext;
> import org.apache.jmeter.threads.JMeterContextService;
>
> SampleResult
> previousResult=JMeterContextService.getContext().getPreviousResult();
> previousResult.setSampleLabel(previousResult.getSampleLabel() + "_" +
> vars.get("comny_id_#") + "-Rows");
>
> if(Integer.parseInt(vars.get("stopLooping")) == 3)
> {
>   vars.put("stopAsking", "true");
>   Failure = true;
>   FailureMessage = "Dont received data";
> }
>
> if(vars.get("comny_id_#") != null &&
> Integer.parseInt(vars.get("comny_id_#")) != 0)
> {
>   vars.put("stopAsking","true");
>   FileOutputStream outPath = new
> FileOutputStream(vars.get("pathtoinputdata") + "comny_id_year.csv");
>   PrintStream outFile = new PrintStream(outPath);
>
>   int iterMax = Integer.parseInt(vars.get("comny_id_#"));
>   for(int i = 1; i <= iterMax; i++)
>     outFile.println(vars.get("comny_id_" + i.toString()) + "," +
> vars.get("year_" + i.toString()));
>
>   outPath.close();
>   outFile.close();
> }
>
> help me as asap.
>
> Thanks
> Srikrishna.D
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message