|
39 | 39 | import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
40 | 40 |
|
41 | 41 | import static org.hamcrest.Matchers.equalTo;
|
| 42 | +import static org.hamcrest.Matchers.instanceOf; |
| 43 | +import static org.hamcrest.Matchers.not; |
42 | 44 | import static org.junit.Assert.assertEquals;
|
43 | 45 | import static org.junit.Assert.assertNotNull;
|
44 | 46 | import static org.junit.Assert.assertNull;
|
45 | 47 | import static org.junit.Assert.assertSame;
|
46 | 48 | import static org.junit.Assert.assertThat;
|
| 49 | +import static org.mockito.Mockito.mock; |
47 | 50 |
|
48 | 51 | /**
|
49 | 52 | * Tests for {@link MultipartAutoConfiguration}. Tests an empty configuration, no
|
@@ -165,6 +168,16 @@ public Object getProperty(String name) {
|
165 | 168 | assertEquals(0, this.context.getBeansOfType(MultipartConfigElement.class).size());
|
166 | 169 | }
|
167 | 170 |
|
| 171 | + @Test |
| 172 | + public void containerWithCustomMulipartResolver() throws Exception { |
| 173 | + this.context = new AnnotationConfigEmbeddedWebApplicationContext( |
| 174 | + ContainerWithCustomMultipartResolver.class, BaseConfiguration.class); |
| 175 | + MultipartResolver multipartResolver = this.context |
| 176 | + .getBean(MultipartResolver.class); |
| 177 | + assertThat(multipartResolver, |
| 178 | + not(instanceOf(StandardServletMultipartResolver.class))); |
| 179 | + } |
| 180 | + |
168 | 181 | private void verifyServletWorks() {
|
169 | 182 | RestTemplate restTemplate = new RestTemplate();
|
170 | 183 | assertEquals("Hello", restTemplate.getForObject("http://localhost:"
|
@@ -243,6 +256,15 @@ WebController webController() {
|
243 | 256 |
|
244 | 257 | }
|
245 | 258 |
|
| 259 | + public static class ContainerWithCustomMultipartResolver { |
| 260 | + |
| 261 | + @Bean |
| 262 | + MultipartResolver multipartResolver() { |
| 263 | + return mock(MultipartResolver.class); |
| 264 | + } |
| 265 | + |
| 266 | + } |
| 267 | + |
246 | 268 | @Controller
|
247 | 269 | public static class WebController {
|
248 | 270 |
|
|
0 commit comments