use of org.kie.api.builder.KieScanner in project drools by kiegroup.
the class KieRepositoryScannerTest method testKScannerWithType.
private void testKScannerWithType(boolean useTypeDeclaration) throws Exception {
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId("org.kie", "scanner-test", "1.0-SNAPSHOT");
InternalKieModule kJar1 = createKieJarWithClass(ks, releaseId, useTypeDeclaration, 2, 7);
KieMavenRepository repository = getKieMavenRepository();
repository.installArtifact(releaseId, kJar1, createKPom(fileManager, releaseId));
KieContainer kieContainer = ks.newKieContainer(releaseId);
KieScanner scanner = ks.newKieScanner(kieContainer);
KieSession ksession = kieContainer.newKieSession("KSession1");
checkKSession(ksession, 14);
InternalKieModule kJar2 = createKieJarWithClass(ks, releaseId, useTypeDeclaration, 3, 5);
repository.installArtifact(releaseId, kJar2, createKPom(fileManager, releaseId));
scanner.scanNow();
KieSession ksession2 = kieContainer.newKieSession("KSession1");
checkKSession(ksession2, 15);
ks.getRepository().removeKieModule(releaseId);
}
use of org.kie.api.builder.KieScanner in project drools by kiegroup.
the class KieRepositoryScannerTest method testScanIncludedDependency.
@Test
public void testScanIncludedDependency() throws Exception {
KieMavenRepository repository = getKieMavenRepository();
KieServices ks = KieServices.Factory.get();
ReleaseId containerReleaseId = KieServices.Factory.get().newReleaseId("org.kie", "test-container", "1.0.0-SNAPSHOT");
ReleaseId includedReleaseId = KieServices.Factory.get().newReleaseId("org.kie", "test-project", "1.0.0-SNAPSHOT");
InternalKieModule kJar1 = createKieJar(ks, includedReleaseId, "rule1");
repository.installArtifact(includedReleaseId, kJar1, createKPom(fileManager, includedReleaseId));
resetFileManager();
KieFileSystem kfs = ks.newKieFileSystem();
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());
InternalKieModule containerKJar = (InternalKieModule) kieBuilder.getKieModule();
repository.installArtifact(containerReleaseId, containerKJar, createKPom(fileManager, containerReleaseId, includedReleaseId));
KieContainer kieContainer = ks.newKieContainer(containerReleaseId);
KieSession ksession = kieContainer.newKieSession("KSession2");
checkKSession(ksession, "rule1");
KieScanner scanner = ks.newKieScanner(kieContainer);
InternalKieModule kJar2 = createKieJar(ks, includedReleaseId, "rule2");
repository.installArtifact(includedReleaseId, kJar2, createKPom(fileManager, includedReleaseId));
scanner.scanNow();
KieSession ksession2 = kieContainer.newKieSession("KSession2");
checkKSession(ksession2, "rule2");
ks.getRepository().removeKieModule(containerReleaseId);
ks.getRepository().removeKieModule(includedReleaseId);
}
use of org.kie.api.builder.KieScanner 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.kie.api.builder.KieScanner 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.kie.api.builder.KieScanner in project drools by kiegroup.
the class KieRepositoryScannerTest method testScannerOnPomProjectSameKieSession.
@Test
public void testScannerOnPomProjectSameKieSession() 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, true, 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(false, 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, true, 3, 5);
repository.installArtifact(releaseId2, kJar2, createKPom(fileManager, releaseId1));
scanner.scanNow();
checkKSession(ksession, 10, 15);
ks.getRepository().removeKieModule(releaseId1);
ks.getRepository().removeKieModule(releaseId2);
}
Aggregations