On 15 May 2012 13:46, <[email protected]> wrote: > sebb <[email protected]> wrote on 05/14/2012 12:44:31 PM: > >> From: sebb <[email protected]> >> To: JMeter Users List <[email protected]> >> Date: 05/14/2012 12:51 PM >> Subject: Re: Question about __logn() >> >> On 14 May 2012 17:30, <[email protected]> wrote: >> > I have a BeanShell Sampler that I have placed into a Once Only > Controller. >> > >> > In it, I have some code to help randomize my test in ways that I can't >> > easily do. >> > >> > The code is : >> > >> > <start code> >> > import java.io.*; >> > import java.util.*; >> > int n = 0; >> > for(Scanner sc = new Scanner( new File("..\\tests\\LoadTest\\resources >> > \\job_titles.txt") ); sc.hasNext(); ) >> > { >> > String line = sc.nextLine(); >> > line = line.replaceAll(" ", "+"); >> > vars.put("otl_JOB_TITLES_" + n, line); >> > n++; >> > } >> > >> > vars.put("otl_Counter", Integer.toString(n)); >> > >> > </end code> >> > >> > >> > However, as I am still developing this, I wanted to add a line to write > the >> > value of the counter variable to the logfile. >> > >> > When I add ${__logn(Counter is: ${otl_Counter})}; to the end of the > file, >> > after the final vars.put(), I get the following error: >> > >> > >> > 2012/05/14 11:22:43 ERROR - jmeter.util.BeanShellInterpreter: Error >> > invoking bsh method: eval Sourced file: inline evaluation of: > ``import >> > java.io.*; import java.util.*; int n = 0; for(Scanner sc = new Scanner >> > ( n . . . '' Token Parsing Error: Lexical error at line 4, column 50. >> > Encountered: "L" (76), after : "\"..\\tests\\" >> > > >> Read the error message - it's complaining about "L" after "tests\\" > > It's not actually an escaping issue - this code works without error if I > don't have the call to the __logn() function.
So don't use the function call. It does not make sense anyway to use it in a BeanShell script, because it will be processed before the script is passed to the interpreter. If you want to log from a BeanShell script, use the "log" object which is provided. > I've seen it do this before, where I had an error later in the code that > was being masked by an escaping error. > >> >> Looks like an escaping error. >> > > > This communication and any attachments are confidential, protected by > Communications Privacy Act 18 USCS § 2510, solely for the use of the intended > recipient, and may contain legally privileged material. If you are not the > intended recipient, please return or destroy it immediately. Thank you. > > --------------------------------------------------------------------- > 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]
