ksession.getObjects().size() );
}
@Test @Ignore("This test is suspicious to say the least...")
public void testScheduledActivation() {
KnowledgeBaseImpl knowledgeBase = (KnowledgeBaseImpl) KnowledgeBaseFactory.newKnowledgeBase();
KnowledgePackageImp impl = new KnowledgePackageImp();
impl.pkg = new org.drools.core.rule.Package( "test" );
BuildContext buildContext = new BuildContext( (InternalRuleBase) knowledgeBase.getRuleBase(), ((ReteooRuleBase) knowledgeBase.getRuleBase())
.getReteooBuilder().getIdGenerator() );
//simple rule that fires after 10 seconds
final Rule rule = new Rule( "test-rule" );
new RuleTerminalNode( 1, new MockTupleSource( 2 ), rule, rule.getLhs(), 0, buildContext );
final List<String> fired = new ArrayList<String>();
rule.setConsequence( new Consequence() {
public void evaluate(KnowledgeHelper knowledgeHelper,
WorkingMemory workingMemory) throws Exception {
fired.add( "a" );
}
public String getName() {
return "default";
}
} );
rule.setTimer( new DurationTimer( 10000 ) );
rule.setPackage( "test" );
impl.pkg.addRule( rule );
knowledgeBase.addKnowledgePackages( Collections.singleton( (KnowledgePackage) impl ) );
SessionConfiguration config = new SessionConfiguration();
config.setClockType( ClockType.PSEUDO_CLOCK );
StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession( config, KnowledgeBaseFactory.newEnvironment() );
PseudoClockScheduler scheduler = (PseudoClockScheduler) ksession.<SessionClock> getSessionClock();
Marshaller marshaller = MarshallerFactory.newMarshaller( knowledgeBase );
ksession.insert( "cheese" );
assertTrue( fired.isEmpty() );