use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class ConfigurationTest method testEngineParameters.
@Test
public void testEngineParameters() throws InterruptedException {
SpongeEngine engine = DefaultSpongeEngine.builder().config("examples/core/configuration/engine_parameters.xml").build();
engine.startup();
try {
assertEquals("EngineParametersTest", engine.getName());
assertEquals(21, engine.getConfigurationManager().getMainProcessingUnitThreadCount());
assertEquals(engine.getConfigurationManager().getMainProcessingUnitThreadCount(), engine.getConfigurationManager().getAsyncEventSetProcessorExecutorThreadCount());
assertEquals(EventClonePolicy.DEEP, engine.getConfigurationManager().getEventClonePolicy());
assertEquals(false, engine.getConfigurationManager().getAutoEnable());
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class CoreCorrelatorsTest method testCorrelatorsEventPattern.
@Test
public void testCorrelatorsEventPattern() {
SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase(TestUtils.DEFAULT_KB, "examples/core/correlators_event_pattern.py").build();
engine.startup();
try {
await().atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "nameCount").intValue() >= 3 && engine.getOperations().getVariable(Number.class, "patternCount").intValue() >= 7);
assertEquals(3, engine.getOperations().getVariable(Number.class, "nameCount").intValue());
assertEquals(7, engine.getOperations().getVariable(Number.class, "patternCount").intValue());
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class CoreFiltersTest method testFiltersEventPattern.
@Test
public void testFiltersEventPattern() {
SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase(TestUtils.DEFAULT_KB, "examples/core/filters_event_pattern.py").build();
engine.startup();
try {
await().atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "nameCount").intValue() >= 2 && engine.getOperations().getVariable(Number.class, "patternCount").intValue() >= 3 && engine.getOperations().getVariable(Number.class, "acceptedCount").intValue() >= 5);
assertEquals(2, engine.getOperations().getVariable(Number.class, "nameCount").intValue());
assertEquals(3, engine.getOperations().getVariable(Number.class, "patternCount").intValue());
assertEquals(5, engine.getOperations().getVariable(Number.class, "acceptedCount").intValue());
assertEquals(0, engine.getOperations().getVariable(Number.class, "notAcceptedCount").intValue());
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class CoreRulesTest method testRulesImmediateNoDuration.
@Test
public void testRulesImmediateNoDuration() {
SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase(TestUtils.DEFAULT_KB, "examples/core/rules_immediate_no_duration.py").build();
engine.getConfigurationManager().setAutoEnable(false);
engine.startup();
try {
doTestRulesImmediate(engine, createCommonExpectedSequences());
ScriptKnowledgeBaseInterpreter interpreter = SpongeUtils.getScriptInterpreter(engine, TestUtils.DEFAULT_KB);
evalEnableRuleWithException(interpreter, "RuleFFL");
evalEnableRuleWithException(interpreter, "RuleFFN");
evalEnableRuleWithException(interpreter, "RuleFLL");
evalEnableRuleWithException(interpreter, "RuleFLN");
evalEnableRuleWithException(interpreter, "RuleFAL");
evalEnableRuleWithException(interpreter, "RuleFNL");
evalEnableRuleWithException(interpreter, "RuleFAN");
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class CoreRulesTest method testRulesImmediateDuration.
@Test
public void testRulesImmediateDuration() {
SpongeEngine engine = DefaultSpongeEngine.builder().knowledgeBase(TestUtils.DEFAULT_KB, "examples/core/rules_immediate_duration.py").build();
engine.startup();
try {
Map<String, String[][]> expected = new LinkedHashMap<>(createCommonExpectedSequences());
expected.put("RuleFFL", new String[][] { { "1", "2", "7" } });
expected.put("RuleFFN", new String[][] { { "1", "2", null } });
expected.put("RuleFLL", new String[][] { { "1", "5", "7" } });
expected.put("RuleFLN", new String[][] { { "1", "5", null } });
expected.put("RuleFAL", new String[][] { { "1", "2", "7" }, { "1", "3", "7" }, { "1", "5", "7" } });
expected.put("RuleFNL", new String[][] { { "1", null, "7" } });
expected.put("RuleFAN", new String[][] { { "1", "2", null }, { "1", "3", null }, { "1", "5", null } });
doTestRulesImmediate(engine, expected);
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
Aggregations