// Creates first class loader and use it to load fact classes
ClassLoader loader1 = new SubvertedClassLoader( new URL[]{getClass().getResource( "/testEnumReteoo.jar" )},
this.getClass().getClassLoader() );
// create a builder with the given classloader
KnowledgeBuilderConfiguration conf = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(null, loader1);
Collection<KnowledgePackage> kpkgs = loadKnowledgePackages(conf, "test_EnumSerialization.drl");
// serialize out
byte[] out = DroolsStreamUtils.streamOut( kpkgs );
// adding original packages to a kbase just to make sure they are fine
KieBaseConfiguration kbaseConf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration( null, loader1 );
KnowledgeBase kbase = getKnowledgeBase(kbaseConf);
kbase.addKnowledgePackages( kpkgs );
StatefulKnowledgeSession ksession = createKnowledgeSession( kbase );
List list = new ArrayList();
ksession.setGlobal( "list", list);
assertEquals( 1, ksession.fireAllRules() );
assertEquals( 1, list.size() );
// now, create another classloader and make sure it has access to the classes
ClassLoader loader2 = new SubvertedClassLoader( new URL[]{getClass().getResource( "/testEnumReteoo.jar" )},
this.getClass().getClassLoader() );
// create another builder
KnowledgeBuilderConfiguration conf2 = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration( null,
loader2 );
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
Collection<KnowledgePackage> kpkgs2 = null;
try {