@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); }