use of cn.taketoday.web.servlet.DispatcherServlet in project today-framework by TAKETODAY.
the class ResourceHttpRequestHandlerIntegrationTests method initDispatcherServlet.
private DispatcherServlet initDispatcherServlet(Class<?>... configClasses) throws ServletException {
AnnotationConfigServletWebApplicationContext context = new AnnotationConfigServletWebApplicationContext();
context.setServletContext(this.servletContext);
context.register(configClasses);
context.refresh();
DispatcherServlet servlet = new DispatcherServlet(context);
// servlet.setApplicationContext(context);
servlet.init(this.servletConfig);
return servlet;
}
use of cn.taketoday.web.servlet.DispatcherServlet in project today-framework by TAKETODAY.
the class ResourceHttpRequestHandlerIntegrationTests method classpathLocationWithEncodedPath.
@ParameterizedTest
@MethodSource("argumentSource")
void classpathLocationWithEncodedPath(boolean usePathPatterns, String pathPrefix) throws Exception {
MockHttpServletRequest request = initRequest(pathPrefix + "/test/foo with spaces.css");
MockHttpServletResponse response = new MockHttpServletResponse();
DispatcherServlet servlet = initDispatcherServlet(WebConfig.class);
servlet.service(request, response);
String description = "usePathPattern=" + usePathPatterns + ", prefix=" + pathPrefix;
assertThat(response.getStatus()).as(description).isEqualTo(200);
assertThat(response.getContentType()).as(description).isEqualTo("text/css");
assertThat(response.getContentAsString()).as(description).isEqualTo("h1 { color:red; }");
}
use of cn.taketoday.web.servlet.DispatcherServlet in project today-infrastructure by TAKETODAY.
the class ResourceHttpRequestHandlerIntegrationTests method initDispatcherServlet.
private DispatcherServlet initDispatcherServlet(Class<?>... configClasses) throws ServletException {
AnnotationConfigServletWebApplicationContext context = new AnnotationConfigServletWebApplicationContext();
context.setServletContext(this.servletContext);
context.register(configClasses);
context.refresh();
DispatcherServlet servlet = new DispatcherServlet(context);
// servlet.setApplicationContext(context);
servlet.init(this.servletConfig);
return servlet;
}
use of cn.taketoday.web.servlet.DispatcherServlet in project today-infrastructure by TAKETODAY.
the class ResourceHttpRequestHandlerIntegrationTests method cssFile.
@ParameterizedTest
@MethodSource("argumentSource")
void cssFile(boolean usePathPatterns, String pathPrefix) throws Exception {
MockHttpServletRequest request = initRequest(pathPrefix + "/test/foo.css");
MockHttpServletResponse response = new MockHttpServletResponse();
DispatcherServlet servlet = initDispatcherServlet(WebConfig.class);
servlet.service(request, response);
String description = "usePathPattern=" + usePathPatterns + ", prefix=" + pathPrefix;
assertThat(response.getStatus()).as(description).isEqualTo(200);
assertThat(response.getContentType()).as(description).isEqualTo("text/css");
assertThat(response.getContentAsString()).as(description).isEqualTo("h1 { color:red; }");
}
Aggregations