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%2Fruntimembean%2FRuntimeBeanRegistratorImplTest.java;h=e55e4f76b1814ce73f911514dfee888d8634a633;hp=fd225f1b93f01fd1d5c1f5105d1f36c357090624;hb=2b78ca93f44c372fd72927db6cbd65f5d8387b49;hpb=597ffbbfe362fcea479b7fdb52f685289b7ea5fd diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/runtimembean/RuntimeBeanRegistratorImplTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/runtimembean/RuntimeBeanRegistratorImplTest.java index fd225f1b93..e55e4f76b1 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/runtimembean/RuntimeBeanRegistratorImplTest.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/runtimembean/RuntimeBeanRegistratorImplTest.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, @@ -29,26 +29,21 @@ import org.opendaylight.controller.config.manager.impl.jmx.BaseJMXRegistrator; import org.opendaylight.controller.config.manager.impl.jmx.HierarchicalRuntimeBeanRegistrationImpl; import org.opendaylight.controller.config.manager.impl.jmx.RootRuntimeBeanRegistratorImpl; -public class RuntimeBeanRegistratorImplTest extends - AbstractLockedPlatformMBeanServerTest { - static final String module1 = "module1"; - static final String INSTANCE_NAME = "instanceName"; +public class RuntimeBeanRegistratorImplTest extends AbstractLockedPlatformMBeanServerTest { + private static final String MODULE1 = "module1"; + private static final String INSTANCE_NAME = "instanceName"; String additionalKey = "key"; String additionalValue = "value"; - Map additionalProperties = ImmutableMap.of(additionalKey, - additionalValue); + Map additionalProperties = ImmutableMap.of(additionalKey, additionalValue); private BaseJMXRegistrator baseJMXRegistrator; private RootRuntimeBeanRegistratorImpl tested; - private final ModuleIdentifier moduleIdentifier = new ModuleIdentifier( - module1, INSTANCE_NAME); + private final ModuleIdentifier moduleIdentifier = new ModuleIdentifier(MODULE1, INSTANCE_NAME); @Before public void setUp() { - baseJMXRegistrator = new BaseJMXRegistrator( - ManagementFactory.getPlatformMBeanServer()); - tested = baseJMXRegistrator - .createRuntimeBeanRegistrator(moduleIdentifier); + baseJMXRegistrator = new BaseJMXRegistrator(ManagementFactory.getPlatformMBeanServer()); + tested = baseJMXRegistrator.createRuntimeBeanRegistrator(moduleIdentifier); } @After @@ -65,8 +60,8 @@ public class RuntimeBeanRegistratorImplTest extends try { platformMBeanServer.getMBeanInfo(on); fail(); - } catch (InstanceNotFoundException e) { - + } catch (final InstanceNotFoundException e) { + // FIXME: should it be empty? } } @@ -75,13 +70,11 @@ public class RuntimeBeanRegistratorImplTest extends createRoot(); } - private HierarchicalRuntimeBeanRegistrationImpl createRoot() - throws Exception { - HierarchicalRuntimeBeanRegistrationImpl rootRegistration = tested - .registerRoot(new TestingRuntimeBean()); + private HierarchicalRuntimeBeanRegistrationImpl createRoot() throws Exception { + HierarchicalRuntimeBeanRegistrationImpl rootRegistration = tested.registerRoot(new TestingRuntimeBean()); - ObjectName expectedON1 = ObjectNameUtil.createRuntimeBeanName(module1, - INSTANCE_NAME, Maps. newHashMap()); + ObjectName expectedON1 = ObjectNameUtil.createRuntimeBeanName(MODULE1, INSTANCE_NAME, + Maps.newHashMap()); assertEquals(expectedON1, rootRegistration.getObjectName()); checkExists(rootRegistration.getObjectName()); @@ -95,14 +88,12 @@ public class RuntimeBeanRegistratorImplTest extends } private HierarchicalRuntimeBeanRegistration createAdditional( - final HierarchicalRuntimeBeanRegistrationImpl rootRegistration) - throws Exception { + final HierarchicalRuntimeBeanRegistrationImpl rootRegistration) throws Exception { - HierarchicalRuntimeBeanRegistrationImpl registration = rootRegistration - .register(additionalKey, additionalValue, new TestingRuntimeBean()); + HierarchicalRuntimeBeanRegistrationImpl registration = rootRegistration.register(additionalKey, additionalValue, + new TestingRuntimeBean()); - ObjectName expectedON1 = ObjectNameUtil.createRuntimeBeanName(module1, - INSTANCE_NAME, additionalProperties); + ObjectName expectedON1 = ObjectNameUtil.createRuntimeBeanName(MODULE1, INSTANCE_NAME, additionalProperties); assertEquals(expectedON1, registration.getObjectName()); checkExists(registration.getObjectName()); @@ -137,13 +128,10 @@ public class RuntimeBeanRegistratorImplTest extends try { createRoot(); fail(); - } catch (IllegalStateException e) { - assertThat(e.getMessage(), containsString(rootRegistration - .getObjectName().toString())); - assertThat(e.getMessage(), - containsString("Could not register runtime bean")); - assertThat(e.getMessage(), - containsString(moduleIdentifier.toString())); + } catch (final IllegalStateException e) { + assertThat(e.getMessage(), containsString(rootRegistration.getObjectName().toString())); + assertThat(e.getMessage(), containsString("Could not register runtime bean")); + assertThat(e.getMessage(), containsString(moduleIdentifier.toString())); } } @@ -153,5 +141,4 @@ public class RuntimeBeanRegistratorImplTest extends platformMBeanServer.unregisterMBean(rootRegistration.getObjectName()); rootRegistration.close(); } - }