config-it-base: final parameters
[controller.git] / opendaylight / config / config-it-base / src / main / java / org / opendaylight / controller / config / it / base / AbstractConfigTestBase.java
index 05bcfbc04341bccce5985cd66f6108745b3ce392..84dcd65e48ce25f66a8a4fe5070f4b8fa78f6a09 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.controller.config.it.base;
 
 import static org.ops4j.pax.exam.CoreOptions.maven;
 package org.opendaylight.controller.config.it.base;
 
 import static org.ops4j.pax.exam.CoreOptions.maven;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.when;
 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.CoreOptions.when;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
@@ -32,6 +33,7 @@ import org.opendaylight.controller.config.api.ConfigRegistry;
 import org.opendaylight.controller.config.util.ConfigRegistryJMXClient;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.opendaylight.controller.config.util.ConfigRegistryJMXClient;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.OptionUtils;
 import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
 import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
 import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
 import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
 import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
 import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
@@ -57,7 +59,7 @@ public abstract class AbstractConfigTestBase {
      */
     private static final String KARAF_DISTRO_TYPE = "zip";
     private static final String KARAF_DISTRO_ARTIFACTID = "opendaylight-karaf-empty";
      */
     private static final String KARAF_DISTRO_TYPE = "zip";
     private static final String KARAF_DISTRO_ARTIFACTID = "opendaylight-karaf-empty";
-    private static final String KARAF_DISTRO_GROUPID = "org.opendaylight.controller";
+    private static final String KARAF_DISTRO_GROUPID = "org.opendaylight.odlparent";
 
     /*
      * Property names to override defaults for karaf distro artifactId, groupId, version, and type
 
     /*
      * Property names to override defaults for karaf distro artifactId, groupId, version, and type
@@ -77,9 +79,25 @@ public abstract class AbstractConfigTestBase {
      */
     private static final int MODULE_TIMEOUT_MILLIS = 60000;
 
      */
     private static final int MODULE_TIMEOUT_MILLIS = 60000;
 
-    public abstract String getModuleName();
+    /**
+     * This method need only be overridden if using the config system.
+     *
+     * @return the config module name
+     */
+    @Deprecated
+    public String getModuleName() {
+        return null;
+    }
 
 
-    public abstract String getInstanceName();
+    /**
+     * This method need only be overridden if using the config system.
+     *
+     * @return the config module instance name
+     */
+    @Deprecated
+    public String getInstanceName() {
+        return null;
+    }
 
     public abstract MavenUrlReference getFeatureRepo();
 
 
     public abstract MavenUrlReference getFeatureRepo();
 
@@ -92,7 +110,16 @@ public abstract class AbstractConfigTestBase {
         return option;
     }
 
         return option;
     }
 
-    public String logConfiguration(Class<?> klazz) {
+    /**
+     * Override this method to provide more options to config
+     *
+     * @return An array of additional config options
+     */
+    protected Option[] getAdditionalOptions() {
+        return null;
+    }
+
+    public String logConfiguration(final Class<?> klazz) {
         return "log4j.logger." + klazz.getPackage().getName();
     }
 
         return "log4j.logger." + klazz.getPackage().getName();
     }
 
@@ -108,7 +135,7 @@ public abstract class AbstractConfigTestBase {
             try (InputStream abstractConfigTestBaseInputStream = Thread.currentThread().getContextClassLoader()
                     .getResourceAsStream(PROPERTIES_FILENAME)) {
                 abstractConfigTestBaseProps.load(abstractConfigTestBaseInputStream);
             try (InputStream abstractConfigTestBaseInputStream = Thread.currentThread().getContextClassLoader()
                     .getResourceAsStream(PROPERTIES_FILENAME)) {
                 abstractConfigTestBaseProps.load(abstractConfigTestBaseInputStream);
-            } catch (IOException e) {
+            } catch (final IOException e) {
                 LOG.error("Unable to load {} to determine the Karaf version", PROPERTIES_FILENAME, e);
             }
             version = abstractConfigTestBaseProps.getProperty(KARAF_DISTRO_VERSION_PROP);
                 LOG.error("Unable to load {} to determine the Karaf version", PROPERTIES_FILENAME, e);
             }
             version = abstractConfigTestBaseProps.getProperty(KARAF_DISTRO_VERSION_PROP);
@@ -138,27 +165,34 @@ public abstract class AbstractConfigTestBase {
                         .useDeployFolder(false),
                 when(Boolean.getBoolean(KEEP_UNPACK_DIRECTORY_PROP)).useOptions(keepRuntimeFolder()),
                 features(getFeatureRepo(), getFeatureName()),
                         .useDeployFolder(false),
                 when(Boolean.getBoolean(KEEP_UNPACK_DIRECTORY_PROP)).useOptions(keepRuntimeFolder()),
                 features(getFeatureRepo(), getFeatureName()),
+                mavenBundle("org.apache.aries.quiesce", "org.apache.aries.quiesce.api", "1.0.0"),
                 getLoggingOption(),
                 mvnLocalRepoOption(),
                 editConfigurationFilePut(ETC_ORG_OPS4J_PAX_LOGGING_CFG, "log4j.rootLogger", "INFO, stdout, osgi:*")};
                 getLoggingOption(),
                 mvnLocalRepoOption(),
                 editConfigurationFilePut(ETC_ORG_OPS4J_PAX_LOGGING_CFG, "log4j.rootLogger", "INFO, stdout, osgi:*")};
