use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class KieRepositoryScannerTest method testReleaseDowngrade.
@Test
public void testReleaseDowngrade() throws Exception {
// DROOLS-1720
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId1 = ks.newReleaseId("org.kie", "downgrade-test", "1.1");
ReleaseId releaseId2 = ks.newReleaseId("org.kie", "downgrade-test", "1.2");
ReleaseId kcRelId = ks.newReleaseId("org.kie", "downgrade-test", "[1.0,)");
final String drl1 = "global java.util.List list; \n" + "rule R1 when then \n" + " list.add(1);\n" + "end ";
final String drl2 = "global java.util.List list; \n" + "rule R1 when then \n" + " list.add(2);\n" + "end ";
InternalKieModule kJar1 = createKieJarFromDrl(ks, releaseId1, drl1);
InternalKieModule kJar2 = createKieJarFromDrl(ks, releaseId2, drl2);
KieMavenRepository repository = getKieMavenRepository();
repository.installArtifact(releaseId1, kJar1, createKPom(fileManager, releaseId1));
repository.installArtifact(releaseId2, kJar2, createKPom(fileManager, releaseId2));
KieContainer kieContainer = ks.newKieContainer(kcRelId);
checkKSession(kieContainer.newKieSession("KSession1"), 2);
kieContainer.updateToVersion(releaseId1);
checkKSession(kieContainer.newKieSession("KSession1"), 1);
KieScanner kieScanner = ks.newKieScanner(kieContainer);
kieScanner.scanNow();
checkKSession(kieContainer.newKieSession("KSession1"), 2);
kieContainer.updateToVersion(releaseId1);
checkKSession(kieContainer.newKieSession("KSession1"), 1);
kieScanner.scanNow();
checkKSession(kieContainer.newKieSession("KSession1"), 2);
ks.getRepository().removeKieModule(releaseId1);
ks.getRepository().removeKieModule(releaseId2);
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class KieRepositoryScannerTest method createKieJarWithRules.
private InternalKieModule createKieJarWithRules(KieServices ks, ReleaseId releaseId, ReleaseId depId) throws IOException {
KieFileSystem kfs = createKieFileSystemWithKProject(ks);
kfs.write("src/main/resources/KBase1/r1.drl", "package org.kie.test\n" + getDRLWithRules(3, 5));
kfs.writePomXML(getPom(releaseId, depId));
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
kieBuilder.buildAll();
assertTrue(kieBuilder.getResults().getMessages().isEmpty());
return (InternalKieModule) kieBuilder.getKieModule();
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class KieRepositoryScannerTest method testScannerOnPomProjectWithFixedVersion.
@Test
public void testScannerOnPomProjectWithFixedVersion() throws Exception {
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId1 = ks.newReleaseId("org.kie", "scanner-test", "1.0");
ReleaseId releaseId2 = ks.newReleaseId("org.kie", "scanner-test", "2.0");
KieMavenRepository repository = getKieMavenRepository();
repository.deployPomArtifact("org.kie", "scanner-master-test", "1.0", createMasterKPom("scanner-test", "1.0"));
resetFileManager();
InternalKieModule kJar1 = createKieJarWithClass(ks, releaseId1, false, 2, 7);
repository.installArtifact(releaseId1, kJar1, createKPom(fileManager, releaseId1));
KieContainer kieContainer = ks.newKieContainer(ks.newReleaseId("org.kie", "scanner-master-test", "LATEST"));
KieSession ksession = kieContainer.newKieSession("KSession1");
checkKSession(ksession, 14);
KieScanner scanner = ks.newKieScanner(kieContainer);
repository.deployPomArtifact("org.kie", "scanner-master-test", "2.0", createMasterKPom("scanner-test", "2.0"));
InternalKieModule kJar2 = createKieJarWithClass(ks, releaseId2, false, 3, 5);
repository.installArtifact(releaseId2, kJar2, createKPom(fileManager, releaseId1));
scanner.scanNow();
KieSession ksession2 = kieContainer.newKieSession("KSession1");
checkKSession(ksession2, 15);
ks.getRepository().removeKieModule(releaseId1);
ks.getRepository().removeKieModule(releaseId2);
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class KieRepositoryScannerTest method createIncludingKJar.
private InternalKieModule createIncludingKJar(ReleaseId containerReleaseId, ReleaseId includedReleaseId, String rule) {
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
String file = "org/test/" + rule + ".drl";
kfs.write("src/main/resources/KBase2/" + file, createDRL(rule));
KieModuleModel kproj = ks.newKieModuleModel();
kproj.newKieBaseModel("KBase2").addInclude("KBase1").newKieSessionModel("KSession2");
kfs.writeKModuleXML(kproj.toXML());
kfs.writePomXML(getPom(containerReleaseId, includedReleaseId));
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
assertTrue(kieBuilder.buildAll().getResults().getMessages().isEmpty());
return (InternalKieModule) kieBuilder.getKieModule();
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class KieRepositoryScannerTest method createKieJarWithGDRL.
private InternalKieModule createKieJarWithGDRL(KieServices ks, ReleaseId releaseId, String rule) throws IOException {
KieFileSystem kfs = createKieFileSystemWithKProject(ks, false);
kfs.writePomXML(getPom(releaseId));
kfs.write("src/main/resources/rule.drl", rule);
kfs.write("src/main/resources/global.gdrl", "global java.util.List list;");
KieBuilder kieBuilder = ks.newKieBuilder(kfs);
assertTrue(kieBuilder.buildAll().getResults().getMessages().isEmpty());
return (InternalKieModule) kieBuilder.getKieModule();
}
Aggregations