Add constant class for shared strings in SouthboundIT 65/18365/5
authorSam Hague <shague@redhat.com>
Wed, 15 Apr 2015 17:59:22 +0000 (13:59 -0400)
committerSam Hague <shague@redhat.com>
Wed, 15 Apr 2015 19:54:44 +0000 (15:54 -0400)
patchset 3: fix checkstyle error

Change-Id: If0c4441848ccf7e002f1bf43a6186465431c7d8a
Signed-off-by: Sam Hague <shague@redhat.com>
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/AbstractConfigTestBase.java
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/AbstractMdsalTestBase.java
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundIT.java
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundITConstants.java [new file with mode: 0644]

index 5a7b5e3a033866a5f84eb9ca7c228e4ce5566da8..1cc72e64b11a1732a2d645871526c7e9de1f9baf 100644 (file)
@@ -36,17 +36,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class AbstractConfigTestBase {
-
     private static final Logger LOG = LoggerFactory.getLogger(AbstractConfigTestBase.class);
-    public static final String ORG_OPS4J_PAX_LOGGING_CFG = "etc/org.ops4j.pax.logging.cfg";
-    public static final String CUSTOM_PROPERTIES = "etc/custom.properties";
-    private static final String SERVER_IPADDRESS = "ovsdbserver.ipaddress";
-    private static final String SERVER_PORT = "ovsdbserver.port";
-    private static final String CONNECTION_TYPE = "ovsdbserver.connection";
-    private static final String CONNECTION_TYPE_ACTIVE = "active";
-    private static final String CONNECTION_TYPE_PASSIVE = "passive";
-    private static final String DEFAULT_SERVER_IPADDRESS = "127.0.0.1";
-    private static final String DEFAULT_SERVER_PORT = "6640";
 
     /*
      * Wait up to 10s for our configured module to come up
@@ -63,12 +53,9 @@ public abstract class AbstractConfigTestBase {
 
     public Option[] getLoggingOptions() {
         Option[] options = new Option[] {
-                editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
+                editConfigurationFilePut(SouthboundITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
                         logConfiguration(AbstractConfigTestBase.class),
-                        LogLevel.INFO.name()),
-                editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
-                        "log4j.logger.org.opendaylight.ovsdb.southbound-impl",
-                        LogLevel.DEBUG.name())
+                        LogLevel.INFO.name())
         };
         return options;
     }
index 792eb4793d78c78b03c53b809acef048d22e308c..922684f4e9636fc6f29a3131d63bac6cabcfb2f4 100644 (file)
@@ -63,7 +63,7 @@ public abstract class AbstractMdsalTestBase extends AbstractConfigTestBase imple
     @Override
     public Option[] getLoggingOptions() {
         Option[] options = new Option[] {
-                editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
+                editConfigurationFilePut(SouthboundITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
                         logConfiguration(AbstractMdsalTestBase.class),
                         LogLevel.INFO.name()),
         };
index 25812f62dbc87a08bbe0ecd3cde694a37d32253f..1b865fe3b206fc4cae44ce4e59c05734dd2b8d9f 100644 (file)
@@ -16,6 +16,7 @@ import static org.ops4j.pax.exam.CoreOptions.maven;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
 
 import com.google.common.base.Optional;
+import com.google.common.collect.ObjectArrays;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
@@ -53,6 +54,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.karaf.options.LogLevelOption;
 import org.ops4j.pax.exam.options.MavenUrlReference;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
@@ -69,14 +71,6 @@ import org.slf4j.LoggerFactory;
 @ExamReactorStrategy(PerClass.class)
 public class SouthboundIT extends AbstractMdsalTestBase {
     private static final Logger LOG = LoggerFactory.getLogger(SouthboundIT.class);
-    private static final String SERVER_IPADDRESS = "ovsdbserver.ipaddress";
-    private static final String SERVER_PORT = "ovsdbserver.port";
-    private static final String CONNECTION_TYPE = "ovsdbserver.connection";
-    private static final String CONNECTION_TYPE_ACTIVE = "active";
-    private static final String CONNECTION_TYPE_PASSIVE = "passive";
-    private static final int CONNECTION_INIT_TIMEOUT = 10000;
-    private static final String DEFAULT_SERVER_IPADDRESS = "127.0.0.1";
-    private static final String DEFAULT_SERVER_PORT = "6640";
     private static Boolean writeStatus = false;
     private static Boolean readStatus = false;
     private static Boolean deleteStatus = false;
@@ -126,20 +120,37 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 + "passive connection : mvn -Dovsdbserver.connection=passive verify\n";
     }
 
+    @Override
+    public Option[] getLoggingOptions() {
+        Option[] options = new Option[] {
+                editConfigurationFilePut(SouthboundITConstants.ORG_OPS4J_PAX_LOGGING_CFG,
+                        "log4j.logger.org.opendaylight.ovsdb.southbound-impl",
+                        LogLevelOption.LogLevel.DEBUG.name())
+        };
+        options = ObjectArrays.concat(options, super.getLoggingOptions(), Option.class);
+        return options;
+    }
+
     @Override
     public Option[] getPropertiesOptions() {
         Properties props = new Properties(System.getProperties());
-        String addressStr = props.getProperty(SERVER_IPADDRESS, DEFAULT_SERVER_IPADDRESS);
-        String portStr = props.getProperty(SERVER_PORT, DEFAULT_SERVER_PORT);
-        String connectionType = props.getProperty(CONNECTION_TYPE, CONNECTION_TYPE_ACTIVE);
+        String addressStr = props.getProperty(SouthboundITConstants.SERVER_IPADDRESS,
+                SouthboundITConstants.DEFAULT_SERVER_IPADDRESS);
+        String portStr = props.getProperty(SouthboundITConstants.SERVER_PORT,
+                SouthboundITConstants.DEFAULT_SERVER_PORT);
+        String connectionType = props.getProperty(SouthboundITConstants.CONNECTION_TYPE,
+                SouthboundITConstants.CONNECTION_TYPE_ACTIVE);
 
         LOG.info("Using the following properties: mode= {}, ip:port= {}:{}",
                 connectionType, addressStr, portStr);
 
         Option[] options = new Option[] {
-                editConfigurationFilePut(CUSTOM_PROPERTIES, SERVER_IPADDRESS, addressStr),
-                editConfigurationFilePut(CUSTOM_PROPERTIES, SERVER_PORT, portStr),
-                editConfigurationFilePut(CUSTOM_PROPERTIES, CONNECTION_TYPE, connectionType)
+                editConfigurationFilePut(SouthboundITConstants.CUSTOM_PROPERTIES,
+                        SouthboundITConstants.SERVER_IPADDRESS, addressStr),
+                editConfigurationFilePut(SouthboundITConstants.CUSTOM_PROPERTIES,
+                        SouthboundITConstants.SERVER_PORT, portStr),
+                editConfigurationFilePut(SouthboundITConstants.CUSTOM_PROPERTIES,
+                        SouthboundITConstants.CONNECTION_TYPE, connectionType)
         };
         return options;
     }
@@ -161,13 +172,13 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         dataBroker = SouthboundProvider.getDb();
         Assert.assertNotNull("db should not be null", dataBroker);
 
-        addressStr = bc.getProperty(SERVER_IPADDRESS);
-        portStr = bc.getProperty(SERVER_PORT);
-        connectionType = bc.getProperty(CONNECTION_TYPE);
+        addressStr = bc.getProperty(SouthboundITConstants.SERVER_IPADDRESS);
+        portStr = bc.getProperty(SouthboundITConstants.SERVER_PORT);
+        connectionType = bc.getProperty(SouthboundITConstants.CONNECTION_TYPE);
 
         LOG.info("Using the following properties: mode= {}, ip:port= {}:{}",
                 connectionType, addressStr, portStr);
-        if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_ACTIVE)) {
+        if (connectionType.equalsIgnoreCase(SouthboundITConstants.CONNECTION_TYPE_ACTIVE)) {
             if (addressStr == null) {
                 fail(usage());
             }
@@ -179,9 +190,9 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
     @Test
     public void testPassiveNode() throws InterruptedException {
-        if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_PASSIVE)) {
+        if (connectionType.equalsIgnoreCase(SouthboundITConstants.CONNECTION_TYPE_PASSIVE)) {
             //Wait for CONNECTION_INIT_TIMEOUT for the Passive connection to be initiated by the ovsdb-server.
-            Thread.sleep(CONNECTION_INIT_TIMEOUT);
+            Thread.sleep(SouthboundITConstants.CONNECTION_INIT_TIMEOUT);
         }
     }
 
diff --git a/southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundITConstants.java b/southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundITConstants.java
new file mode 100644 (file)
index 0000000..0b4ceb2
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.ovsdb.southbound.it;
+
+/**
+ * Constants for SouthboundIT
+ */
+public final class SouthboundITConstants {
+    private SouthboundITConstants() {
+        throw new AssertionError("This class should not be instantiated.");
+    }
+
+    public static final String ORG_OPS4J_PAX_LOGGING_CFG = "etc/org.ops4j.pax.logging.cfg";
+    public static final String CUSTOM_PROPERTIES = "etc/custom.properties";
+    public static final String SERVER_IPADDRESS = "ovsdbserver.ipaddress";
+    public static final String SERVER_PORT = "ovsdbserver.port";
+    public static final String SERVER_EXTRAS = "ovsdbserver.extras";
+    public static final String CONNECTION_TYPE = "ovsdbserver.connection";
+    public static final String CONNECTION_TYPE_ACTIVE = "active";
+    public static final String CONNECTION_TYPE_PASSIVE = "passive";
+    public static final int CONNECTION_INIT_TIMEOUT = 10000;
+    public static final String DEFAULT_SERVER_IPADDRESS = "127.0.0.1";
+    public static final String DEFAULT_SERVER_PORT = "6640";
+    public static final String DEFAULT_SERVER_EXTRAS = "false";
+}