use of org.drools.core.SessionConfiguration in project drools by kiegroup.
the class JDKTimerServiceTest method testRepeatedExecutionJob.
@Test
public void testRepeatedExecutionJob() throws Exception {
SessionConfiguration config = SessionConfiguration.newInstance();
config.setClockType(ClockType.REALTIME_CLOCK);
TimerService timeService = TimerServiceFactory.getTimerService(config);
Trigger trigger = new DelayedTrigger(new long[] { 100, 100, 100 });
HelloWorldJobContext ctx = new HelloWorldJobContext("hello world", timeService);
timeService.scheduleJob(new HelloWorldJob(), ctx, trigger);
Thread.sleep(500);
timeService.shutdown();
assertEquals(3, ctx.getList().size());
}
use of org.drools.core.SessionConfiguration in project drools by kiegroup.
the class JDKTimerServiceTest method testSingleExecutionJob.
@Test
public void testSingleExecutionJob() throws Exception {
SessionConfiguration config = SessionConfiguration.newInstance();
config.setClockType(ClockType.REALTIME_CLOCK);
TimerService timeService = TimerServiceFactory.getTimerService(config);
Trigger trigger = new DelayedTrigger(100);
HelloWorldJobContext ctx = new HelloWorldJobContext("hello world", timeService);
timeService.scheduleJob(new HelloWorldJob(), ctx, trigger);
Thread.sleep(500);
timeService.shutdown();
assertEquals(1, ctx.getList().size());
}
use of org.drools.core.SessionConfiguration in project drools by kiegroup.
the class BayesBeliefSystemTest method getSessionFromString.
protected KieSession getSessionFromString(String drlString) {
KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kBuilder.add(ResourceFactory.newByteArrayResource(drlString.getBytes()), ResourceType.DRL);
kBuilder.add(ResourceFactory.newClassPathResource("Garden.xmlbif", AssemblerTest.class), ResourceType.BAYES);
if (kBuilder.hasErrors()) {
System.err.println(kBuilder.getErrors());
fail();
}
InternalKnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
kBase.addPackages(kBuilder.getKnowledgePackages());
KieSessionConfiguration ksConf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
((SessionConfiguration) ksConf).setBeliefSystemType(BeliefSystemType.DEFEASIBLE);
KieSession kSession = kBase.newKieSession(ksConf, null);
return kSession;
}
Aggregations