JmsUtils { public static void deleteTemporaryDestination(Destination d) { if (d == null) return; if (d instanceof TemporaryQueue) { deleteQuietly((TemporaryQueue) d); } if (d instanceof TemporaryTopic) { deleteQuietly((TemporaryTopic) d); } }  static JMSException wrapJMSException(Throwable e); static JMSException wrapJMSException(String msg, Throwable e); static void rethrowJMSException(Throwable e); static void rethrowJMSException(String msg, Throwable e); static void deleteQuietly(TemporaryQueue q); static void deleteQuietly(TemporaryTopic t); static void deleteTemporaryDestination(Destination d); static void closeQuietly(Connection con); static void closeQuietly(Connection con, boolean stopFirst); static void stopQuietly(Connection con); static void closeQuietly(Session session); static void closeQuietly(MessageProducer producer); static void closeQuietly(MessageConsumer consumer);  }
@Test public void testDeleteTemporaryDestination() throws Exception { EmbeddedActiveMq broker = new EmbeddedActiveMq(); try { broker.start(); Session session = broker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE); Destination dest = session.createTemporaryQueue(); JmsUtils.deleteTemporaryDestination(dest); dest = session.createTemporaryTopic(); JmsUtils.deleteTemporaryDestination(dest); JmsUtils.deleteTemporaryDestination(null); dest = (TemporaryQueue) Proxy.newProxyInstance(TemporaryQueue.class.getClassLoader(), new Class[] { TemporaryQueue.class }, new FailingDynamicProxy()); JmsUtils.deleteTemporaryDestination(dest); dest = session.createQueue("myQueue"); JmsUtils.deleteTemporaryDestination(dest); JmsUtils.closeQuietly(session); } finally { broker.destroy(); } }