Search in sources :

Example 1 with ExecuteScriptRequest

use of com.hazelcast.internal.management.request.ExecuteScriptRequest in project hazelcast by hazelcast.

the class ExecuteScriptRequestTest method testExecuteScriptRequest_withScriptException.

@Test
public void testExecuteScriptRequest_withScriptException() throws Exception {
    ExecuteScriptRequest request = new ExecuteScriptRequest("print(;", "JavaScript", true, bindings);
    JsonObject jsonObject = new JsonObject();
    request.writeResponse(managementCenterService, jsonObject);
    JsonObject result = (JsonObject) jsonObject.get("result");
    String response = (String) request.readResponse(result);
    assertNotNull(response);
}
Also used : ExecuteScriptRequest(com.hazelcast.internal.management.request.ExecuteScriptRequest) JsonObject(com.eclipsesource.json.JsonObject) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with ExecuteScriptRequest

use of com.hazelcast.internal.management.request.ExecuteScriptRequest in project hazelcast by hazelcast.

the class ExecuteScriptRequestTest method testExecuteScriptRequest_withIllegalScriptEngine.

@Test
public void testExecuteScriptRequest_withIllegalScriptEngine() throws Exception {
    ExecuteScriptRequest request = new ExecuteScriptRequest("script", "engine", true, bindings);
    JsonObject jsonObject = new JsonObject();
    request.writeResponse(managementCenterService, jsonObject);
    JsonObject result = (JsonObject) jsonObject.get("result");
    String response = (String) request.readResponse(result);
    assertContains(response, "IllegalArgumentException");
}
Also used : ExecuteScriptRequest(com.hazelcast.internal.management.request.ExecuteScriptRequest) JsonObject(com.eclipsesource.json.JsonObject) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with ExecuteScriptRequest

use of com.hazelcast.internal.management.request.ExecuteScriptRequest in project hazelcast by hazelcast.

the class ExecuteScriptRequestTest method testExecuteScriptRequest_whenTargetAllMembers_withTarget.

@Test
public void testExecuteScriptRequest_whenTargetAllMembers_withTarget() throws Exception {
    Address address = cluster.getLocalMember().getAddress();
    Set<String> targets = Collections.singleton(address.getHost() + ":" + address.getPort());
    ExecuteScriptRequest request = new ExecuteScriptRequest("print('test');", "JavaScript", targets, bindings);
    JsonObject jsonObject = new JsonObject();
    request.writeResponse(managementCenterService, jsonObject);
    JsonObject result = (JsonObject) jsonObject.get("result");
    String response = (String) request.readResponse(result);
    assertEquals("error", response.trim());
}
Also used : Address(com.hazelcast.nio.Address) ExecuteScriptRequest(com.hazelcast.internal.management.request.ExecuteScriptRequest) JsonObject(com.eclipsesource.json.JsonObject) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with ExecuteScriptRequest

use of com.hazelcast.internal.management.request.ExecuteScriptRequest in project hazelcast by hazelcast.

the class ExecuteScriptRequestTest method testExecuteScriptRequest_whenTargetAllMembers.

@Test
public void testExecuteScriptRequest_whenTargetAllMembers() throws Exception {
    ExecuteScriptRequest request = new ExecuteScriptRequest("print('test');", "JavaScript", true, null);
    JsonObject jsonObject = new JsonObject();
    request.writeResponse(managementCenterService, jsonObject);
    JsonObject result = (JsonObject) jsonObject.get("result");
    String response = (String) request.readResponse(result);
    assertEquals("error\nerror\n", response);
}
Also used : ExecuteScriptRequest(com.hazelcast.internal.management.request.ExecuteScriptRequest) JsonObject(com.eclipsesource.json.JsonObject) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 5 with ExecuteScriptRequest

use of com.hazelcast.internal.management.request.ExecuteScriptRequest in project hazelcast by hazelcast.

the class ExecuteScriptRequestTest method testExecuteScriptRequest.

@Test
public void testExecuteScriptRequest() throws Exception {
    ExecuteScriptRequest request = new ExecuteScriptRequest("print('test');", "JavaScript", false, bindings);
    JsonObject jsonObject = new JsonObject();
    request.writeResponse(managementCenterService, jsonObject);
    JsonObject result = (JsonObject) jsonObject.get("result");
    String response = (String) request.readResponse(result);
    assertEquals("", response.trim());
}
Also used : ExecuteScriptRequest(com.hazelcast.internal.management.request.ExecuteScriptRequest) JsonObject(com.eclipsesource.json.JsonObject) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

JsonObject (com.eclipsesource.json.JsonObject)5 ExecuteScriptRequest (com.hazelcast.internal.management.request.ExecuteScriptRequest)5 ParallelTest (com.hazelcast.test.annotation.ParallelTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 Address (com.hazelcast.nio.Address)1