jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Srikrishna Dandamraju <skdandamr...@gmail.com>
Subject Re: Sampler parameters in Log file or jtl file??
Date Tue, 29 Mar 2016 07:36:47 GMT
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




On Fri, Mar 25, 2016 at 11:44 PM, Deepak Shetty <shettyd@gmail.com> wrote:

> A variable can be written to file using sample_variables (
> http://jmeter.apache.org/usermanual/listeners.html#sample_variables) -
> However thats probably not what you are looking for
> If I understand correctly , you want the parameters that the Sampler is
> sending , to be printed out in the JTL file . I can see two options
>
> a. If you are limiting yourself to HTTPSamplers , it should be possible to
> write a Pre-processor that reads all the parameters on the sampler and
> writes it as a single string to a pre-defined variable , and then you
> configure that variable to be written using sample_variables
> b. Write your own listener (or use a listener that allows you to write
> custom code)
>
> However the question is why do you want to do this ? Is it to debug
> failures ? In which case there are probably better ways to handle it (for
> e.g. saving responses or diagnostic information only on errors) - I also
> sometimes use variable names in the Assertion , so that it gives me enough
> information when the assertion fails
>
> regards
> deepak
>
> On Thu, Mar 24, 2016 at 8:26 PM, Prakash Palnati <
> prakash.palnati@snapwiz.com> wrote:
>
> > Hi,
> >
> > Is there  a way that I get the parameters that are being passed in each
> > sample in a log file or a jtl file?
> >
> > Thanks in advance.
> >
> > Best,
> > Prakash
> >
>

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