Exemplo n.º 1
0
        public virtual void testOverrideScriptSource()
        {
            // when a script is created and executed
            SourceExecutableScript script = CreateScript(SCRIPT_LANGUAGE, EXAMPLE_SCRIPT);

            Assert.NotNull(script);
            ExecuteScript(script);

            // it was compiled
            Assert.IsFalse(script.IsShouldBeCompiled());
            Assert.NotNull(script.CompiledScript);

            // if the script source changes
            script.SetScriptSource(EXAMPLE_SCRIPT);

            // then it should not be compiled after change
            Assert.True(script.IsShouldBeCompiled());
            Assert.IsNull(script.CompiledScript);

            // but after next execution
            ExecuteScript(script);

            // it is compiled again
            Assert.IsFalse(script.IsShouldBeCompiled());
            Assert.NotNull(script.CompiledScript);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Void call() throws Exception
                public Void call()
                {
                    ScriptingEngines scriptingEngines = outerInstance.outerInstance.processEngineConfiguration.ScriptingEngines;
                    ScriptEngine     scriptEngine     = scriptingEngines.getScriptEngineForLanguage(SCRIPT_LANGUAGE);

                    SourceExecutableScript script = outerInstance.outerInstance.createScript(SCRIPT_LANGUAGE, SCRIPT);

                    ScriptingEnvironment scriptingEnvironment = outerInstance.outerInstance.processEngineConfiguration.ScriptingEnvironment;

                    scriptingEnvironment.execute(script, null, null, scriptEngine);

                    return(null);
                }
Exemplo n.º 3
0
        public virtual void testScriptShouldBeCompiledByDefault()
        {
            // when a script is created
            SourceExecutableScript script = CreateScript(SCRIPT_LANGUAGE, EXAMPLE_SCRIPT);

            Assert.NotNull(script);

            // then it should not be compiled on creation
            Assert.True(script.IsShouldBeCompiled());
            Assert.IsNull(script.CompiledScript);

            // but after first execution
            ExecuteScript(script);

            // it was compiled
            Assert.IsFalse(script.IsShouldBeCompiled());
            Assert.NotNull(script.CompiledScript);
        }
Exemplo n.º 4
0
        public virtual void testDisableScriptCompilationByDisabledScriptEngineCaching()
        {
            // when script engine caching is disabled and a script is created
            processEngineConfiguration.SetEnableScriptEngineCaching(false);
            SourceExecutableScript script = CreateScript(SCRIPT_LANGUAGE, EXAMPLE_SCRIPT);

            Assert.NotNull(script);

            // then it should not be compiled on creation
            Assert.True(script.IsShouldBeCompiled());
            Assert.IsNull(script.CompiledScript);

            // and after first execution
            ExecuteScript(script);

            // it was also not compiled
            Assert.IsFalse(script.IsShouldBeCompiled());
            Assert.IsNull(script.CompiledScript);

            // re-enable script engine caching
            processEngineConfiguration.SetEnableScriptEngineCaching(true);
        }