@Test
public void shouldReturnSizeOfQueue() throws Exception {

    final String destinationName = "queue-name";
    final Queue queue = mock(Queue.class);
    final Connection connection = mock(Connection.class);
    final Session session = mock(Session.class);
    final QueueBrowser queueBrowser = mock(QueueBrowser.class);
    final Message message = mock(Message.class);
    when(destinationProvider.getDestination(destinationName)).thenReturn(queue);
    when(connectionFactory.createConnection()).thenReturn(connection);
    when(connection.createSession(false, AUTO_ACKNOWLEDGE)).thenReturn(session);
    when(session.createBrowser(queue)).thenReturn(queueBrowser);
    when(queueBrowser.getEnumeration()).thenReturn(enumeration(asList(message, message, message, message, message)));
    final int queueSize = jmsQueueBrowser.sizeOf(destinationName);
    assertThat(queueSize, is(5));
}