use of org.drools.core.impl.InternalKieContainer in project drools by kiegroup.
the class KieContainerTest method testUpdateToNonExistingRelease.
@Test
public void testUpdateToNonExistingRelease() {
// DROOLS-1562
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId("org.kie", "test-release", "1.0.0");
createAndDeployJar(ks, releaseId, createDRL("ruleA"));
KieContainer kieContainer = ks.newKieContainer(releaseId);
Results results = kieContainer.updateToVersion(ks.newReleaseId("org.kie", "test-release", "1.0.1"));
assertEquals(1, results.getMessages(Level.ERROR).size());
assertEquals("1.0.0", ((InternalKieContainer) kieContainer).getContainerReleaseId().getVersion());
}
use of org.drools.core.impl.InternalKieContainer in project drools by kiegroup.
the class KieContainerDefaultsTest method testTwoKieSessionsOneDefault.
/**
* This test checks if default KieSessions behave as expected.
*/
@Test
public void testTwoKieSessionsOneDefault() {
final KieModuleModel kieModule = kieServices.newKieModuleModel();
kieModule.newKieBaseModel("firstKBase").setDefault(true).newKieSessionModel("firstKSession").setDefault(true);
kieModule.newKieBaseModel("secondKBase").setDefault(true).newKieSessionModel("secondKSession");
buildKieModule(kieModule);
final KieContainer kieContainer = kieServices.newKieContainer(RELEASE_ID);
final KieSession firstKSession = kieContainer.newKieSession("firstKSession");
final KieSession secondKSession = kieContainer.newKieSession("secondKSession");
try {
Assertions.assertThat(firstKSession).isEqualTo(((InternalKieContainer) kieContainer).getKieSession());
Assertions.assertThat(secondKSession).isNotEqualTo(((InternalKieContainer) kieContainer).getKieSession());
} finally {
firstKSession.dispose();
secondKSession.dispose();
}
}
use of org.drools.core.impl.InternalKieContainer in project drools by kiegroup.
the class KieContainerDefaultsTest method testTwoStatelessKieSessionsOneDefault.
/**
* This test checks if default StatelessKieSessions behave as expected.
*/
@Test
public void testTwoStatelessKieSessionsOneDefault() {
final KieModuleModel kieModule = kieServices.newKieModuleModel();
kieModule.newKieBaseModel("firstKBase").setDefault(true).newKieSessionModel("firstKSession").setType(KieSessionModel.KieSessionType.STATELESS).setDefault(true);
kieModule.newKieBaseModel("secondKBase").setDefault(true).newKieSessionModel("secondKSession").setType(KieSessionModel.KieSessionType.STATELESS).setDefault(false);
buildKieModule(kieModule);
final KieContainer kieContainer = kieServices.newKieContainer(RELEASE_ID);
final StatelessKieSession firstKSession = kieContainer.newStatelessKieSession("firstKSession");
final StatelessKieSession secondKSession = kieContainer.newStatelessKieSession("secondKSession");
Assertions.assertThat(firstKSession).isEqualTo(((InternalKieContainer) kieContainer).getStatelessKieSession());
Assertions.assertThat(secondKSession).isNotEqualTo(((InternalKieContainer) kieContainer).getStatelessKieSession());
}
use of org.drools.core.impl.InternalKieContainer in project drools by kiegroup.
the class KieContainerTest method testMainKieModule.
@Test
public void testMainKieModule() {
KieServices ks = KieServices.Factory.get();
// Create an in-memory jar for version 1.0.0
ReleaseId releaseId = ks.newReleaseId("org.kie", "test-delete", "1.0.0");
createAndDeployJar(ks, releaseId, createDRL("ruleA"));
KieContainer kieContainer = ks.newKieContainer(releaseId);
KieModule kmodule = ((InternalKieContainer) kieContainer).getMainKieModule();
assertEquals(releaseId, kmodule.getReleaseId());
}
use of org.drools.core.impl.InternalKieContainer in project drools by kiegroup.
the class KieContainerTest method testReleaseIdGetters.
@Test
public void testReleaseIdGetters() {
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId("org.kie", "test-delete-v", "1.0.1");
createAndDeployJar(ks, releaseId, createDRL("ruleA"));
ReleaseId configuredReleaseId = ks.newReleaseId("org.kie", "test-delete-v", "RELEASE");
KieContainer kieContainer = ks.newKieContainer(configuredReleaseId);
InternalKieContainer iKieContainer = (InternalKieContainer) kieContainer;
assertEquals(configuredReleaseId, iKieContainer.getConfiguredReleaseId());
assertEquals(releaseId, iKieContainer.getResolvedReleaseId());
assertEquals(releaseId, iKieContainer.getReleaseId());
// demonstrate internal API behavior, in the future shall this be enforced?
assertEquals(configuredReleaseId, iKieContainer.getContainerReleaseId());
ReleaseId newReleaseId = ks.newReleaseId("org.kie", "test-delete-v", "1.0.2");
createAndDeployJar(ks, newReleaseId, createDRL("ruleA"));
iKieContainer.updateToVersion(newReleaseId);
assertEquals(configuredReleaseId, iKieContainer.getConfiguredReleaseId());
assertEquals(newReleaseId, iKieContainer.getResolvedReleaseId());
assertEquals(newReleaseId, iKieContainer.getReleaseId());
// demonstrate internal API behavior, in the future shall this be enforced?
assertEquals(newReleaseId, iKieContainer.getContainerReleaseId());
}
Aggregations