KieContainerFromKieRepoExample { public void go(PrintStream out) { KieServices ks = KieServices.Factory.get(); KieContainer kContainer = ks.newKieContainer(ks.newReleaseId("org.drools", "named-kiesession", Drools.getFullVersion())); KieSession kSession = kContainer.newKieSession("ksession1"); kSession.setGlobal("out", out); Object msg1 = createMessage(kContainer, "Dave", "Hello, HAL. Do you read me, HAL?"); kSession.insert(msg1); kSession.fireAllRules(); }  void go(PrintStream out); static void main(String[] args);  }
@Test public void testGo() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); new KieContainerFromKieRepoExample().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; assertEquals(expected, actual); }