Package org.drools.core.impl

Examples of org.drools.core.impl.StatefulKnowledgeSessionImpl$GlobalsAdapter


    }

    @Test
    public void testStatefulKnowledgeConsoleLogger() throws Exception {
        KieSession statefulSession = (KieSession) context.getBean( "ConsoleLogger-statefulSession" );
        StatefulKnowledgeSessionImpl impl = (StatefulKnowledgeSessionImpl)statefulSession;
        for ( Object listener : impl.getRuleRuntimeEventListeners()) {
            assertTrue(listener instanceof WorkingMemoryConsoleLogger);
        }
        statefulSession.dispose();
    }
View Full Code Here


    @Test
    public void testStatefulKnowledgeFileLogger() throws Exception {
        KieSession statefulSession = (KieSession) context.getBean( "FileLogger-statefulSession" );
        assertNotNull(statefulSession.getGlobals().get("list"));
        StatefulKnowledgeSessionImpl impl = (StatefulKnowledgeSessionImpl)statefulSession;
        for ( Object listener : impl.getRuleRuntimeEventListeners()) {
            assertTrue(listener instanceof WorkingMemoryFileLogger);
        }
        KnowledgeLoggerAdaptor adaptor = (KnowledgeLoggerAdaptor) context.getBean("sf_fl_logger");
        assertNotNull(adaptor);
        assertNotNull(adaptor.getRuntimeLogger());
View Full Code Here

    @Test
    public void testStatefulKnowledgeThreadedFileLogger() throws Exception {
        KieSession statefulSession = (KieSession) context.getBean( "ThreadedFileLogger-statefulSession" );
        assertNotNull(statefulSession.getGlobals().get("list"));
        StatefulKnowledgeSessionImpl impl = (StatefulKnowledgeSessionImpl)statefulSession;
        for ( Object listener : impl.getRuleRuntimeEventListeners()) {
            assertTrue(listener instanceof ThreadedWorkingMemoryFileLogger);
        }
        KnowledgeLoggerAdaptor adaptor = (KnowledgeLoggerAdaptor) context.getBean("sf_tfl_logger");
        assertNotNull(adaptor);
        assertNotNull(adaptor.getRuntimeLogger());
View Full Code Here

        assertEquals( EventProcessingOption.CLOUD,
                      rconf.getEventProcessingMode() );
        assertEquals( AssertBehaviour.EQUALITY,
                      rconf.getAssertBehaviour() );

        StatefulKnowledgeSessionImpl ksession1 = (StatefulKnowledgeSessionImpl) context.getBean( "ksession1" );
        SessionConfiguration sconf = ksession1.getSessionConfiguration();
        assertTrue( sconf.isKeepReference() );
        assertEquals( ClockType.REALTIME_CLOCK,
                      sconf.getClockType() );
        Map<String, WorkItemHandler> wih = sconf.getWorkItemHandlers();
        assertEquals( 4,
                      wih.size() );
        assertTrue( wih.containsKey( "wih1" ) );
        assertTrue( wih.containsKey( "wih2" ) );
        assertTrue( wih.containsKey( "Human Task" ) );
        assertTrue( wih.containsKey( "MyWork" ) );
        assertNotSame( wih.get( "wih1" ),
                       wih.get( "wih2" ) );
        assertEquals( HumanTaskHandler.class,
                      wih.get( "wih1" ).getClass() );
        assertEquals( HumanTaskHandler.class,
                      wih.get( "wih2" ).getClass() );

        StatefulKnowledgeSessionImpl ksession2 = (StatefulKnowledgeSessionImpl) context.getBean( "ksession2" );
        sconf = ksession2.getSessionConfiguration();
        assertFalse( sconf.isKeepReference() );
        assertEquals( ClockType.PSEUDO_CLOCK,
                      sconf.getClockType() );

    }
View Full Code Here

    }

    @Test
    public void testStatefulKnowledgeConsoleLogger() throws Exception {
        KieSession statefulSession = (KieSession) context.getBean("ConsoleLogger-statefulSession");
        StatefulKnowledgeSessionImpl impl = (StatefulKnowledgeSessionImpl) statefulSession;
        for (Object listener : impl.getRuleRuntimeEventListeners()) {
            assertTrue(listener instanceof WorkingMemoryConsoleLogger);
        }
    }
