ShutteringJmsEnvelopeSender implements JmsEnvelopeSender { @Override public void send(final JsonEnvelope envelope, final String destinationName) { envelopeSenderSelector.getEnvelopeSender().send(envelope, destinationName); } ShutteringJmsEnvelopeSender(final EnvelopeSenderSelector envelopeSenderSelector); @Override void send(final JsonEnvelope envelope, final String destinationName);  }
@Test public void shouldPublishValidEnvelopeToDestination() throws Exception { final String destinationName = "destination name"; final JsonEnvelope jsonEnvelope = mock(JsonEnvelope.class); final EnvelopeSender envelopeSender = mock(EnvelopeSender.class); when(envelopeSenderSelector.getEnvelopeSender()).thenReturn(envelopeSender); shutteringJmsEnvelopeSender.send(jsonEnvelope, destinationName); verify(envelopeSender).send(jsonEnvelope, destinationName); }