public void testAddFromRuleSetLoader() throws IntegrationException,
SAXException,
IOException,
FactException
{
WorkingMemory workingMemory;
List list;
RuleBase ruleBase;
RuleBaseLoader ruleBaseLoader;
RuleSetLoader ruleSetLoader = new RuleSetLoader( );
// single URL parameter
ruleSetLoader.addFromUrl( RuleBaseLoaderTest.class.getResource( "simple.java.drl" ) );
// Try with addFromRuleSetLoader
ruleBaseLoader = new RuleBaseLoader( );
ruleBaseLoader.addFromRuleSetLoader( ruleSetLoader );
ruleBase = ruleBaseLoader.buildRuleBase( );
workingMemory = ruleBase.newWorkingMemory( );
list = new ArrayList( );
workingMemory.setApplicationData( "list",
list );
workingMemory.assertObject( "help" );
workingMemory.fireAllRules( );
assertEquals( "help",
list.get( 0 ) );
// Try with addFromRuleSetLoader []
ruleBaseLoader = new RuleBaseLoader( );
ruleBaseLoader.addFromRuleSetLoader( new RuleSetLoader[]{ruleSetLoader} );
ruleBase = ruleBaseLoader.buildRuleBase( );
workingMemory = ruleBase.newWorkingMemory( );
list = new ArrayList( );
workingMemory.setApplicationData( "list",
list );
workingMemory.assertObject( "help" );
workingMemory.fireAllRules( );
assertEquals( "help",
list.get( 0 ) );
}