Deprecate getModuleName()/getInstanceName() in AbstractConfigTestBase 91/39891/3
authorTom Pantelis <tpanteli@brocade.com>
Mon, 6 Jun 2016 07:44:38 +0000 (03:44 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 7 Jun 2016 01:07:21 +0000 (01:07 +0000)
The AbstractConfigTestBase currently requires a config system
moduleName/instanceName to be provided by the derived class to ensure
the config module is pushed and present in JMX. However blueprint-enabled
apps won't have a config system module so deprecate these methods and
make them optional along with the check.

Change-Id: I1f2f6a993cf99ba25d766ba0ec20ed27b1a9915f
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/config/config-it-base/src/main/java/org/opendaylight/controller/config/it/base/AbstractConfigTestBase.java

index d7c42f5..13639ce 100644 (file)
@@ -78,9 +78,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();
 
@@ -156,17 +172,23 @@ public abstract class AbstractConfigTestBase {
 
     @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;
             } catch (Exception e) {
                 if(i<MODULE_TIMEOUT_MILLIS) {
                 break;
             } catch (Exception e) {
                 if(i<MODULE_TIMEOUT_MILLIS) {
@@ -179,10 +201,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");
         }
     }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.