use of org.drools.mvel.compiler.Message in project drools by kiegroup.
the class SequentialTest method testKnowledgeRuntimeAccess.
@Test
public void testKnowledgeRuntimeAccess() throws Exception {
String str = "";
str += "package org.drools.mvel.compiler.test\n";
str += "import org.drools.mvel.compiler.Message\n";
str += "rule \"Hello World\"\n";
str += "when\n";
str += " Message( )\n";
str += "then\n";
str += " System.out.println( drools.getKieRuntime() );\n";
str += "end\n";
final KieModule kieModule = KieUtil.getKieModuleFromDrls("test", kieBaseTestConfiguration, str);
final KieBase kbase = KieBaseUtil.newKieBaseFromKieModuleWithAdditionalOptions(kieModule, kieBaseTestConfiguration, SequentialOption.YES);
StatelessKieSession ksession = kbase.newStatelessKieSession();
ksession.execute(new Message("help"));
}
use of org.drools.mvel.compiler.Message in project drools by kiegroup.
the class StatefulSessionTest method testDispose.
@Test
public void testDispose() throws Exception {
final StringBuilder rule = new StringBuilder();
rule.append("package org.drools.mvel.compiler\n");
rule.append("rule X\n");
rule.append("when\n");
rule.append(" Message()\n");
rule.append("then\n");
rule.append("end\n");
// building stuff
KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, rule.toString());
KieSession ksession = kbase.newKieSession();
ksession.insert(new Message("test"));
final int rules = ksession.fireAllRules();
assertEquals(1, rules);
ksession.dispose();
try {
// the following should raise an IllegalStateException as the session was already disposed
ksession.fireAllRules();
fail("An IllegallStateException should have been raised as the session was disposed before the method call.");
} catch (final IllegalStateException ise) {
// success
}
}
use of org.drools.mvel.compiler.Message in project drools by kiegroup.
the class ExecutionFlowControlTest method testDateEffective.
@Test
public void testDateEffective() throws Exception {
// read in the source
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_EffectiveDate.drl");
KieSession ksession = kbase.newKieSession();
final List list = new ArrayList();
ksession.setGlobal("list", list);
// go !
final Message message = new Message("hola");
ksession.insert(message);
ksession.fireAllRules();
assertFalse(message.isFired());
}
use of org.drools.mvel.compiler.Message in project drools by kiegroup.
the class FirstOrderLogicTest method testOrs.
@Test
public void testOrs() throws Exception {
String str = "package org.drools.mvel.integrationtests\n" + "import " + Message.class.getName() + "\n" + "rule X\n" + " when\n" + " Message( message == 'test' )\n" + " Message( !fired ) or eval( !false )\n" + " then\n" + "end\n";
KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration, str);
KieSession ksession = kbase.newKieSession();
ksession.insert(new Message("test"));
int rules = ksession.fireAllRules();
assertEquals(2, rules);
ksession.dispose();
}
use of org.drools.mvel.compiler.Message in project drools by kiegroup.
the class SerializedPackageMergeTest method getObject.
private Message getObject() throws ParseException {
Message message = new Message();
message.setMessage("hola");
message.setNumber(50);
message.getList().add("hello");
message.setBirthday(DF.parse("10-Jul-1976"));
return message;
}
Aggregations