use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class Py4JTest method testPy4JPythonServer.
@Test
public void testPy4JPythonServer() throws Exception {
String rootDir = "examples/py4j/python_server";
SpongeEngine engine = DefaultSpongeEngine.builder().config(rootDir + "/py4j_python_server_sponge_hello_world.xml").build();
engine.startup();
Process process = null;
try {
Pair<Process, String> scriptResult = startCPython(engine, rootDir + "/py4j_python_server_python_hello_world.py", false);
process = scriptResult.getLeft();
// Wait for the Python process to start.
TimeUnit.SECONDS.sleep(2);
assertEquals("TEST", engine.getOperations().call("PythonUpperCase", "test"));
assertFalse(engine.isError());
} finally {
if (process != null) {
process.destroy();
}
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class Py4JTest method testPy4JJavaServer.
@Test
public void testPy4JJavaServer() throws Exception {
String rootDir = "examples/py4j/java_server";
SpongeEngine engine = DefaultSpongeEngine.builder().config(rootDir + "/py4j_java_server_sponge_hello_world.xml").build();
engine.startup();
try {
Pair<Process, String> scriptResult = startCPython(engine, rootDir + "/py4j_java_server_python_hello_world.py", true);
Process process = scriptResult.getLeft();
String outputText = scriptResult.getRight();
process.waitFor(60, TimeUnit.SECONDS);
await().atMost(60, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "eventCounter").intValue() > 0);
assertEquals(String.format("Connected to %s\nTriggers count: %d, first: %s", engine.getDescription(), engine.getTriggers().size(), engine.getTriggers().get(0).getName()), outputText);
assertEquals(1, engine.getOperations().getVariable(Number.class, "eventCounter").intValue());
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class ReactiveXTest method testReactiveX.
@Test
public void testReactiveX() throws Exception {
SpongeEngine engine = DefaultSpongeEngine.builder().config("examples/reactivex/reactivex.xml").knowledgeBase(new ReactiveXTestKnowledgeBase()).build();
engine.startup();
await().atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "eventCounter").intValue() >= 3);
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class GrovePiBlinkLedMain method run.
public void run() {
LoggingUtils.initLoggingBridge();
SpongeEngine engine = DefaultSpongeEngine.builder().config("examples/rpi-grovepi/grovepi_led_blink.xml").build();
engine.startup();
SpongeUtils.registerShutdownHook(engine);
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class SpringAutoStartupTest method testSpringAutoStartupFalse.
@Test
public void testSpringAutoStartupFalse() throws InterruptedException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(TestConfigAutoStartupFalse.class);
ctx.start();
try {
SpongeEngine engine = ctx.getBean(SpongeEngine.class);
assertFalse(engine.isRunning());
assertFalse(engine.isError());
} finally {
ctx.close();
}
}
Aggregations