Package org.kie.api.runtime

Examples of org.kie.api.runtime.StatelessKieSession


        assertNotNull(ksession);
    }

    @Test
    public void testKieSessionRef() throws Exception {
        StatelessKieSession ksession = (StatelessKieSession) container.getComponentInstance("ksession99");
        assertNotNull(ksession);
//
//        KieObjectsResolver kieObjectsResolver = new KieObjectsResolver();
//        Object obj = kieObjectsResolver.resolveKSession("ksession99", null);
//        assertSame(ksession, obj);
View Full Code Here


    }

    @Test
    public void testInvalidKieSessionRef() throws Exception {
        try {
            StatelessKieSession ksession = (StatelessKieSession) container.getComponentInstance("should-fail-ksession1");
            assertNull(ksession);
        } catch(Exception e){
            assertTrue(e instanceof NoSuchComponentException);
            return;
        }
View Full Code Here

        fail();
    }

    @Test
    public void testKSessionExecution() throws Exception {
        StatelessKieSession ksession = (StatelessKieSession) container.getComponentInstance("ksession99");
        assertNotNull(ksession);

        Person person = (Person) container.getComponentInstance("person1");
        assertNotNull(person);
        assertFalse(person.isHappy());

        ksession.execute(person);
        assertTrue(person.isHappy());
    }
View Full Code Here

        assertTrue(counterFromListener > 0);
    }

    @Test
    public void testStatelessWithGroupedListeners() throws Exception {
        StatelessKieSession StatelessKieSession = (StatelessKieSession) context.getBean("statelessWithGroupedListeners");
        assertEquals(1, StatelessKieSession.getRuleRuntimeEventListeners().size());

        StatelessKieSession.execute(new Person());
        // this assert to show that our listener was called X number of times.
        // once from agenda listener, and second from working memory event listener
        assertEquals(2, counterFromListener);
    }
View Full Code Here

    }


    @Test
    public void testStatelessPrototypeKieSession() throws Exception {
        StatelessKieSession ksession = (StatelessKieSession) context.getBean("statelessPrototypeSession");
        assertNotNull(ksession);

        StatelessKieSession anotherKsession = (StatelessKieSession) context.getBean("statelessPrototypeSession");
        assertNotNull(anotherKsession);
        assertNotEquals(ksession.hashCode(), anotherKsession.hashCode());
    }
View Full Code Here

        assertNotEquals(ksession.hashCode(), anotherKsession.hashCode());
    }

    @Test
    public void testStatelessSingletonKieSession() throws Exception {
        StatelessKieSession ksession = (StatelessKieSession) context.getBean("statelessSingletonSession");
        assertNotNull(ksession);

        StatelessKieSession anotherKsession = (StatelessKieSession) context.getBean("statelessSingletonSession");
        assertNotNull(anotherKsession);
        assertEquals(ksession.hashCode(), anotherKsession.hashCode());
    }
View Full Code Here

    public static void runAfterClass() {
    }

    @Test
    public void testStatelessSessionRefConsoleLogger() throws Exception {
        StatelessKieSession session = (StatelessKieSession) context.getBean("loggerSession");
        StatelessKnowledgeSessionImpl impl = (StatelessKnowledgeSessionImpl) session;
        for (Object listener : impl.getRuleRuntimeEventListeners()) {
            assertTrue(listener instanceof WorkingMemoryConsoleLogger);
        }
    }
View Full Code Here

        assertNotNull(adaptor.getRuntimeLogger());
    }

    @Test
    public void testStatelessKnowledgeConsoleLogger() throws Exception {
        StatelessKieSession statelessKnowledgeSession = (StatelessKieSession) context.getBean("ConsoleLogger-statelessSession");
        StatelessKnowledgeSessionImpl impl = (StatelessKnowledgeSessionImpl) statelessKnowledgeSession;
        for (Object listener : impl.getRuleRuntimeEventListeners()) {
            assertTrue(listener instanceof WorkingMemoryConsoleLogger);
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testStatelessKnowledgeFileLogger() throws Exception {
        StatelessKieSession statelessKnowledgeSession = (StatelessKieSession) context.getBean("FileLogger-statelessSession");
        StatelessKnowledgeSessionImpl impl = (StatelessKnowledgeSessionImpl) statelessKnowledgeSession;
        for (Object listener : impl.getRuleRuntimeEventListeners()) {
            assertTrue(listener instanceof WorkingMemoryFileLogger);
        }
        LoggerAdaptor adaptor = (LoggerAdaptor) context.getBean("ss_fl_logger");
View Full Code Here

        assertNotNull(adaptor.getRuntimeLogger());
    }

    @Test
    public void testStatelessKnowledgeThreadedFileLogger() throws Exception {
        StatelessKieSession statelessKnowledgeSession = (StatelessKieSession) context.getBean("ThreadedFileLogger-statelessSession");
        StatelessKnowledgeSessionImpl impl = (StatelessKnowledgeSessionImpl) statelessKnowledgeSession;
        for (Object listener : impl.getRuleRuntimeEventListeners()) {
            assertTrue(listener instanceof ThreadedWorkingMemoryFileLogger);
        }
        LoggerAdaptor loggerAdaptor = (LoggerAdaptor) context.getBean("ss_tfl_logger");
View Full Code Here

TOP

Related Classes of org.kie.api.runtime.StatelessKieSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.