|
95 | 95 | import org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter;
|
96 | 96 | import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
|
97 | 97 | import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
|
| 98 | +import org.springframework.web.servlet.mvc.ParameterizableViewController; |
98 | 99 | import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter;
|
99 | 100 | import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder;
|
100 | 101 | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
|
@@ -648,9 +649,17 @@ public void testViewControllersDefaultConfig() {
|
648 | 649 |
|
649 | 650 | SimpleUrlHandlerMapping hm = this.appContext.getBean(SimpleUrlHandlerMapping.class);
|
650 | 651 | assertNotNull(hm);
|
651 |
| - assertNotNull(hm.getUrlMap().get("/path")); |
652 |
| - assertNotNull(hm.getUrlMap().get("/old")); |
653 |
| - assertNotNull(hm.getUrlMap().get("/bad")); |
| 652 | + ParameterizableViewController viewController = (ParameterizableViewController) hm.getUrlMap().get("/path"); |
| 653 | + assertNotNull(viewController); |
| 654 | + assertEquals("home", viewController.getViewName()); |
| 655 | + |
| 656 | + ParameterizableViewController redirectViewController = (ParameterizableViewController) hm.getUrlMap().get("/old"); |
| 657 | + assertNotNull(redirectViewController); |
| 658 | + assertThat(redirectViewController.getView(), Matchers.instanceOf(RedirectView.class)); |
| 659 | + |
| 660 | + ParameterizableViewController statusViewController = (ParameterizableViewController) hm.getUrlMap().get("/bad"); |
| 661 | + assertNotNull(statusViewController); |
| 662 | + assertEquals(404, statusViewController.getStatusCode().value()); |
654 | 663 |
|
655 | 664 | BeanNameUrlHandlerMapping beanNameMapping = this.appContext.getBean(BeanNameUrlHandlerMapping.class);
|
656 | 665 | assertNotNull(beanNameMapping);
|
|
0 commit comments