use of org.openksavi.sponge.standalone.StandaloneEngineMain in project sponge by softelnet.
the class StandaloneErrorReportingTest method testErrorReporting.
protected void testErrorReporting(String name, KnowledgeBaseType type) {
StandaloneEngineMain engineMain = null;
try {
List<String> args = new ArrayList<>();
args.add("-k");
args.add("examples/standalone/" + name + "/" + name + "." + type.getFileExtensions().get(0));
engineMain = StandaloneTestUtils.startupStandaloneEngineMain(args.toArray(new String[args.size()]));
try {
TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (!engineMain.getEngine().isError()) {
Assert.fail("Expected exception");
}
} catch (SpongeException e) {
// Ignore expected exception.
} finally {
StandaloneTestUtils.shutdownStandaloneEngineMain(engineMain);
}
}
use of org.openksavi.sponge.standalone.StandaloneEngineMain in project sponge by softelnet.
the class StandaloneTest method testPythonRss.
@Test
public void testPythonRss() {
StandaloneEngineMain engineMain = null;
try {
engineMain = StandaloneTestUtils.startupStandaloneEngineMain("-c", "examples/standalone/python_rss/sponge_python_rss.xml");
SpongeEngine engine = engineMain.getEngine();
await().atMost(TIMEOUT, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable(Number.class, "receivedRssCount").intValue() > 1);
assertFalse(engine.isError());
} finally {
StandaloneTestUtils.shutdownStandaloneEngineMain(engineMain);
}
}
use of org.openksavi.sponge.standalone.StandaloneEngineMain in project sponge by softelnet.
the class StandaloneTest method testNews.
@Test
public void testNews() throws InterruptedException {
StandaloneEngineMain engineMain = null;
try {
engineMain = StandaloneTestUtils.startupStandaloneEngineMain("-c", "examples/standalone/news/config/config.xml");
SpongeEngine engine = engineMain.getEngine();
await().atMost(TIMEOUT, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable("alarmSounded", null) != null && engine.getOperations().getVariable(AtomicBoolean.class, "alarmSounded").get());
TimeUnit.SECONDS.sleep(SLEEP);
assertFalse(engine.isError());
} finally {
StandaloneTestUtils.shutdownStandaloneEngineMain(engineMain);
}
}
use of org.openksavi.sponge.standalone.StandaloneEngineMain in project sponge by softelnet.
the class StandaloneTestUtils method startupStandaloneEngineMain.
public static StandaloneEngineMain startupStandaloneEngineMain(String... args) {
System.out.println("Starting up standalone engine with args: " + Arrays.asList(args));
StandaloneEngineMain result = new StandaloneEngineMain(true);
result.startup(args);
return result;
}
Aggregations