public void testExplictTemporaryTopicDeletion() throws Exception
{
final Connection conn = getConnection();
final Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
final TemporaryTopic topic = session.createTemporaryTopic();
assertNotNull(topic);
final MessageConsumer consumer = session.createConsumer(topic);
conn.start();
try
{
topic.delete();
fail("Expected JMSException : should not be able to delete while there are active consumers");
}
catch (JMSException je)
{
//pass
assertEquals("Temporary Topic has consumers so cannot be deleted", je.getMessage());
}
consumer.close();
// Now deletion should succeed.
topic.delete();
try
{
session.createConsumer(topic);
fail("Exception not thrown");