List<String> list = new ArrayList<String>();
ksession.setGlobal("list", list);
ksession.insert("Some String");
ksession.insert("Some Other String");
QueryResults queryResults = ksession.getQueryResults("all the Strings");
ksession.dispose();
assertEquals(2, queryResults.size());
Iterator<QueryResultsRow> iterator = queryResults.iterator();
while (iterator.hasNext()){
System.out.println("Row= "+iterator.next().get("$strings"));
}
//we are going to modify the query definition
// have to sleep here as linux lastModified does not do milliseconds
// http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=1&t=019789
System.gc();
Thread.sleep(2000);
//we are going to add function1 now
String query1V2 = "";
query1V2 += "query \"all the Strings\"\n";
query1V2 += " $strings : String(this == \"Some String\")\n";
query1V2 += "end\n";
output = new BufferedWriter(new FileWriter(f1));
output.write(header);
output.write(query1V2);
output.write(rule1);
output.close();
System.gc();
Thread.sleep(3000);
ksession = kbase.newStatefulKnowledgeSession();
list = new ArrayList<String>();
ksession.setGlobal("list", list);
ksession.insert("Some String");
ksession.insert("Some Other String");
queryResults = ksession.getQueryResults("all the Strings");
ksession.dispose();
assertEquals(1, queryResults.size());
assertEquals("Some String",queryResults.iterator().next().get("$strings"));
kagent.monitorResourceChangeEvents(false);
}