Exemplo n.º 1
0
        public virtual 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.ShouldBeCompiled);
            assertNotNull(script.CompiledScript);

            // if the script source changes
            script.ScriptSource = EXAMPLE_SCRIPT;

            // then it should not be compiled after change
            assertTrue(script.ShouldBeCompiled);
            assertNull(script.CompiledScript);

            // but after next execution
            executeScript(script);

            // it is compiled again
            assertFalse(script.ShouldBeCompiled);
            assertNotNull(script.CompiledScript);
        }
Exemplo n.º 2
0
        public virtual 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.ShouldBeCompiled);
            assertNull(script.CompiledScript);

            // but after first execution
            executeScript(script);

            // it was compiled
            assertFalse(script.ShouldBeCompiled);
            assertNotNull(script.CompiledScript);
        }
Exemplo n.º 3
0
        public virtual void testDisableScriptCompilationByDisabledScriptEngineCaching()
        {
            // when script engine caching is disabled and a script is created
            processEngineConfiguration.EnableScriptEngineCaching = false;
            SourceExecutableScript script = createScript(SCRIPT_LANGUAGE, EXAMPLE_SCRIPT);

            assertNotNull(script);

            // then it should not be compiled on creation
            assertTrue(script.ShouldBeCompiled);
            assertNull(script.CompiledScript);

            // and after first execution
            executeScript(script);

            // it was also not compiled
            assertFalse(script.ShouldBeCompiled);
            assertNull(script.CompiledScript);

            // re-enable script engine caching
            processEngineConfiguration.EnableScriptEngineCaching = true;
        }