@Test
public void shouldThrowJmsQueueBrowserExceptionIfJMSExceptionThrown() throws Exception {

    final String destinationName = "queue-name";
    final Queue queue = mock(Queue.class);
    final JMSException jmsException = new JMSException("Test Message");
    when(destinationProvider.getDestination(destinationName)).thenReturn(queue);
    when(connectionFactory.createConnection()).thenThrow(jmsException);
    try {
        jmsQueueBrowser.sizeOf(destinationName);
        fail();
    } catch (final JmsQueueBrowserException exception) {
        assertThat(exception.getMessage(), is("Failed to connect to queue: 'queue-name', when requesting queue size."));
    }
}