((SessionConfiguration) ksconf).setTimerJobFactoryManager( new TrackableTimeJobFactoryManager() );
StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession( ksconf, null );
List list = new ArrayList();
ksession.setGlobal( "list", list );
WorkingMemoryEntryPoint aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
aep.insert( new A() );
ksession = marsallStatefulKnowledgeSession( ksession );
WorkingMemoryEntryPoint bep = ksession.getWorkingMemoryEntryPoint( "b-ep" );
bep.insert( new B() );
ksession = marsallStatefulKnowledgeSession( ksession );
WorkingMemoryEntryPoint cep = ksession.getWorkingMemoryEntryPoint( "c-ep" );
cep.insert( new C() );
ksession = marsallStatefulKnowledgeSession( ksession );
ksession.fireAllRules();
ksession = marsallStatefulKnowledgeSession( ksession );
assertEquals( 3,
list.size() );
aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
assertEquals( 1, aep.getFactHandles().size() );
bep = ksession.getWorkingMemoryEntryPoint( "b-ep" );
assertEquals( 1, bep.getFactHandles().size() );
cep = ksession.getWorkingMemoryEntryPoint( "c-ep" );
assertEquals( 1, cep.getFactHandles().size() );
PseudoClockScheduler timeService = (PseudoClockScheduler) ksession.<SessionClock> getSessionClock();
timeService.advanceTime( 11, TimeUnit.SECONDS );
ksession = marsallStatefulKnowledgeSession( ksession );
ksession.fireAllRules();
ksession = marsallStatefulKnowledgeSession( ksession );
aep = ksession.getWorkingMemoryEntryPoint( "a-ep" );
assertEquals( 0, aep.getFactHandles().size() );
bep = ksession.getWorkingMemoryEntryPoint( "b-ep" );
assertEquals( 0, bep.getFactHandles().size() );
cep = ksession.getWorkingMemoryEntryPoint( "c-ep" );
assertEquals( 1, cep.getFactHandles().size() );
}