### Question:
RoutingTableProviderMonitor extends DynamicMBeanProvider { @Override public RoutingTableProviderMonitor register() throws JMException { List<DynamicMetric<?, ?>> attributeList = new ArrayList<>(); attributeList.add(_dataRefreshLatencyGauge); attributeList.add(_callbackCounter); attributeList.add(_eventQueueSizeGauge); attributeList.add(_dataRefreshCounter); if (_statePropLatencyGauge != null) { attributeList.add(_statePropLatencyGauge); } doRegister(attributeList, MBEAN_DESCRIPTION, getMBeanName()); return this; } RoutingTableProviderMonitor(final PropertyType propertyType, String clusterName); @Override String getSensorName(); void increaseCallbackCounters(long currentQueueSize); void increaseDataRefreshCounters(long startTime); void recordStatePropagationLatency(long latency); @Override RoutingTableProviderMonitor register(); static final String DATA_TYPE_KEY; static final String CLUSTER_KEY; static final String DEFAULT; }### Answer:
@Test public void testMBeanRegisteration() throws JMException { Set<RoutingTableProviderMonitor> monitors = new HashSet<>(); for (PropertyType type : PropertyType.values()) { monitors.add(new RoutingTableProviderMonitor(type, TEST_CLUSTER).register()); Assert.assertTrue(_beanServer.isRegistered(buildObjectName(type, TEST_CLUSTER))); } for (PropertyType type : PropertyType.values()) { monitors.add(new RoutingTableProviderMonitor(type, TEST_CLUSTER).register()); Assert.assertTrue(_beanServer.isRegistered(buildObjectName(type, TEST_CLUSTER, 1))); } for (PropertyType type : PropertyType.values()) { monitors.add(new RoutingTableProviderMonitor(type, TEST_CLUSTER).register()); Assert.assertTrue(_beanServer.isRegistered(buildObjectName(type, TEST_CLUSTER, 2))); } for (RoutingTableProviderMonitor monitor : monitors) { monitor.unregister(); } for (PropertyType type : PropertyType.values()) { Assert.assertFalse(_beanServer.isRegistered(buildObjectName(type, TEST_CLUSTER))); Assert.assertFalse(_beanServer.isRegistered(buildObjectName(type, TEST_CLUSTER, 1))); Assert.assertFalse(_beanServer.isRegistered(buildObjectName(type, TEST_CLUSTER, 2))); } }