MBeans { static public ObjectName register(String serviceName, String nameName, Object theMbean) { return register(serviceName, nameName, new HashMap<String, String>(), theMbean); } private  MBeans(); static ObjectName register(String serviceName, String nameName,
                                    Object theMbean); static ObjectName register(String serviceName, String nameName,
                                    Map<String, String> properties,
                                    Object theMbean); static String getMbeanNameService(final ObjectName objectName); static String getMbeanNameName(final ObjectName objectName); static void unregister(ObjectName mbeanName);  }
@Test public void testRegister() throws Exception { ObjectName objectName = null; try { counter = 23; objectName = MBeans.register("UnitTest", "RegisterTest", this); MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); int jmxCounter = (int) platformMBeanServer .getAttribute(objectName, "Counter"); Assert.assertEquals(counter, jmxCounter); } finally { if (objectName != null) { MBeans.unregister(objectName); } } }