Questions tagged [jsr223]

JSR223 (Scripting for the Java Platform) is the Java Specification Request for a common scripting engine abstraction layer.

JSR223 (Scripting for the Java Platform) is the Java Specification Request for a common scripting engine abstraction layer.

As an example (from the Java Scripting Programmer's Guide):

import javax.script.*;
public class EvalScript {
    public static void main(String[] args) throws Exception {
        // create a script engine manager
        ScriptEngineManager factory = new ScriptEngineManager();
        // create a JavaScript engine
        ScriptEngine engine = factory.getEngineByName("JavaScript");
        // evaluate JavaScript code from String
        engine.eval("print('Hello, World')");
    }
}

The interface to instantiate a scripting engine and evaluate a script is language-agnostic; "JavaScript" could be changed to "Python" to evaluate in Python (via Jython) rather than JavaScript (via Rhino).

343 questions
0
votes
1 answer

How to install additional packages to jython jar in jmeter?

I am using jython inside jmeter by placing the jython.jar under "lib" folder of your JMeter installation. It runs successfully. But the problem is I can't install additional packages or modules of python inside it. To be more specific, I want to run…
Ahsanul Haque
  • 9,145
  • 2
  • 27
  • 48
0
votes
3 answers

User inputed formula parsing (eval)

Good day all, I am trying to figure out how to allow users to call a method on some specified data. I would like to provide a predefined set of functions: Moving average, moving_ave(x,5) ..would be a 5 day moving average on x. 3*x+y....and so…
Nick Siderakis
  • 1,941
  • 2
  • 20
  • 39
0
votes
2 answers

Jmeter. JSR223,Groovy. Can't generate load more than 5 hits/sec

I'm using jsr223 sampler in JMeter 3.1 to generate keys for HTTP request data. The problem is that my script uses cryptographic algorithms, therefore, when the number of threads increases, the script duration time increases as well (it increases…
Fundorin
  • 23
  • 1
0
votes
1 answer

Adding javascript function to jMeter using jsr223

I am trying to get a javascript function work with jMeter test plan uing JSR223. It is used to decode a string. I have the below two functions which i need to implement in jmeter: function AESEncryption(text, passphase, bytessize) { var key =…
0
votes
2 answers

Write to a file using JSR223 Assertion

Is it possible to write data to a file inside a JSR223 Assertion using javascript as the language? How can it be done?
Rafael Colucci
  • 5,712
  • 4
  • 45
  • 114
0
votes
1 answer

Maven entry for SpEL as a ScriptEngine

Can you please point me to maven dependency to add the SpEL - Spring Expression Language - as a ScriptEngine to my project - is there any in Spring?) I've found some…
fedd
  • 850
  • 9
  • 35
0
votes
1 answer

How to get the length of a json array in JSR223 Post processor using groovy

I have a query related to how to get the length of a json array in JSR223 Post processor using groovy. There is 2 info blocks inside the "outBound" array. I need to get the length of the array "outBound" so that I can put the length in a for loop. I…
Jyothi
  • 1
  • 1
0
votes
1 answer

How to pass types and functions to a JSR-223 script?

A typical JSR-223 script would begin with a series of surrogate imports like this (JavaScript+Nashorn chosen for example purposes): // "import" classes and static methods var Foo = Java.type("my.package.Foo"); // application classes require…
Dimitri
  • 291
  • 2
  • 11
0
votes
1 answer

Jmeter. JSR223+Grovy 2.4.5 sampler response times degradation

(question is continue from Jmeter protobuf testing. Could not read Protobuf message) I am testing application via Protobuf protocol. Initially i used HTTP sampler but was a problem with saving binary data to a string. Solution was to use Beanshell…
v0devil
  • 462
  • 1
  • 5
  • 19
0
votes
1 answer

How to pass JMeter JSR223 sampler function output to Master in distributed testing?

Scenario: 5 slaves, 1 master JMeter environment. The Jmeter project basically picks up urls from a list and the JSR223 sampler has web-driver code to call the url and measure the total load time of each url. Problem statement: While performing a…
0
votes
0 answers

Groovy script in JMeter: error "expecting anything but ''\n''; got it anyway @ line..." when contains closure that uses GString interpolation

I have this groovy script that defines a closure that works properly. escape = { str -> str.collect{ ch -> def escaped = ch switch (ch) { case "\"" : escaped = "\\\"" ; break // other cases omitted for…
0
votes
2 answers

Cannot load JRubyEngine because org.apache.bsf.util.BSFEngineImpl not found

I'm trying to use JRuby in a custom application, and I don't seem to be able to load the JRubyEngine object. My class looks like functionally similar to this: public class ScriptEngine { private static ScriptEngine engine = new JRubyEngine(); …
Ceilingfish
  • 5,131
  • 3
  • 41
  • 68
0
votes
1 answer

JRuby : using StringScanner : NoMethodError: undefined method `bol?' for nil:NilClass

I'm trying to use JRuby 1.7.4 within a Java webapp. Here's the code I'm trying to run: require 'strscan' scanner = StringScanner.new("test\ntest\n") scanner.bol? this is being executed using the following Java code: ScriptEngineManager manager…
0
votes
1 answer

Javascript and classes from packages from other bundle

I try to describe my problem. Following configuration: On Servicemix I have two bundles: one with model, second with service. Model bundle exports model packages, service bundle imports model packages from model bundle. In the service bundle I have…
user1337302
  • 103
  • 8
0
votes
1 answer

Java - "safe" scripting

Does anyone know of any scripting for the Java platform that can be forcefully restricted to a provided function set (preferably absolutely no functions unless provided)? I've experimented with several JSR223 compatible languages, but have been…
Luke A. Leber
  • 614
  • 5
  • 17
1 2 3
22
23