@Test
public void testThrowRuntimeException() throws Exception {

    MBeanHolder mbh = new MBeanHolder(new Object(), new ObjectName("foo:bar=123"));
    Map<?,?> registrations = (Map<?,?>) getPrivateField(mbh, "registrations");
    Logger ml = Mockito.mock(Logger.class);
    setPrivateField(mbh, "log", ml);
    MBeanServer ms = Mockito.mock(MBeanServer.class);
    Mockito.when(ms.registerMBean(Mockito.any(), Mockito.eq(new ObjectName("foo:bar=123")))).
        thenThrow(new NullPointerException());
    assertEquals(0, registrations.size());
    try {
        mbh.register(ms, new String [] {});
        fail("Should have thrown a NullPointerException");
    } catch (NullPointerException npe) {
        // good!
    }
}