Skip to content

Commit a9fd0d0

Browse files
committed
Polishing.
Related ticket GH-3054.
1 parent e074fcc commit a9fd0d0

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/test/java/org/springframework/data/web/config/EnableSpringDataWebSupportIntegrationTests.java

+16-13
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.List;
2424

2525
import org.junit.jupiter.api.Test;
26-
2726
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
2827
import org.springframework.beans.factory.annotation.Autowired;
2928
import org.springframework.context.ApplicationContext;
@@ -68,7 +67,7 @@ class EnableSpringDataWebSupportIntegrationTests {
6867

6968
@Configuration
7069
@EnableWebMvc
71-
@EnableSpringDataWebSupport(pageSerializationMode = EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO)
70+
@EnableSpringDataWebSupport
7271
static class SampleConfig {
7372

7473
@Bean
@@ -292,35 +291,39 @@ void picksUpEntityPathResolverIfRegistered() {
292291
.isEqualTo(CustomEntityPathResolver.resolver);
293292
}
294293

295-
@Test // GH-3024
296-
void registersSpringDataWebSettingsBean() {
294+
@Test // GH-3024, GH-3054
295+
void doesNotRegistersSpringDataWebSettingsBeanByDefault() {
297296

298297
ApplicationContext context = WebTestUtils.createApplicationContext(SampleConfig.class);
299298

300-
assertThatNoException().isThrownBy(() -> context.getBean(SpringDataWebSettings.class));
299+
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
300+
.isThrownBy(() -> context.getBean(SpringDataWebSettings.class));
301301
assertThatNoException().isThrownBy(() -> context.getBean(PageModule.class));
302302
}
303303

304-
@Test // GH-3024
304+
@Test // GH-3024, GH-3054
305305
void usesDirectPageSerializationMode() throws Exception {
306306

307-
var applicationContext = WebTestUtils.createApplicationContext(PageSampleConfigWithDirect.class);
307+
var context = WebTestUtils.createApplicationContext(PageSampleConfigWithDirect.class);
308308

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));
311311

312-
var mvc = MockMvcBuilders.webAppContextSetup(applicationContext).build();
312+
var mvc = MockMvcBuilders.webAppContextSetup(context).build();
313313

314314
mvc.perform(post("/page"))//
315315
.andExpect(status().isOk()) //
316316
.andExpect(jsonPath("$.pageable").exists());
317317
}
318318

319-
@Test // GH-3024
319+
@Test // GH-3024, GH-3054
320320
void usesViaDtoPageSerializationMode() throws Exception {
321321

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();
324327

325328
mvc.perform(post("/page")) //
326329
.andExpect(status().isOk()) //

0 commit comments

Comments
 (0)