KieModuleFromMultipleFilesExample { public void go(PrintStream out) { KieServices ks = KieServices.Factory.get(); KieRepository kr = ks.getRepository(); Resource ex1Res = ks.getResources().newFileSystemResource(getFile("kiebase-inclusion")); Resource ex2Res = ks.getResources().newFileSystemResource(getFile("named-kiesession")); KieModule kModule = kr.addKieModule(ex1Res, ex2Res); KieContainer kContainer = ks.newKieContainer(kModule.getReleaseId()); KieSession kSession = kContainer.newKieSession("ksession2"); kSession.setGlobal("out", out); Object msg1 = createMessage(kContainer, "Dave", "Hello, HAL. Do you read me, HAL?"); kSession.insert(msg1); kSession.fireAllRules(); Object msg2 = createMessage(kContainer, "Dave", "Open the pod bay doors, HAL."); kSession.insert(msg2); kSession.fireAllRules(); }  void go(PrintStream out); static void main(String[] args); static File getFile(String exampleName);  }
@Test public void testGo() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); new KieModuleFromMultipleFilesExample().go(ps); ps.close(); String actual = new String(baos.toByteArray()); String expected = "" + "Dave: Hello, HAL. Do you read me, HAL?" + NL + "HAL: Dave. I read you." + NL + "Dave: Open the pod bay doors, HAL." + NL + "HAL: I'm sorry, Dave. I'm afraid I can't do that." + NL; assertEquals(expected, actual); }