final List list = new ArrayList();
session.setGlobal( "list",
list );
final State state = new State( "initial" );
session.insert( state,
true );
session.fireAllRules();
assertEquals( 1,
((List) session.getGlobal( "list" )).size() );
state.setFlag( true );
assertEquals( 1,
((List) session.getGlobal( "list" )).size() );
session.fireAllRules();
assertEquals( 2,
((List) session.getGlobal( "list" )).size() );
state.setState( "finished" );
StatefulKnowledgeSession ksesion = SerializationHelper.getSerialisedStatefulKnowledgeSession( new StatefulKnowledgeSessionImpl( (ReteooWorkingMemory) session ),
// MarshallerFactory.newIdentityMarshallingStrategy(),
false );
ksesion.fireAllRules();
assertEquals( 3,
((List) session.getGlobal( "list" )).size() );
session.dispose();
// checks that the session removed itself from the bean listeners list
assertEquals( 0,
state.getPropertyChangeListeners().length );
}