KieServices ks = KieServices.Factory.get();
// Create an in-memory jar for version 1.0.0
ReleaseId releaseId1 = ks.newReleaseId("org.kie", "test-delete", "1.0.0");
KieModule km = createAndDeployJar( ks, releaseId1, type, drl1, drl2 );
KieContainer kieContainer = ks.newKieContainer(releaseId1);
KieContainer kieContainer2 = ks.newKieContainer(releaseId1);
KieSession ksession = kieContainer.newKieSession();
KieSession ksession2 = kieContainer2.newKieSession();
insertMessageFromTypeDeclaration( ksession );
assertEquals( 2, ksession.fireAllRules() );
ReleaseId releaseId2 = ks.newReleaseId("org.kie", "test-delete", "1.0.1");
km = createAndDeployJar( ks, releaseId2, type, null, drl2 );
kieContainer.updateToVersion(releaseId2);
// test with the old ksession ...
ksession = kieContainer.newKieSession();
insertMessageFromTypeDeclaration( ksession );
assertEquals( 1, ksession.fireAllRules() );
// ... and with a brand new one
ksession = kieContainer.newKieSession();
insertMessageFromTypeDeclaration (ksession );
assertEquals( 1, ksession.fireAllRules() );
// check that the second kieContainer hasn't been affected by the update of the first one
insertMessageFromTypeDeclaration( ksession2 );
assertEquals( 2, ksession2.fireAllRules() );
ksession2 = kieContainer2.newKieSession();
insertMessageFromTypeDeclaration( ksession2 );
assertEquals( 2, ksession2.fireAllRules() );
}