use of org.kie.api.KieServices in project drools by kiegroup.
the class IncrementalCompilationTest method testRuleRemovalWithSubnetworkAndOR.
@Test
public void testRuleRemovalWithSubnetworkAndOR() throws Exception {
// DROOLS-1025
String drl1 = "global java.util.concurrent.atomic.AtomicInteger globalInt\n" + "rule R1 when\n" + " $s : String()\n" + " (or exists Integer(this == 1)\n" + " exists Integer(this == 2) )\n" + " exists Integer() from globalInt.get()\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.setGlobal("globalInt", new AtomicInteger(0));
ksession.insert(1);
ksession.insert("1");
ksession.fireAllRules();
ReleaseId releaseId2 = ks.newReleaseId("org.kie", "test-upgrade", "1.1.2");
km = createAndDeployJar(ks, releaseId2);
try {
kc.updateToVersion(releaseId2);
} catch (Exception e) {
e.printStackTrace();
fail("Incremental update should succeed, but failed with " + e.getLocalizedMessage());
}
ksession.fireAllRules();
}
use of org.kie.api.KieServices 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.KieServices 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.KieServices 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.KieServices 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");
}
Aggregations