use of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter in project spring-framework by spring-projects.
the class StandaloneMockMvcBuilder method registerMvcSingletons.
private void registerMvcSingletons(StubWebApplicationContext wac) {
StandaloneConfiguration config = new StandaloneConfiguration();
config.setApplicationContext(wac);
wac.addBeans(this.controllerAdvice);
StaticRequestMappingHandlerMapping hm = config.getHandlerMapping();
hm.setServletContext(wac.getServletContext());
hm.setApplicationContext(wac);
hm.afterPropertiesSet();
hm.registerHandlers(this.controllers);
wac.addBean("requestMappingHandlerMapping", hm);
RequestMappingHandlerAdapter handlerAdapter = config.requestMappingHandlerAdapter();
handlerAdapter.setServletContext(wac.getServletContext());
handlerAdapter.setApplicationContext(wac);
handlerAdapter.afterPropertiesSet();
wac.addBean("requestMappingHandlerAdapter", handlerAdapter);
wac.addBean("handlerExceptionResolver", config.handlerExceptionResolver());
wac.addBeans(initViewResolvers(wac));
wac.addBean(DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME, this.localeResolver);
wac.addBean(DispatcherServlet.THEME_RESOLVER_BEAN_NAME, new FixedThemeResolver());
wac.addBean(DispatcherServlet.REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME, new DefaultRequestToViewNameTranslator());
this.flashMapManager = new SessionFlashMapManager();
wac.addBean(DispatcherServlet.FLASH_MAP_MANAGER_BEAN_NAME, this.flashMapManager);
}
use of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter in project spring-boot by spring-projects.
the class HypermediaAutoConfigurationTests method customizationOfSupportedMediaTypesCanBeDisabled.
@Test
public void customizationOfSupportedMediaTypesCanBeDisabled() {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(BaseConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, "spring.hateoas.use-hal-as-default-json-media-type:false");
this.context.refresh();
RequestMappingHandlerAdapter handlerAdapter = this.context.getBean(RequestMappingHandlerAdapter.class);
for (HttpMessageConverter<?> converter : handlerAdapter.getMessageConverters()) {
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
assertThat(converter.getSupportedMediaTypes()).containsExactly(MediaTypes.HAL_JSON);
}
}
}
use of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method overrideIgnoreDefaultModelOnRedirect.
@Test
public void overrideIgnoreDefaultModelOnRedirect() throws Exception {
this.context = new AnnotationConfigServletWebServerApplicationContext();
EnvironmentTestUtils.addEnvironment(this.context, "spring.mvc.ignore-default-model-on-redirect:false");
this.context.register(Config.class, WebMvcAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
RequestMappingHandlerAdapter adapter = this.context.getBean(RequestMappingHandlerAdapter.class);
assertThat(adapter).extracting("ignoreDefaultModelOnRedirect").containsExactly(false);
}
use of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method ignoreDefaultModelOnRedirectIsTrue.
@Test
public void ignoreDefaultModelOnRedirectIsTrue() throws Exception {
load();
RequestMappingHandlerAdapter adapter = this.context.getBean(RequestMappingHandlerAdapter.class);
assertThat(adapter).extracting("ignoreDefaultModelOnRedirect").containsExactly(true);
}
use of org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method customAsyncRequestTimeout.
@Test
public void customAsyncRequestTimeout() throws Exception {
load("spring.mvc.async.request-timeout:123456");
RequestMappingHandlerAdapter adapter = this.context.getBean(RequestMappingHandlerAdapter.class);
Object actual = ReflectionTestUtils.getField(adapter, "asyncRequestTimeout");
assertThat(actual).isEqualTo(123456L);
}
Aggregations