The answer is to use ctx.getVariables().get("_somelist") rather than vars.get("_somelist") (and similarly for put). I guess this is something missing from the documentation!
Paul. On Wed, Oct 6, 2010 at 12:09 PM, Paul Loy <ketera...@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 > p...@keteracel.com > http://uk.linkedin.com/in/paulloy > -- --------------------------------------------- Paul Loy p...@keteracel.com http://uk.linkedin.com/in/paulloy