Search in sources :

Example 86 with SpongeEngine

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

the class TriggersTestTemplate method testTriggersEventPatternIncorrect.

public static void testTriggersEventPatternIncorrect(KnowledgeBaseType type) {
    SpongeEngine engine = null;
    try {
        engine = ScriptTestUtils.startWithKnowledgeBase(type, "triggers_event_pattern_incorrect");
        fail("Expected pattern syntax exception");
    } catch (SpongeException e) {
        if (ExceptionUtils.indexOfThrowable(e, PatternSyntaxException.class) < 0) {
            throw e;
        }
    } finally {
        if (engine != null) {
            engine.shutdown();
        }
    }
}
Also used : SpongeException(org.openksavi.sponge.SpongeException) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine)

Example 87 with SpongeEngine

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

the class StandaloneTest method testPythonRss.

@Test
public void testPythonRss() {
    StandaloneEngineMain engineMain = null;
    try {
        engineMain = StandaloneTestUtils.startupStandaloneEngineMain("-c", "examples/standalone/python_rss/sponge_python_rss.xml");
        SpongeEngine engine = engineMain.getEngine();
        await().atMost(TIMEOUT, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "receivedRssCount").intValue() > 1);
        assertFalse(engine.isError());
    } finally {
        StandaloneTestUtils.shutdownStandaloneEngineMain(engineMain);
    }
}
Also used : StandaloneEngineMain(org.openksavi.sponge.standalone.StandaloneEngineMain) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine) Test(org.junit.Test)

Example 88 with SpongeEngine

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

the class StandaloneTest method testNews.

@Test
public void testNews() throws InterruptedException {
    StandaloneEngineMain engineMain = null;
    try {
        engineMain = StandaloneTestUtils.startupStandaloneEngineMain("-c", "examples/standalone/news/config/config.xml");
        SpongeEngine engine = engineMain.getEngine();
        await().atMost(TIMEOUT, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable("alarmSounded", null) != null && engine.getOperations().getVariable(AtomicBoolean.class, "alarmSounded").get());
        TimeUnit.SECONDS.sleep(SLEEP);
        assertFalse(engine.isError());
    } finally {
        StandaloneTestUtils.shutdownStandaloneEngineMain(engineMain);
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) StandaloneEngineMain(org.openksavi.sponge.standalone.StandaloneEngineMain) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine) Test(org.junit.Test)

Example 89 with SpongeEngine

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

the class ScriptTestUtils method startWithKnowledgeBase.

public static SpongeEngine startWithKnowledgeBase(KnowledgeBaseType type, String knowledgeBaseFile) {
    SpongeEngine engine = buildWithKnowledgeBase(type, knowledgeBaseFile);
    engine.startup();
    return engine;
}
Also used : DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine)

Example 90 with SpongeEngine

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

the class ScriptTestUtils method startWithConfig.

public static SpongeEngine startWithConfig(KnowledgeBaseType type, String config) {
    SpongeEngine engine = DefaultSpongeEngine.builder().config(getConfigFileName(type, config)).build();
    engine.startup();
    return 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