@Test
public void testDeleteTemporaryQueueAfterConnectionIsClosed() throws Exception {
SimpleString queue = RandomUtil.randomSimpleString();
SimpleString address = RandomUtil.randomSimpleString();
session.createTemporaryQueue(address, queue);
RemotingConnectionImpl conn = (RemotingConnectionImpl) server.getRemotingService().getConnections().iterator().next();
final CountDownLatch latch = new CountDownLatch(1);
conn.addCloseListener(new CloseListener() {
@Override
public void connectionClosed() {
latch.countDown();
}
});
session.close();
sf.close();
assertTrue("connection close listeners not fired", latch.await(2 * TemporaryQueueTest.CONNECTION_TTL, TimeUnit.MILLISECONDS));
sf = addSessionFactory(createSessionFactory(locator));
session = sf.createSession(false, true, true);
session.start();
try {
session.createConsumer(queue);
fail("temp queue must not exist after the remoting connection is closed");
} catch (ActiveMQNonExistentQueueException neqe) {
} catch (ActiveMQException e) {
fail("Invalid Exception type:" + e.getType());
}
session.close();
}