Search in sources :

Example 1 with ScriptTask

use of org.infinispan.scripting.impl.ScriptTask in project infinispan by infinispan.

the class SecureScriptingTaskManagerTest method testTask.

public void testTask() throws Exception {
    Security.doAs(PHEIDIPPIDES, new PrivilegedExceptionAction<Void>() {

        @Override
        public Void run() throws Exception {
            String result = CompletionStages.join(taskManager.runTask(SCRIPT_NAME, new TaskContext().addParameter("a", "a")));
            assertEquals("a", result);
            return null;
        }
    });
    List<Task> tasks = taskManager.getTasks();
    assertEquals(1, tasks.size());
    ScriptTask scriptTask = (ScriptTask) tasks.get(0);
    assertEquals(SCRIPT_NAME, scriptTask.getName());
    assertEquals(TaskExecutionMode.ONE_NODE, scriptTask.getExecutionMode());
    assertEquals("Script", scriptTask.getType());
}
Also used : ScriptTask(org.infinispan.scripting.impl.ScriptTask) Task(org.infinispan.tasks.Task) TaskContext(org.infinispan.tasks.TaskContext) ScriptTask(org.infinispan.scripting.impl.ScriptTask) CommonsTestingUtil.loadFileAsString(org.infinispan.commons.test.CommonsTestingUtil.loadFileAsString)

Example 2 with ScriptTask

use of org.infinispan.scripting.impl.ScriptTask in project infinispan by infinispan.

the class ScriptingTaskManagerTest method testTask.

public void testTask() throws Exception {
    ScriptingManager scriptingManager = extractGlobalComponent(cacheManager, ScriptingManager.class);
    ScriptingUtils.loadScript(scriptingManager, TEST_SCRIPT);
    String result = CompletionStages.join(taskManager.runTask(TEST_SCRIPT, new TaskContext().addParameter("a", "a")));
    assertEquals("a", result);
    List<Task> tasks = taskManager.getTasks();
    assertEquals(1, tasks.size());
    ScriptTask scriptTask = (ScriptTask) tasks.get(0);
    assertEquals("test.js", scriptTask.getName());
    assertEquals(TaskExecutionMode.ONE_NODE, scriptTask.getExecutionMode());
    assertEquals("Script", scriptTask.getType());
}
Also used : ScriptTask(org.infinispan.scripting.impl.ScriptTask) Task(org.infinispan.tasks.Task) TaskContext(org.infinispan.tasks.TaskContext) ScriptTask(org.infinispan.scripting.impl.ScriptTask)

Aggregations

ScriptTask (org.infinispan.scripting.impl.ScriptTask)2 Task (org.infinispan.tasks.Task)2 TaskContext (org.infinispan.tasks.TaskContext)2 CommonsTestingUtil.loadFileAsString (org.infinispan.commons.test.CommonsTestingUtil.loadFileAsString)1