@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);
    }
  }
}