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%2Fdynamicmbean%2FDynamicWritableWrapperTest.java;h=48accc56ac228e8f5b1f90b84f50b5284ad0e3bd;hp=d453f1e7798eee1aeb848ac9bd23ad98625f7bf4;hb=f43b01b81319959b1907e3e04537f5169e7f33d8;hpb=ebb4158697741bc88fde22ac5f75edf65869506f diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/DynamicWritableWrapperTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/DynamicWritableWrapperTest.java index d453f1e779..48accc56ac 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/DynamicWritableWrapperTest.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/DynamicWritableWrapperTest.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, @@ -20,7 +20,6 @@ import javax.management.ObjectName; import org.junit.Test; import org.opendaylight.controller.config.api.ModuleIdentifier; import org.opendaylight.controller.config.api.jmx.ObjectNameUtil; -import org.opendaylight.controller.config.manager.impl.TransactionIdentifier; import org.opendaylight.controller.config.manager.impl.dynamicmbean.ReadOnlyAtomicBoolean.ReadOnlyAtomicBooleanImpl; import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPConfigMXBean; import org.opendaylight.controller.config.manager.testingservices.parallelapsp.TestingParallelAPSPModule; @@ -31,22 +30,17 @@ import org.opendaylight.controller.config.spi.Module; public class DynamicWritableWrapperTest extends AbstractDynamicWrapperTest { private final int newThreadCount = 10; private final AtomicBoolean atomicBoolean = new AtomicBoolean(); - private final ReadOnlyAtomicBoolean readOnlyAtomicBoolean = new ReadOnlyAtomicBooleanImpl( - atomicBoolean); + private final ReadOnlyAtomicBoolean readOnlyAtomicBoolean = new ReadOnlyAtomicBooleanImpl(atomicBoolean); @Override - protected AbstractDynamicWrapper getDynamicWrapper(Module module, - ModuleIdentifier moduleIdentifier) { - return new DynamicWritableWrapper(module, moduleIdentifier, - new TransactionIdentifier("transaction-1"), - readOnlyAtomicBoolean, MBeanServerFactory.createMBeanServer(), - platformMBeanServer); + protected AbstractDynamicWrapper getDynamicWrapper(final Module module, final ModuleIdentifier moduleIdentifier) { + return new DynamicWritableWrapper(module, moduleIdentifier, "transaction-1", readOnlyAtomicBoolean, + MBeanServerFactory.createMBeanServer(), platformMBeanServer); } @Test public void testSetAttribute() throws Exception { - DynamicMBean proxy = JMX.newMBeanProxy(platformMBeanServer, - threadPoolDynamicWrapperON, DynamicMBean.class); + DynamicMBean proxy = JMX.newMBeanProxy(platformMBeanServer, threadPoolDynamicWrapperON, DynamicMBean.class); proxy.setAttribute(new Attribute(THREAD_COUNT, newThreadCount)); @@ -65,49 +59,39 @@ public class DynamicWritableWrapperTest extends AbstractDynamicWrapperTest { @Test public void testSettersWithMXBeanProxy() { - TestingFixedThreadPoolConfigMXBean proxy = JMX.newMXBeanProxy( - platformMBeanServer, threadPoolDynamicWrapperON, + TestingFixedThreadPoolConfigMXBean proxy = JMX.newMXBeanProxy(platformMBeanServer, threadPoolDynamicWrapperON, TestingFixedThreadPoolConfigMXBean.class); proxy.setThreadCount(newThreadCount); assertEquals(newThreadCount, threadPoolConfigBean.getThreadCount()); } /* - * Try to call setter with ObjectName containing transaction name. Verify - * that ObjectName without transaction name was actually passed on the - * config bean. + * Try to call setter with ObjectName containing transaction name. Verify that + * ObjectName without transaction name was actually passed on the config bean. */ @Test - public void testObjectNameSetterWithONContainingTransaction_shouldBeTranslatedToReadOnlyON() - throws Exception { + public void testObjectNameSetterWithONContainingTransaction_shouldBeTranslatedToReadOnlyON() throws Exception { TestingParallelAPSPModuleFactory testingParallelAPSPConfigBeanFactory = new TestingParallelAPSPModuleFactory(); - TestingParallelAPSPModule apspConfigBean = testingParallelAPSPConfigBeanFactory - .createModule("", null, null); - ModuleIdentifier moduleIdentifier2 = new ModuleIdentifier("apsp", - "parallel"); - ObjectName dynON2 = ObjectNameUtil - .createReadOnlyModuleON(moduleIdentifier2); - AbstractDynamicWrapper dyn = getDynamicWrapper(apspConfigBean, - moduleIdentifier2); + TestingParallelAPSPModule apspConfigBean = testingParallelAPSPConfigBeanFactory.createModule("", null, null); + ModuleIdentifier moduleIdentifier2 = new ModuleIdentifier("apsp", "parallel"); + ObjectName dynON2 = ObjectNameUtil.createReadOnlyModuleON(moduleIdentifier2); + AbstractDynamicWrapper dyn = getDynamicWrapper(apspConfigBean, moduleIdentifier2); platformMBeanServer.registerMBean(dyn, dynON2); try { - TestingParallelAPSPConfigMXBean proxy = JMX.newMBeanProxy( - platformMBeanServer, dynON2, + TestingParallelAPSPConfigMXBean proxy = JMX.newMBeanProxy(platformMBeanServer, dynON2, TestingParallelAPSPConfigMXBean.class); - ObjectName withTransactionName = ObjectNameUtil - .createTransactionModuleON("transaction1", "moduleName", "instanceName"); + ObjectName withTransactionName = ObjectNameUtil.createTransactionModuleON("transaction1", "moduleName", + "instanceName"); proxy.setThreadPool(withTransactionName); - ObjectName withoutTransactionName = ObjectNameUtil - .withoutTransactionName(withTransactionName); + ObjectName withoutTransactionName = ObjectNameUtil.withoutTransactionName(withTransactionName); assertEquals(withoutTransactionName, proxy.getThreadPool()); } finally { platformMBeanServer.unregisterMBean(dynON2); } } - private void setNumberOfThreads(int numberOfThreads) throws Exception { - DynamicMBean proxy = JMX.newMBeanProxy(platformMBeanServer, - threadPoolDynamicWrapperON, DynamicMBean.class); + private void setNumberOfThreads(final int numberOfThreads) throws Exception { + DynamicMBean proxy = JMX.newMBeanProxy(platformMBeanServer, threadPoolDynamicWrapperON, DynamicMBean.class); proxy.setAttribute(new Attribute(THREAD_COUNT, numberOfThreads)); @@ -120,12 +104,10 @@ public class DynamicWritableWrapperTest extends AbstractDynamicWrapperTest { try { setNumberOfThreads(newThreadCount); fail(); - } catch (IllegalStateException e) { + } catch (final IllegalStateException e) { assertEquals("Operation is not allowed now", e.getMessage()); } finally { atomicBoolean.set(false); } - } - }