Added TestHelper with new PaxExam options, which could be reused by other ITs. 43/2043/1
authorTony Tkacik <ttkacik@cisco.com>
Mon, 21 Oct 2013 11:24:33 +0000 (13:24 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Mon, 21 Oct 2013 11:25:48 +0000 (13:25 +0200)
Change-Id: I8ee9e5e9f56c77fe6fa177ecb2675752e437ef48
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
opendaylight/md-sal/sal-binding-it/pom.xml
opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java [new file with mode: 0644]
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/AbstractTest.java

index 86b6626..e5d9ba9 100644 (file)
       <version>${exam.version}</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam</artifactId>
+      <version>${exam.version}</version>
+      <!--  Compile scope here is intentional, it is used
+            in TestHelper class which could be downloaded
+            via nexus and reused in other integration tests.
+      -->
+      <scope>compile</scope>
+    </dependency>
     <dependency>
       <groupId>org.ops4j.pax.exam</groupId>
       <artifactId>pax-exam-link-mvn</artifactId>
diff --git a/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java b/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java
new file mode 100644 (file)
index 0000000..842b80e
--- /dev/null
@@ -0,0 +1,99 @@
+package org.opendaylight.controller.test.sal.binding.it;
+
+import static org.ops4j.pax.exam.CoreOptions.frameworkProperty;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.repository;
+
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.options.DefaultCompositeOption;
+
+public class TestHelper {
+
+    public static final String CONTROLLER = "org.opendaylight.controller";
+    public static final String YANGTOOLS = "org.opendaylight.yangtools";
+
+    public static final String CONTROLLER_MODELS = "org.opendaylight.controller.model";
+    public static final String YANGTOOLS_MODELS = "org.opendaylight.yangtools.model";
+
+    public static Option mdSalCoreBundles() {
+        return new DefaultCompositeOption( //
+                mavenBundle(YANGTOOLS, "concepts").versionAsInProject(), //
+                mavenBundle(YANGTOOLS, "yang-binding").versionAsInProject(), //
+                mavenBundle(YANGTOOLS, "yang-common").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "sal-common").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "sal-common-api").versionAsInProject(), //
+                mavenBundle("com.google.guava", "guava").versionAsInProject(), //
+                mavenBundle(YANGTOOLS + ".thirdparty", "xtend-lib-osgi").versionAsInProject() //
+        );
+    }
+
+    public static Option bindingAwareSalBundles() {
+        return new DefaultCompositeOption( //
+                mavenBundle(CONTROLLER, "sal-binding-api").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "sal-binding-broker-impl").versionAsInProject(), //
+                mavenBundle("org.javassist", "javassist").versionAsInProject(), //
+                mavenBundle(CONTROLLER, "sal-common-util").versionAsInProject() //
+        );
+
+    }
+
+    public static Option bindingIndependentSalBundles() {
+        return new DefaultCompositeOption(
+
+        );
+
+    }
+
+    public static Option flowCapableModelBundles() {
+        return new DefaultCompositeOption( //
+                mavenBundle(CONTROLLER_MODELS, "model-flow-base").versionAsInProject(), //
+                mavenBundle(CONTROLLER_MODELS, "model-flow-service").versionAsInProject(), //
+                mavenBundle(CONTROLLER_MODELS, "model-inventory").versionAsInProject() //
+        );
+
+    }
+
+    public static Option baseModelBundles() {
+        return new DefaultCompositeOption( //
+                mavenBundle(YANGTOOLS_MODELS, "yang-ext").versionAsInProject(), //
+                mavenBundle(YANGTOOLS_MODELS, "ietf-inet-types").versionAsInProject(), //
+                mavenBundle(YANGTOOLS_MODELS, "ietf-yang-types").versionAsInProject(), //
+                mavenBundle(YANGTOOLS_MODELS, "opendaylight-l2-types").versionAsInProject(), //
+                mavenBundle(CONTROLLER_MODELS, "model-inventory").versionAsInProject());
+    }
+
+    public static Option junitAndMockitoBundles() {
+        return new DefaultCompositeOption(
+        // Repository required to load harmcrest (OSGi-fied version).
+                repository("http://repository.springsource.com/maven/bundles/external").id(
+                        "com.springsource.repository.bundles.external"),
+
+                // Mockito
+                mavenBundle("org.mockito", "mockito-all", "1.9.5"),
+                junitBundles(),
+
+                /*
+                 * Felix has implicit boot delegation enabled by default. It
+                 * conflicts with Mockito: java.lang.LinkageError: loader
+                 * constraint violation in interface itable initialization: when
+                 * resolving method
+                 * "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
+                 * .
+                 * newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object
+                 * ;" the class loader (instance of
+                 * org/mockito/internal/creation/jmock/SearchingClassLoader) of
+                 * the current class, org/osgi/service/useradmin/
+                 * User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class
+                 * loader (instance of org/apache/felix/framework/
+                 * BundleWiringImpl$BundleClassLoaderJava5) for interface
+                 * org/mockito/cglib/proxy/Factory have different Class objects
+                 * for the type org/mockito/cglib/ proxy/Callback used in the
+                 * signature
+                 * 
+                 * So we disable the bootdelegation. this property has no effect
+                 * on the other OSGi implementation.
+                 */
+                frameworkProperty("felix.bootdelegation.implicit").value("false"));
+    }
+}
index cddf7e8..6e772b5 100644 (file)
@@ -1,6 +1,7 @@
 package org.opendaylight.controller.test.sal.binding.it;
 
 import static org.ops4j.pax.exam.CoreOptions.*;
