Fix Eclipse warnings in config-manager
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / testingservices / threadpool / test / SimpleConfigurationTest.java
index 4ba3dc89399d11f157fdc833b5a72277e8e33ea1..df08f894c9151349e0356b8205c77d3ef3469961 100644 (file)
@@ -7,7 +7,24 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.threadpool.test;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import com.google.common.collect.Sets;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ThreadPoolExecutor;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -21,28 +38,10 @@ import org.opendaylight.controller.config.manager.impl.factoriesresolver.Hardcod
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPool;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolConfigMXBean;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory;
+import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolIfc;
 import org.opendaylight.controller.config.util.ConfigTransactionClient;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 
-import javax.management.DynamicMBean;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ThreadPoolExecutor;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 /**
  * Tests basic functionality of configuration registry:
  * <ol>
@@ -97,7 +96,7 @@ public class SimpleConfigurationTest extends AbstractConfigTest {
     }
 
     static ObjectName createFixedThreadPool(
-            ConfigTransactionJMXClient transaction)
+            final ConfigTransactionJMXClient transaction)
             throws InstanceAlreadyExistsException, InstanceNotFoundException {
         transaction.assertVersion(0, 1);
 
@@ -132,7 +131,7 @@ public class SimpleConfigurationTest extends AbstractConfigTest {
     }
 
 
-    private void testValidation(ConfigTransactionClient transaction)
+    private static void testValidation(final ConfigTransactionClient transaction)
             throws InstanceAlreadyExistsException, ReflectionException,
             InstanceNotFoundException, MBeanException, ConflictingVersionException {
         ObjectName fixed1names = transaction.createModule(
@@ -213,11 +212,9 @@ public class SimpleConfigurationTest extends AbstractConfigTest {
         ObjectName fixed1name = firstCommit();
 
         // 2, check that configuration was copied to platform
-        DynamicMBean dynamicMBean = configRegistryClient.newMBeanProxy(
-                ObjectNameUtil.withoutTransactionName(fixed1name),
-                DynamicMBean.class);
-        dynamicMBean.getMBeanInfo();
-        assertEquals(numberOfThreads, dynamicMBean.getAttribute("ThreadCount"));
+        ObjectName on = ObjectNameUtil.withoutTransactionName(fixed1name);
+        platformMBeanServer.getMBeanInfo(on);
+        assertEquals(numberOfThreads, platformMBeanServer.getAttribute(on, "ThreadCount"));
 
         // 3, shutdown fixed1 in new transaction
         assertFalse(TestingFixedThreadPool.allExecutors.get(0).isShutdown());
@@ -250,10 +247,10 @@ public class SimpleConfigurationTest extends AbstractConfigTest {
 
         // dynamic config should be removed from platform
         try {
-            dynamicMBean.getMBeanInfo();
+            platformMBeanServer.getMBeanInfo(on);
             fail();
         } catch (Exception e) {
-            assertTrue(e.getCause() instanceof InstanceNotFoundException);
+            assertTrue(e instanceof InstanceNotFoundException);
         }
     }
 
@@ -280,8 +277,8 @@ public class SimpleConfigurationTest extends AbstractConfigTest {
         checkThreadPools(1, numberOfThreads2);
     }
 
-    private void checkThreadPools(int expectedTotalNumberOfExecutors,
-            int expectedNumberOfThreadsInLastExecutor) {
+    private static void checkThreadPools(final int expectedTotalNumberOfExecutors,
+            final int expectedNumberOfThreadsInLastExecutor) {
         assertEquals(expectedTotalNumberOfExecutors,
                 TestingFixedThreadPool.allExecutors.size());
         for (int i = 0; i < expectedTotalNumberOfExecutors - 1; i++) {
@@ -313,9 +310,8 @@ public class SimpleConfigurationTest extends AbstractConfigTest {
     }
 
     // return MBeanProxy for 'fixed1' and current transaction
-    private TestingFixedThreadPoolConfigMXBean startReconfiguringFixed1ThreadPool(
-            ConfigTransactionJMXClient transaction)
-            throws InstanceNotFoundException {
+    private static TestingFixedThreadPoolConfigMXBean startReconfiguringFixed1ThreadPool(
+            final ConfigTransactionJMXClient transaction) throws InstanceNotFoundException {
         ObjectName fixed1name = transaction.lookupConfigBean(
                 TestingFixedThreadPoolModuleFactory.NAME, fixed1);