Fixed potential class pool override in integration tests. 46/5946/1
authorTony Tkacik <ttkacik@cisco.com>
Mon, 7 Apr 2014 15:34:04 +0000 (17:34 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Mon, 7 Apr 2014 15:36:51 +0000 (17:36 +0200)
Classloader in JUnit test is shared resource and in order
to integrate well with Javassist we are required to share
also classpool in order to compile generated code
using previously existing generated code in same Classloader.

If we introduce new ClassPool for same classloader,
compilation may fail, because new ClassPool is unable
to fetch bytecode for already generated classes.

Change-Id: Idd933670fe0a1c06d40aeed182f46997a843ab91
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/util/BindingBrokerTestFactory.java
opendaylight/md-sal/sal-binding-dom-it/src/test/java/org/opendaylight/controller/sal/binding/test/bugfix/DOMCodecBug02Test.java

index e5b57e3..08c5d06 100644 (file)
@@ -17,7 +17,7 @@ import com.google.common.util.concurrent.MoreExecutors;
 
 public class BindingBrokerTestFactory {
 
 
 public class BindingBrokerTestFactory {
 
-    private static final ClassPool CLASS_POOL = new ClassPool();
+    private static final ClassPool CLASS_POOL = ClassPool.getDefault();
     private boolean startWithParsedSchema = true;
     private ExecutorService executor;
     private ClassPool classPool;
     private boolean startWithParsedSchema = true;
     private ExecutorService executor;
     private ClassPool classPool;
@@ -27,7 +27,7 @@ public class BindingBrokerTestFactory {
         return startWithParsedSchema;
     }
 
         return startWithParsedSchema;
     }
 
-    public void setStartWithParsedSchema(boolean startWithParsedSchema) {
+    public void setStartWithParsedSchema(final boolean startWithParsedSchema) {
         this.startWithParsedSchema = startWithParsedSchema;
     }
 
         this.startWithParsedSchema = startWithParsedSchema;
     }
 
@@ -35,7 +35,7 @@ public class BindingBrokerTestFactory {
         return executor;
     }
 
         return executor;
     }
 
-    public void setExecutor(ExecutorService executor) {
+    public void setExecutor(final ExecutorService executor) {
         this.executor = executor;
     }
 
         this.executor = executor;
     }
 
@@ -54,7 +54,7 @@ public class BindingBrokerTestFactory {
         return classPool;
     }
 
         return classPool;
     }
 
-    public void setClassPool(ClassPool classPool) {
+    public void setClassPool(final ClassPool classPool) {
         this.classPool = classPool;
     }
 
         this.classPool = classPool;
     }
 
index 6784c0c..bc6f567 100644 (file)
@@ -17,8 +17,6 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
-import javassist.ClassPool;
-
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
@@ -77,7 +75,6 @@ public class DOMCodecBug02Test extends AbstractDataServiceTest {
         ListeningExecutorService executor = MoreExecutors.sameThreadExecutor();
         BindingBrokerTestFactory factory = new BindingBrokerTestFactory();
         factory.setExecutor(executor);
         ListeningExecutorService executor = MoreExecutors.sameThreadExecutor();
         BindingBrokerTestFactory factory = new BindingBrokerTestFactory();
         factory.setExecutor(executor);
-        factory.setClassPool(new ClassPool());
         factory.setStartWithParsedSchema(getStartWithSchema());
         testContext = factory.getTestContext();
         testContext.start();
         factory.setStartWithParsedSchema(getStartWithSchema());
         testContext = factory.getTestContext();
         testContext.start();