use of org.springframework.web.servlet.DispatcherServlet in project pinpoint by naver.
the class SpringWebMvcIT method testRequest.
@Test
public void testRequest() throws Exception {
MockServletConfig config = new MockServletConfig();
MockHttpServletRequest req = new MockHttpServletRequest();
MockHttpServletResponse res = new MockHttpServletResponse();
config.addInitParameter("contextConfigLocation", "classpath:spring-web-test.xml");
req.setMethod("GET");
req.setRequestURI("/");
req.setRemoteAddr("1.2.3.4");
DispatcherServlet servlet = new DispatcherServlet();
servlet.init(config);
servlet.service(req, res);
Method method = FrameworkServlet.class.getDeclaredMethod("doGet", HttpServletRequest.class, HttpServletResponse.class);
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
verifier.printCache();
verifier.verifyTrace(Expectations.event(SPRING_MVC, method));
verifier.verifyTraceCount(0);
}
use of org.springframework.web.servlet.DispatcherServlet in project spring-boot by spring-projects.
the class MultipartAutoConfigurationTests method webServerWithNothing.
@Test
public void webServerWithNothing() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext(WebServerWithNothing.class, BaseConfiguration.class);
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
verify404();
assertThat(servlet.getMultipartResolver()).isNotNull();
assertThat(this.context.getBeansOfType(StandardServletMultipartResolver.class)).hasSize(1);
assertThat(this.context.getBeansOfType(MultipartResolver.class)).hasSize(1);
}
use of org.springframework.web.servlet.DispatcherServlet in project spring-framework by spring-projects.
the class DefaultMockMvcBuilderTests method dispatcherServletCustomizer.
/**
* See /SPR-14277
*/
@Test
public void dispatcherServletCustomizer() {
StubWebApplicationContext root = new StubWebApplicationContext(this.servletContext);
DefaultMockMvcBuilder builder = webAppContextSetup(root);
builder.addDispatcherServletCustomizer(ds -> ds.setContextId("test-id"));
builder.dispatchOptions(true);
MockMvc mvc = builder.build();
DispatcherServlet ds = (DispatcherServlet) new DirectFieldAccessor(mvc).getPropertyValue("servlet");
assertEquals("test-id", ds.getContextId());
}
use of org.springframework.web.servlet.DispatcherServlet in project spring-boot by spring-projects.
the class EndpointWebMvcChildContextConfiguration method dispatcherServlet.
@Bean(name = DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME)
public DispatcherServlet dispatcherServlet() {
DispatcherServlet dispatcherServlet = new DispatcherServlet();
// Ensure the parent configuration does not leak down to us
dispatcherServlet.setDetectAllHandlerAdapters(false);
dispatcherServlet.setDetectAllHandlerExceptionResolvers(false);
dispatcherServlet.setDetectAllHandlerMappings(false);
dispatcherServlet.setDetectAllViewResolvers(false);
return dispatcherServlet;
}
use of org.springframework.web.servlet.DispatcherServlet in project spring-boot by spring-projects.
the class DispatcherServletAutoConfigurationTests method renamesMultipartResolver.
@Test
public void renamesMultipartResolver() throws Exception {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(MultipartResolverConfiguration.class, DispatcherServletAutoConfiguration.class);
this.context.refresh();
DispatcherServlet dispatcherServlet = this.context.getBean(DispatcherServlet.class);
dispatcherServlet.onApplicationEvent(new ContextRefreshedEvent(this.context));
assertThat(dispatcherServlet.getMultipartResolver()).isInstanceOf(MockMultipartResolver.class);
}
Aggregations