Merge "Remove raw references to Map in XSQL"
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / impl / ServiceReferenceRegistryImplTest.java
index 6d0b340cd3c1c0720fbe78ee6823098bf92b17ca..27515cf9698e4756f4e9ee0844862a2d61302f7b 100644 (file)
@@ -7,40 +7,42 @@
  */
 package org.opendaylight.controller.config.manager.impl;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.opendaylight.controller.config.api.jmx.ObjectNameUtil.withoutTransactionName;
+
 import com.google.common.collect.ImmutableMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.management.Attribute;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.JMX;
+import javax.management.MBeanException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
+import org.opendaylight.controller.config.api.jmx.ServiceReferenceMXBean;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest.RecordingBundleContextServiceRegistrationHandler.RegistrationHolder;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceMXBean;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModuleFactory;
 import org.opendaylight.controller.config.manager.testingservices.parallelapsp.test.AbstractParallelAPSPTest;
 import org.opendaylight.controller.config.manager.testingservices.scheduledthreadpool.TestingScheduledThreadPoolModuleFactory;
 import org.opendaylight.controller.config.manager.testingservices.seviceinterface.TestingThreadPoolServiceInterface;
 import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingFixedThreadPoolModuleFactory;
+import org.opendaylight.controller.config.manager.testingservices.threadpool.TestingThreadPoolIfc;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMX;
-import javax.management.MBeanException;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
-import java.util.Map;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.opendaylight.controller.config.api.jmx.ObjectNameUtil.withoutTransactionName;
-
 public class ServiceReferenceRegistryImplTest extends AbstractParallelAPSPTest {
 
 
     @Before
     public void setUp() {
         super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(
+                mockedContext,
                 new TestingFixedThreadPoolModuleFactory(),
                 new TestingParallelAPSPModuleFactory(),
                 new TestingScheduledThreadPoolModuleFactory()));
@@ -71,11 +73,19 @@ public class ServiceReferenceRegistryImplTest extends AbstractParallelAPSPTest {
         // create apsp-parallel
         createParallelAPSP(transaction1, serviceReference);
         transaction1.commit();
+
         // check fixed1 is used
         ServiceReferenceMXBean serviceReferenceMXBean = JMX.newMXBeanProxy(platformMBeanServer,
                 withoutTransactionName(serviceReference), ServiceReferenceMXBean.class);
         assertEquals(withoutTransactionName(fixedTPTransactionON), serviceReferenceMXBean.getCurrentImplementation());
         checkApspThreadCount(fixedNrOfThreads);
+        // check OSGi SR
+        List<RegistrationHolder> registrations =
+                ((RecordingBundleContextServiceRegistrationHandler) currentBundleContextServiceRegistrationHandler).getRegistrations();
+        assertEquals(1, registrations.size());
+        RegistrationHolder record = registrations.get(0);
+        assertEquals(TestingThreadPoolIfc.class, record.clazz);
+        assertEquals(ImmutableMap.of("name","ref"), (Map<String, String>) record.props);
 
         // switch reference to scheduled
         ConfigTransactionJMXClient transaction2 = configRegistryClient.createTransaction();