SystemCommanderClient implements Closeable { public SystemCommanderMBean getRemote(final String contextName) { return mBeanConnector.connect( contextName, SystemCommanderMBean.class, jmxConnector ); } SystemCommanderClient(final JMXConnector jmxConnector, final MBeanConnector mBeanConnector); SystemCommanderMBean getRemote(final String contextName); @Override void close();  }
@Test public void shouldGetTheRemoteSystemCommanderMBean() throws Exception { final String contextName = "my-context"; final SystemCommanderMBean systemCommanderMBean = mock(SystemCommanderMBean.class); when(mBeanConnector.connect( contextName, SystemCommanderMBean.class, jmxConnector)).thenReturn(systemCommanderMBean); assertThat(systemCommanderClient.getRemote(contextName), is(systemCommanderMBean)); }