Fix sonar integration test reporting
[ovsdb.git] / library / it / src / test / java / org / opendaylight / ovsdb / lib / it / LibraryIntegrationTestBase.java
1 /*
2  * Copyright © 2015 Red Hat, 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.ovsdb.lib.it;
10
11 import static org.ops4j.pax.exam.CoreOptions.composite;
12 import static org.ops4j.pax.exam.CoreOptions.maven;
13 import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperties;
14 import static org.ops4j.pax.exam.CoreOptions.vmOption;
15 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
16 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
17
18 import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
19 import org.ops4j.pax.exam.Configuration;
20 import org.ops4j.pax.exam.Option;
21 import org.ops4j.pax.exam.karaf.options.LogLevelOption;
22 import org.ops4j.pax.exam.options.MavenUrlReference;
23
24 /**
25  * Base class for library IT.
26  */
27 public abstract class LibraryIntegrationTestBase extends AbstractMdsalTestBase {
28     @Override
29     public String getModuleName() {
30         return "library";
31     }
32
33     @Override
34     public String getInstanceName() {
35         return "library-default";
36     }
37
38     @Override
39     public MavenUrlReference getFeatureRepo() {
40         return maven()
41                 .groupId("org.opendaylight.ovsdb")
42                 .artifactId("library-features")
43                 .classifier("features")
44                 .type("xml")
45                 .versionAsInProject();
46     }
47
48     @Override
49     public String getFeatureName() {
50         return "odl-ovsdb-library";
51     }
52
53     @Configuration
54     @Override
55     public Option[] config() {
56         Option[] parentOptions = super.config();
57         Option[] propertiesOptions = getPropertiesOptions();
58         Option[] otherOptions = getOtherOptions();
59         Option[] options = new Option[parentOptions.length + propertiesOptions.length + otherOptions.length];
60         System.arraycopy(parentOptions, 0, options, 0, parentOptions.length);
61         System.arraycopy(propertiesOptions, 0, options, parentOptions.length, propertiesOptions.length);
62         System.arraycopy(otherOptions, 0, options, parentOptions.length + propertiesOptions.length,
63                 otherOptions.length);
64         return options;
65     }
66
67     private Option[] getOtherOptions() {
68         return new Option[] {
69                 vmOption("-javaagent:../jars/org.jacoco.agent.jar=destfile=../../jacoco-it.exec"),
70                 keepRuntimeFolder()
71         };
72     }
73
74     public Option[] getPropertiesOptions() {
75         return new Option[] {
76                 propagateSystemProperties(
77                         LibraryIntegrationTestUtils.SERVER_IPADDRESS,
78                         LibraryIntegrationTestUtils.SERVER_PORT,
79                         LibraryIntegrationTestUtils.CONNECTION_TYPE),
80         };
81     }
82
83     @Override
84     public Option getLoggingOption() {
85         Option option = editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
86                 logConfiguration(getClass()),
87                 LogLevelOption.LogLevel.INFO.name());
88         option = composite(option, super.getLoggingOption());
89         return option;
90     }
91 }