Sorry, that should have been: print("Size=${clientSize}.");
This does not define clientSize; it displays the value in the console window so you can check that you have defined it properly. On 13/06/07, bvm101 <[EMAIL PROTECTED]> wrote:
I am sorry, I am looking at the example to define clientSize, but I can't figure it out: print("Size=${clientSize}.";. Will you elaborate? sebb-2 wrote: > > On 12/06/07, bvm101 <[EMAIL PROTECTED]> wrote: >> >> I did try ${__Random(0,${clientSize} ,myRandom)};, however, I get >> following >> error (error log): > > There's a space after ${clientSize} - try removing it. > > If that does not help, make sure that clientSize is defined, e.g. by > adding the following to the BeanShell script: > > print("Size=${clientSize}."; > >> >> 2007/06/12 17:41:43 ERROR - jmeter.threads.JMeterThread: >> java.lang.NumberFormatException: For input string: "${clientSize}" >> at java.lang.NumberFormatException.forInputString(Unknown Source) >> at java.lang.Long.parseLong(Unknown Source) >> at java.lang.Long.parseLong(Unknown Source) >> at org.apache.jmeter.functions.Random.execute(Random.java:78) >> at >> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:127) >> at >> org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:96) >> at >> org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:85) >> at >> org.apache.jmeter.testbeans.TestBeanHelper.prepare(TestBeanHelper.java:69) >> at >> org.apache.jmeter.threads.TestCompiler.runPreProcessors(TestCompiler.java:109) >> at >> org.apache.jmeter.threads.TestCompiler.configureSampler(TestCompiler.java:98) >> at >> org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:236) >> at java.lang.Thread.run(Unknown Source) >> >> ${__Random(0,${clientSize} ,myRandom)}; >> >> sebb-2 wrote: >> > >> > On 12/06/07, bvm101 <[EMAIL PROTECTED]> wrote: >> >> >> >> Within a BeanShell PreProcessor I have a following code: >> >> >> >> java.util.List ids = new java.util.ArrayList(); >> >> ids.add("key1"); >> >> ids.add("key2"); >> >> ids.add("key3"); >> >> >> >> int clientSize = ids.size(); >> >> >> >> ${__Random(0,3 ,myRandom)}; >> > >> > The above line should give the clue ... try >> > >> > ${__Random(0,${clientSize} ,myRandom)}; >> > >> >> vars.put("Col_65537", ids.get(${myRandom})); >> >> >> >> >> >> However, when calling random function I would like to pass a variable >> for >> >> the max value, in this case "clientSize", instead of number 3. >> >> >> >> Your help will be greatly appreciated. >> > >> > If your test uses this Pre-processor a lot, you may find you get memory >> > leaks. >> > >> > You could put the code in an init file, and then call a method passing >> > in the Random number. >> > >> >> Thanks, >> >> >> >> Boban >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11085352 >> >> Sent from the JMeter - User mailing list archive at Nabble.com. >> >> >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> >> > >> > --------------------------------------------------------------------- >> > To unsubscribe, e-mail: [EMAIL PROTECTED] >> > For additional commands, e-mail: [EMAIL PROTECTED] >> > >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11088976 >> Sent from the JMeter - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/How-to-pass-a-variable-as-a-parameter-to-random-function-tf3909593.html#a11090492 Sent from the JMeter - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]