" $s : String( )\n" +
"then\n" +
" list.add( $s );\n" +
"end\n";
Resource resource1 = ResourceFactory.newByteArrayResource(str1.getBytes());
Collection<KnowledgePackage> kpackages1 = buildKnowledgePackage( resource1,
ResourceType.DRL );
kbase1.addKnowledgePackages( kpackages1 );
StatefulKnowledgeSession ksession1 = JPAKnowledgeService.newStatefulKnowledgeSession(kbase1, null,
createEnvironment(context));
int ksessionId = ksession1.getId();
ArrayList<String> list = new ArrayList<String>();
ksession1.setGlobal( "list", list );
ksession1.insert("hello");
ksession1.fireAllRules();
ksession1.dispose(); // dispose before firing
Assert.assertEquals(0, list.size());
Thread.sleep(5000);
// A new kbase without the timer's activated rule
KnowledgeBase kbase2 = KnowledgeBaseFactory.newKnowledgeBase(kconf);
String str2 = "package org.test; " +
"import java.util.*; " +
"global java.util.List list; " +
"rule R2\n" +
"when\n" +
" $s : Integer( )\n" +
"then\n" +
" list.add( $s );\n" +
"end\n";
Resource resource2 = ResourceFactory.newByteArrayResource(str2.getBytes());
Collection<KnowledgePackage> kpackages2 = buildKnowledgePackage( resource2,
ResourceType.DRL );
kbase2.addKnowledgePackages( kpackages2 );
StatefulKnowledgeSession ksession2 = JPAKnowledgeService.loadStatefulKnowledgeSession(ksessionId, kbase2, null,