@Test
public void testManners() throws Exception {
final RuleBase ruleBase = RuleBaseFactory.newRuleBase( RuleBase.RETEOO );
ruleBase.addPackage( this.pkg );
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
final DefaultAgendaEventListener listener = new DefaultAgendaEventListener() {
private int counter = 0;
// public void matchCreated(ActivationCreatedEvent event) {
// super.matchCreated( event );
// System.out.println( event );
// }
//
// public void matchCancelled(ActivationCancelledEvent event) {
// super.matchCancelled( event );
// System.out.println( event );
// }
//
// public void beforeMatchFired(BeforeActivationFiredEvent event) {
// super.beforeMatchFired( event );
// System.out.println( event );
// }
public void afterActivationFired(AfterActivationFiredEvent event) {
this.counter++;
//super.afterMatchFired( event );
//System.out.println( event );
}
public String toString() {
return "fired : " + this.counter;
}
};
//workingMemory.addEventListener(listener );
final InputStream is = getClass().getResourceAsStream( "/manners5.dat" );
final List list = getInputObjects( is );
for ( final Iterator it = list.iterator(); it.hasNext(); ) {
final Object object = it.next();
workingMemory.insert( object );
}
workingMemory.insert( new Count( 1 ) );
final long start = System.currentTimeMillis();
workingMemory.fireAllRules();
// System.err.println( System.currentTimeMillis() - start );
//System.out.println( listener );
// while (1==1){