public StatefulKnowledgeSession genSession(String[] sources, int numerrors) {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
for (String source : sources)
kbuilder.add( ResourceFactory.newClassPathResource(source, getClass()), ResourceType.DRL );
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if ( kbuilder.getErrors().size() > 0 ) {
for ( KnowledgeBuilderError error : kbuilder.getErrors() ) {
System.err.println( error );
}
}
assertEquals(numerrors, errors.size() );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );