@Test
public void testExceptionsAsWarnings2() 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());
    mbh.register(ms, new String [] {InstanceAlreadyExistsException.class.getName(), NullPointerException.class.getName()});
    assertEquals(0, registrations.size());
    Mockito.verify(ml, Mockito.times(1)).warn(Mockito.anyString(), Mockito.isA(NullPointerException.class));
}