use of org.drools.core.rule.EvalCondition in project drools by kiegroup.
the class PackageCompilationDataTest method testCodeSourceUrl.
@Test
public void testCodeSourceUrl() throws Exception {
final String className = TestEvalExpression.class.getName();
KnowledgeBaseImpl kBase = new KnowledgeBaseImpl("xxx", null);
InternalKnowledgePackage pkg = CoreComponentFactory.get().createKnowledgePackage("org.drools");
pkg.setClassLoader(Thread.currentThread().getContextClassLoader());
JavaDialectRuntimeData data = new JavaDialectRuntimeData();
data.onAdd(pkg.getDialectRuntimeRegistry(), kBase.getRootClassLoader());
pkg.getDialectRuntimeRegistry().setDialectData("java", data);
kBase.addPackage(pkg);
final JavaDialectRuntimeData pcData = (JavaDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData("java");
final EvalCondition invoker = new EvalCondition(null);
pcData.putInvoker(className, invoker);
final InputStream is = getClass().getClassLoader().getResourceAsStream(className.replace('.', '/') + ".class");
try {
pcData.write(className.replace('.', '/') + ".class", read(is));
} finally {
is.close();
}
pcData.onAdd(pkg.getDialectRuntimeRegistry(), kBase.getRootClassLoader());
pcData.onBeforeExecute();
Class cls = kBase.getRootClassLoader().loadClass("org.drools.mvel.rule.PackageCompilationDataTest$TestEvalExpression");
final CodeSource codeSource = invoker.getEvalExpression().getClass().getProtectionDomain().getCodeSource();
assertNotNull(codeSource.getLocation());
}
Aggregations