use of org.kie.api.builder.KieScanner in project jbpm by kiegroup.
the class KieScannerTest method testKScanner.
@Test
public void testKScanner() throws Exception {
List<String> results = new ArrayList<String>();
Map<String, Object> params = new HashMap<String, Object>();
params.put("results", results);
InternalKieModule kJar1 = createJbpmKieJar("Hello");
KieContainer kieContainer = ks.newKieContainer(releaseId);
KieMavenRepository repository = getKieMavenRepository();
repository.deployArtifact(releaseId, kJar1, kPom);
// create a ksesion and check it works as expected
KieSession ksession = kieContainer.newKieSession("KSession1");
ProcessInstance processInstance = ksession.startProcess("Minimal", params);
assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);
assertEquals(1, results.size());
assertEquals("Hello", results.get(0));
results.clear();
InternalKieModule kJar2 = createJbpmKieJar("Morning");
repository.deployArtifact(releaseId, kJar2, kPom);
KieScanner scanner = ks.newKieScanner(kieContainer);
scanner.scanNow();
// create a ksesion and check it works as expected
KieSession ksession2 = kieContainer.newKieSession("KSession1");
ProcessInstance processInstance2 = ksession2.startProcess("Minimal", params);
assertTrue(processInstance2.getState() == ProcessInstance.STATE_COMPLETED);
assertEquals(1, results.size());
assertEquals("Morning", results.get(0));
results.clear();
ks.getRepository().removeKieModule(releaseId);
}
use of org.kie.api.builder.KieScanner in project drools by kiegroup.
the class KieScannerMemoryTest method testScannerMemoryFootprint.
@Test
public void testScannerMemoryFootprint() throws IOException {
final KieServices kieServices = KieServices.Factory.get();
final KieMavenRepository repository = KieMavenRepository.getKieMavenRepository();
final KieModule kieModule = KieUtil.getKieModuleFromDrls(TestConstants.PACKAGE_FUNCTIONAL, KieBaseTestConfiguration.CLOUD_IDENTITY, "rule R when then end");
final ReleaseId releaseId = kieModule.getReleaseId();
repository.installArtifact(releaseId, (InternalKieModule) kieModule, MavenUtil.createPomXml(fileManager, releaseId));
final KieContainer kieContainer = kieServices.newKieContainer(releaseId);
final KieScanner kieScanner = kieServices.newKieScanner(kieContainer);
kieScanner.start(20);
try {
measureMemoryFootprint(1000, 100, 6, 30);
} finally {
kieScanner.stop();
}
}
use of org.kie.api.builder.KieScanner in project drools by kiegroup.
the class KieRepositoryScannerTest method testScanIncludedAndIncludingDependency.
@Test
@Ignore
public void testScanIncludedAndIncludingDependency() 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();
InternalKieModule containerKJar = createIncludingKJar(containerReleaseId, includedReleaseId, "ruleX");
repository.installArtifact(containerReleaseId, containerKJar, createKPom(fileManager, containerReleaseId, includedReleaseId));
KieContainer kieContainer = ks.newKieContainer(containerReleaseId);
KieSession ksession = kieContainer.newKieSession("KSession2");
checkKSession(ksession, "rule1", "ruleX");
resetFileManager();
KieScanner scanner = ks.newKieScanner(kieContainer);
InternalKieModule kJar2 = createKieJar(ks, includedReleaseId, "rule2");
repository.installArtifact(includedReleaseId, kJar2, createKPom(fileManager, includedReleaseId));
resetFileManager();
InternalKieModule containerKJar2 = createIncludingKJar(containerReleaseId, includedReleaseId, "ruleY");
repository.installArtifact(containerReleaseId, containerKJar2, createKPom(fileManager, containerReleaseId, includedReleaseId));
resetFileManager();
scanner.scanNow();
KieSession ksession2 = kieContainer.newKieSession("KSession2");
checkKSession(ksession2, "rule2", "ruleY");
ks.getRepository().removeKieModule(containerReleaseId);
ks.getRepository().removeKieModule(includedReleaseId);
}
use of org.kie.api.builder.KieScanner in project drools by kiegroup.
the class KieScannerIncrementalCompilationTest method checkIncrementalCompilation.
private void checkIncrementalCompilation(boolean useJavaInDrl) throws IOException {
KieServices ks = KieServices.Factory.get();
KieMavenRepository repository = getKieMavenRepository();
InternalKieModule kJar1 = createKieJarWithClass(ks, releaseId, FIRST_VALUE, useJavaInDrl);
repository.installArtifact(releaseId, kJar1, createKPom(releaseId));
KieContainer kieContainer = ks.newKieContainer(releaseId);
KieScanner scanner = ks.newKieScanner(kieContainer);
checkValue(kieContainer, FIRST_VALUE);
InternalKieModule kJar2 = createKieJarWithClass(ks, releaseId, SECOND_VALUE, useJavaInDrl);
repository.installArtifact(releaseId, kJar2, createKPom(releaseId));
scanner.scanNow();
checkValue(kieContainer, SECOND_VALUE);
ks.getRepository().removeKieModule(releaseId);
}
use of org.kie.api.builder.KieScanner in project drools by kiegroup.
the class KieRepositoryScannerTest method testKieScannerScopesNotRequired.
@Test
public void testKieScannerScopesNotRequired() throws Exception {
MavenRepository repository = getMavenRepository();
KieServices ks = KieServices.Factory.get();
ReleaseId releaseIdWithDep = ks.newReleaseId("org.kie", "test-with-dep", "1.0-SNAPSHOT");
Dependency dep1 = dependencyWithScope("org.kie", "test-dep1-in-test-scope", "1.0-SNAPSHOT", "test");
Dependency dep2 = dependencyWithScope("org.kie", "test-dep2-in-provided-scope", "1.0-SNAPSHOT", "provided");
Dependency dep3 = dependencyWithScope("org.kie", "test-dep3-in-system-scope", "1.0-SNAPSHOT", "system");
dep3.setSystemPath(fileManager.getRootDirectory().getAbsolutePath());
// to ensure KieBuilder is able to build correctly:
repository.installArtifact(ks.newReleaseId("org.kie", "test-dep3-in-system-scope", "1.0-SNAPSHOT"), new byte[] {}, new byte[] {});
InternalKieModule kJar2 = createKieJarWithDependencies(ks, releaseIdWithDep, false, "rule1", dep1, dep2, dep3);
KieContainer kieContainer = ks.newKieContainer(releaseIdWithDep);
// DROOLS-1051 following should not throw NPE because dependencies are not in scope of scanner
KieScanner scanner = ks.newKieScanner(kieContainer);
assertNotNull(scanner);
}
Aggregations