X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fmanager%2Fimpl%2FServiceReferenceRegistryImplTest.java;h=5ab15570230e58e085db9d5615b31b2b07c058c0;hp=9b9a92270a37354af1b5f7defa414ec245b18487;hb=f43b01b81319959b1907e3e04537f5169e7f33d8;hpb=405c97ddf445b6057a2654545dd8072d28eedcce diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImplTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImplTest.java index 9b9a92270a..5ab1557023 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImplTest.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -38,14 +38,11 @@ import org.opendaylight.controller.config.util.ConfigTransactionJMXClient; public class ServiceReferenceRegistryImplTest extends AbstractParallelAPSPTest { - @Before public void setUp() { - super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver( - mockedContext, - new TestingFixedThreadPoolModuleFactory(), - new TestingParallelAPSPModuleFactory(), - new TestingScheduledThreadPoolModuleFactory())); + super.initConfigTransactionManagerImpl( + new HardcodedModuleFactoriesResolver(mockedContext, new TestingFixedThreadPoolModuleFactory(), + new TestingParallelAPSPModuleFactory(), new TestingScheduledThreadPoolModuleFactory())); } @Override @@ -57,19 +54,19 @@ public class ServiceReferenceRegistryImplTest extends AbstractParallelAPSPTest { public void test() throws Exception { ConfigTransactionJMXClient transaction1 = configRegistryClient.createTransaction(); // create fixed1 - int fixedNrOfThreads = 20, scheduledNrOfThreads = 30; + int fixedNrOfThreads = 20; + int scheduledNrOfThreads = 30; ObjectName fixedTPTransactionON = transaction1.createModule(getThreadPoolImplementationName(), fixed1); platformMBeanServer.setAttribute(fixedTPTransactionON, new Attribute("ThreadCount", fixedNrOfThreads)); - ObjectName scheduledTPTransactionON = transaction1.createModule( - TestingScheduledThreadPoolModuleFactory.NAME, "scheduled1"); - platformMBeanServer.setAttribute(scheduledTPTransactionON, new Attribute("ThreadCount", - scheduledNrOfThreads)); + ObjectName scheduledTPTransactionON = transaction1.createModule(TestingScheduledThreadPoolModuleFactory.NAME, + "scheduled1"); + platformMBeanServer.setAttribute(scheduledTPTransactionON, new Attribute("ThreadCount", scheduledNrOfThreads)); String refName = "ref"; - ObjectName serviceReference = transaction1.saveServiceReference(TestingThreadPoolServiceInterface.QNAME, refName, - fixedTPTransactionON); + ObjectName serviceReference = transaction1.saveServiceReference(TestingThreadPoolServiceInterface.QNAME, + refName, fixedTPTransactionON); // create apsp-parallel createParallelAPSP(transaction1, serviceReference); transaction1.commit(); @@ -81,11 +78,12 @@ public class ServiceReferenceRegistryImplTest extends AbstractParallelAPSPTest { checkApspThreadCount(fixedNrOfThreads); // check OSGi SR List registrations = - ((RecordingBundleContextServiceRegistrationHandler) currentBundleContextServiceRegistrationHandler).getRegistrations(); + ((RecordingBundleContextServiceRegistrationHandler) currentBundleContextServiceRegistrationHandler) + .getRegistrations(); assertEquals(1, registrations.size()); RegistrationHolder record = registrations.get(0); assertEquals(TestingThreadPoolIfc.class, record.clazz); - assertEquals(ImmutableMap.of("name","ref"), record.props); + assertEquals(ImmutableMap.of("name", "ref"), record.props); // switch reference to scheduled ConfigTransactionJMXClient transaction2 = configRegistryClient.createTransaction(); @@ -95,21 +93,22 @@ public class ServiceReferenceRegistryImplTest extends AbstractParallelAPSPTest { // check scheduled is used checkApspThreadCount(scheduledNrOfThreads); // check that dummy MXBean points to scheduled - assertEquals(withoutTransactionName(scheduledTPTransactionON), serviceReferenceMXBean.getCurrentImplementation()); + assertEquals(withoutTransactionName(scheduledTPTransactionON), + serviceReferenceMXBean.getCurrentImplementation()); // empty transaction configRegistryClient.createTransaction().commit(); // get service mapping - Map> serviceMapping = configRegistryClient.getServiceMapping(); - Map> expectedMapping = ImmutableMap.of(TestingThreadPoolServiceInterface.QNAME, - (Map)ImmutableMap.of(refName, withoutTransactionName(scheduledTPTransactionON))); + Map> serviceMapping = configRegistryClient.getServiceMapping(); + Map> expectedMapping = ImmutableMap.of(TestingThreadPoolServiceInterface.QNAME, + (Map) ImmutableMap.of(refName, withoutTransactionName(scheduledTPTransactionON))); assertEquals(expectedMapping, serviceMapping); // destroy all ConfigTransactionJMXClient transaction4 = configRegistryClient.createTransaction(); Set objectNames = transaction4.lookupConfigBeans(); - for(ObjectName on: objectNames) { + for (ObjectName on : objectNames) { transaction4.destroyModule(on); } transaction4.commit(); @@ -118,8 +117,8 @@ public class ServiceReferenceRegistryImplTest extends AbstractParallelAPSPTest { assertTrue(serviceMapping.isEmpty()); } - private void checkApspThreadCount(final int fixedNrOfThreads) throws MBeanException, AttributeNotFoundException, - InstanceNotFoundException, ReflectionException { + private void checkApspThreadCount(final int fixedNrOfThreads) + throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException { ObjectName apspON = ObjectNameUtil.createReadOnlyModuleON(TestingParallelAPSPModuleFactory.NAME, apsp1); assertEquals(fixedNrOfThreads, platformMBeanServer.getAttribute(apspON, "MaxNumberOfThreads")); }