KnowledgeAgent ag = KnowledgeAgentFactory.newKnowledgeAgent("fii", KnowledgeAgentFactory.newKnowledgeAgentConfiguration());
ag.applyChangeSet( ResourceFactory.newUrlResource( fxml.toURI().toURL() ) );
KnowledgeBase kb = ag.getKnowledgeBase();
assertEquals(1, kb.getKnowledgePackages().size());
KnowledgePackage kp = kb.getKnowledgePackages().iterator().next();
assertTrue(kb.getKnowledgePackages().size() > 0);
assertEquals(1, kp.getRules().size());
//check the HEAD method
HttpClient client = new HttpClient();
HeadMethod hm = new HeadMethod("http://localhost:9000/package/testPDSGetPackage/LATEST.drl");
client.executeMethod(hm);
Header lastMod = hm.getResponseHeader("lastModified");
Thread.sleep(50);
long now = System.currentTimeMillis();
long before = Long.parseLong(lastMod.getValue());
assertTrue(before < now);
//now lets add a rule
asset = pkg.addAsset("someRule2", "");
asset.updateContent("when \n SampleFact() \n then \n System.err.println(43);");
asset.updateFormat(AssetFormats.DRL);
asset.checkin("");
assertNull(impl.buildPackage(pkg.getUUID(), true));
Thread.sleep(3000);
kb = ag.getKnowledgeBase();
assertEquals(1, kb.getKnowledgePackages().size());
kp = kb.getKnowledgePackages().iterator().next();
if (kp.getRules().size() != 2) {
Thread.sleep(2000);
kb = ag.getKnowledgeBase();
assertEquals(1, kb.getKnowledgePackages().size());
kp = kb.getKnowledgePackages().iterator().next();
}
if (kp.getRules().size() != 2) {
Thread.sleep(2000);
kb = ag.getKnowledgeBase();
assertEquals(1, kb.getKnowledgePackages().size());
kp = kb.getKnowledgePackages().iterator().next();
}
assertEquals(2, kp.getRules().size());
server.stop();
repo.logout();
}