JmsUtils { public static void closeQuietly(MessageProducer messageProducer) { if (messageProducer == null) { return; } try { messageProducer.close(); } catch (JMSException e) { LOGGER.error("Error closing MessageProducer", e); } } private  JmsUtils(); static void closeQuietly(MessageProducer messageProducer); static void closeQuietly(MessageConsumer messageConsumer); static void closeQuietly(Session session); static void closeQuietly(Connection connection); static T getFromMessage(Message message, Class<T> tClass); static String getJMSCorrelationID(Message message); static String getJMSMessageID(Message message);  }
@Test public void closeQuietly_whenProducerIsNull_expectNoAction() throws Exception { JmsUtils.closeQuietly((MessageProducer) null); }
@Test public void closeQuietly_whenProducerIsNotNull_expectClose() throws Exception { MessageProducer mockedProducer = Mockito.mock(MessageProducer.class); JmsUtils.closeQuietly(mockedProducer); verify(mockedProducer).close(); }
@Test public void closeQuietly_whenConsumerIsNull_expectNoAction() throws Exception { JmsUtils.closeQuietly((MessageConsumer) null); }
@Test public void closeQuietly_whenConsumerIsNotNull_expectClose() throws Exception { MessageConsumer mockedConsumer = Mockito.mock(MessageConsumer.class); JmsUtils.closeQuietly(mockedConsumer); verify(mockedConsumer).close(); }
@Test public void closeQuietly_whenSessionIsNull_expectNoAction() throws Exception { JmsUtils.closeQuietly((Session) null); }
@Test public void closeQuietly_whenSessionIsNotNull_expectClose() throws Exception { Session mockedSession = Mockito.mock(Session.class); JmsUtils.closeQuietly(mockedSession); verify(mockedSession).close(); }
@Test public void closeQuietly_whenConnectionIsNull_expectNoAction() throws Exception { JmsUtils.closeQuietly((Connection) null); }
@Test public void closeQuietly_whenConnectionIsNotNull_expectClose() throws Exception { Connection mockedConnection = Mockito.mock(Connection.class); JmsUtils.closeQuietly(mockedConnection); verify(mockedConnection).close(); }