Search in sources :

Example 1 with StandardServletAsyncWebRequest

use of cn.taketoday.web.context.async.StandardServletAsyncWebRequest in project today-infrastructure by TAKETODAY.

the class ErrorPageFilterTests method setUpAsyncDispatch.

private void setUpAsyncDispatch() throws Exception {
    this.request.setAsyncSupported(true);
    this.request.setAsyncStarted(true);
    DeferredResult<String> result = new DeferredResult<>();
    ServletRequestContext context = new ServletRequestContext(null, request, response);
    WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(context);
    asyncManager.setAsyncRequest(new StandardServletAsyncWebRequest(context));
    asyncManager.startDeferredResultProcessing(result);
}
Also used : WebAsyncManager(cn.taketoday.web.context.async.WebAsyncManager) StandardServletAsyncWebRequest(cn.taketoday.web.context.async.StandardServletAsyncWebRequest) ServletRequestContext(cn.taketoday.web.servlet.ServletRequestContext) DeferredResult(cn.taketoday.web.context.async.DeferredResult)

Example 2 with StandardServletAsyncWebRequest

use of cn.taketoday.web.context.async.StandardServletAsyncWebRequest in project today-infrastructure by TAKETODAY.

the class ReactiveTypeHandlerTests method resetRequest.

private void resetRequest() {
    this.servletRequest = new MockHttpServletRequest();
    this.servletResponse = new MockHttpServletResponse();
    this.webRequest = new ServletRequestContext(null, this.servletRequest, this.servletResponse);
    AsyncWebRequest webRequest = new StandardServletAsyncWebRequest(this.webRequest);
    WebAsyncUtils.getAsyncManager(this.webRequest).setAsyncRequest(webRequest);
    this.servletRequest.setAsyncSupported(true);
}
Also used : StandardServletAsyncWebRequest(cn.taketoday.web.context.async.StandardServletAsyncWebRequest) MockHttpServletRequest(cn.taketoday.web.mock.MockHttpServletRequest) ServletRequestContext(cn.taketoday.web.servlet.ServletRequestContext) AsyncWebRequest(cn.taketoday.web.context.async.AsyncWebRequest) StandardServletAsyncWebRequest(cn.taketoday.web.context.async.StandardServletAsyncWebRequest) MockHttpServletResponse(cn.taketoday.web.mock.MockHttpServletResponse)

Example 3 with StandardServletAsyncWebRequest

use of cn.taketoday.web.context.async.StandardServletAsyncWebRequest in project today-framework by TAKETODAY.

the class ResponseBodyEmitterReturnValueHandlerTests method setup.

@BeforeEach
public void setup() throws Exception {
    List<HttpMessageConverter<?>> converters = Collections.singletonList(new MappingJackson2HttpMessageConverter());
    this.handler = new ResponseBodyEmitterReturnValueHandler(converters);
    this.request = new MockHttpServletRequest();
    this.response = new MockHttpServletResponse();
    this.webRequest = new ServletRequestContext(null, this.request, this.response);
    AsyncWebRequest asyncWebRequest = new StandardServletAsyncWebRequest(this.request, this.response);
    WebAsyncUtils.getAsyncManager(this.webRequest).setAsyncRequest(asyncWebRequest);
    this.request.setAsyncSupported(true);
}
Also used : StandardServletAsyncWebRequest(cn.taketoday.web.context.async.StandardServletAsyncWebRequest) MappingJackson2HttpMessageConverter(cn.taketoday.http.converter.json.MappingJackson2HttpMessageConverter) MockHttpServletRequest(cn.taketoday.web.testfixture.servlet.MockHttpServletRequest) HttpMessageConverter(cn.taketoday.http.converter.HttpMessageConverter) MappingJackson2HttpMessageConverter(cn.taketoday.http.converter.json.MappingJackson2HttpMessageConverter) ServletRequestContext(cn.taketoday.web.servlet.ServletRequestContext) AsyncWebRequest(cn.taketoday.web.context.async.AsyncWebRequest) StandardServletAsyncWebRequest(cn.taketoday.web.context.async.StandardServletAsyncWebRequest) MockHttpServletResponse(cn.taketoday.web.testfixture.servlet.MockHttpServletResponse) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with StandardServletAsyncWebRequest

use of cn.taketoday.web.context.async.StandardServletAsyncWebRequest in project today-framework by TAKETODAY.

the class ReactiveTypeHandlerTests method resetRequest.

private void resetRequest() {
    this.servletRequest = new MockHttpServletRequest();
    this.servletResponse = new MockHttpServletResponse();
    this.webRequest = new ServletRequestContext(null, this.servletRequest, this.servletResponse);
    AsyncWebRequest webRequest = new StandardServletAsyncWebRequest(this.servletRequest, this.servletResponse);
    WebAsyncUtils.getAsyncManager(this.webRequest).setAsyncRequest(webRequest);
    this.servletRequest.setAsyncSupported(true);
}
Also used : StandardServletAsyncWebRequest(cn.taketoday.web.context.async.StandardServletAsyncWebRequest) MockHttpServletRequest(cn.taketoday.web.testfixture.servlet.MockHttpServletRequest) ServletRequestContext(cn.taketoday.web.servlet.ServletRequestContext) AsyncWebRequest(cn.taketoday.web.context.async.AsyncWebRequest) StandardServletAsyncWebRequest(cn.taketoday.web.context.async.StandardServletAsyncWebRequest) MockHttpServletResponse(cn.taketoday.web.testfixture.servlet.MockHttpServletResponse)

Example 5 with StandardServletAsyncWebRequest

use of cn.taketoday.web.context.async.StandardServletAsyncWebRequest in project today-framework by TAKETODAY.

the class ErrorPageFilterTests method setUpAsyncDispatch.

private void setUpAsyncDispatch() throws Exception {
    this.request.setAsyncSupported(true);
    this.request.setAsyncStarted(true);
    DeferredResult<String> result = new DeferredResult<>();
    ServletRequestContext context = new ServletRequestContext(null, request, response);
    WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(context);
    asyncManager.setAsyncRequest(new StandardServletAsyncWebRequest(request, response));
    asyncManager.startDeferredResultProcessing(result);
}
Also used : WebAsyncManager(cn.taketoday.web.context.async.WebAsyncManager) StandardServletAsyncWebRequest(cn.taketoday.web.context.async.StandardServletAsyncWebRequest) ServletRequestContext(cn.taketoday.web.servlet.ServletRequestContext) DeferredResult(cn.taketoday.web.context.async.DeferredResult)

Aggregations

StandardServletAsyncWebRequest (cn.taketoday.web.context.async.StandardServletAsyncWebRequest)5 ServletRequestContext (cn.taketoday.web.servlet.ServletRequestContext)5 AsyncWebRequest (cn.taketoday.web.context.async.AsyncWebRequest)3 DeferredResult (cn.taketoday.web.context.async.DeferredResult)2 WebAsyncManager (cn.taketoday.web.context.async.WebAsyncManager)2 MockHttpServletRequest (cn.taketoday.web.testfixture.servlet.MockHttpServletRequest)2 MockHttpServletResponse (cn.taketoday.web.testfixture.servlet.MockHttpServletResponse)2 HttpMessageConverter (cn.taketoday.http.converter.HttpMessageConverter)1 MappingJackson2HttpMessageConverter (cn.taketoday.http.converter.json.MappingJackson2HttpMessageConverter)1 MockHttpServletRequest (cn.taketoday.web.mock.MockHttpServletRequest)1 MockHttpServletResponse (cn.taketoday.web.mock.MockHttpServletResponse)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1