|
23 | 23 | import java.util.List;
|
24 | 24 |
|
25 | 25 | import org.junit.jupiter.api.Test;
|
26 |
| - |
27 | 26 | import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
28 | 27 | import org.springframework.beans.factory.annotation.Autowired;
|
29 | 28 | import org.springframework.context.ApplicationContext;
|
@@ -68,7 +67,7 @@ class EnableSpringDataWebSupportIntegrationTests {
|
68 | 67 |
|
69 | 68 | @Configuration
|
70 | 69 | @EnableWebMvc
|
71 |
| - @EnableSpringDataWebSupport(pageSerializationMode = EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO) |
| 70 | + @EnableSpringDataWebSupport |
72 | 71 | static class SampleConfig {
|
73 | 72 |
|
74 | 73 | @Bean
|
@@ -292,35 +291,39 @@ void picksUpEntityPathResolverIfRegistered() {
|
292 | 291 | .isEqualTo(CustomEntityPathResolver.resolver);
|
293 | 292 | }
|
294 | 293 |
|
295 |
| - @Test // GH-3024 |
296 |
| - void registersSpringDataWebSettingsBean() { |
| 294 | + @Test // GH-3024, GH-3054 |
| 295 | + void doesNotRegistersSpringDataWebSettingsBeanByDefault() { |
297 | 296 |
|
298 | 297 | ApplicationContext context = WebTestUtils.createApplicationContext(SampleConfig.class);
|
299 | 298 |
|
300 |
| - assertThatNoException().isThrownBy(() -> context.getBean(SpringDataWebSettings.class)); |
| 299 | + assertThatExceptionOfType(NoSuchBeanDefinitionException.class) |
| 300 | + .isThrownBy(() -> context.getBean(SpringDataWebSettings.class)); |
301 | 301 | assertThatNoException().isThrownBy(() -> context.getBean(PageModule.class));
|
302 | 302 | }
|
303 | 303 |
|
304 |
| - @Test // GH-3024 |
| 304 | + @Test // GH-3024, GH-3054 |
305 | 305 | void usesDirectPageSerializationMode() throws Exception {
|
306 | 306 |
|
307 |
| - var applicationContext = WebTestUtils.createApplicationContext(PageSampleConfigWithDirect.class); |
| 307 | + var context = WebTestUtils.createApplicationContext(PageSampleConfigWithDirect.class); |
308 | 308 |
|
309 |
| - // SpringDataWebSettings shouldn't be registered if pageSerializationMode is default |
310 |
| - assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> applicationContext.getBean(SpringDataWebSettings.class)); |
| 309 | + assertThatExceptionOfType(NoSuchBeanDefinitionException.class) |
| 310 | + .isThrownBy(() -> context.getBean(SpringDataWebSettings.class)); |
311 | 311 |
|
312 |
| - var mvc = MockMvcBuilders.webAppContextSetup(applicationContext).build(); |
| 312 | + var mvc = MockMvcBuilders.webAppContextSetup(context).build(); |
313 | 313 |
|
314 | 314 | mvc.perform(post("/page"))//
|
315 | 315 | .andExpect(status().isOk()) //
|
316 | 316 | .andExpect(jsonPath("$.pageable").exists());
|
317 | 317 | }
|
318 | 318 |
|
319 |
| - @Test // GH-3024 |
| 319 | + @Test // GH-3024, GH-3054 |
320 | 320 | void usesViaDtoPageSerializationMode() throws Exception {
|
321 | 321 |
|
322 |
| - var applicationContext = WebTestUtils.createApplicationContext(PageSampleConfigWithViaDto.class); |
323 |
| - var mvc = MockMvcBuilders.webAppContextSetup(applicationContext).build(); |
| 322 | + var context = WebTestUtils.createApplicationContext(PageSampleConfigWithViaDto.class); |
| 323 | + |
| 324 | + assertThatNoException().isThrownBy(() -> context.getBean(SpringDataWebSettings.class)); |
| 325 | + |
| 326 | + var mvc = MockMvcBuilders.webAppContextSetup(context).build(); |
324 | 327 |
|
325 | 328 | mvc.perform(post("/page")) //
|
326 | 329 | .andExpect(status().isOk()) //
|
|
0 commit comments