use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class KieModuleMetaDataTest method testKieModuleMetaDataForDependenciesInMemory.
private void testKieModuleMetaDataForDependenciesInMemory(boolean useTypeDeclaration) throws Exception {
KieServices ks = KieServices.Factory.get();
ReleaseId dependency = ks.newReleaseId("org.drools", "drools-core", "5.5.0.Final");
ReleaseId releaseId = ks.newReleaseId("org.kie", "metadata-test", "1.0-SNAPSHOT");
InternalKieModule kieModule = createKieJarWithClass(ks, releaseId, useTypeDeclaration, 2, 7, dependency);
KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newKieModuleMetaData(kieModule);
checkDroolsCoreDep(kieModuleMetaData);
Collection<String> testClasses = kieModuleMetaData.getClasses("org.drools");
assertEquals(55, testClasses.size());
Class<?> beanClass = kieModuleMetaData.getClass("org.drools", "QueryResult");
assertNotNull(beanClass);
// Classes in dependencies should have TypeMetaInfo
TypeMetaInfo beanTypeInfo = kieModuleMetaData.getTypeMetaInfo(beanClass);
assertNotNull(beanTypeInfo);
if (useTypeDeclaration) {
assertTrue(beanTypeInfo.isEvent());
}
assertEquals(useTypeDeclaration, beanTypeInfo.isDeclaredType());
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class KieRepositoryScannerNexusTest method testKScannerNewContainer.
@Test
public void testKScannerNewContainer() throws Exception {
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId("com.redhat.gss", "scanner-test", "1.0-SNAPSHOT");
InternalKieModule kJar1 = createKieJar(ks, releaseId, getPomWithDistributionManagement(releaseId), true, "rule1", "rule2");
KieMavenRepository repository = getKieMavenRepository();
repository.deployArtifact(releaseId, kJar1, createKPomWithDistributionManagement(fileManager, releaseId));
// remove kjar from KieRepo
ks.getRepository().removeKieModule(releaseId);
KieContainer kieContainer = ks.newKieContainer(releaseId);
// create a ksesion and check it works as expected
KieSession ksession = kieContainer.newKieSession("KSession1");
checkKSession(ksession, "rule1", "rule2");
// create a new kjar
InternalKieModule kJar2 = createKieJar(ks, releaseId, getPomWithDistributionManagement(releaseId), true, "rule2", "rule3");
// deploy it on maven
repository.deployArtifact(releaseId, kJar2, createKPomWithDistributionManagement(fileManager, releaseId));
// remove kjar from KieRepo
ks.getRepository().removeKieModule(releaseId);
// create new KieContainer
KieContainer kieContainer2 = ks.newKieContainer(releaseId);
// create a ksession for the new container and check it works as expected
KieSession ksession2 = kieContainer2.newKieSession("KSession1");
checkKSession(ksession2, "rule2", "rule3");
ks.getRepository().removeKieModule(releaseId);
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class KieRepositoryScannerTest method testKScannerStartNotDeployed.
@Test
public void testKScannerStartNotDeployed() throws Exception {
// BZ-1200784
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId("org.kie", "scanner-start-not-deployed-test", "1.0-SNAPSHOT");
InternalKieModule kJar1 = createKieJar(ks, releaseId, "rule1", "rule2");
KieContainer kieContainer = ks.newKieContainer(releaseId);
// starting KieScanner
KieScanner scanner = ks.newKieScanner(kieContainer);
// scan the maven repo to get the new kjar version before it is deployed into Maven repo
// should not throw NPE because of uninitialized dependencies due to parsing parent pom failure
scanner.scanNow();
KieMavenRepository repository = getKieMavenRepository();
repository.installArtifact(releaseId, kJar1, createKPom(fileManager, releaseId));
// create a ksesion and check it works as expected
KieSession ksession = kieContainer.newKieSession("KSession1");
checkKSession(ksession, "rule1", "rule2");
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class KieRepositoryScannerTest method testKScannerWithKJarContainingClassLoadedFromClassLoader.
private void testKScannerWithKJarContainingClassLoadedFromClassLoader(boolean differentKbases) throws Exception {
// DROOLS-1231
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId("org.kie", "scanner-test", "1.0-SNAPSHOT");
InternalKieModule kJar1 = createKieJarWithJavaClass(ks, releaseId, "KBase1", 7);
KieMavenRepository repository = getKieMavenRepository();
repository.installArtifact(releaseId, kJar1, createKPom(fileManager, releaseId));
ks.getRepository().removeKieModule(releaseId);
KieContainer kieContainer = ks.newKieContainer(releaseId);
KieScanner scanner = ks.newKieScanner(kieContainer);
Class<?> beanClass = kieContainer.getClassLoader().loadClass("org.kie.test.Bean");
KieSession ksession = kieContainer.newKieSession("KSession1");
Object bean = beanClass.getDeclaredConstructors()[0].newInstance(2);
ksession.insert(bean);
checkKSession(ksession, 14);
InternalKieModule kJar2 = createKieJarWithJavaClass(ks, releaseId, differentKbases ? "KBase2" : "KBase1", 5);
repository.installArtifact(releaseId, kJar2, createKPom(fileManager, releaseId));
ks.getRepository().removeKieModule(releaseId);
// forces cache of old Bean class definition before updating to newer release
Class<?> beanClass1 = Class.forName("org.kie.test.Bean", true, kieContainer.getClassLoader());
kieContainer.updateToVersion(releaseId);
beanClass = kieContainer.getClassLoader().loadClass("org.kie.test.Bean");
KieSession ksession2 = kieContainer.newKieSession("KSession1");
bean = beanClass.getDeclaredConstructors()[0].newInstance(3);
ksession2.insert(bean);
checkKSession(ksession2, 15);
ks.getRepository().removeKieModule(releaseId);
}
use of org.drools.compiler.kie.builder.impl.InternalKieModule in project drools by kiegroup.
the class KieRepositoryScannerTest method testKScannerNewContainer.
@Test
public void testKScannerNewContainer() throws Exception {
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId("org.kie", "scanner-test", "1.0-SNAPSHOT");
InternalKieModule kJar1 = createKieJar(ks, releaseId, "rule1", "rule2");
KieMavenRepository repository = getKieMavenRepository();
repository.installArtifact(releaseId, kJar1, createKPom(fileManager, releaseId));
ks.getRepository().removeKieModule(releaseId);
KieContainer kieContainer = ks.newKieContainer(releaseId);
// create a ksesion and check it works as expected
KieSession ksession = kieContainer.newKieSession("KSession1");
checkKSession(ksession, "rule1", "rule2");
// create a new kjar
InternalKieModule kJar2 = createKieJar(ks, releaseId, "rule2", "rule3");
// deploy it on maven
repository.installArtifact(releaseId, kJar2, createKPom(fileManager, releaseId));
ks.getRepository().removeKieModule(releaseId);
// create new KieContainer
KieContainer kieContainer2 = ks.newKieContainer(releaseId);
// create a ksession for the new container and check it works as expected
KieSession ksession2 = kieContainer2.newKieSession("KSession1");
checkKSession(ksession2, "rule2", "rule3");
ks.getRepository().removeKieModule(releaseId);
}
Aggregations