@Test(expected = MessageDeliveryException.class)
 public void invokePoxSourceTimeout() throws Exception {
   gateway.setRequestTimeout(10);
   gateway.setReplyTimeout(10);
   when(requestChannel.send(isA(Message.class), anyLong())).thenReturn(false);
   when(request.getPayloadSource()).thenReturn(payloadSource);
   gateway.invoke(context);
 }
 @Test
 public void invokePoxSourceWithReply() throws Exception {
   when(requestChannel.send(isA(Message.class), eq(1000L))).thenAnswer(withReplyTo(replyChannel));
   when(request.getPayloadSource()).thenReturn(payloadSource);
   gateway.start();
   gateway.invoke(context);
   verify(requestChannel).send(messageWithPayload(payloadSource), eq(1000L));
   assertTrue(output.toString().endsWith(input));
 }
 @Before
 public void setup() {
   gateway.setRequestChannel(requestChannel);
   gateway.setReplyChannel(replyChannel);
   gateway.setBeanFactory(mock(BeanFactory.class));
   when(context.getResponse()).thenReturn(response);
   when(response.getPayloadResult()).thenReturn(payloadResult);
   when(context.getRequest()).thenReturn(request);
 }