use of org.camunda.bpm.engine.impl.scripting.SourceExecutableScript in project camunda-bpm-platform by camunda.
the class EnvScriptCachingTest method executeScript.
protected void executeScript(final ProcessApplicationInterface processApplication) {
processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {
public Void execute(CommandContext commandContext) {
return Context.executeWithinProcessApplication(new Callable<Void>() {
public Void call() throws Exception {
ScriptingEngines scriptingEngines = processEngineConfiguration.getScriptingEngines();
ScriptEngine scriptEngine = scriptingEngines.getScriptEngineForLanguage(SCRIPT_LANGUAGE);
SourceExecutableScript script = createScript(SCRIPT_LANGUAGE, SCRIPT);
ScriptingEnvironment scriptingEnvironment = processEngineConfiguration.getScriptingEnvironment();
scriptingEnvironment.execute(script, null, null, scriptEngine);
return null;
}
}, processApplication.getReference());
}
});
}
use of org.camunda.bpm.engine.impl.scripting.SourceExecutableScript in project camunda-bpm-platform by camunda.
the class ScriptCompilationTest method testDisableScriptCompilationByDisabledScriptEngineCaching.
public void testDisableScriptCompilationByDisabledScriptEngineCaching() {
// when script engine caching is disabled and a script is created
processEngineConfiguration.setEnableScriptEngineCaching(false);
SourceExecutableScript script = createScript(SCRIPT_LANGUAGE, EXAMPLE_SCRIPT);
assertNotNull(script);
// then it should not be compiled on creation
assertTrue(script.isShouldBeCompiled());
assertNull(script.getCompiledScript());
// and after first execution
executeScript(script);
// it was also not compiled
assertFalse(script.isShouldBeCompiled());
assertNull(script.getCompiledScript());
// re-enable script engine caching
processEngineConfiguration.setEnableScriptEngineCaching(true);
}
use of org.camunda.bpm.engine.impl.scripting.SourceExecutableScript in project camunda-bpm-platform by camunda.
the class ScriptCompilationTest method testScriptShouldBeCompiledByDefault.
public void testScriptShouldBeCompiledByDefault() {
// when a script is created
SourceExecutableScript script = createScript(SCRIPT_LANGUAGE, EXAMPLE_SCRIPT);
assertNotNull(script);
// then it should not be compiled on creation
assertTrue(script.isShouldBeCompiled());
assertNull(script.getCompiledScript());
// but after first execution
executeScript(script);
// it was compiled
assertFalse(script.isShouldBeCompiled());
assertNotNull(script.getCompiledScript());
}
use of org.camunda.bpm.engine.impl.scripting.SourceExecutableScript in project camunda-bpm-platform by camunda.
the class ScriptCompilationTest method testOverrideScriptSource.
public void testOverrideScriptSource() {
// when a script is created and executed
SourceExecutableScript script = createScript(SCRIPT_LANGUAGE, EXAMPLE_SCRIPT);
assertNotNull(script);
executeScript(script);
// it was compiled
assertFalse(script.isShouldBeCompiled());
assertNotNull(script.getCompiledScript());
// if the script source changes
script.setScriptSource(EXAMPLE_SCRIPT);
// then it should not be compiled after change
assertTrue(script.isShouldBeCompiled());
assertNull(script.getCompiledScript());
// but after next execution
executeScript(script);
// it is compiled again
assertFalse(script.isShouldBeCompiled());
assertNotNull(script.getCompiledScript());
}
use of org.camunda.bpm.engine.impl.scripting.SourceExecutableScript in project camunda-bpm-platform by camunda.
the class ScriptCompilationTest method testDisableScriptCompilation.
public void testDisableScriptCompilation() {
// when script compilation is disabled and a script is created
processEngineConfiguration.setEnableScriptCompilation(false);
SourceExecutableScript script = createScript(SCRIPT_LANGUAGE, EXAMPLE_SCRIPT);
assertNotNull(script);
// then it should not be compiled on creation
assertTrue(script.isShouldBeCompiled());
assertNull(script.getCompiledScript());
// and after first execution
executeScript(script);
// it was also not compiled
assertFalse(script.isShouldBeCompiled());
assertNull(script.getCompiledScript());
// re-enable script compilation
processEngineConfiguration.setEnableScriptCompilation(true);
}
Aggregations