Search in sources :

Example 1 with GroovyScriptEngineFactory

use of org.codehaus.groovy.jsr223.GroovyScriptEngineFactory in project hazelcast by hazelcast.

the class HazelcastOSGiScriptEngineFactoryTest method registerAndGetScriptEngineByExtensionSuccessfully.

@Test
public void registerAndGetScriptEngineByExtensionSuccessfully() {
    ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
    GroovyScriptEngineFactory groovyScriptEngineFactory = new GroovyScriptEngineFactory();
    scriptEngineManager.registerEngineExtension("groovy", groovyScriptEngineFactory);
    ScriptEngine scriptEngine = scriptEngineManager.getEngineByExtension("groovy");
    assertNotNull(scriptEngine);
    ScriptEngineFactory scriptEngineFactory = scriptEngine.getFactory();
    verifyScriptEngineFactory(scriptEngineFactory);
}
Also used : GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineFactory(javax.script.ScriptEngineFactory) GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineManager(javax.script.ScriptEngineManager) ScriptEngine(javax.script.ScriptEngine) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with GroovyScriptEngineFactory

use of org.codehaus.groovy.jsr223.GroovyScriptEngineFactory in project hazelcast by hazelcast.

the class HazelcastOSGiScriptEngineTest method scriptEngineEvaluatedSuccessfully.

@Test
public void scriptEngineEvaluatedSuccessfully() throws ScriptException {
    ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
    GroovyScriptEngineFactory groovyScriptEngineFactory = new GroovyScriptEngineFactory();
    scriptEngineManager.registerEngineName("groovy", groovyScriptEngineFactory);
    ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("groovy");
    assertNotNull(scriptEngine);
    verifyScriptEngineEvaluation(scriptEngine);
}
Also used : GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineManager(javax.script.ScriptEngineManager) ScriptEngine(javax.script.ScriptEngine) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with GroovyScriptEngineFactory

use of org.codehaus.groovy.jsr223.GroovyScriptEngineFactory in project hazelcast by hazelcast.

the class HazelcastOSGiScriptEngineFactoryTest method registerAndGetScriptEngineByMimeTypeSuccessfully.

@Test
public void registerAndGetScriptEngineByMimeTypeSuccessfully() {
    ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
    GroovyScriptEngineFactory groovyScriptEngineFactory = new GroovyScriptEngineFactory();
    scriptEngineManager.registerEngineMimeType("application/x-groovy", groovyScriptEngineFactory);
    ScriptEngine scriptEngine = scriptEngineManager.getEngineByMimeType("application/x-groovy");
    assertNotNull(scriptEngine);
    ScriptEngineFactory scriptEngineFactory = scriptEngine.getFactory();
    verifyScriptEngineFactory(scriptEngineFactory);
}
Also used : GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineFactory(javax.script.ScriptEngineFactory) GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineManager(javax.script.ScriptEngineManager) ScriptEngine(javax.script.ScriptEngine) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with GroovyScriptEngineFactory

use of org.codehaus.groovy.jsr223.GroovyScriptEngineFactory in project hazelcast by hazelcast.

the class HazelcastOSGiScriptEngineFactoryTest method registerAndGetScriptEngineByNameSuccessfully.

@Test
public void registerAndGetScriptEngineByNameSuccessfully() {
    ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
    GroovyScriptEngineFactory groovyScriptEngineFactory = new GroovyScriptEngineFactory();
    scriptEngineManager.registerEngineName("groovy", groovyScriptEngineFactory);
    ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("groovy");
    assertNotNull(scriptEngine);
    ScriptEngineFactory scriptEngineFactory = scriptEngine.getFactory();
    verifyScriptEngineFactory(scriptEngineFactory);
}
Also used : GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineFactory(javax.script.ScriptEngineFactory) GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineManager(javax.script.ScriptEngineManager) ScriptEngine(javax.script.ScriptEngine) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with GroovyScriptEngineFactory

use of org.codehaus.groovy.jsr223.GroovyScriptEngineFactory in project OpenAM by OpenRock.

the class OidcClaimsExtensionTest method setupScript.

@BeforeClass
public void setupScript() throws Exception {
    String rawScript = IOUtils.readStream(this.getClass().getClassLoader().getResourceAsStream("oidc-claims-extension.groovy"));
    SupportedScriptingLanguage scriptType = SupportedScriptingLanguage.GROOVY;
    this.script = new ScriptObject("oidc-claims-script", rawScript, scriptType, null);
    StandardScriptEngineManager scriptEngineManager = new StandardScriptEngineManager();
    scriptEngineManager.registerEngineName(SupportedScriptingLanguage.GROOVY_ENGINE_NAME, new GroovyScriptEngineFactory());
    scriptEvaluator = new StandardScriptEvaluator(scriptEngineManager);
}
Also used : StandardScriptEngineManager(org.forgerock.openam.scripting.StandardScriptEngineManager) StandardScriptEvaluator(org.forgerock.openam.scripting.StandardScriptEvaluator) ScriptObject(org.forgerock.openam.scripting.ScriptObject) GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) SupportedScriptingLanguage(org.forgerock.openam.scripting.SupportedScriptingLanguage) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

GroovyScriptEngineFactory (org.codehaus.groovy.jsr223.GroovyScriptEngineFactory)5 QuickTest (com.hazelcast.test.annotation.QuickTest)4 ScriptEngine (javax.script.ScriptEngine)4 ScriptEngineManager (javax.script.ScriptEngineManager)4 Test (org.junit.Test)4 ScriptEngineFactory (javax.script.ScriptEngineFactory)3 ScriptObject (org.forgerock.openam.scripting.ScriptObject)1 StandardScriptEngineManager (org.forgerock.openam.scripting.StandardScriptEngineManager)1 StandardScriptEvaluator (org.forgerock.openam.scripting.StandardScriptEvaluator)1 SupportedScriptingLanguage (org.forgerock.openam.scripting.SupportedScriptingLanguage)1 BeforeClass (org.testng.annotations.BeforeClass)1