Search in sources :

Example 6 with StandaloneEngineMain

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);
    }
}
Also used : StandaloneEngineMain(org.openksavi.sponge.standalone.StandaloneEngineMain) SpongeException(org.openksavi.sponge.SpongeException) ArrayList(java.util.ArrayList)

Example 7 with StandaloneEngineMain

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);
    }
}
Also used : StandaloneEngineMain(org.openksavi.sponge.standalone.StandaloneEngineMain) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine) Test(org.junit.Test)

Example 8 with StandaloneEngineMain

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);
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) StandaloneEngineMain(org.openksavi.sponge.standalone.StandaloneEngineMain) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine) Test(org.junit.Test)

Example 9 with StandaloneEngineMain

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;
}
Also used : StandaloneEngineMain(org.openksavi.sponge.standalone.StandaloneEngineMain)

Aggregations

StandaloneEngineMain (org.openksavi.sponge.standalone.StandaloneEngineMain)9 Test (org.junit.Test)7 SpongeEngine (org.openksavi.sponge.engine.SpongeEngine)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 ArrayList (java.util.ArrayList)1 SpongeException (org.openksavi.sponge.SpongeException)1