jdk8 로 복원
This commit is contained in:
+2
-2
@@ -50,8 +50,8 @@ dependencies {
|
|||||||
implementation 'org.apache.httpcomponents:httpclient:4.5.14'
|
implementation 'org.apache.httpcomponents:httpclient:4.5.14'
|
||||||
|
|
||||||
|
|
||||||
implementation("org.graalvm.polyglot:polyglot:24.1.0")
|
// implementation("org.graalvm.polyglot:polyglot:24.1.0")
|
||||||
implementation("org.graalvm.polyglot:js:24.1.0")
|
// implementation("org.graalvm.polyglot:js:24.1.0")
|
||||||
|
|
||||||
|
|
||||||
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import javax.script.ScriptEngine;
|
||||||
|
import javax.script.ScriptEngineManager;
|
||||||
|
import javax.script.ScriptException;
|
||||||
import org.apache.commons.lang3.SerializationUtils;
|
import org.apache.commons.lang3.SerializationUtils;
|
||||||
import org.graalvm.polyglot.Context;
|
|
||||||
import org.graalvm.polyglot.HostAccess;
|
|
||||||
import org.graalvm.polyglot.Value;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -193,44 +193,35 @@ public class VirtualUser implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executePreRequestScript(ApiRequestDTO apiRequest) {
|
private void executePreRequestScript(ApiRequestDTO apiRequest) {
|
||||||
try (Context context = Context.newBuilder("js")
|
ScriptEngineManager manager = new ScriptEngineManager();
|
||||||
.allowHostAccess(HostAccess.ALL)
|
ScriptEngine engine = manager.getEngineByName("nashorn");
|
||||||
.allowHostClassLookup(className -> true)
|
engine.put("console", new Console());
|
||||||
.build()) {
|
engine.put("globals", globals);
|
||||||
|
engine.put("variables", variables);
|
||||||
Value bindings = context.getBindings("js");
|
engine.put("request", apiRequest);
|
||||||
bindings.putMember("console", new Console());
|
try {
|
||||||
bindings.putMember("globals", globals);
|
if(apiRequest.getPreRequestScript() != null)
|
||||||
bindings.putMember("variables", variables);
|
engine.eval(apiRequest.getPreRequestScript());
|
||||||
bindings.putMember("request", apiRequest);
|
} catch (ScriptException e) {
|
||||||
|
logger.error("Error executing pre-request script", e);
|
||||||
if(apiRequest.getPreRequestScript() != null) {
|
|
||||||
context.eval("js", apiRequest.getPreRequestScript());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Error executing post-request script", e);
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executePostRequestScript(ApiRequestDTO apiRequest, ApiResponse response) {
|
private void executePostRequestScript(ApiRequestDTO apiRequest, ApiResponse response) {
|
||||||
try (Context context = Context.newBuilder("js")
|
ScriptEngineManager manager = new ScriptEngineManager();
|
||||||
.allowHostAccess(HostAccess.ALL)
|
ScriptEngine engine = manager.getEngineByName("nashorn");
|
||||||
.allowHostClassLookup(className -> true)
|
engine.put("console", new Console());
|
||||||
.build()) {
|
engine.put("globals", globals);
|
||||||
|
engine.put("variables", variables);
|
||||||
Value bindings = context.getBindings("js");
|
engine.put("request", apiRequest);
|
||||||
bindings.putMember("console", new Console());
|
engine.put("response", response);
|
||||||
bindings.putMember("globals", globals);
|
try {
|
||||||
bindings.putMember("variables", variables);
|
if (apiRequest.getPostRequestScript() != null){
|
||||||
bindings.putMember("request", apiRequest);
|
engine.eval(apiRequest.getPostRequestScript());
|
||||||
bindings.putMember("response", response);
|
|
||||||
|
|
||||||
if (apiRequest.getPostRequestScript() != null) {
|
|
||||||
context.eval("js", apiRequest.getPostRequestScript());
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (ScriptException e) {
|
||||||
logger.error("Error executing post-request script", e);
|
logger.error("Error executing post-request script", e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user