Updated implementation of internal RPC Router for Binding-Aware Broker and added...
[controller.git] / opendaylight / md-sal / sal-binding-it / src / test / java / org / opendaylight / controller / test / sal / binding / it / AbstractTest.java
1 package org.opendaylight.controller.test.sal.binding.it;
2
3 import static org.ops4j.pax.exam.CoreOptions.*;
4
5 import javax.inject.Inject;
6
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;
14
15 @RunWith(PaxExam.class)
16 public abstract class AbstractTest {
17
18     public static final String CONTROLLER = "org.opendaylight.controller";
19     public static final String YANGTOOLS = "org.opendaylight.yangtools";
20     
21     public static final String CONTROLLER_MODELS = "org.opendaylight.controller.model";
22     public static final String YANGTOOLS_MODELS = "org.opendaylight.yangtools.model";
23     
24     
25     @Inject
26     BindingAwareBroker broker;
27
28     @Inject
29     BundleContext bundleContext;
30
31     
32     
33     public BindingAwareBroker getBroker() {
34         return broker;
35     }
36
37
38
39     public void setBroker(BindingAwareBroker broker) {
40         this.broker = broker;
41     }
42
43
44
45     public BundleContext getBundleContext() {
46         return bundleContext;
47     }
48
49
50
51     public void setBundleContext(BundleContext bundleContext) {
52         this.bundleContext = bundleContext;
53     }
54
55
56
57     @Configuration
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(), //
64                 
65                 // MD-SAL Dependencies
66                 mavenBundle(YANGTOOLS, "concepts").versionAsInProject(),
67                 mavenBundle(YANGTOOLS, "yang-binding").versionAsInProject(), //
68                 mavenBundle(YANGTOOLS, "yang-common").versionAsInProject(), //
69                 
70                 mavenBundle(YANGTOOLS+".thirdparty", "xtend-lib-osgi").versionAsInProject(),
71                 mavenBundle("com.google.guava", "guava").versionAsInProject(), //
72                 mavenBundle("org.javassist", "javassist").versionAsInProject(),
73                 
74                 // MD SAL
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(), //
80                 
81                 // BASE Models
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()
90                 );
91     }
92     
93     
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"),
99
100                 // Mockito without Hamcrest and Objenesis
101                 mavenBundle("org.mockito", "mockito-all", "1.9.5"),
102
103                 // Hamcrest with a version matching the range expected by Mockito
104                 //mavenBundle("org.hamcrest", "com.springsource.org.hamcrest.core", "1.1.0"),
105
106                 // Objenesis with a version matching the range expected by Mockito
107                 //wrappedBundle(mavenBundle("org.objenesis", "objenesis", "1.2"))
108                  //       .exports("*;version=1.2"),
109
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.
113                 junitBundles(),
114
115                 /*
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
125                  *
126                  * So we disable the bootdelegation. this property has no effect on the other OSGi implementation.
127                  */
128                 frameworkProperty("felix.bootdelegation.implicit").value("false")
129         );
130     }
131 }