Search in sources :

Example 66 with SpongeEngine

use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.

the class CoreVariablesJythonBugTest method testGlobalVariablesRubyNoBug.

@Test
public void testGlobalVariablesRubyNoBug() {
    SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase(TestUtils.DEFAULT_KB, "examples/core/stability/global_variable_access.rb").build();
    engine.startup();
    try {
        await().atMost(30, TimeUnit.MINUTES).until(() -> engine.getOperations().getVariable(AtomicBoolean.class, "stopped").get() || engine.isError());
        assertFalse(engine.isError());
    } finally {
        engine.shutdown();
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine) Test(org.junit.Test)

Example 67 with SpongeEngine

use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.

the class MpdSetPlaylistMain method run.

public void run() {
    SpongeEngine engine = DefaultSpongeEngine.builder().config("examples/mpd/mpd_set_playlist.xml").build();
    try {
        engine.startup();
        SpongeUtils.registerShutdownHook(engine);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
}
Also used : DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine)

Example 68 with SpongeEngine

use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.

the class Py4JTest method testPy4JJavaServerTls.

@Test
public void testPy4JJavaServerTls() throws Exception {
    String rootDir = "examples/py4j/java_server_tls";
    SpongeEngine engine = DefaultSpongeEngine.builder().config(rootDir + "/py4j_java_server_tls_sponge_hello_world.xml").build();
    engine.startup();
    try {
        Pair<Process, String> scriptResult = startCPython(engine, rootDir + "/py4j_java_server_tls_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();
    }
}
Also used : DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine) Test(org.junit.Test)

Example 69 with SpongeEngine

use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.

the class Pi4JBlinkLedMain method run.

public void run() {
    LoggingUtils.initLoggingBridge();
    SpongeEngine engine = DefaultSpongeEngine.builder().config("examples/rpi-pi4j/pi4j_led_blink.xml").build();
    engine.startup();
    SpongeUtils.registerShutdownHook(engine);
}
Also used : DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine)

Example 70 with SpongeEngine

use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.

the class MidiInputMain method run.

public void run() {
    SpongeEngine engine = DefaultSpongeEngine.builder().config("examples/midi/midi_input.xml").build();
    engine.startup();
    SpongeUtils.registerShutdownHook(engine);
}
Also used : DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine)

Aggregations

SpongeEngine (org.openksavi.sponge.engine.SpongeEngine)91 DefaultSpongeEngine (org.openksavi.sponge.core.engine.DefaultSpongeEngine)55 Test (org.junit.Test)49 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 StandaloneEngineMain (org.openksavi.sponge.standalone.StandaloneEngineMain)6 SpringSpongeEngine (org.openksavi.sponge.spring.SpringSpongeEngine)5 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)5 CamelContext (org.apache.camel.CamelContext)4 SpongeException (org.openksavi.sponge.SpongeException)4 CorrelationEventsLog (org.openksavi.sponge.test.util.CorrelationEventsLog)4 LinkedHashMap (java.util.LinkedHashMap)3 ProducerTemplate (org.apache.camel.ProducerTemplate)3 RouteBuilder (org.apache.camel.builder.RouteBuilder)3 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)3 SimpleRegistry (org.apache.camel.impl.SimpleRegistry)3 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)2 IOException (java.io.IOException)1 Reader (java.io.Reader)1 BigInteger (java.math.BigInteger)1 List (java.util.List)1