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();
}
}
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();
}
}
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);
}
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();
}
}
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();
}
}
Aggregations