use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class CoreUnorderedRulesTest method testUnorderedRulesEvents.
@Test
public void testUnorderedRulesEvents() {
SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase(TestUtils.DEFAULT_KB, "examples/core/unordered_rules_events.py").build();
engine.startup();
try {
doTestUnorderedRulesEvents(engine, 180);
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class CoreUnorderedRulesTest method testUnorderedRulesInstances.
@Test
public void testUnorderedRulesInstances() {
SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase(TestUtils.DEFAULT_KB, "examples/core/unordered_rules_instances.py").build();
engine.startup();
try {
await().atMost(60, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "countAB").intValue() >= engine.getOperations().getVariable(Number.class, "max").intValue() * 2 - 1);
await().atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "countA").intValue() >= engine.getOperations().getVariable(Number.class, "max").intValue() - 1);
assertEquals(engine.getOperations().getVariable(Number.class, "max").intValue() * 2 - 1, engine.getOperations().getVariable(Number.class, "countAB").intValue());
assertEquals(engine.getOperations().getVariable(Number.class, "max").intValue() - 1, engine.getOperations().getVariable(Number.class, "countA").intValue());
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class EngineBuilderTest method createAndStartupEngine.
private SpongeEngine createAndStartupEngine() {
EchoPlugin plugin = new EchoPlugin();
plugin.setName("testPlugin");
plugin.setEcho("Echo text!");
// @formatter:off
SpongeEngine engine = DefaultSpongeEngine.builder().systemProperty("system.property", "1").property("test.property", "TEST").plugin(plugin).knowledgeBase(new TestKnowledgeBase("testJavaKb")).build();
// @formatter:on
engine.getConfigurationManager().setMainProcessingUnitThreadCount(2);
engine.getConfigurationManager().setEventClonePolicy(EventClonePolicy.DEEP);
engine.startup();
return engine;
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class EventPatternTest method testEventPattern.
@Test
public void testEventPattern() {
SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase(TestUtils.DEFAULT_KB, "examples/core/event_pattern.py").build();
engine.startup();
try {
await().pollDelay(5, TimeUnit.SECONDS).atMost(60, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "count").intValue() >= 6);
assertEquals(6, engine.getOperations().getVariable(Number.class, "count").intValue());
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class FibonacciTest method testFibonacci.
@Test
public void testFibonacci() {
SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase("kb", "examples/core/fibonacci.py").build();
engine.startup();
try {
await().atMost(60, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable("f(maxIndex)") != null);
Number fmax = engine.getOperations().getVariable(Number.class, "f(maxIndex)");
assertEquals(new BigInteger("354224848179261915075"), fmax);
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
Aggregations