use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class MidiPlayFileMain method run.
public void run() {
SpongeEngine engine = DefaultSpongeEngine.builder().config("examples/midi/midi_play_file.xml").build();
engine.startup();
SpongeUtils.registerShutdownHook(engine);
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class CorrelatorsTestTemplate method testCorrelators.
public static void testCorrelators(KnowledgeBaseType type) {
SpongeEngine engine = ScriptTestUtils.startWithKnowledgeBase(type, "correlators");
try {
await().atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "hardwareFailureScriptFinishCount").intValue() >= 1 && engine.getOperations().getVariable(Number.class, "hardwareFailureJavaFinishCount").intValue() >= 1);
assertEquals(4, engine.getOperations().getVariable(Number.class, "hardwareFailureScriptCount").intValue());
assertEquals(4, engine.getOperations().getVariable(Number.class, "hardwareFailureJavaCount").intValue());
assertEquals(1, engine.getOperations().getVariable(Number.class, "hardwareFailureScriptFinishCount").intValue());
assertEquals(1, engine.getOperations().getVariable(Number.class, "hardwareFailureJavaFinishCount").intValue());
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class CorrelatorsTestTemplate method testCorrelatorsDuration.
public static void testCorrelatorsDuration(KnowledgeBaseType type) {
SpongeEngine engine = ScriptTestUtils.startWithKnowledgeBase(type, "correlators_duration");
try {
await().pollDelay(5, TimeUnit.SECONDS).atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "hardwareFailureScriptCount").intValue() >= 3);
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class EventsTestTemplate method testCron.
public static void testCron(KnowledgeBaseType type) {
SpongeEngine engine = ScriptTestUtils.startWithKnowledgeBase(type, "events_cron");
try {
await().atMost(30, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "eventCounter").intValue() >= 2);
TimeUnit.SECONDS.sleep(5);
assertEquals(2, engine.getOperations().getVariable(Number.class, "eventCounter").intValue());
assertFalse(engine.isError());
} catch (InterruptedException ie) {
throw new SpongeException(ie);
} finally {
engine.shutdown();
}
}
use of org.openksavi.sponge.engine.SpongeEngine in project sponge by softelnet.
the class EventsTestTemplate method testClonePolicy.
public static void testClonePolicy(KnowledgeBaseType type) {
SpongeEngine engine = ScriptTestUtils.startWithConfig(type, "events_clone_policy");
try {
await().atMost(30, TimeUnit.SECONDS).until(() -> TestUtils.getEvents(engine, "defaultClonePolicy").size() >= 3 && TestUtils.getEvents(engine, "deepClonePolicy").size() >= 3 && TestUtils.getEvents(engine, "shallowClonePolicy").size() >= 3);
// Default clone policy is set to DEEP in the configuration xml.
List<Event> defaultClonePolicyEvents = TestUtils.getEvents(engine, "defaultClonePolicy");
assertEquals("Value 1", getValue(defaultClonePolicyEvents, 0));
assertEquals("Value 2", getValue(defaultClonePolicyEvents, 1));
assertEquals("Value 3", getValue(defaultClonePolicyEvents, 2));
List<Event> deepClonePolicyEvents = TestUtils.getEvents(engine, "deepClonePolicy");
assertEquals("Value 1", getValue(deepClonePolicyEvents, 0));
assertEquals("Value 2", getValue(deepClonePolicyEvents, 1));
assertEquals("Value 3", getValue(deepClonePolicyEvents, 2));
List<Event> shallowClonePolicyEvents = TestUtils.getEvents(engine, "shallowClonePolicy");
assertEquals("Value " + defaultClonePolicyEvents.size(), getValue(shallowClonePolicyEvents, 0));
assertEquals("Value " + defaultClonePolicyEvents.size(), getValue(shallowClonePolicyEvents, 1));
assertEquals("Value " + defaultClonePolicyEvents.size(), getValue(shallowClonePolicyEvents, 2));
assertFalse(engine.isError());
} finally {
engine.shutdown();
}
}
Aggregations