/** * Create a Provider. * * @param url * @param rulesets * @return * @throws Exception */ public RuleServiceProvider getServiceProvider(final String url, final String ruleset) throws Exception { // create the provider final Class clazz = this.getClass() .getClassLoader() .loadClass("org.drools.jsr94.rules.RuleServiceProviderImpl"); RuleServiceProviderManager.registerRuleServiceProvider(url, clazz); final RuleServiceProvider serviceProvider = RuleServiceProviderManager.getRuleServiceProvider(url); final RuleAdministrator ruleAdministrator = serviceProvider.getRuleAdministrator(); // register the ruleset final InputStream inStream = this.getClass().getResourceAsStream(ruleset); final RuleExecutionSet res1 = ruleAdministrator .getLocalRuleExecutionSetProvider(null) .createRuleExecutionSet(inStream, null); inStream.close(); final String uri = res1.getName(); System.out.println(uri); ruleAdministrator.registerRuleExecutionSet(uri, res1, null); return serviceProvider; }
/** Test rule name and description. */ public void testRule() throws Exception { final InputStream in = RuleEngineTestBase.class.getResourceAsStream(this.bindUri); final RuleExecutionSet ruleExecutionSet = this.ruleSetProvider.createRuleExecutionSet(in, null); final List rules = ruleExecutionSet.getRules(); assertEquals("number of rules", 1, rules.size()); final Rule rule01 = (Rule) ruleExecutionSet.getRules().get(0); assertEquals("rule name", "FindSisters", rule01.getName()); assertEquals("rule description", "FindSisters", rule01.getDescription()); }