workItemHandlerStub);
}
//Run Test Scenario
try {
AuditLogReporter logger = new AuditLogReporter(workingMemory);
CompositeClassLoader classLoader = ((InternalRuleBase) ruleBase).getRootClassLoader();
StringBuilder buf = new StringBuilder();
AssetItemIterator it = item.listAssetsByFormat(AssetFormats.DRL_MODEL);
while (it.hasNext()) {
AssetItem as = it.next();
buf.append(as.getContent());
buf.append('\n');
}
String droolsHeader = DroolsHeader.getDroolsHeader(item);
DrlParser parser = new DrlParser();
PackageDescr pkgItem =null;
try {
pkgItem = parser.parse( droolsHeader + "\n" + buf.toString() );
} catch ( final DroolsParserException e1 ) {
throw new IllegalStateException( "Serious error, unable to validate package." );
}
List<ImportDescr> imports= new ArrayList<ImportDescr>( pkgItem.getImports() );
new ScenarioRunner(
new ClassTypeResolver(
getAllImports(aPackage),
classLoader),
classLoader,
workingMemory,
imports
).run(scenario);
return new SingleScenarioResult(
new ScenarioRunResult(scenario),
logger.buildReport());
} catch (ClassNotFoundException e) {
log.error("Unable to load a required class.",
e);
throw new DetailedSerializationException("Unable to load a required class.",
e.getMessage());