1 package org.opendaylight.controller.test.sal.binding.it;
3 import static org.ops4j.pax.exam.CoreOptions.*;
5 import javax.inject.Inject;
7 import org.junit.runner.RunWith;
8 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
9 import org.ops4j.pax.exam.Configuration;
10 import org.ops4j.pax.exam.Option;
11 import org.ops4j.pax.exam.junit.PaxExam;
12 import org.ops4j.pax.exam.options.DefaultCompositeOption;
13 import org.osgi.framework.BundleContext;
15 @RunWith(PaxExam.class)
16 public abstract class AbstractTest {
18 public static final String CONTROLLER = "org.opendaylight.controller";
19 public static final String YANGTOOLS = "org.opendaylight.yangtools";
21 public static final String CONTROLLER_MODELS = "org.opendaylight.controller.model";
22 public static final String YANGTOOLS_MODELS = "org.opendaylight.yangtools.model";
26 BindingAwareBroker broker;
29 BundleContext bundleContext;
33 public BindingAwareBroker getBroker() {
39 public void setBroker(BindingAwareBroker broker) {
45 public BundleContext getBundleContext() {
51 public void setBundleContext(BundleContext bundleContext) {
52 this.bundleContext = bundleContext;
58 public Option[] config() {
59 return options(systemProperty("osgi.console").value("2401"),
60 mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(), //
61 mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(), //
62 mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(), //
63 mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(), //
65 // MD-SAL Dependencies
66 mavenBundle(YANGTOOLS, "concepts").versionAsInProject(),
67 mavenBundle(YANGTOOLS, "yang-binding").versionAsInProject(), //
68 mavenBundle(YANGTOOLS, "yang-common").versionAsInProject(), //
70 mavenBundle(YANGTOOLS+".thirdparty", "xtend-lib-osgi").versionAsInProject(),
71 mavenBundle("com.google.guava", "guava").versionAsInProject(), //
72 mavenBundle("org.javassist", "javassist").versionAsInProject(),
75 mavenBundle(CONTROLLER, "sal-binding-api").versionAsInProject(), //
76 mavenBundle(CONTROLLER, "sal-binding-broker-impl").versionAsInProject(), //
77 mavenBundle(CONTROLLER, "sal-common").versionAsInProject(), //
78 mavenBundle(CONTROLLER, "sal-common-api").versionAsInProject(),
79 mavenBundle(CONTROLLER, "sal-common-util").versionAsInProject(), //
82 mavenBundle(YANGTOOLS_MODELS,"yang-ext").versionAsInProject(),
83 mavenBundle(YANGTOOLS_MODELS,"ietf-inet-types").versionAsInProject(),
84 mavenBundle(YANGTOOLS_MODELS,"ietf-yang-types").versionAsInProject(),
85 mavenBundle(YANGTOOLS_MODELS,"opendaylight-l2-types").versionAsInProject(),
86 mavenBundle(CONTROLLER_MODELS,"model-flow-base").versionAsInProject(),
87 mavenBundle(CONTROLLER_MODELS,"model-flow-service").versionAsInProject(),
88 mavenBundle(CONTROLLER_MODELS,"model-inventory").versionAsInProject(),
89 junitAndMockitoBundles()
94 public static Option junitAndMockitoBundles() {
95 return new DefaultCompositeOption(
96 // Repository required to load harmcrest (OSGi-fied version).
97 repository("http://repository.springsource.com/maven/bundles/external").id(
98 "com.springsource.repository.bundles.external"),
100 // Mockito without Hamcrest and Objenesis
101 mavenBundle("org.mockito", "mockito-all", "1.9.5"),
103 // Hamcrest with a version matching the range expected by Mockito
104 //mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
106 // Objenesis with a version matching the range expected by Mockito
107 //wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
108 // .exports("*;version=1.2"),
110 // The default JUnit bundle also exports Hamcrest, but with an (incorrect) version of
111 // 4.9 which does not match the Mockito import. When deployed after the hamcrest bundles, it gets
112 // resolved correctly.
116 * Felix has implicit boot delegation enabled by default. It conflicts with Mockito:
117 * java.lang.LinkageError: loader constraint violation in interface itable initialization:
118 * when resolving method "org.osgi.service.useradmin.User$$EnhancerByMockitoWithCGLIB$$dd2f81dc
119 * .newInstance(Lorg/mockito/cglib/proxy/Callback;)Ljava/lang/Object;" the class loader
120 * (instance of org/mockito/internal/creation/jmock/SearchingClassLoader) of the current class,
121 * org/osgi/service/useradmin/User$$EnhancerByMockitoWithCGLIB$$dd2f81dc, and the class loader
122 * (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) for interface
123 * org/mockito/cglib/proxy/Factory have different Class objects for the type org/mockito/cglib/
124 * proxy/Callback used in the signature
126 * So we disable the bootdelegation. this property has no effect on the other OSGi implementation.
128 frameworkProperty("felix.bootdelegation.implicit").value("false")