|
142 | 142 | import org.springframework.web.servlet.view.AbstractView; |
143 | 143 | import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; |
144 | 144 | import org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator; |
| 145 | +import org.springframework.web.servlet.view.InternalResourceViewResolver; |
145 | 146 | import org.springframework.web.util.UrlPathHelper; |
146 | 147 |
|
147 | 148 | import static org.assertj.core.api.Assertions.assertThat; |
|
160 | 161 | * @author Artsiom Yudovin |
161 | 162 | * @author Scott Frederick |
162 | 163 | * @author Vedran Pavic |
| 164 | + * @author daewon kim |
163 | 165 | */ |
164 | 166 | class WebMvcAutoConfigurationTests { |
165 | 167 |
|
@@ -1028,6 +1030,22 @@ void problemDetailsExceptionHandlerIsOrderedAt0() { |
1028 | 1030 | OrderedControllerAdviceBeansConfiguration.LowestOrderedControllerAdvice.class)); |
1029 | 1031 | } |
1030 | 1032 |
|
| 1033 | + @Test |
| 1034 | + void jspViewResolverIsAutoConfiguredWhenJspPrefixIsSet() { |
| 1035 | + this.contextRunner.withConfiguration(AutoConfigurations.of(WebMvcAutoConfiguration.class)) |
| 1036 | + .withPropertyValues("spring.mvc.jsp.prefix=/WEB-INF/views/", "spring.mvc.jsp.suffix=.jsp") |
| 1037 | + .run((context) -> { |
| 1038 | + assertThat(context).hasSingleBean(InternalResourceViewResolver.class); |
| 1039 | + |
| 1040 | + InternalResourceViewResolver resolver = context.getBean(InternalResourceViewResolver.class); |
| 1041 | + String prefix = (String) ReflectionTestUtils.getField(resolver, "prefix"); |
| 1042 | + String suffix = (String) ReflectionTestUtils.getField(resolver, "suffix"); |
| 1043 | + |
| 1044 | + assertThat(prefix).isEqualTo("/WEB-INF/views/"); |
| 1045 | + assertThat(suffix).isEqualTo(".jsp"); |
| 1046 | + }); |
| 1047 | + } |
| 1048 | + |
1031 | 1049 | private void assertResourceHttpRequestHandler(AssertableWebApplicationContext context, |
1032 | 1050 | Consumer<ResourceHttpRequestHandler> handlerConsumer) { |
1033 | 1051 | Map<String, Object> handlerMap = getHandlerMap(context.getBean("resourceHandlerMapping", HandlerMapping.class)); |
|
0 commit comments