-        return options;
+        return OptionUtils.combine(options, getAdditionalOptions());
     }
 
     @Before
     public void setup() throws Exception {
     }
 
     @Before
     public void setup() throws Exception {
+        String moduleName = getModuleName();
+        String instanceName = getInstanceName();
+        if(moduleName == null || instanceName == null) {
+            return;
+        }
+
         LOG.info("Module: {} Instance: {} attempting to configure.",
         LOG.info("Module: {} Instance: {} attempting to configure.",
-                getModuleName(),getInstanceName());
+                moduleName, instanceName);
         Stopwatch stopWatch = Stopwatch.createStarted();
         ObjectName objectName = null;
         for(int i = 0;i<MODULE_TIMEOUT_MILLIS;i++) {
             try {
                 ConfigRegistry configRegistryClient = new ConfigRegistryJMXClient(ManagementFactory
                         .getPlatformMBeanServer());
         Stopwatch stopWatch = Stopwatch.createStarted();
         ObjectName objectName = null;
         for(int i = 0;i<MODULE_TIMEOUT_MILLIS;i++) {
             try {
                 ConfigRegistry configRegistryClient = new ConfigRegistryJMXClient(ManagementFactory
                         .getPlatformMBeanServer());
-                objectName = configRegistryClient.lookupConfigBean(getModuleName(), getInstanceName());
+                objectName = configRegistryClient.lookupConfigBean(moduleName, instanceName);
                 LOG.info("Module: {} Instance: {} ObjectName: {}.",
                 LOG.info("Module: {} Instance: {} ObjectName: {}.",
-                        getModuleName(),getInstanceName(),objectName);
+                        moduleName,instanceName,objectName);
                 break;
                 break;
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 if(i<MODULE_TIMEOUT_MILLIS) {
                     Thread.sleep(1);
                     continue;
                 if(i<MODULE_TIMEOUT_MILLIS) {
                     Thread.sleep(1);
                     continue;
@@ -169,10 +203,10 @@ public abstract class AbstractConfigTestBase {
         }
         if(objectName != null) {
             LOG.info("Module: {} Instance: {} configured after {} ms",
         }
         if(objectName != null) {
             LOG.info("Module: {} Instance: {} configured after {} ms",
-                getModuleName(),getInstanceName(),
+                moduleName,instanceName,
                 stopWatch.elapsed(TimeUnit.MILLISECONDS));
         } else {
                 stopWatch.elapsed(TimeUnit.MILLISECONDS));
         } else {
-            throw new RuntimeException("NOT FOUND Module: " +getModuleName() + " Instance: " + getInstanceName() +
+            throw new RuntimeException("NOT FOUND Module: " +moduleName + " Instance: " + instanceName +
                     " configured after " + stopWatch.elapsed(TimeUnit.MILLISECONDS) + " ms");
         }
     }
                     " configured after " + stopWatch.elapsed(TimeUnit.MILLISECONDS) + " ms");
         }
     }
@@ -181,27 +215,27 @@ public abstract class AbstractConfigTestBase {
     public TestRule watcher = new TestWatcher() {
 
         @Override
     public TestRule watcher = new TestWatcher() {
 
         @Override
-        protected void starting(Description description) {
+        protected void starting(final Description description) {
             LOG.info("TestWatcher: Starting test: {}", description.getDisplayName());
         }
 
         @Override
             LOG.info("TestWatcher: Starting test: {}", description.getDisplayName());
         }
 
         @Override
-        protected void finished(Description description) {
+        protected void finished(final Description description) {
             LOG.info("TestWatcher: Finished test: {}", description.getDisplayName());
         }
 
         @Override
             LOG.info("TestWatcher: Finished test: {}", description.getDisplayName());
         }
 
         @Override
-        protected void succeeded(Description description) {
+        protected void succeeded(final Description description) {
             LOG.info("TestWatcher: Test succeeded: {}", description.getDisplayName());
         }
 
         @Override
             LOG.info("TestWatcher: Test succeeded: {}", description.getDisplayName());
         }
 
         @Override
-        protected void failed(Throwable ex, Description description) {
+        protected void failed(final Throwable ex, final Description description) {
             LOG.info("TestWatcher: Test failed: {}", description.getDisplayName(), ex);
         }
 
         @Override
             LOG.info("TestWatcher: Test failed: {}", description.getDisplayName(), ex);
         }
 
         @Override
-        protected void skipped(AssumptionViolatedException ex, Description description) {
+        protected void skipped(final AssumptionViolatedException ex, final Description description) {
             LOG.info("TestWatcher: Test skipped: {} ", description.getDisplayName(), ex);
         }
     };
             LOG.info("TestWatcher: Test skipped: {} ", description.getDisplayName(), ex);
         }
     };