Search in sources :

Example 11 with SpongeEngine

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

the class SyncAsyncEventSetProcessorsTest method testSyncEventSetProcessorsConfig.

@Test
public void testSyncEventSetProcessorsConfig() throws InterruptedException {
    SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase("kb", "examples/core/sync_async_event_set_processors.py").build();
    engine.startup();
    assertFalse(engine.getConfigurationManager().getEventSetProcessorDefaultSynchronous());
    doTestAsyncEventSetProcessors(engine);
}
Also used : DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine) Test(org.junit.Test)

Example 12 with SpongeEngine

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

the class LoadTest method testTriggersLoad.

@Test
public void testTriggersLoad() {
    SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase(TestUtils.DEFAULT_KB, "examples/performance/triggers_load.py").build();
    engine.startup();
    int sleepMinutes = 2;
    try {
        TimeUnit.MINUTES.sleep(sleepMinutes);
        logger.info("Event performance after {} minutes is: {}", sleepMinutes, String.format("%.2f events/s", engine.getStatisticsManager().getEventPerformance()));
    } catch (InterruptedException e) {
        throw SpongeUtils.wrapException(e);
    } finally {
        engine.shutdown();
    }
}
Also used : DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine) Test(org.junit.Test)

Example 13 with SpongeEngine

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

the class CoreVariablesJythonBugTest method testGlobalVariablesJythonBug.

/**
 * This test detects a Jython 2.7.1 bug: http://bugs.jython.org/issue2487.
 */
@Test
public void testGlobalVariablesJythonBug() {
    SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase(TestUtils.DEFAULT_KB, "examples/core/stability/global_variable_access_jython_bug.py").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 14 with SpongeEngine

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

the class ConfigurationKnowledgeBaseFileTest method doTestExisting.

private void doTestExisting(String config) {
    SpongeEngine engine = DefaultSpongeEngine.builder().config(DIR + config).build();
    engine.startup();
    try {
        assertTrue(engine.getOperations().getVariable(Boolean.class, "loaded"));
        assertFalse(engine.isError());
    } finally {
        engine.shutdown();
    }
}
Also used : DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine)

Example 15 with SpongeEngine

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

the class ConfigurationTest method testPropertySubstitution.

@Test
public void testPropertySubstitution() throws InterruptedException {
    SpongeEngine engine = DefaultSpongeEngine.builder().property("sourceProperty", "source").config("examples/core/configuration/property_substitution.xml").build();
    engine.startup();
    try {
        assertEquals("source value", engine.getConfigurationManager().getProperty("resultProperty"));
        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)

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