Package org.kie.runtime

Examples of org.kie.runtime.KieSession


    public void initStartDisposeAndLoadSession() {
        try {
            EntityManager em = txm.getEntityManagerFactory().createEntityManager();
            // create new ksession with kstore
            KieSession ksession = kstore.newKieSession( kbase,
                                                        null,
                                                        getEnvironment() );
            sessionId = ksession.getId();

            logger.info( "\n\tSession id: " + sessionId + "\n" );

            ksession.getWorkItemManager().registerWorkItemHandler( "testWorkItemHandler",
                                                                   workItemHandler );

            ksession.startProcess( "timer-flow",
                                   null );
            Thread.sleep( 4000 );
            ksession.dispose();
        } catch ( Exception ex ) {
            throw new IllegalStateException("The endTheProcess method has been interrupted", ex);
        }
    }
View Full Code Here


        return timerTriggerCount;
    }

    public void endTheProcess() {
        try {
            KieSession ksession = kstore.loadKieSession( sessionId,
                                                         kbase,
                                                         null,
                                                         getEnvironment() );

            //Sleep to check if the timer continues executing.
            logger.info( "\n\nSleeping to check that the timer is still running" );
            Thread.sleep( 5000 );

            ksession.getWorkItemManager().completeWorkItem( TestWorkItemHandler.getWorkItem().getId(),
                                                            null );

            logger.info( "\n\nSleeping to check that the timer is no longer running" );
            Thread.sleep( 3000 );
            logger.info( "Ok" );

            ksession.dispose();

        } catch ( InterruptedException ex ) {
            throw new IllegalStateException("The endTheProcess method has been interrupted", ex);
        }
    }
View Full Code Here

        counterFromListener++;
    }

    //@Test
    public void testStatefulAgendaEventListener() throws Exception {
        KieSession KieSession = (KieSession) context.getBean("statefulSession");
        assertEquals(1, KieSession.getAgendaEventListeners().size());
        assertTrue(KieSession.getAgendaEventListeners().toArray()[0] instanceof MockAgendaEventListener);
    }
View Full Code Here

        assertTrue(KieSession.getAgendaEventListeners().toArray()[0] instanceof MockAgendaEventListener);
    }

    @Test
    public void testStatefulProcessEventListener() throws Exception {
        KieSession KieSession = (KieSession) context.getBean("statefulSession");
        assertEquals(1, KieSession.getProcessEventListeners().size());
        assertTrue(KieSession.getProcessEventListeners().toArray()[0] instanceof MockProcessEventListener);
    }
View Full Code Here

        assertTrue(KieSession.getProcessEventListeners().toArray()[0] instanceof MockProcessEventListener);
    }

    @Test
    public void testStatefulWMEventListener() throws Exception {
        KieSession KieSession = (KieSession) context.getBean("statefulSession");
        assertEquals(1, KieSession.getWorkingMemoryEventListeners().size());
        assertTrue(KieSession.getWorkingMemoryEventListeners().toArray()[0] instanceof MockWorkingMemoryEventListener);

        KieSession.setGlobal("list", list);
        KieSession.insert(new Person());
        KieSession.fireAllRules();
        //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

        assertEquals(2, counterFromListener);
    }

    @Test
    public void testStatefulWithNestedBean() throws Exception {
        KieSession KieSession = (KieSession) context.getBean("statefulWithNestedBean");
        assertEquals(1, KieSession.getWorkingMemoryEventListeners().size());

        KieSession.setGlobal("list", list);
        KieSession.insert(new Person());
        KieSession.fireAllRules();
        //this assert to show that our listener was called X number of times.
        assertEquals(1, counterFromListener);
    }
View Full Code Here

        assertEquals(1, counterFromListener);
    }

    @Test
    public void testStatefulWithRef() throws Exception {
        KieSession KieSession = (KieSession) context.getBean("statefulWithRef");
        assertEquals(1, KieSession.getWorkingMemoryEventListeners().size());

        KieSession.setGlobal("list", list);
        KieSession.insert(new Person());
        KieSession.fireAllRules();
        //this assert to show that our listener was called X number of times.
        assertEquals(1, counterFromListener);
    }
View Full Code Here

        assertEquals(1, counterFromListener);
    }

    @Test
    public void testStatefulWithDefault() throws Exception {
        KieSession KieSession = (KieSession) context.getBean("statefulWithDefault");
        assertEquals(1, KieSession.getWorkingMemoryEventListeners().size());
        assertTrue(KieSession.getWorkingMemoryEventListeners().iterator().next() instanceof DebugWorkingMemoryEventListener);
    }
View Full Code Here

        assertTrue(KieSession.getWorkingMemoryEventListeners().iterator().next() instanceof DebugWorkingMemoryEventListener);
    }

    @Test
    public void testStatefulWithLegacyDebugListener() throws Exception {
        KieSession KieSession = (KieSession) context.getBean("statefulWithDebugListener");
        assertEquals(1, KieSession.getWorkingMemoryEventListeners().size());
        assertTrue(KieSession.getWorkingMemoryEventListeners().iterator().next() instanceof DebugWorkingMemoryEventListener);
    }
View Full Code Here

        assertTrue(KieSession.getWorkingMemoryEventListeners().iterator().next() instanceof DebugWorkingMemoryEventListener);
    }

    @Test
    public void testStatefulWithGroupedListeners() throws Exception {
        KieSession KieSession = (KieSession) context.getBean("statefulWithGroupedListeners");
        assertEquals(1, KieSession.getWorkingMemoryEventListeners().size());

        KieSession.setGlobal("list", list);
        KieSession.insert(new Person());
        KieSession.fireAllRules();
        //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

TOP

Related Classes of org.kie.runtime.KieSession

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.