Search in sources :

Example 21 with SpongeEngine

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

the class FiltersTestTemplate method testJavaFilter.

public static void testJavaFilter(KnowledgeBaseType type) {
    SpongeEngine engine = ScriptTestUtils.startWithKnowledgeBase(type, "filters_java");
    try {
        await().atMost(30, TimeUnit.SECONDS).until(() -> TestUtils.getEventCounter(engine, "e2") >= 5 && TestUtils.getEventCounter(engine, "e3") >= 5);
        TimeUnit.SECONDS.sleep(1);
        assertEquals(0, TestUtils.getEventCounter(engine, "e1"));
        assertFalse(engine.isError());
    } catch (InterruptedException e) {
        throw SpongeUtils.wrapException(e);
    } finally {
        engine.shutdown();
    }
}
Also used : SpongeEngine(org.openksavi.sponge.engine.SpongeEngine)

Example 22 with SpongeEngine

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

the class KnowledgeBaseTestTemplate method testManager.

public static void testManager(KnowledgeBaseType type) {
    SpongeEngine engine = ScriptTestUtils.buildWithKnowledgeBase(type, "knowledge_base_manager");
    engine.getConfigurationManager().setAutoEnable(false);
    engine.startup();
    try {
        await().atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(AtomicBoolean.class, "verificationDone").get());
        assertTrue(engine.getOperations().getVariable(AtomicBoolean.class, "verifyTriggerEnabled").get());
        assertTrue(engine.getOperations().getVariable(AtomicBoolean.class, "verifyTriggerDisabled").get());
        assertFalse(engine.isError());
    } finally {
        engine.shutdown();
    }
}
Also used : DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine)

Example 23 with SpongeEngine

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

the class KnowledgeBaseTestTemplate method testCallbacks.

public static void testCallbacks(KnowledgeBaseType type) {
    SpongeEngine engine = ScriptTestUtils.startWithKnowledgeBase(type, "knowledge_base_callbacks");
    try {
        await().atMost(30, TimeUnit.SECONDS).until(() -> ((AtomicBoolean) engine.getOperations().getVariable("onInitCalled")).get());
        await().atMost(30, TimeUnit.SECONDS).until(() -> ((AtomicBoolean) engine.getOperations().getVariable("onStartupCalled")).get());
        await().pollDelay(5, TimeUnit.SECONDS).atMost(30, TimeUnit.SECONDS).until(() -> ((AtomicBoolean) engine.getOperations().getVariable("onBeforeReloadCalled")).get());
        await().atMost(30, TimeUnit.SECONDS).until(() -> ((AtomicBoolean) engine.getOperations().getVariable("onAfterReloadCalled")).get());
        await().atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "onLoadCalled").intValue() == 2);
        TestStatus.onShutdownCalled = false;
        assertFalse(engine.isError());
    } finally {
        engine.shutdown();
    }
    assertTrue(TestStatus.onShutdownCalled);
}
Also used : DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine)

Example 24 with SpongeEngine

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

the class PluginsTestTemplate method testJavaPlugin.

public static void testJavaPlugin(KnowledgeBaseType type) {
    SpongeEngine engine = ScriptTestUtils.startWithConfig(type, "plugins_java");
    try {
        await().pollDelay(1, TimeUnit.SECONDS).atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable("connectionName") != null);
        assertEquals("Example connection", engine.getOperations().getVariable("connectionName"));
        assertEquals("Echo test! x 2", engine.getOperations().getVariable("echoConfig"));
        assertFalse(engine.isError());
    } finally {
        engine.shutdown();
    }
}
Also used : SpongeEngine(org.openksavi.sponge.engine.SpongeEngine)

Example 25 with SpongeEngine

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

the class ProcessorsTestTemplate method testProcessorInheritance.

public static void testProcessorInheritance(KnowledgeBaseType type) {
    SpongeEngine engine = ScriptTestUtils.startWithKnowledgeBase(type, "processor_inheritance");
    try {
        await().atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable("result") != null);
        assertEquals(2, engine.getOperations().getVariable(Number.class, "result").intValue());
        assertEquals(1, engine.getActions().size());
        assertFalse(engine.isError());
    } finally {
        engine.shutdown();
    }
}
Also used : 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