use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class IncrementalCompilationTest method testRuleRemovalWithOR.
@Test
public void testRuleRemovalWithOR() throws Exception {
// DROOLS-1007
String drl1 = "rule R1 when\n" + " $s : String()\n" + " (Integer(this == $s.length) or Long(this == $s.length))\n" + "then\n" + "end\n";
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId1 = ks.newReleaseId("org.kie", "test-upgrade", "1.1.1");
KieModule km = createAndDeployJar(ks, releaseId1, drl1);
KieContainer kc = ks.newKieContainer(km.getReleaseId());
KieSession ksession = kc.newKieSession();
ksession.fireAllRules();
ReleaseId releaseId2 = ks.newReleaseId("org.kie", "test-upgrade", "1.1.2");
km = createAndDeployJar(ks, releaseId2);
try {
kc.updateToVersion(releaseId2);
} catch (Exception e) {
fail("Incremental update should succeed, but failed with " + e.getLocalizedMessage());
}
ksession.fireAllRules();
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class IncrementalCompilationTest method testDeclaredTypeInDifferentPackage.
@Test
public void testDeclaredTypeInDifferentPackage() {
// DROOLS-1707
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId1 = ks.newReleaseId("org.kie", "test-upgrade", "1.0.0");
KieModule km = createAndDeployJar(ks, releaseId1, DECLARES_DRL, RULES1_DRL);
KieContainer kContainer = ks.newKieContainer(km.getReleaseId());
doFire(kContainer.getKieBase(), "reply 1");
ReleaseId releaseId2 = ks.newReleaseId("org.kie", "test-upgrade", "1.1.0");
km = createAndDeployJar(ks, releaseId2, DECLARES_DRL, RULES2_DRL);
kContainer.updateToVersion(releaseId2);
doFire(kContainer.getKieBase(), "reply 2");
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class IncrementalCompilationTest method testRemoveRuleWithRia.
@Test
public void testRemoveRuleWithRia() throws Exception {
// DROOLS-954
String drl1 = "import " + List.class.getCanonicalName() + "\n" + "rule R when\n" + " $list : List()\n" + " exists Integer( this == 1 ) from $list\n" + " exists Integer( this == 2 ) from $list\n" + "then \n" + "end\n";
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId1 = ks.newReleaseId("org.kie", "test-upgrade", "1.1.1");
KieModule km = createAndDeployJar(ks, releaseId1, drl1);
KieContainer kc = ks.newKieContainer(km.getReleaseId());
KieSession ksession = kc.newKieSession();
ReleaseId releaseId2 = ks.newReleaseId("org.kie", "test-upgrade", "1.1.2");
km = createAndDeployJar(ks, releaseId2);
kc.updateToVersion(releaseId2);
Rete rete = ((InternalKnowledgeBase) (InternalKnowledgeBase) ksession.getKieBase()).getRete();
EntryPointNode entryPointNode = rete.getEntryPointNodes().values().iterator().next();
for (ObjectTypeNode otns : entryPointNode.getObjectTypeNodes().values()) {
assertEquals(0, otns.getObjectSinkPropagator().getSinks().length);
}
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class IncrementalCompilationTest method testDeclaredTypeInIncludedKieBase.
@Test
public void testDeclaredTypeInIncludedKieBase() {
// DROOLS-1707
KieServices ks = KieServices.Factory.get();
KieModule kModule = buildKieModule("0.0.1", DECLARES_DRL, RULES1_DRL);
KieContainer kContainer = ks.newKieContainer(kModule.getReleaseId());
doFire(kContainer.getKieBase("kiemodulemodel"), "reply 1");
KieModule kModule2 = buildKieModule("0.0.2", DECLARES_DRL, RULES2_DRL);
kContainer.updateToVersion(kModule2.getReleaseId());
doFire(kContainer.getKieBase("kiemodulemodel"), "reply 2");
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class IncrementalCompilationTest method testRetractLogicalAssertedObjectOnRuleRemovalWithSameObject.
@Test
public void testRetractLogicalAssertedObjectOnRuleRemovalWithSameObject() throws Exception {
// DROOLS-951
String drl1 = "rule R1 when\n" + " exists( Integer() )\n" + "then\n" + " insertLogical( \"found\" );" + "end\n";
String drl2 = "package org.drools.compiler\n" + "rule R2 when\n" + " exists( Integer() )\n" + "then\n" + " insertLogical( \"found\" );" + "end\n";
String drl3 = "package org.drools.compiler\n" + "rule R3 when\n" + " exists( Integer() )\n" + "then\n" + " insertLogical( \"found\");" + "end\n";
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId1 = ks.newReleaseId("org.kie", "test-upgrade", "1.1.1");
KieModule km = createAndDeployJar(ks, releaseId1, drl1, drl2, drl3);
KieContainer kc = ks.newKieContainer(km.getReleaseId());
KieSession ksession = kc.newKieSession();
ksession.insert(4);
ksession.fireAllRules();
assertEquals(1, ksession.getObjects(new ClassObjectFilter(String.class)).size());
ReleaseId releaseId2 = ks.newReleaseId("org.kie", "test-upgrade", "1.1.2");
km = createAndDeployJar(ks, releaseId2, drl1, drl2);
kc.updateToVersion(releaseId2);
ksession.fireAllRules();
assertEquals(1, ksession.getObjects(new ClassObjectFilter(String.class)).size());
ReleaseId releaseId3 = ks.newReleaseId("org.kie", "test-upgrade", "1.1.3");
km = createAndDeployJar(ks, releaseId3, drl1);
kc.updateToVersion(releaseId3);
ksession.fireAllRules();
assertEquals(1, ksession.getObjects(new ClassObjectFilter(String.class)).size());
ReleaseId releaseId4 = ks.newReleaseId("org.kie", "test-upgrade", "1.1.4");
km = createAndDeployJar(ks, releaseId4);
kc.updateToVersion(releaseId4);
ksession.fireAllRules();
assertEquals(0, ksession.getObjects(new ClassObjectFilter(String.class)).size());
}
Aggregations