Squashed commit of the following:
[ovsdb.git] / southbound / southbound-it / src / test / java / org / opendaylight / ovsdb / southbound / it / AbstractConfigTestBase.java
index 04c5a1f4c07c6f96e20bcf4d60f124d1f30dc317..6bab26e44c310c7a8a3d410486fbaf193d3f4f99 100644 (file)
@@ -1,8 +1,14 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, 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;
 
 import static org.ops4j.pax.exam.CoreOptions.maven;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
 
@@ -15,6 +21,7 @@ import java.util.Calendar;
 import javax.management.InstanceNotFoundException;
 
 import org.junit.Rule;
+import org.junit.internal.AssumptionViolatedException;
 import org.junit.rules.TestRule;
 import org.junit.rules.TestWatcher;
 import org.junit.runner.Description;
@@ -29,22 +36,13 @@ 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
      */
     private static final int MODULE_TIMEOUT = 10000;
+    private static int configTimes = 0;
 
     public abstract String getModuleName();
 
@@ -56,12 +54,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;
     }
@@ -70,30 +65,42 @@ public abstract class AbstractConfigTestBase {
         return "log4j.logger." + klazz.getPackage().getName();
     }
 
+    public Option[] getFeaturesOptions() {
+        return new Option[]{};
+    }
+
     public Option[] getPropertiesOptions() {
-        return null;
+        return new Option[]{};
     }
 
     public MavenArtifactUrlReference getKarafDistro() {
-        MavenArtifactUrlReference karafUrl = maven()
-                .groupId("org.opendaylight.controller")
-                .artifactId("opendaylight-karaf-empty")
-                .version("1.5.0-SNAPSHOT")
+        MavenArtifactUrlReference karafUrl;
+        karafUrl = maven()
+                // karaf-empty is busted
+                //.groupId("org.opendaylight.controller")
+                //.artifactId("opendaylight-karaf-empty")
+                //.version("1.5.0-SNAPSHOT")
+                .groupId("org.opendaylight.ovsdb")
+                .artifactId("southbound-karaf")
+                .version("1.1.0-SNAPSHOT")
                 .type("zip");
         return karafUrl;
     }
 
     @Configuration
     public Option[] config() {
+        LOG.info("Calling config, configTimes: {}", configTimes);
+        configTimes++;
         Option[] options = new Option[] {
-                // KarafDistributionOption.debugConfiguration("5005", true),
+                //KarafDistributionOption.debugConfiguration("5005", true),
                 karafDistributionConfiguration()
                         .frameworkUrl(getKarafDistro())
                         .unpackDirectory(new File("target/exam"))
                         .useDeployFolder(false),
                 keepRuntimeFolder(),
-                features(getFeatureRepo() , getFeatureName()),
+                //features(getFeatureRepo() , getFeatureName())
         };
+        options = ObjectArrays.concat(options, getFeaturesOptions(), Option.class);
         options = ObjectArrays.concat(options, getLoggingOptions(), Option.class);
         options = ObjectArrays.concat(options, getPropertiesOptions(), Option.class);
         return options;
@@ -110,9 +117,7 @@ public abstract class AbstractConfigTestBase {
                 configRegistryClient.lookupConfigBean(getModuleName(), getInstanceName());
                 Thread.sleep(1);
             } catch (InstanceNotFoundException e) {
-                if (timer < MODULE_TIMEOUT) {
-                    continue;
-                } else {
+                if (timer >= MODULE_TIMEOUT) {
                     throw e;
                 }
             } catch (InterruptedException e) {
@@ -129,13 +134,27 @@ public abstract class AbstractConfigTestBase {
     public TestRule watcher = new TestWatcher() {
         @Override
         protected void starting(Description description) {
-            LOG.info("TestWatcher: Starting test: {}",
-                    description.getDisplayName());
+            LOG.info("TestWatcher: Starting test:\n{}", description.getDisplayName());
         }
 
         @Override
         protected void finished(Description description) {
-            LOG.info("TestWatcher: Finished test: {}", description.getDisplayName());
+            LOG.info("TestWatcher: Finished test:\n{}", description.getDisplayName());
+        }
+
+        @Override
+        protected void succeeded(Description description) {
+            LOG.info("TestWatcher: Test succeeded:\n{}", description.getDisplayName());
+        }
+
+        @Override
+        protected void failed(Throwable ex, Description description) {
+            LOG.info("TestWatcher: Test failed:\n{} ", description.getDisplayName(), ex);
+        }
+
+        @Override
+        protected void skipped(AssumptionViolatedException ex, Description description) {
+            LOG.info("TestWatcher: Test skipped:\n{} ", description.getDisplayName(), ex);
         }
     };
 }