Search in sources :

Example 1 with QueueFullException

use of org.openksavi.sponge.engine.QueueFullException in project sponge by softelnet.

the class EventOverloadTest method testEventOverload.

@Test
public void testEventOverload() {
    EngineBuilder<DefaultSpongeEngine> builder = DefaultSpongeEngine.builder().knowledgeBase("kb", "examples/core/event_overload.py");
    builder.getEngineDefaultParameters().setMainEventQueueCapacity(2);
    builder.getEngineDefaultParameters().setDecomposedQueueCapacity(2);
    SpongeEngine engine = builder.build();
    // Caution: this test depends on the exact configuration values as they are specified below.
    engine.getConfigurationManager().setMainProcessingUnitThreadCount(1);
    engine.getConfigurationManager().setEventQueueCapacity(5);
    // engine.getConfigurationManager().setEventSetProcessorDefaultSynchronous(false);
    engine.startup();
    try {
        await().atMost(120, TimeUnit.SECONDS).until(() -> engine.getOperations().getVariable("testStatus") != null);
        assertTrue(engine.getOperations().getVariable("testStatus") instanceof QueueFullException);
        assertFalse(engine.isError());
    } finally {
        engine.shutdown();
    }
}
Also used : DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) QueueFullException(org.openksavi.sponge.engine.QueueFullException) DefaultSpongeEngine(org.openksavi.sponge.core.engine.DefaultSpongeEngine) SpongeEngine(org.openksavi.sponge.engine.SpongeEngine) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DefaultSpongeEngine (org.openksavi.sponge.core.engine.DefaultSpongeEngine)1 QueueFullException (org.openksavi.sponge.engine.QueueFullException)1 SpongeEngine (org.openksavi.sponge.engine.SpongeEngine)1