use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class KieRepositoryTest method testLoadingNotAKJar.
@Test
public void testLoadingNotAKJar() {
// DROOLS-1351
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { this.getClass().getResource("/only-jar-pojo-not-kjar-no-kmodule-1.0.0.jar") });
Thread.currentThread().setContextClassLoader(urlClassLoader);
try {
KieServices ks = KieServices.Factory.get();
KieRepository kieRepository = ks.getRepository();
ReleaseId releaseId = ks.newReleaseId("org.test", "only-jar-pojo-not-kjar-no-kmodule", "1.0.0");
KieModule kieModule = kieRepository.getKieModule(releaseId);
assertNull(kieModule);
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class KieRepositoryTest method testLoadKjarFromClasspath.
@Test
public void testLoadKjarFromClasspath() {
// DROOLS-1335
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { this.getClass().getResource("/kie-project-simple-1.0.0.jar") });
Thread.currentThread().setContextClassLoader(urlClassLoader);
try {
KieServices ks = KieServices.Factory.get();
KieRepository kieRepository = ks.getRepository();
ReleaseId releaseId = ks.newReleaseId("org.test", "kie-project-simple", "1.0.0");
KieModule kieModule = kieRepository.getKieModule(releaseId);
assertNotNull(kieModule);
assertEquals(releaseId, kieModule.getReleaseId());
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class KieRepositoryTest method testTryLoadNotExistingKjarFromClasspath.
@Test
public void testTryLoadNotExistingKjarFromClasspath() {
// DROOLS-1335
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { this.getClass().getResource("/kie-project-simple-1.0.0.jar") });
Thread.currentThread().setContextClassLoader(urlClassLoader);
try {
KieServices ks = KieServices.Factory.get();
KieRepository kieRepository = ks.getRepository();
ReleaseId releaseId = ks.newReleaseId("org.test", "kie-project-simple", "1.0.1");
KieModule kieModule = kieRepository.getKieModule(releaseId);
assertNull(kieModule);
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class I18nTest method testKieModuleJar.
@Test
public void testKieModuleJar() {
String str = "package org.drools.compiler.i18ntest;\n" + "import org.drools.compiler.I18nPerson;\n" + "\n" + "global java.util.List list;\n" + "rule \"名称 is 山田花子\"\n" + " when\n" + " p : I18nPerson( 名称 == \"山田花子\" )\n" + " then\n" + " list.add( \"名称は山田花子です\" );\n" + "end\n";
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId("org.kie", "118ntest", "1.0.0");
byte[] jar = createKJar(ks, releaseId, null, str);
KieModule km = deployJar(ks, jar);
KieContainer kc = ks.newKieContainer(km.getReleaseId());
KieSession ksession = kc.newKieSession();
List list = new ArrayList();
ksession.setGlobal("list", list);
I18nPerson i18nPerson = new I18nPerson();
i18nPerson.set名称("山田花子");
ksession.insert(i18nPerson);
ksession.fireAllRules();
assertTrue(list.contains("名称は山田花子です"));
ksession.dispose();
}
use of org.kie.api.builder.KieModule in project drools by kiegroup.
the class Misc2Test method testPackagingJarWithTypeDeclarations.
@Test
public void testPackagingJarWithTypeDeclarations() throws Exception {
// BZ-1054823
String drl1 = "package org.drools.compiler\n" + "import org.drools.compiler.Message\n" + "declare Message\n" + " @role (event)\n" + "end\n" + "rule R1 when\n" + " $m : Message()\n" + "then\n" + "end\n";
KieServices ks = KieServices.Factory.get();
// Create an in-memory jar for version 1.0.0
ReleaseId releaseId = ks.newReleaseId("org.kie", "test-upgrade", "1.0.0");
byte[] jar = createKJar(ks, releaseId, null, drl1);
KieModule km = deployJar(ks, jar);
// Create a session and fire rules
KieContainer kc = ks.newKieContainer(km.getReleaseId());
KieSession ksession = kc.newKieSession();
ksession.insert(new Message("Hello World"));
ksession.fireAllRules();
}
Aggregations