use of javax.script.ScriptEngineManager in project hazelcast by hazelcast.
the class HazelcastOSGiScriptEngineManagerTest method bindingsGetAndSetSuccessfully.
@Test
public void bindingsGetAndSetSuccessfully() {
ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
assertNotNull(scriptEngineManager.getBindings());
Bindings mockBindings = mock(Bindings.class);
scriptEngineManager.setBindings(mockBindings);
assertEquals(mockBindings, scriptEngineManager.getBindings());
}
use of javax.script.ScriptEngineManager 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);
}
use of javax.script.ScriptEngineManager in project hazelcast by hazelcast.
the class HazelcastOSGiScriptEngineTest method putAndGetContextSuccessfully.
@Test
public void putAndGetContextSuccessfully() {
ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
List<ScriptEngineFactory> engineFactories = scriptEngineManager.getEngineFactories();
assertNotNull(engineFactories);
for (ScriptEngineFactory engineFactory : engineFactories) {
verifyThatPutAndGetContextSuccessfully(engineFactory.getScriptEngine());
}
}
use of javax.script.ScriptEngineManager in project hazelcast by hazelcast.
the class HazelcastOSGiScriptEngineTest method putAndGetSuccessfully.
@Test
public void putAndGetSuccessfully() {
ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
List<ScriptEngineFactory> engineFactories = scriptEngineManager.getEngineFactories();
assertNotNull(engineFactories);
for (ScriptEngineFactory engineFactory : engineFactories) {
verifyThatPutAndGetSuccessfully(engineFactory.getScriptEngine());
}
}
use of javax.script.ScriptEngineManager in project opennms by OpenNMS.
the class OSGiScriptEngineManager method getEngineByMimeType.
public ScriptEngine getEngineByMimeType(String mimeType) {
//TODO this is a hack to deal with context class loader issues
ScriptEngine engine = null;
for (ScriptEngineManager manager : classLoaders.keySet()) {
ClassLoader old = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classLoaders.get(manager));
engine = manager.getEngineByMimeType(mimeType);
Thread.currentThread().setContextClassLoader(old);
if (engine != null)
break;
}
return engine;
}
Aggregations