use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class FiltersTestTemplate method testFilter.
public static void testFilter(KnowledgeBaseType type) {
SpongeEngine engine = ScriptTestUtils.startWithKnowledgeBase(type, "filters");
try {
await().atMost(30, TimeUnit.SECONDS).until(() -> TestUtils.getEventCounter(engine, "blue") >= 1);
TimeUnit.SECONDS.sleep(1);
assertEquals(0, TestUtils.getEventCounter(engine, "red"));
assertFalse(engine.isError());
} catch (InterruptedException e) {
throw SpongeUtils.wrapException(e);
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class FiltersTestTemplate method testDeduplication.
public static void testDeduplication(KnowledgeBaseType type) {
SpongeEngine engine = ScriptTestUtils.startWithKnowledgeBase(type, "filters_deduplication");
try {
await().atMost(30, TimeUnit.SECONDS).until(() -> TestUtils.getEventCounter(engine, "e1-red") >= 1 && TestUtils.getEventCounter(engine, "e1-blue") >= 1 && TestUtils.getEventCounter(engine, "e2-red") >= 2 && TestUtils.getEventCounter(engine, "e2-blue") >= 2);
assertEquals(1, TestUtils.getEventCounter(engine, "e1-red"));
assertEquals(1, TestUtils.getEventCounter(engine, "e1-blue"));
assertEquals(2, TestUtils.getEventCounter(engine, "e2-red"));
assertEquals(2, TestUtils.getEventCounter(engine, "e2-blue"));
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class KnowledgeBaseTestTemplate method testLoad.
public static void testLoad(KnowledgeBaseType type) {
SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase(TestUtils.DEFAULT_KB, ScriptTestUtils.getScriptKnowledgeBaseFileName(type, "knowledge_base_load")).build();
engine.getConfigurationManager().setAutoEnable(false);
engine.startup();
try {
await().atMost(60, TimeUnit.SECONDS).until(() -> TestUtils.getEventCounter(engine, "Trigger1, file3") >= 20);
assertTrue(TestUtils.getEventCounter(engine, "Trigger1, file1") > 1);
assertTrue(TestUtils.getEventCounter(engine, "Trigger2, file1") > 1);
assertTrue(TestUtils.getEventCounter(engine, "Trigger1, file2") > 1);
assertTrue(TestUtils.getEventCounter(engine, "Trigger2, file2") > 1);
assertEquals(0, TestUtils.getEventCounter(engine, "Trigger3, file3"));
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class KnowledgeBaseTestTemplate method testAutoEnable.
public static void testAutoEnable(KnowledgeBaseType type) {
SpongeEngine engine = ScriptTestUtils.startWithKnowledgeBase(type, "knowledge_base_auto_enable");
try {
await().atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "counter").intValue() >= 5);
assertEquals(5, engine.getOperations().getVariable(Number.class, "counter").intValue());
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class KnowledgeBaseTestTemplate method testScriptOverriding.
public static void testScriptOverriding(KnowledgeBaseType type) {
SpongeEngine engine = DefaultSpongeEngine.builder().config(ScriptTestUtils.getConfigFileName(type, "knowledge_base_script_overriding")).build();
engine.getConfigurationManager().setAutoEnable(false);
engine.startup();
try {
await().atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "receivedEventA2").intValue() == 2);
assertEquals(0, engine.getOperations().getVariable(Number.class, "receivedEventA1").intValue());
assertEquals(0, engine.getOperations().getVariable(Number.class, "functionA1").intValue());
assertEquals(2, engine.getOperations().getVariable(Number.class, "functionA2").intValue());
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
Aggregations