You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by JMeter User <us...@gmail.com> on 2018/06/28 19:13:43 UTC
JSR223 PreProcessor - Issue
Added JSR223 PreProcessor with Script Language = Beanshell (Beanshell
2.0lb5)
Code is below
**********************************************************************
String MESSAGE = vars.get("MESSAGE");
log.info("OLD ----- " + MESSAGE);
int my_counter = Integer.parseInt(vars.get("my_counter"));
log.info("Initial Counter ----- " + my_counter);
my_counter = my_counter + 1;
log.info("Incremented Counter ----- " + my_counter);
//vars.put("my_counter", String.valueOf(my_counter));
*vars.put("my_counter", my_counter);*
//vars.put("my_counter", ${my_counter});
String NEWMESSAGE ="";
NEWMESSAGE = MESSAGE.replace("MYBILLERACCOUNT", my_counter);
// NEWMESSAGE = MESSAGE.replace("MYBILLERACCOUNT", ${my_counter});
log.info("NEW ----" + NEWMESSAGE);
**********************************************************************
I tried few options of all the commented code above
***********************************************************************
Getting below error line highlighted in bold
2018-06-28 14:07:37,683 ERROR o.a.j.m.JSR223PreProcessor: Problem in JSR223
script, JSR223 PreProcessor - {"account": {"accountType":
"INDIV","billerAccountId": "MYBILLERACCOUNT: []}
javax.script.ScriptException: Sourced file: inline evaluation of: ``String
MESSAGE = vars.get("MESSAGE"); log.info("OLD ----- " + MESSAGE); int my_ .
. . '' : Error in method invocation: Method put( java.lang.String, int )
not found in class'org.apache.jmeter.threads.JMeterVariables' : at Line: 10
: in file: inline evaluation of: ``String MESSAGE = vars.get("MESSAGE");
log.info("OLD ----- " + MESSAGE); int my_ . . . '' : vars .put (
"my_counter" , my_counter )
in inline evaluation of: ``String MESSAGE = vars.get("MESSAGE"); log.info("OLD
----- " + MESSAGE); int my_ . . . '' at line number 10
Re: JSR223 PreProcessor - Issue
Posted by "glinius@live.com" <gl...@live.com>.
Don't inline JMeter Functions and/or Variables
<https://jmeter.apache.org/usermanual/functions.html> into Groovy code.
As per JSR223 Sampler documentation
<http://jmeter.apache.org/usermanual/component_reference.html#JSR223_Sampler>
> When using this feature, ensure your script code does not use JMeter
> variables directly in script code as caching would only cache first
> replacement. Instead use script parameters
If you're looking for a "pure" Groovy
<https://www.blazemeter.com/blog/groovy-new-black> equivalent of your code
it would be something like:
> vars.put('MESSAGE', new File('C:\\Users\\xyz\\Desktop\\Test.txt').text)
--
Sent from: http://www.jmeter-archive.org/JMeter-User-f512775.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
Re: JSR223 PreProcessor - Issue
Posted by UserJMeter999 <us...@gmail.com>.
When i try to use this function in JSR Preprocessor
${__FileToString(C:\Users\svc_automation\Desktop\Test.txt,,MESSAGE)}
getting below error
2018-06-28 14:38:19,325 ERROR o.a.j.m.JSR223PreProcessor: Problem in JSR223
script, JSR223 PreProcessor -
in inline evaluation of: ``{"account": {"accountType": "INDIV"," . . . '' at
line number 1
--
Sent from: http://www.jmeter-archive.org/JMeter-User-f512775.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org
Re: JSR223 PreProcessor - Issue
Posted by UBIK LOAD PACK Support <su...@ubikloadpack.com>.
Hello,
1/ *vars.put("my_counter", my_counter);*
Should be:
*vars.put("my_counter", Integer.toString(my_counter));*
2/ Switch to Groovy instead of Beanshell and check cache . Beanshell does
not perform well
UbikLoadPack Support Team
@ubikloadpack
On Thu, Jun 28, 2018 at 9:13 PM, JMeter User <us...@gmail.com> wrote:
> Added JSR223 PreProcessor with Script Language = Beanshell (Beanshell
> 2.0lb5)
>
>
> Code is below
> **********************************************************************
>
> String MESSAGE = vars.get("MESSAGE");
> log.info("OLD ----- " + MESSAGE);
>
> int my_counter = Integer.parseInt(vars.get("my_counter"));
> log.info("Initial Counter ----- " + my_counter);
> my_counter = my_counter + 1;
> log.info("Incremented Counter ----- " + my_counter);
>
> //vars.put("my_counter", String.valueOf(my_counter));
> *vars.put("my_counter", my_counter);*
> //vars.put("my_counter", ${my_counter});
>
> String NEWMESSAGE ="";
> NEWMESSAGE = MESSAGE.replace("MYBILLERACCOUNT", my_counter);
> // NEWMESSAGE = MESSAGE.replace("MYBILLERACCOUNT", ${my_counter});
> log.info("NEW ----" + NEWMESSAGE);
>
>
> **********************************************************************
> I tried few options of all the commented code above
> ***********************************************************************
> Getting below error line highlighted in bold
>
> 2018-06-28 14:07:37,683 ERROR o.a.j.m.JSR223PreProcessor: Problem in JSR223
> script, JSR223 PreProcessor - {"account": {"accountType":
> "INDIV","billerAccountId": "MYBILLERACCOUNT: []}
> javax.script.ScriptException: Sourced file: inline evaluation of: ``String
> MESSAGE = vars.get("MESSAGE"); log.info("OLD ----- " + MESSAGE); int my_
> .
> . . '' : Error in method invocation: Method put( java.lang.String, int )
> not found in class'org.apache.jmeter.threads.JMeterVariables' : at Line:
> 10
> : in file: inline evaluation of: ``String MESSAGE = vars.get("MESSAGE");
> log.info("OLD ----- " + MESSAGE); int my_ . . . '' : vars .put (
> "my_counter" , my_counter )
> in inline evaluation of: ``String MESSAGE = vars.get("MESSAGE"); log.info
> ("OLD
> ----- " + MESSAGE); int my_ . . . '' at line number 10
>