@Test public void testCreateQueueFails() throws Exception { when(session.createQueue(destinationName)) .thenThrow(new JMSException("")); try { create(); fail("Expected exception: org.apache.flume.FlumeException"); } catch (FlumeException e) { verify(session).close(); verify(connection).close(); } }
void close() { try { if (session != null) { session.close(); } } catch (JMSException e) { logger.error("Could not destroy session", e); } try { if (connection != null) { connection.close(); } } catch (JMSException e) { logger.error("Could not destroy connection", e); } }
JMSMessageConsumer { void close() { try { if (session != null) { session.close(); } } catch (JMSException e) { logger.error("Could not destroy session", e); } try { if (connection != null) { connection.close(); } } catch (JMSException e) { logger.error("Could not destroy connection", e); } } }
JMSMessageConsumer { void close() { try { if (session != null) { session.close(); } } catch (JMSException e) { logger.error("Could not destroy session", e); } try { if (connection != null) { connection.close(); } } catch (JMSException e) { logger.error("Could not destroy connection", e); } } JMSMessageConsumer(InitialContext initialContext, ConnectionFactory connectionFactory,
                     String destinationName, JMSDestinationLocator destinationLocator,
                     JMSDestinationType destinationType, String messageSelector, int batchSize,
                     long pollTimeout, JMSMessageConverter messageConverter,
                     Optional<String> userName, Optional<String> password,
                     Optional<String> clientId, boolean createDurableSubscription,
                     String durableSubscriptionName); }
JMSMessageConsumer { void close() { try { if (session != null) { session.close(); } } catch (JMSException e) { logger.error("Could not destroy session", e); } try { if (connection != null) { connection.close(); } } catch (JMSException e) { logger.error("Could not destroy connection", e); } } JMSMessageConsumer(InitialContext initialContext, ConnectionFactory connectionFactory,
                     String destinationName, JMSDestinationLocator destinationLocator,
                     JMSDestinationType destinationType, String messageSelector, int batchSize,
                     long pollTimeout, JMSMessageConverter messageConverter,
                     Optional<String> userName, Optional<String> password,
                     Optional<String> clientId, boolean createDurableSubscription,
                     String durableSubscriptionName);  }
JMSMessageConsumer { void close() { try { if (session != null) { session.close(); } } catch (JMSException e) { logger.error("Could not destroy session", e); } try { if (connection != null) { connection.close(); } } catch (JMSException e) { logger.error("Could not destroy connection", e); } } JMSMessageConsumer(InitialContext initialContext, ConnectionFactory connectionFactory,
                     String destinationName, JMSDestinationLocator destinationLocator,
                     JMSDestinationType destinationType, String messageSelector, int batchSize,
                     long pollTimeout, JMSMessageConverter messageConverter,
                     Optional<String> userName, Optional<String> password,
                     Optional<String> clientId, boolean createDurableSubscription,
                     String durableSubscriptionName);   }