@Test
public void shouldThrowExceptionIfJmsExceptionIsThrown() throws Exception {

    final String destinationName = "destination name";
    final JsonEnvelope jsonEnvelope = mock(JsonEnvelope.class);
    final Metadata metadata = mock(Metadata.class);
    final Destination destination = mock(Destination.class);
    when(destinationProvider.getDestination(destinationName)).thenReturn(destination);
    when(connectionFactory.createConnection()).thenThrow(new JMSException("Test exception"));
    when(jsonEnvelope.metadata()).thenReturn(metadata);
    when(metadata.name()).thenReturn("command.test");
    try {
        jmsSender.send(jsonEnvelope, destinationName);
        fail();
    } catch (final JmsEnvelopeSenderException e) {
        assertThat(e.getMessage(), is("Exception while sending envelope with name command.test"));
    }
}