// assertTrue( Serializable.class.isAssignableFrom( AgendaEventSupport.class ) );
// }
@Test
public void testAgendaEventListener() throws Exception {
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
// create a simple package with one rule to test the events
final Package pkg = new Package( "org.drools.test" );
final Rule rule = new Rule( "test1" );
rule.setAgendaGroup( "test group" );
final ClassObjectType cheeseObjectType = new ClassObjectType( Cheese.class );
final Pattern pattern = new Pattern( 0,
cheeseObjectType );
pkg.setClassFieldAccessorCache( new ClassFieldAccessorCache( Thread.currentThread().getContextClassLoader() ) );
pkg.getClassFieldAccessorStore().setEagerWire( true );
final ClassFieldReader extractor = pkg.getClassFieldAccessorStore().getReader(Cheese.class,
"type",
getClass().getClassLoader());
final FieldValue field = FieldFactory.getInstance().getFieldValue( "cheddar" );
final MvelConstraint constraint = new MvelConstraintTestUtil("type == \"cheddar\"", field, extractor);
pattern.addConstraint( constraint );
rule.addPattern( pattern );
rule.setConsequence( new Consequence() {
public void evaluate(final KnowledgeHelper knowledgeHelper,
final org.drools.WorkingMemory workingMemory) throws Exception {
}
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
}
public void writeExternal(ObjectOutput out) throws IOException {
}
public String getName() {
// TODO Auto-generated method stub
return null;
}
} );
pkg.addRule( rule );
List<KnowledgePackage> pkgs = new ArrayList<KnowledgePackage>();
pkgs.add( new KnowledgePackageImp( pkg ) );
kbase.addKnowledgePackages( pkgs );
// create a new working memory and add an AgendaEventListener
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
final List agendaList = new ArrayList();
final AgendaEventListener agendaEventListener = new AgendaEventListener() {
public void matchCancelled(MatchCancelledEvent event) {
assertNotNull( event.getKieRuntime() );