Merge "Fix config-manager activator"
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / testingservices / parallelapsp / test / DependentWiringTest.java
index 5b1a6f6e8184f69805ec5245e2d4b99089467e5d..165a6c7ed62e02bdbb05e5644962dc15b42712d9 100644 (file)
@@ -7,17 +7,16 @@
  */
 package org.opendaylight.controller.config.manager.testingservices.parallelapsp.test;
 
+import static org.hamcrest.CoreMatchers.containsString;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.junit.internal.matchers.StringContains.containsString;
 
 import java.util.Map;
 
 import javax.management.ObjectName;
 
-import org.json.simple.JSONObject;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -28,11 +27,11 @@ import org.opendaylight.controller.config.manager.impl.factoriesresolver.Hardcod
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPImpl;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory;
+import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface;
 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.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.util.jolokia.ConfigTransactionJolokiaClient;
 
 public class DependentWiringTest extends AbstractParallelAPSPTest {
     private final String fixed1 = "fixed1";
@@ -40,7 +39,7 @@ public class DependentWiringTest extends AbstractParallelAPSPTest {
 
     @Before
     public void setUp() {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,
                 new TestingFixedThreadPoolModuleFactory(),
                 new TestingParallelAPSPModuleFactory()));
     }
@@ -51,7 +50,7 @@ public class DependentWiringTest extends AbstractParallelAPSPTest {
     }
 
     @Override
-    String getThreadPoolImplementationName() {
+    protected String getThreadPoolImplementationName() {
         return TestingFixedThreadPoolModuleFactory.NAME;
     }
 
@@ -137,42 +136,15 @@ public class DependentWiringTest extends AbstractParallelAPSPTest {
     }
 
     @Test
-    public void testUsingJolokia() throws Exception {
-
-        ConfigTransactionJolokiaClient transactionClient = configRegistryJolokiaClient
-                .createTransaction();
-        // fixed1
-        ObjectName fixed1ON = transactionClient.createModule(
-                getThreadPoolImplementationName(), fixed1);
-        transactionClient.setAttribute(fixed1ON, "ThreadCount",
-                TestingParallelAPSPImpl.MINIMAL_NUMBER_OF_THREADS);
-
-        // apsp-parallel with syntetic attrib
-        String threadPoolString = "ThreadPool";
-        ObjectName apsp1ON = transactionClient.createModule(
-                TestingParallelAPSPModuleFactory.NAME, apsp1);
-        transactionClient.setAttribute(apsp1ON, threadPoolString, fixed1ON);
-        // check
-        assertEquals(ObjectNameUtil.withoutTransactionName(fixed1ON),
-                transactionClient.getAttributeON(apsp1ON, threadPoolString));
-        transactionClient.setAttribute(apsp1ON, "SomeParam", "ahoj");
-
-        // commit
-        transactionClient.commit();
-        // check thread pool
-        assertEquals(1, TestingFixedThreadPool.allExecutors.size());
-        // check platform MBeanServer
-        ObjectName apspReadOnlyON = ObjectNameUtil
-                .withoutTransactionName(apsp1ON);
-        JSONObject threadPoolONJson = (JSONObject) configRegistryJolokiaClient
-                .getAttribute(apspReadOnlyON, threadPoolString);
-        ObjectName fixed1ReadOnlyON = ObjectNameUtil
-                .withoutTransactionName(fixed1ON);
-        assertEquals(fixed1ReadOnlyON, ObjectNameUtil.createON(threadPoolONJson
-                .get("objectName").toString()));
-        assertEquals(fixed1ReadOnlyON,
-                configRegistryJolokiaClient.getAttributeON(apspReadOnlyON,
-                        threadPoolString));
+    public void testUsingServiceReferences() throws Exception {
+        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        ObjectName threadPoolON = createFixed1(transaction, 10);
+                transaction.lookupConfigBean(getThreadPoolImplementationName(), fixed1);
+        String refName = "ref";
+        ObjectName serviceReferenceON = transaction.saveServiceReference(TestingThreadPoolServiceInterface.QNAME, refName,
+                threadPoolON);
+        createParallelAPSP(transaction, serviceReferenceON);
+        transaction.commit();
 
     }
 }