+import static org.opendaylight.controller.test.sal.binding.it.TestHelper.*;
 
 import javax.inject.Inject;
 
@@ -17,115 +18,45 @@ public abstract class AbstractTest {
 
     public static final String CONTROLLER = "org.opendaylight.controller";
     public static final String YANGTOOLS = "org.opendaylight.yangtools";
-    
+
     public static final String CONTROLLER_MODELS = "org.opendaylight.controller.model";
     public static final String YANGTOOLS_MODELS = "org.opendaylight.yangtools.model";
-    
-    
+
     @Inject
     BindingAwareBroker broker;
 
     @Inject
     BundleContext bundleContext;
 
-    
-    
     public BindingAwareBroker getBroker() {
         return broker;
     }
 
-
-
     public void setBroker(BindingAwareBroker broker) {
         this.broker = broker;
     }
 
-
-
     public BundleContext getBundleContext() {
         return bundleContext;
     }
 
-
-
     public void setBundleContext(BundleContext bundleContext) {
         this.bundleContext = bundleContext;
     }
 
-
-
     @Configuration
     public Option[] config() {
-        return options(systemProperty("osgi.console").value("2401"), 
-                mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(), //
+        return options(systemProperty("osgi.console").value("2401"), mavenBundle("org.slf4j", "slf4j-api")
+                .versionAsInProject(), //
                 mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(), //
                 mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(), //
                 mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(), //
-                
-                // MD-SAL Dependencies
-                mavenBundle(YANGTOOLS, "concepts").versionAsInProject(),
-                mavenBundle(YANGTOOLS, "yang-binding").versionAsInProject(), //
-                mavenBundle(YANGTOOLS, "yang-common").versionAsInProject(), //
-                
-                mavenBundle(YANGTOOLS+".thirdparty", "xtend-lib-osgi").versionAsInProject(),
-                mavenBundle("com.google.guava", "guava").versionAsInProject(), //
-                mavenBundle("org.javassist", "javassist").versionAsInProject(),
-                
-                // MD SAL
-                mavenBundle(CONTROLLER, "sal-binding-api").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-binding-broker-impl").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-common").versionAsInProject(), //
-                mavenBundle(CONTROLLER, "sal-common-api").versionAsInProject(),
-                mavenBundle(CONTROLLER, "sal-common-util").versionAsInProject(), //
-                
+
+                mdSalCoreBundles(),
+
+                bindingAwareSalBundles(),
+
                 // BASE Models
-                mavenBundle(YANGTOOLS_MODELS,"yang-ext").versionAsInProject(),
-                mavenBundle(YANGTOOLS_MODELS,"ietf-inet-types").versionAsInProject(),
-                mavenBundle(YANGTOOLS_MODELS,"ietf-yang-types").versionAsInProject(),
-                mavenBundle(YANGTOOLS_MODELS,"opendaylight-l2-types").versionAsInProject(),
-                mavenBundle(CONTROLLER_MODELS,"model-flow-base").versionAsInProject(),
-                mavenBundle(CONTROLLER_MODELS,"model-flow-service").versionAsInProject(),
-                mavenBundle(CONTROLLER_MODELS,"model-inventory").versionAsInProject(),
-                junitAndMockitoBundles()
-                );
-    }
-    
-    
-    public static Option junitAndMockitoBundles() {
-        return new DefaultCompositeOption(
-                // Repository required to load harmcrest (OSGi-fied version).
-                repository("http://repository.springsource.com/maven/bundles/external").id(
-                        "com.springsource.repository.bundles.external"),
-
-                // Mockito without Hamcrest and Objenesis
-                mavenBundle("org.mockito", "mockito-all", "1.9.5"),
-
-                // Hamcrest with a version matching the range expected by Mockito
-                //mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
-
-                // Objenesis with a version matching the range expected by Mockito
-                //wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
-                 //       .exports("*;version=1.2"),
-
-                // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
-                // 4.9 which does not match the Mockito import. When deployed after the hamcrest bundles, it gets
-                // resolved correctly.
-                junitBundles(),
-
-                /*
-                 * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
-                 * java.lang.LinkageError: loader constraint violation in interface itable initialization:
-                 * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
-                 * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
-                 * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
-                 * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
-                 * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
-                 * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
-                 * proxy/Callback used in the signature
-                 *
-                 * So we disable the bootdelegation. this property has no effect on the other OSGi implementation.
-                 */
-                frameworkProperty("felix.bootdelegation.implicit").value("false")
-        );
+                baseModelBundles(), flowCapableModelBundles(), junitAndMockitoBundles());
     }
 }