Questions tagged [beanshell]

Lightweight scripting for Java

From the official site:

BeanShell is a small, free, embeddable Java source interpreter with object scripting language features, written in Java. BeanShell dynamically executes standard Java syntax and extends it with common scripting conveniences such as loose types, commands, and method closures like those in Perl and JavaScript

943 questions
3
votes
2 answers

Jmeter while controller doesn't seem to evaluate variables as numbers

I am writing a jmeter script that keeps loading data until a table reaches a specified size. I have a while loop, in which I have one HTTP Sampler to loads the data, then another HTTP Sampler with an XPath Post-processor to check the table size…
Julie Sheffield
  • 145
  • 2
  • 9
3
votes
4 answers

Generating sequence number in Beanshell scripting

I am new to Beanshell scripting. I am trying to generate sequential numbers, the scripting code I tried is as below File Name: sequence.bsh string = new String(); Long[] n = new Long[] {1000}; for (i=0; i < n; i++){ sequence =…
Rocky
  • 45
  • 1
  • 2
  • 8
3
votes
1 answer

JMeter: Calling external classes and methods?

I have a Java test project that I would like to import in my JMeter test so that I can call the existing methods in the test project. I did some research, and came to know that I can create a jar of my Java project, copy the jar into the…
Eshi
  • 53
  • 1
  • 3
  • 6
3
votes
3 answers

Can I write to the Beanshell console from Java?

I'm using Beanshell as an embedded debugging tool in my app. It means I can telnet to my app and poke around with its internals while it is running (I typically wrap the telnet session with rlwrap). The problem is that the only way I've found to…
sanity
  • 35,347
  • 40
  • 135
  • 226
3
votes
1 answer

Jmeter - regex in beanshell (matcher()/pattern() ) is cutting national characters

i need to cut some words from server response data. Use Regular Expression Extractor I get Działalność lecznicza. from that i need just: "Działalność lecznicza" so i write a…
kendzi
  • 311
  • 2
  • 6
  • 22
3
votes
1 answer

Can I instantiate beanshell class sourced from another Beanshell script?

I would like to run class imported from different beanshell file. But I've no idea how instantiate class from main beanshell file. Is this possible? Class which I import: class HelloW { public void run(){ print("Hello World"); } } Main…
PotOfTea
  • 213
  • 3
  • 12
3
votes
1 answer

Jmeter, beanshell - how to write exec() output into a string?

I have the following code in my beanshell postprocessor that executes a C# program and writes its output into Jmeter's console: import it.sauronsoftware.base64.Base64; prev.setDataEncoding("ANSI"); encoded =…
Ray Poward
  • 366
  • 5
  • 12
3
votes
1 answer

beanshell newbie- getting error when running simple script

I am trying to run a simple switch-case statement in Beanshell This is the code I am trying to run-- temp = assignee.toString(); switch( temp.toString() ) { case 'missing' : check = "missing"; break; case '404' : check = "404"; break; default:…
Arvind
  • 6,404
  • 20
  • 94
  • 143
3
votes
2 answers

beanshell beginner- how do I check if a variable.toString contains no value in it?

In a beanshell program, I get a value in a variable. Now, if there was no value obtained for this variable, then I want to set this as "Missing" In a very old version of Beanshell I used the command as shown below to do this-- contact.toString()…
Arvind
  • 6,404
  • 20
  • 94
  • 143
3
votes
2 answers

Token Parsing Error .. encountered \' .. in Beanshell?

I am trying to run the following Beanshell code-- assignee.toString()!='' Here 'assignee' is a variable in Beanshell context. But I am getting the following error-- Caused by: Sourced file: inline evaluation of: ``assignee.toString()!='';'' Token…
Arvind
  • 6,404
  • 20
  • 94
  • 143
3
votes
1 answer

Why does break in a for loop not work when finally is involved in beanshell

This code: print(" - Start"); int[] num = new int[] {1,2,3,4,5,6,7,8,9,10}; for(int i : num) { print("--> "+ i); try { print(" . try"); if(i == 2) break; } catch (java.lang.Exception e) {} …
Nils
  • 9,682
  • 6
  • 46
  • 72
3
votes
0 answers

Java - How to read user input from BeanShell's JConsole?

I'm trying to create a simple console and I found this: Create a "Command" Console I decided to try it out and it seems perfect for my need. Only problem is, I can't seem to get the user input from the user because the BufferedReader is blocked. I'm…
FljpFl0p
  • 348
  • 1
  • 2
  • 10
2
votes
1 answer

Why does Beanshell choke on the '@' characters in source files?

When interpreting a .java source file, in this case a JUnit test suite with the following declaration in it: @RunWith(Suite.class) @SuiteClasses({ MiamiAForm.class }) Why does Beanshell (version 1.3 and also 2.1b5) choke on those…
djangofan
  • 28,471
  • 61
  • 196
  • 289
2
votes
2 answers

Java Beanshell scripting with args[] to the the program?

The Beanshell documentation implies that you can run a script using this format on the command line: java bsh.Interpreter script.bsh [args] The only problem with this is that I cannot get it to work. I know how to call other scripts with args from…
djangofan
  • 28,471
  • 61
  • 196
  • 289
2
votes
1 answer

Can I pass arguments to a external Beanshell script, sourced from another Beanshell script?

I am trying to figure out how to pass arguments to a second script that I call from an initial script. The Beanshell documentation says nothing about this. Does anyone know how to do this? // Start.bsh import bsh.Interpreter; Interpreter i = new…
djangofan
  • 28,471
  • 61
  • 196
  • 289