use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class KnowledgeBaseOnRunTest method testOnRunReturnsTrue.
@Test
public void testOnRunReturnsTrue() {
SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase("kb", "examples/core/knowledge_base_on_run_returns_true.py").build();
engine.startup();
try {
await().atMost(20, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(AtomicBoolean.class, "trigger").get());
assertTrue(engine.getOperations().getVariable(AtomicBoolean.class, "onRun").get());
assertFalse(engine.isError());
assertTrue(engine.isRunning());
assertFalse(engine.isTerminated());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class KnowledgeBaseOnRunTest method testOnRunNotPresent.
@Test
public void testOnRunNotPresent() {
SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase("kb", "examples/core/knowledge_base_on_run_not_present.py").build();
engine.startup();
try {
await().atMost(20, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(AtomicBoolean.class, "trigger").get());
assertFalse(engine.isError());
assertTrue(engine.isRunning());
assertFalse(engine.isTerminated());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class SyncAsyncEventSetProcessorsTest method testAsyncEventSetProcessors.
@Test
public void testAsyncEventSetProcessors() throws InterruptedException {
SpongeEngine engine = DefaultSpongeEngine.builder().config("examples/core/sync_async_event_set_processors.xml").build();
engine.startup();
assertTrue(engine.getConfigurationManager().getEventSetProcessorDefaultSynchronous());
doTestAsyncEventSetProcessors(engine);
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class SystemEventsTest method testSystemEvents.
@Test
public void testSystemEvents() {
SpongeEngine engine = DefaultSpongeEngine.builder().config("examples/core/system_events.xml").build();
engine.startup();
try {
await().atMost(60, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "countA").intValue() >= 5 && engine.getOperations().getVariable(Number.class, "countB").intValue() >= 1 && engine.getOperations().getVariable(List.class, "listC").size() >= 7);
assertEquals(5, engine.getOperations().getVariable(Number.class, "countA").intValue());
assertEquals(1, engine.getOperations().getVariable(Number.class, "countB").intValue());
assertEquals(Lists.newArrayList("startup", "x", "e", "e", "e", "e", "e"), engine.getOperations().getVariable(List.class, "listC"));
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class LoadTest method testRulesLoad.
@Test
public void testRulesLoad() {
SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase(TestUtils.DEFAULT_KB, "examples/performance/rules_load.py").build();
engine.startup();
CorrelationEventsLog eventsLog = engine.getOperations().getVariable(CorrelationEventsLog.class, CorrelationEventsLog.VARIABLE_NAME);
try {
int maxIterations = 50;
for (int i = 0; i < maxIterations; i++) {
logger.info("Iteration {}", i + 1);
eventsLog.clear();
engine.getOperations().event("sendEvents").send();
RulesTestTemplate.doTestRulesEvents(PythonConstants.TYPE, engine, 3600);
}
logger.info("Event performance is: {}", String.format("%.2f events/s", engine.getStatisticsManager().getEventPerformance()));
} finally {
engine.shutdown();
}
}
Aggregations