Java源码示例:org.springframework.mock.web.MockAsyncContext

示例1
@Before
public void setUp() {
    provider = new SseEventSinkContextProvider();
    
    final Exchange exchange = mock(Exchange.class);
    final Endpoint endpoint = mock(Endpoint.class);
    final ContinuationProvider continuationProvider = mock(ContinuationProvider.class);
    
    final MockHttpServletResponse response = new MockHttpServletResponse();
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final MockAsyncContext ctx = new MockAsyncContext(request, response) {
        @Override
        public void start(Runnable runnable) {
            /* do nothing */
        } 
    };
    request.setAsyncContext(ctx);
    
    message = new MessageImpl();
    message.setExchange(exchange);
    message.put(ContinuationProvider.class.getName(), continuationProvider);
    message.put(AbstractHTTPDestination.HTTP_REQUEST, request);
    
    when(exchange.getEndpoint()).thenReturn(endpoint);
}
 
示例2
@SuppressWarnings("unchecked")
@Before
public void setUp() {
    broadcaster = new SseBroadcasterImpl();
    response = new MockHttpServletResponse();
    writer = mock(MessageBodyWriter.class);
    ctx = new MockAsyncContext(new MockHttpServletRequest(), response);
}