@SuppressWarnings({"unchecked", "rawtypes"})

@Test
public void shouldGetConnectorUsingEmptyCredentials() throws Exception
{
    String                                   url        = "service:jmx:rmi:///jndi/rmi://localhost:40000/jmxrmi";
    DeferredJMXConnector.JMXConnectorBuilder builder    = mock(DeferredJMXConnector.JMXConnectorBuilder.class);
    JMXConnector                             connector  = mock(JMXConnector.class);
    JMXServiceURL                            serviceURL = new JMXServiceURL(url);
    when(builder.realize(eq(serviceURL), anyMap())).thenReturn(connector);
    DeferredJMXConnector deferred = new DeferredJMXConnector(url, builder);
    deferred.get();
    ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class);
    verify(builder).realize(eq(serviceURL), captor.capture());
    Map env = captor.getValue();
    assertThat((String[]) env.get(JMXConnector.CREDENTIALS), is(arrayContaining("", "")));
}