BUG-837: it unstable (added missing bundles)
[openflowplugin.git] / openflowplugin-it / src / test / java / org / opendaylight / openflowplugin / openflow / md / it / OFPaxOptionsAssistant.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowplugin.openflow.md.it;
10
11
12 import org.opendaylight.controller.test.sal.binding.it.TestHelper;
13 import org.ops4j.pax.exam.CoreOptions;
14 import org.ops4j.pax.exam.Option;
15 import org.ops4j.pax.exam.options.DefaultCompositeOption;
16
17 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
18
19 /**
20  * The main wiring is assembled in {@link #ofPluginBundles()}
21  * @author mirehak
22  */
23 public abstract class OFPaxOptionsAssistant {
24
25     /** system property required to enable osgi console and remote debugging, only presence matters */
26     private static final String INSPECT_OSGI = "inspectOsgi";
27     /** default remote debug port */
28     public static final String DEBUG_PORT = "6000";
29     /** base controller package */
30     public static final String CONTROLLER = "org.opendaylight.controller";
31     /** base controller.md package */
32     public static final String CONTROLLER_MD = "org.opendaylight.controller.md";
33     /** OFLibrary package */
34     public static final String OFLIBRARY = "org.opendaylight.openflowjava";
35     /** OFPlugin package */
36     public static final String OFPLUGIN = "org.opendaylight.openflowplugin";
37     /** OFPlugin applications package */
38     public static final String OFPLUGIN_APPS = "org.opendaylight.openflowplugin.applications";
39     /** OFPlugin model package */
40     public static final String OFPLUGIN_MODEL = "org.opendaylight.openflowplugin.model";
41     /** controller.model package */
42     public static final String CONTROLLER_MODEL = "org.opendaylight.controller.model";
43
44     public static final String YANGTOOLS = "org.opendaylight.yangtools";
45
46
47     /**
48      * Works only if property -DinspectOsgi is used
49      * @return equinox console setup (in order to inspect running IT through osgi console (telnet))
50      * and remote debugging on port {@link #DEBUG_PORT}
51      */
52     public static Option osgiConsoleBundles() {
53         DefaultCompositeOption option = new DefaultCompositeOption();
54         if (System.getProperty(INSPECT_OSGI) != null) {
55             option
56             .add(CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address="+DEBUG_PORT))
57             .add(CoreOptions.mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject())
58             .add(CoreOptions.mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell").versionAsInProject())
59             .add(CoreOptions.mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime").versionAsInProject())
60             .add(CoreOptions.mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command").versionAsInProject());
61         }
62
63         return option;
64     }
65
66     /**
67      * @return OFLibrary bundles
68      */
69     public static Option ofLibraryBundles() {
70         return new DefaultCompositeOption(
71                 mavenBundle(OFLIBRARY, "util").versionAsInProject(),
72                 mavenBundle(OFLIBRARY, "openflow-protocol-impl").versionAsInProject(),
73                 mavenBundle(OFLIBRARY, "openflow-protocol-api").versionAsInProject(),
74                 mavenBundle(OFLIBRARY, "openflow-protocol-spi").versionAsInProject(),
75                 mavenBundle(OFLIBRARY, "simple-client").versionAsInProject().start());
76     }
77
78     /**
79      * Here we construct whole wiring
80      * @return OFLibrary + OFPlugin bundles
81      */
82     public static Option ofPluginBundles() {
83         return new DefaultCompositeOption(
84                 mdSalApiBundles(),
85                 mdSalImplBundles(),
86                 mdSalBaseModelBundles(),
87                 ofLibraryBundles(),
88                 mavenBundle(OFPLUGIN_MODEL, "model-flow-statistics").versionAsInProject(),
89                 mavenBundle(OFPLUGIN_MODEL, "model-flow-base").versionAsInProject(),
90                 mavenBundle(OFPLUGIN_MODEL, "model-flow-service").versionAsInProject(),
91                 mavenBundle(OFPLUGIN, "openflowplugin-api").versionAsInProject(),
92                 mavenBundle(OFPLUGIN, "openflowplugin-extension-api").versionAsInProject(),
93                 mavenBundle(OFPLUGIN, "openflowplugin").versionAsInProject(),
94                 mavenBundle(OFPLUGIN_APPS, "forwardingrules-manager").versionAsInProject(),
95                 mavenBundle(OFPLUGIN_APPS, "inventory-manager").versionAsInProject(),
96                 mavenBundle("org.openexi", "nagasena").versionAsInProject()
97                 );
98     }
99
100     /**
101      * @return logging bundles
102      */
103     public static Option loggingBudles() {
104         return new DefaultCompositeOption(
105                 mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
106                 mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(),
107                 mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(),
108                 mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject());
109     }
110
111     /**
112      * @return sal + dependencymanager
113      */
114     public static Option mdSalApiBundles() {
115         return new DefaultCompositeOption(
116                 TestHelper.junitAndMockitoBundles(),
117                 TestHelper.mdSalCoreBundles(),
118                 TestHelper.configMinumumBundles(),
119                 mavenBundle(YANGTOOLS + ".thirdparty", "antlr4-runtime-osgi-nohead").versionAsInProject());
120
121     }
122
123     private static Option mdSalImplBundles() {
124         return new DefaultCompositeOption(
125                 TestHelper.bindingAwareSalBundles()
126         );
127     }
128
129     private static Option mdSalBaseModelBundles() {
130         return new DefaultCompositeOption(
131                 TestHelper.baseModelBundles(),
132                 mavenBundle(CONTROLLER_MODEL, "model-inventory").versionAsInProject()
133         );
134     }
135
136 }