From 9a457527fdeea7d06298d0388773a49c63c38379 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 9 Jun 2020 16:00:50 +0200 Subject: [PATCH 1/4] Polish test --- .../jpa/JpaWebAutoConfigurationTests.java | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jpa/JpaWebAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jpa/JpaWebAutoConfigurationTests.java index 70fa9b33cc..a390799807 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jpa/JpaWebAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/jpa/JpaWebAutoConfigurationTests.java @@ -16,21 +16,21 @@ package org.springframework.boot.autoconfigure.data.jpa; -import org.junit.After; import org.junit.Test; +import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage; -import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.data.jpa.city.City; import org.springframework.boot.autoconfigure.data.jpa.city.CityRepository; import org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration; -import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.context.annotation.Configuration; +import org.springframework.data.geo.Distance; import org.springframework.data.web.PageableHandlerMethodArgumentResolver; +import org.springframework.data.web.SortHandlerMethodArgumentResolver; import org.springframework.format.support.FormattingConversionService; -import org.springframework.mock.web.MockServletContext; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import static org.assertj.core.api.Assertions.assertThat; @@ -40,33 +40,31 @@ import static org.assertj.core.api.Assertions.assertThat; * {@link JpaRepositoriesAutoConfiguration}. * * @author Dave Syer + * @author Stephane Nicoll */ public class JpaWebAutoConfigurationTests { - private AnnotationConfigWebApplicationContext context; - - @After - public void close() { - this.context.close(); - } + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withConfiguration( + AutoConfigurations.of(DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class, + JpaRepositoriesAutoConfiguration.class, SpringDataWebAutoConfiguration.class)) + .withPropertyValues("spring.datasource.generate-unique-name=true"); @Test - public void testDefaultRepositoryConfiguration() { - this.context = new AnnotationConfigWebApplicationContext(); - this.context.setServletContext(new MockServletContext()); - this.context.register(TestConfiguration.class, EmbeddedDataSourceConfiguration.class, - HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class, - SpringDataWebAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class); - this.context.refresh(); - assertThat(this.context.getBean(CityRepository.class)).isNotNull(); - assertThat(this.context.getBean(PageableHandlerMethodArgumentResolver.class)).isNotNull(); - assertThat(this.context.getBean(FormattingConversionService.class).canConvert(Long.class, City.class)).isTrue(); + public void springDataWebIsConfiguredWithJpaRepositories() { + this.contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> { + assertThat(context).hasSingleBean(CityRepository.class); + assertThat(context).hasSingleBean(PageableHandlerMethodArgumentResolver.class); + assertThat(context).hasSingleBean(SortHandlerMethodArgumentResolver.class); + assertThat(context.getBean(FormattingConversionService.class).canConvert(String.class, Distance.class)) + .isTrue(); + }); } @Configuration @TestAutoConfigurationPackage(City.class) @EnableWebMvc - protected static class TestConfiguration { + static class TestConfiguration { } From 79f0e38c54979bd13e70f385a136be43c83eecd6 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 9 Jun 2020 16:16:34 +0200 Subject: [PATCH 2/4] Start building against Spring Data Lovelace-SR18 snapshots See gh-21774 --- spring-boot-project/spring-boot-dependencies/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/pom.xml b/spring-boot-project/spring-boot-dependencies/pom.xml index 1756d973a4..b735a5646c 100644 --- a/spring-boot-project/spring-boot-dependencies/pom.xml +++ b/spring-boot-project/spring-boot-dependencies/pom.xml @@ -169,7 +169,7 @@ 2.1.14.RELEASE 4.1.4.RELEASE 2.0.7.RELEASE - Lovelace-SR17 + Lovelace-BUILD-SNAPSHOT ${spring.version} 0.25.2.RELEASE 5.1.11.BUILD-SNAPSHOT From 6597c0c7f7976736146aa1b8ce2dbc13a81f789f Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 9 Jun 2020 16:27:15 +0200 Subject: [PATCH 3/4] Start building against Spring Data Moore-SR8 snapshots See gh-21775 --- spring-boot-project/spring-boot-dependencies/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/pom.xml b/spring-boot-project/spring-boot-dependencies/pom.xml index 236b2c0c9f..cc38d4bad8 100644 --- a/spring-boot-project/spring-boot-dependencies/pom.xml +++ b/spring-boot-project/spring-boot-dependencies/pom.xml @@ -190,7 +190,7 @@ 2.2.6.RELEASE 4.2.3.BUILD-SNAPSHOT 2.0.7.RELEASE - Moore-SR7 + Moore-BUILD-SNAPSHOT 5.2.7.RELEASE 1.0.5.RELEASE 5.2.7.BUILD-SNAPSHOT From a3d39c7f312adf081158ee5dd72ce455a30739ed Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 9 Jun 2020 16:31:27 +0200 Subject: [PATCH 4/4] Start building against Spring Data Neumann-SR1 snapshots See gh-21776 --- spring-boot-project/spring-boot-dependencies/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-dependencies/build.gradle b/spring-boot-project/spring-boot-dependencies/build.gradle index 2f61882a70..b86d979133 100644 --- a/spring-boot-project/spring-boot-dependencies/build.gradle +++ b/spring-boot-project/spring-boot-dependencies/build.gradle @@ -1672,7 +1672,7 @@ bom { ] } } - library("Spring Data Releasetrain", "Neumann-RELEASE") { + library("Spring Data Releasetrain", "Neumann-BUILD-SNAPSHOT") { group("org.springframework.data") { imports = [ "spring-data-releasetrain"