View Full Code Here

    @Test
    public void testStatefulKnowledgeFileLogger() throws Exception {
        KieSession statefulSession = (KieSession) context.getBean("FileLogger-statefulSession");
        assertNotNull(statefulSession.getGlobals().get("persons"));
        StatefulKnowledgeSessionImpl impl = (StatefulKnowledgeSessionImpl) statefulSession;
        for (Object listener : impl.getRuleRuntimeEventListeners()) {
            assertTrue(listener instanceof WorkingMemoryFileLogger);
        }
        LoggerAdaptor adaptor = (LoggerAdaptor) context.getBean("sf_fl_logger");
        assertNotNull(adaptor);
        assertNotNull(adaptor.getRuntimeLogger());
View Full Code Here

    @Test
    public void testStatefulKnowledgeThreadedFileLogger() throws Exception {
        KieSession statefulSession = (KieSession) context.getBean("ThreadedFileLogger-statefulSession");
        assertNotNull(statefulSession.getGlobals().get("persons"));
        StatefulKnowledgeSessionImpl impl = (StatefulKnowledgeSessionImpl) statefulSession;
        for (Object listener : impl.getRuleRuntimeEventListeners()) {
            assertTrue(listener instanceof ThreadedWorkingMemoryFileLogger);
        }
        LoggerAdaptor adaptor = (LoggerAdaptor) context.getBean("sf_tfl_logger");
        assertNotNull(adaptor);
        assertNotNull(adaptor.getRuntimeLogger());
View Full Code Here

        final LeftInputAdapterNode liaNode = new LeftInputAdapterNode( 23,
                                                                       objectTypeNode,
                                                                       buildContext );
        liaNode.attach(context);

        final StatefulKnowledgeSessionImpl workingMemory = new StatefulKnowledgeSessionImpl( 1, kBase );

        final MockLeftTupleSink sink = new MockLeftTupleSink();
        liaNode.addTupleSink( sink );

        final Object string1 = "cheese";

        // assert object
        final DefaultFactHandle f0 = (DefaultFactHandle) workingMemory.insert( string1 );
        liaNode.assertObject( f0,
                              pcontext,
                              workingMemory );

        final List asserted = sink.getAsserted();
        assertLength( 1,
                      asserted );
        final Tuple tuple0 = (Tuple) ((Object[]) asserted.get( 0 ))[0];
        assertSame( string1,
                    workingMemory.getObject( tuple0.get( 0 ) ) );

    }
View Full Code Here

    /**
     * Tests that interfaces and parent classes for an asserted  class are  cached, for  quick future iterations
     */
    @Test
    public void testCache() {
        StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newStatefulKnowledgeSession();

        // Create a Rete network with ObjectTypeNodes for List, Collection and ArrayList
        final Rete rete = kBase.getRete();
        ObjectTypeNode objectTypeNode = new ObjectTypeNode(1,
                                                           this.entryPoint,
                                                           new ClassObjectType(List.class),
                                                           buildContext);
        objectTypeNode.attach(buildContext);
        MockObjectSink sink = new MockObjectSink();
        objectTypeNode.addObjectSink(sink);

        objectTypeNode = new ObjectTypeNode(1,
                                            this.entryPoint,
                                            new ClassObjectType(Collection.class),
                                            buildContext);
        objectTypeNode.attach(buildContext);
        sink = new MockObjectSink();
        objectTypeNode.addObjectSink(sink);

        objectTypeNode = new ObjectTypeNode(1,
                                            this.entryPoint,
                                            new ClassObjectType(ArrayList.class),
                                            buildContext);
        objectTypeNode.attach(buildContext);
        sink = new MockObjectSink();
        objectTypeNode.addObjectSink(sink);

        // ArrayList matches all three ObjectTypeNodes
        final DefaultFactHandle h1 = new DefaultFactHandle(1,
                                                           new ArrayList());
        rete.assertObject(h1,
                          pctxFactory.createPropagationContext(0,
                                                               PropagationContext.INSERTION,
                                                               null,
                                                               null,
                                                               null),
                          ksession);

        // LinkedList matches two ObjectTypeNodes       
        h1.setObject(new LinkedList());
        rete.assertObject(h1,
                          pctxFactory.createPropagationContext(0,
                                                               PropagationContext.INSERTION,
                                                               null,
                                                               null,
                                                               null),
                          ksession);

        ClassObjectTypeConf conf = (ClassObjectTypeConf) ksession.getObjectTypeConfigurationRegistry().getObjectTypeConf(this.entryPoint.getEntryPoint(), new ArrayList());
        assertLength(3,
                     conf.getObjectTypeNodes());

        conf = (ClassObjectTypeConf) ksession.getObjectTypeConfigurationRegistry().getObjectTypeConf(this.entryPoint.getEntryPoint(), new ArrayList());
        assertLength(3,
                     conf.getObjectTypeNodes());

    }
View Full Code Here

     *
     * @throws Exception
     */
    @Test
    public void testAssertObject() throws Exception {
        StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newStatefulKnowledgeSession();

        // Create a Rete network with ObjectTypeNodes for List, Collection and ArrayList
        final Rete rete = kBase.getRete();
        final ObjectTypeNode objectTypeNode = new ObjectTypeNode(1,
                                                                 this.entryPoint,
View Full Code Here

TOP

Related Classes of org.drools.core.impl.StatefulKnowledgeSessionImpl$GlobalsAdapter

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.