/** * Creates a NodeJS Runtime * * @return The NodeJS runtime. * * May throw an UnsupportedOperationException if node.js integration has not * been compiled for your platform. */ public static NodeJS createNodeJS() { return createNodeJS(null); }
/** * Creates a new {@link Nodejs}. * * @param basedir Base dir where to deploy a library. * @param loader Class loader to use. */ public Nodejs(final File basedir, final ClassLoader loader) { this.basedir = requireNonNull(basedir, "Basedir required."); this.loader = requireNonNull(loader, "ClassLoader required."); this.node = NodeJS.createNodeJS(); V8 v8 = node.getRuntime(); this.scope = new MemoryManager(v8); }
/** * Creates a NodeJS Runtime * * @return The NodeJS runtime. * * May throw an UnsupportedOperationException if node.js integration has not * been compiled for your platform. */ public static NodeJS createNodeJS() { return createNodeJS(null); }
@Before public void setup() { if (skipTest()) { return; } nodeJS = NodeJS.createNodeJS(); }
/** * Creates a NodeJS Runtime * * @return The NodeJS runtime. * * May throw an UnsupportedOperationException if node.js integration has not * been compiled for your platform. */ public static NodeJS createNodeJS() { return createNodeJS(null); }
/** * Creates a NodeJS Runtime * * @return The NodeJS runtime. * * May throw an UnsupportedOperationException if node.js integration has not * been compiled for your platform. */ public static NodeJS createNodeJS() { return createNodeJS(null); }
@Test public void testExecuteNodeScript_Startup() throws IOException { assumeFalse(skipMessage, skipTest()); // conditional skip nodeJS.release(); File testScript = createTemporaryScriptFile("global.passed = true;", "testScript"); nodeJS = NodeJS.createNodeJS(testScript); runMessageLoop(); assertEquals(true, nodeJS.getRuntime().getBoolean("passed")); testScript.delete(); }
@Test public void testExecNodeScript() throws IOException { assumeFalse(skipMessage, skipTest()); // conditional skip nodeJS.release(); File testScript = createTemporaryScriptFile("global.passed = true;", "testScript"); nodeJS = NodeJS.createNodeJS(); nodeJS.exec(testScript); runMessageLoop(); assertEquals(true, nodeJS.getRuntime().getBoolean("passed")); testScript.delete(); }
@Test public void testExecuteNodeScript_viaRequire() throws IOException { assumeFalse(skipMessage, skipTest()); // conditional skip nodeJS.release(); File testScript = createTemporaryScriptFile("global.passed = true;", "testScript"); nodeJS = NodeJS.createNodeJS(); nodeJS.require(testScript).close(); runMessageLoop(); assertEquals(true, nodeJS.getRuntime().getBoolean("passed")); testScript.delete(); }
@Test public void testExports() throws IOException { assumeFalse(skipMessage, skipTest()); // conditional skip nodeJS.release(); File testScript = createTemporaryScriptFile("exports.foo=7", "testScript"); nodeJS = NodeJS.createNodeJS(); V8Object exports = nodeJS.require(testScript); runMessageLoop(); assertEquals(7, exports.getInteger("foo")); exports.close(); }
/** * Creates a new {@link Nodejs}. * * @param basedir Base dir where to deploy a library. * @param loader Class loader to use. */ public Nodejs(final File basedir, final ClassLoader loader) { this.basedir = requireNonNull(basedir, "Basedir required."); this.loader = requireNonNull(loader, "ClassLoader required."); this.node = NodeJS.createNodeJS(); V8 v8 = node.getRuntime(); this.scope = new MemoryManager(v8); }