### Question:
JMXAgent implements NotificationListener { public static boolean unregisterMBean(ObjectName oName) { boolean unregistered = false; if (null != oName) { try { if (mbs.isRegistered(oName)) { log.debug("Mbean is registered"); mbs.unregisterMBean(oName); unregistered = !mbs.isRegistered(oName); } else { log.debug("Mbean is not currently registered"); } } catch (Exception e) { log.warn("Exception unregistering mbean {}", e); } } log.debug("leaving unregisterMBean..."); return unregistered; }  static String trimClassName(String className); @SuppressWarnings("unchecked") static boolean registerMBean(Object instance, String className,
			Class interfaceClass); @SuppressWarnings("unchecked") static boolean registerMBean(Object instance, String className,
			Class interfaceClass, ObjectName name); @SuppressWarnings("unchecked") static boolean registerMBean(Object instance, String className,
			Class interfaceClass, String name); static void shutdown(); static boolean unregisterMBean(ObjectName oName); static boolean updateMBeanAttribute(ObjectName oName, String key,
			int value); static boolean updateMBeanAttribute(ObjectName oName, String key,
			String value); void handleNotification(Notification notification, Object handback); void init(); void setEnableRmiAdapter(boolean enableRmiAdapter); void setEnableRmiAdapter(String enableRmiAdapterString); void setEnableSsl(boolean enableSsl); void setEnableSsl(String enableSslString); void setRemoteAccessProperties(String remoteAccessProperties); void setRemotePasswordProperties(String remotePasswordProperties); void setRemoteSSLKeystore(String remoteSSLKeystore); void setRemoteSSLKeystorePass(String remoteSSLKeystorePass); void setRmiAdapterRemotePort(String rmiAdapterRemotePort); void setRmiAdapterPort(String rmiAdapterPort); void setRmiAdapterHost(String rmiAdapterHost); void setStartRegistry(boolean startRegistry); void setEnableMinaMonitor(boolean enableMinaMonitor); void setEnableMinaMonitor(String enableMinaMonitor); static boolean isEnableMinaMonitor();  }### Answer:
@Test public void testUnregisterMBean() throws Exception { logger.info("Default jmx domain: {}", JMXFactory.getDefaultDomain()); JMXAgent agent = new JMXAgent(); agent.init(); MBeanServer mbs = JMXFactory.getMBeanServer(); ObjectName oName = JMXFactory.createMBean( "org.red5.server.net.rtmp.RTMPMinaConnection", "connectionType=persistent,host=10.0.0.1,port=1935,clientId=1"); assertNotNull(oName); ObjectName oName2 = new ObjectName( "org.red5.server:type=RTMPMinaConnection,connectionType=persistent,host=10.0.0.2,port=1935,clientId=2"); logger.info("Register check 1: {}", mbs.isRegistered(oName)); assertTrue(JMXAgent.unregisterMBean(oName)); logger.info("Register check 2: {}", mbs.isRegistered(oName)); assertFalse(JMXAgent.unregisterMBean(oName)); logger.info("Register check 3: {}", mbs.isRegistered(oName2)); assertFalse(JMXAgent.unregisterMBean(oName2)); }