cntorServer.stop();
}
public void testTwoConnectorServers() throws Exception
{
JMXConnectorServer cntorServer1 = null;
JMXConnectorServer cntorServer2 = null;
JMXConnector cntor10 = null;
JMXConnector cntor11 = null;
JMXConnector cntor12 = null;
JMXConnector cntor20 = null;
try
{
JMXServiceURL url1 = createJMXConnectorServerAddress();
JMXServiceURL url2 = new JMXServiceURL(url1.getProtocol(), url1.getHost(), (url1.getPort() > 0) ? (url1.getPort() + 1) : 0, url1.getURLPath());
MBeanServer server = newMBeanServer();
cntorServer1 = JMXConnectorServerFactory.newJMXConnectorServer(url1, getEnvironment(), server);
cntorServer2 = JMXConnectorServerFactory.newJMXConnectorServer(url2, getEnvironment(), server);
cntorServer1.start();
cntorServer2.start();
cntor10 = JMXConnectorFactory.connect(cntorServer1.getAddress(), getEnvironment());
cntor11 = JMXConnectorFactory.connect(cntorServer1.getAddress(), getEnvironment());
cntor12 = JMXConnectorFactory.connect(cntorServer1.getAddress(), getEnvironment());
cntor20 = JMXConnectorFactory.connect(cntorServer2.getAddress(), getEnvironment());
if (cntor10.getConnectionId().equals(cntor11.getConnectionId())) fail();
if (cntor10.getConnectionId().equals(cntor12.getConnectionId())) fail();
if (cntor10.getConnectionId().equals(cntor20.getConnectionId())) fail();
}
finally
{
if (cntor20 != null) cntor20.close();
if (cntor12 != null) cntor12.close();
if (cntor11 != null) cntor11.close();
if (cntor10 != null) cntor10.close();
if (cntorServer2 != null) cntorServer2.stop();
if (cntorServer1 != null) cntorServer1.stop();
}
}