public class GroovyScriptEngineTest {
@Test
public void testRunGroovyScript() throws EngineException, NoSuchFieldException, IllegalAccessException {
JUnitThreadContextInitializer init = new JUnitThreadContextInitializer();
init.initialize();
// for test, used to get groovy source file.
String file = getClass().getClassLoader().getResource("org/ngrinder/TestRunner.groovy").getFile();
GroovyScriptEngine engine = new GroovyScriptEngine(new ScriptLocation(new File(file).getAbsoluteFile()));
init.attachWorkerThreadContext();
GroovyScriptEngine.GroovyWorkerRunnable worker = (GroovyScriptEngine.GroovyWorkerRunnable) engine
.createWorkerRunnable();
assertStaticField(engine.m_groovyClass, "callCount1", 0);
assertStaticField(engine.m_groovyClass, "callCount2", 0);
worker.run();