jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Question about __logn()
Date Mon, 14 May 2012 17:44:31 GMT
On 14 May 2012 17:30,  <llowder@oreillyauto.com> 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\\"

Looks like an escaping error.

Try using / instead of \\ in the path name.

> What am I doing wrong? Based on some Google searches and the jmeter docs, I
> would think that would work.
>
>
> For clarity, here is the full code that produces the error:
>
> <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));
> ${__logn(Counter is: ${otl_Counter})};
> </end code>
>
>
>
> Thank you.
>
>
> Lee Lowder
>
> 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: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Mime
View raw message