conf.setJMXManagementEnabled(true);
conf.getAcceptorConfigurations().add(acceptorConfig);
service = HornetQServers.newHornetQServer(conf, mbeanServer, false);
service.start();
AcceptorControl acceptorControl = createManagementControl(acceptorConfig.getName());
// started by the server
Assert.assertTrue(acceptorControl.isStarted());
ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName()));
ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = sf.createSession(false, true, true);
Assert.assertNotNull(session);
session.close();
acceptorControl.stop();
Assert.assertFalse(acceptorControl.isStarted());
try
{
sf.createSession(false, true, true);
Assert.fail("acceptor must not accept connections when stopped accepting");
}
catch (Exception e)
{
}
acceptorControl.start();
Assert.assertTrue(acceptorControl.isStarted());
locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName()));
sf = locator.createSessionFactory();
session = sf.createSession(false, true, true);
Assert.assertNotNull(session);
session.close();
acceptorControl.stop();
Assert.assertFalse(acceptorControl.isStarted());
try
{
sf.createSession(false, true, true);
Assert.fail("acceptor must not accept connections when stopped accepting");