use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class KnowledgeBaseTestTemplate method testConcurrency.
public static void testConcurrency(KnowledgeBaseType type) {
SpongeEngine engine = ScriptTestUtils.startWithConfig(type, "knowledge_base_concurrency");
try {
await().atMost(30, TimeUnit.SECONDS).until(() -> "A1".equals(getConcurrencyTestValue(engine)));
await().atMost(10, TimeUnit.SECONDS).until(() -> "B1".equals(getConcurrencyTestValue(engine)));
await().atMost(10, TimeUnit.SECONDS).until(() -> "A2".equals(getConcurrencyTestValue(engine)));
await().atMost(10, TimeUnit.SECONDS).until(() -> "B2".equals(getConcurrencyTestValue(engine)));
await().atMost(10, TimeUnit.SECONDS).until(() -> "C1".equals(getConcurrencyTestValue(engine)));
await().atMost(10, TimeUnit.SECONDS).until(() -> "C2".equals(getConcurrencyTestValue(engine)));
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class KnowledgeBaseTestTemplate method testLibrary.
@SuppressWarnings("unchecked")
public static void testLibrary(KnowledgeBaseType type) {
SpongeEngine engine = ScriptTestUtils.startWithConfig(type, "knowledge_base_library");
try {
await().pollDelay(5, TimeUnit.SECONDS).atMost(60, TimeUnit.SECONDS).until(() -> ((Map<String, String>) engine.getOperations().getVariable("hostStatus")).size() >= 2);
Map<String, String> hostStatus = (Map<String, String>) engine.getOperations().getVariable("hostStatus");
assertEquals("ERROR", hostStatus.get("www.wikipedia.org.unknown"));
assertTrue(Integer.decode(hostStatus.get("www.wikipedia.org").trim()).intValue() > 0);
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class PluginsTestTemplate method testKbPlugin.
public static void testKbPlugin(KnowledgeBaseType type) {
SpongeEngine engine = ScriptTestUtils.startWithConfig(type, "plugins_kb");
try {
await().pollDelay(1, TimeUnit.SECONDS).atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable("valueAfter") != null);
assertEquals("Value A", engine.getOperations().getVariable("valueBefore"));
assertEquals("Value B", engine.getOperations().getVariable("valueAfter"));
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class RulesTestTemplate method testHeartbeat.
public static void testHeartbeat(KnowledgeBaseType type) {
SpongeEngine engine = ScriptTestUtils.startWithKnowledgeBase(type, "rules_heartbeat");
try {
await().atMost(60, TimeUnit.SECONDS).until(() -> ((AtomicBoolean) engine.getOperations().getVariable("soundTheAlarm")).get());
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class RulesTestTemplate method testRulesInstances.
public static void testRulesInstances(KnowledgeBaseType type) {
SpongeEngine engine = ScriptTestUtils.buildWithKnowledgeBase(type, "rules_instances");
engine.getDefaultParameters().setAsyncEventSetProcessorProcessingPartitionSize(10);
engine.startup();
try {
await().atMost(60, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "countA").intValue() >= engine.getOperations().getVariable(Number.class, "max").intValue() - 1);
await().atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "countB").intValue() >= engine.getOperations().getVariable(Number.class, "max").intValue() - 1);
assertEquals(engine.getOperations().getVariable(Number.class, "max").intValue() - 1, engine.getOperations().getVariable(Number.class, "countA").intValue());
assertEquals(engine.getOperations().getVariable(Number.class, "max").intValue() - 1, engine.getOperations().getVariable(Number.class, "countB").intValue());
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
Aggregations