BUG-2661:Sonar issue
[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.ops4j.pax.exam.CoreOptions;
13 import org.ops4j.pax.exam.Option;
14 import org.ops4j.pax.exam.options.DefaultCompositeOption;
15
16 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
17
18 /**
19  * @author mirehak
20  *
21  */
22 public abstract class OFPaxOptionsAssistant {
23
24     /** system property required to enable osgi console and remote debugging, only presence matters */
25     private static final String INSPECT_OSGI = "inspectOsgi";
26     /** default remote debug port */
27     public static final String DEBUG_PORT = "6000";
28     /** base controller package */
29     public static final String CONTROLLER = "org.opendaylight.controller";
30     /** base controller.md package */
31     public static final String CONTROLLER_MD = "org.opendaylight.controller.md";
32     /** OFLibrary package */
33     public static final String OFLIBRARY = "org.opendaylight.openflowjava";
34     /** OFLibrary package */
35     public static final String OFPLUGIN = "org.opendaylight.openflowplugin";
36     /** controller.model package */
37     public static final String CONTROLLER_MODEL = "org.opendaylight.controller.model";
38
39     public static final String YANGTOOLS = "org.opendaylight.yangtools";
40
41
42     /**
43      * Works only if property -DinspectOsgi is used
44      * @return equinox console setup (in order to inspect running IT through osgi console (telnet))
45      * and remote debugging on port {@link #DEBUG_PORT}
46      */
47     public static Option osgiConsoleBundles() {
48         DefaultCompositeOption option = new DefaultCompositeOption();
49         if (System.getProperty(INSPECT_OSGI) != null) {
50             option
51             .add(CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address="+DEBUG_PORT))
52             .add(CoreOptions.mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject())
53             .add(CoreOptions.mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell").versionAsInProject())
54             .add(CoreOptions.mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime").versionAsInProject())
55             .add(CoreOptions.mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command").versionAsInProject());
56         }
57
58         return option;
59     }
60
61     /**
62      * @return OFLibrary bundles
63      */
64     public static Option ofLibraryBundles() {
65         return new DefaultCompositeOption(
66                 mavenBundle(OFLIBRARY, "util").versionAsInProject(),
67                 mavenBundle(OFLIBRARY, "openflow-protocol-impl").versionAsInProject(),
68                 mavenBundle(OFLIBRARY, "openflow-protocol-api").versionAsInProject(),
69                 mavenBundle(OFLIBRARY, "openflow-protocol-spi").versionAsInProject(),
70                 mavenBundle(OFLIBRARY, "simple-client").versionAsInProject().start());
71     }
72
73     /**
74      * @return OFLibrary + OFPlugin bundles
75      */
76     public static Option ofPluginBundles() {
77         return new DefaultCompositeOption(
78                 baseSalBundles(),
79                 ofLibraryBundles(),
80                 mavenBundle(CONTROLLER_MODEL, "model-flow-statistics").versionAsInProject(),
81                 mavenBundle(OFPLUGIN, "openflowplugin-api").versionAsInProject(),
82                 mavenBundle(OFPLUGIN, "openflowplugin-extension-api").versionAsInProject(),
83                 mavenBundle(OFPLUGIN, "openflowplugin").versionAsInProject(),
84                 mavenBundle(CONTROLLER_MD, "forwardingrules-manager").versionAsInProject(),
85                 mavenBundle(CONTROLLER_MD, "inventory-manager").versionAsInProject(),
86                 mavenBundle("org.openexi", "nagasena").versionAsInProject()
87                 );
88     }
89
90     /**
91      * @return logging bundles
92      */
93     public static Option loggingBudles() {
94         return new DefaultCompositeOption(
95                 mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
96                 mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(),
97                 mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(),
98                 mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject());
99     }
100
101     /**
102      * @return sal + dependencymanager
103      */
104     public static Option baseSalBundles() {
105         return new DefaultCompositeOption(
106 //                mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager").versionAsInProject(),
107 //                mavenBundle(CONTROLLER, "sal").versionAsInProject(),
108                 mavenBundle(YANGTOOLS + ".thirdparty", "antlr4-runtime-osgi-nohead").versionAsInProject());
109
110     }
111
112 }