jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepak Shetty <shet...@gmail.com>
Subject Re: BeanShell PostProcessor and vars issue
Date Wed, 06 Oct 2010 20:30:31 GMT
> I then (for the sake of doing it simply) have 15 RegEx PostProcessors to
extract each link from the results.
Just to confirm you know you can use a regex to extract 15 values(assuming
this is possible) directly and loop over them right?

On Wed, Oct 6, 2010 at 4:09 AM, Paul Loy <keteracel@gmail.com> wrote:

> Hi All,
>
> I have the following in JMeter
>
> |
> |-- HTTP Request Sampler (search)
> |   |
> |   --- RegEx PostProcessors (x15)
> |
> |-- ForEach
> |   |
> |   --- HTTP Request Sampler (page)
> |       |
> |       |-- RegEx PostProcessor (extracts $_something)
> |       |
> |       --- BeanShell PostProcessor
> |
> |-- HTTP Request Sampler (using $_somelist)
>
> The first HTTP request performs a search that gets a list of 10 items. I
> then (for the sake of doing it simply) have 15 RegEx PostProcessors to
> extract each link from the results. For each of those links I then extract
> some other information via another HTTP Request. The idea is then to create
> a list of some of these items that I use in the final HTTP Request. My
> BeanShell PostProcessor should do this. Here is the code I have in there:
>
> String thing = (String) vars.get("_something");
> Object list_obj = vars.get("_somelist");
> String list = null;
>
> if (list_obj == null) {
>    log.info("new list");
>    list = thing;
> }
> else {
>    log.info("concat list");
>    java.util.Random random = new
> java.util.Random(System.currentTimeMillis());
>
>    int rand = random.nextInt(100);
>
>    if (rand < 40) {
>      list = (String) list_obj;
>      list += "%2C" + thing;
>    }
> }
>
> vars.put("_somelist", list);
>
> When I run this, I get the following Logging:
>
> 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement: *new list*
> 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement: *concat list*
>
> 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement: *new list*
> 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement:* concat list*
>
> 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement: *new list*
> 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement: *concat list*
>
> 2010/10/06 11:46:58 INFO  - jmeter.util.BeanShellTestElement: *new list*
> 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *concat list*
>
> 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *new list*
> 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *concat list*
> 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *concat list*
> 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *concat list*
>
> 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *new list*
> 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *concat list*
>
> 2010/10/06 11:46:59 INFO  - jmeter.util.BeanShellTestElement: *new list*
>
> It does indeed loop through 15 times, but seemingly arbitrarily it thinks
> that var _somelist is null and so starts a new list.
>
> Any thoughts?
>
> Thanks in advance,
>
> Paul.
>
> --
> ---------------------------------------------
> Paul Loy
> paul@keteracel.com
> http://uk.linkedin.com/in/paulloy
>

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