"end";
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
KnowledgeAgent kagent = createKAgent( kbase, false );
ByteArrayResource bres = (ByteArrayResource) ResourceFactory.newByteArrayResource( drl.getBytes() );
bres.setResourceType(ResourceType.DRL);
ChangeSetImpl cs = new ChangeSetImpl();
cs.setResourcesAdded( Arrays.<Resource>asList(bres) );
kagent.applyChangeSet( cs );
KnowledgePackage pack = kagent.getKnowledgeBase().getKnowledgePackage("org.test.myPack");
assertNotNull(pack);
assertEquals(1,pack.getRules().size());
KnowledgePackage pack2 = kagent.getKnowledgeBase().getKnowledgePackage("org.anotherPack");
assertNotNull(pack2);
assertEquals(0,pack2.getRules().size());
String drl2 = "package org.test.myPack;\n" +
"function void foo() { \n" +
"} \n" +
"\n" +
"\n" +
"declare org.anotherPack.MyType2\n" +
" field : String\n" +
"end\n" +
"" +
"rule \"rool\" \n" +
"when\n" +
"then\n" +
"end\n";
ByteArrayResource bres2 = (ByteArrayResource) ResourceFactory.newByteArrayResource( drl2.getBytes() );
bres2.setResourceType(ResourceType.DRL);
ChangeSetImpl cs2 = new ChangeSetImpl();
cs2.setResourcesAdded( Arrays.<Resource>asList(bres2) );
kagent.applyChangeSet( cs2 );
pack = kagent.getKnowledgeBase().getKnowledgePackage("org.test.myPack");