JMXClient { boolean check(JMXConnector jmx) { if (jmx == null) return false; try { jmx.getConnectionId(); return true; } catch (IOException e) { close(jmx); return false; } } JMXClient(String host); MBeanServerConnection connect();  }
@Test void check() throws IOException { when(connector.getConnectionId()).thenReturn("connectionId"); assertThat(jmxClient.check(connector)).isTrue(); }