diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebAnnotationEndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebAnnotationEndpointDiscoverer.java index b10b43dbfe..4d508c8f47 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebAnnotationEndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebAnnotationEndpointDiscoverer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ import org.springframework.context.ApplicationContext; * specific extensions for the {@link HealthEndpoint}. * * @author Madhura Bhave + * @since 2.0.0 */ public class CloudFoundryWebAnnotationEndpointDiscoverer extends WebAnnotationEndpointDiscoverer { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java index 3188537336..746cc25e60 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java @@ -131,8 +131,7 @@ public class MetricsEndpoint { return availableTags; } - private void mergeAvailableTags(Map> availableTags, - Meter meter) { + private void mergeAvailableTags(Map> availableTags, Meter meter) { meter.getId().getTags().forEach((tag) -> { Set value = Collections.singleton(tag.getValue()); availableTags.merge(tag.getKey(), value, this::merge); diff --git a/spring-boot-project/spring-boot-autoconfigure/pom.xml b/spring-boot-project/spring-boot-autoconfigure/pom.xml index 6c79cf09a7..5d10f20196 100755 --- a/spring-boot-project/spring-boot-autoconfigure/pom.xml +++ b/spring-boot-project/spring-boot-autoconfigure/pom.xml @@ -720,6 +720,11 @@ johnzon-jsonb test + + org.apache.tomcat.embed + tomcat-embed-jasper + test + org.hsqldb hsqldb @@ -750,20 +755,15 @@ spring-security-test test - - org.yaml - snakeyaml - test - - - org.apache.tomcat.embed - tomcat-embed-jasper - test - org.testcontainers testcontainers test + + org.yaml + snakeyaml + test + diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java index 397354c1b4..d4b460abe5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java @@ -102,12 +102,14 @@ public class ConcurrentKafkaListenerContainerFactoryConfigurer { .to(container::setAckTime); map.from(properties::getPollTimeout).whenNonNull().as(Duration::toMillis) .to(container::setPollTimeout); - map.from(properties::getNoPollThreshold).whenNonNull().to(container::setNoPollThreshold); + map.from(properties::getNoPollThreshold).whenNonNull() + .to(container::setNoPollThreshold); map.from(properties::getIdleEventInterval).whenNonNull().as(Duration::toMillis) .to(container::setIdleEventInterval); map.from(properties::getMonitorInterval).whenNonNull().as(Duration::getSeconds) .as(Number::intValue).to(container::setMonitorInterval); - map.from(properties::getLogContainerConfig).whenNonNull().to(container::setLogContainerConfig); + map.from(properties::getLogContainerConfig).whenNonNull() + .to(container::setLogContainerConfig); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java index 74524ba301..c3a52c2dd9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java @@ -815,7 +815,8 @@ public class KafkaProperties { private Duration pollTimeout; /** - * Multiplier applied to "pollTimeout" to determine if a consumer is non-responsive. + * Multiplier applied to "pollTimeout" to determine if a consumer is + * non-responsive. */ private Float noPollThreshold; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesCustomizer.java index bb561db45b..01cde94afa 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesCustomizer.java @@ -23,13 +23,14 @@ import java.util.Map; * properties before it is used by an auto-configured {@code EntityManagerFactory}. * * @author Stephane Nicoll + * @since 2.0.0 */ @FunctionalInterface public interface HibernatePropertiesCustomizer { /** * Customize the specified JPA vendor properties. - * @param hibernateProperties the current JPA vendor properties + * @param hibernateProperties the JPA vendor properties to customize */ void customize(Map hibernateProperties); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java index 6e4aeb9963..5c9bd721dc 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java @@ -69,8 +69,8 @@ public class HibernateSettings { public HibernateSettings hibernatePropertiesCustomizers( Collection hibernatePropertiesCustomizers) { - this.hibernatePropertiesCustomizers = new ArrayList<>(); - this.hibernatePropertiesCustomizers.addAll(hibernatePropertiesCustomizers); + this.hibernatePropertiesCustomizers = new ArrayList<>( + hibernatePropertiesCustomizers); return this; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java index 6ddac88415..a7c34b74db 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java @@ -224,11 +224,10 @@ public class JpaProperties { else { result.remove("hibernate.hbm2ddl.auto"); } - Collection hibernatePropertiesCustomizers = - settings.getHibernatePropertiesCustomizers(); - if (!ObjectUtils.isEmpty(hibernatePropertiesCustomizers)) { - hibernatePropertiesCustomizers.forEach((customizer) - -> customizer.customize(result)); + Collection customizers = settings + .getHibernatePropertiesCustomizers(); + if (!ObjectUtils.isEmpty(customizers)) { + customizers.forEach((customizer) -> customizer.customize(result)); } return result; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java index 802322c68e..e716e8ab70 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java @@ -299,14 +299,18 @@ public class KafkaAutoConfigurationTests { assertThat(dfa.getPropertyValue("concurrency")).isEqualTo(3); assertThat(dfa.getPropertyValue("containerProperties.pollTimeout")) .isEqualTo(2000L); - assertThat(dfa.getPropertyValue("containerProperties.noPollThreshold")) - .isEqualTo(2.5f); - assertThat(dfa.getPropertyValue("containerProperties.idleEventInterval")) - .isEqualTo(1000L); - assertThat(dfa.getPropertyValue("containerProperties.monitorInterval")) - .isEqualTo(45); - assertThat(dfa.getPropertyValue("containerProperties.logContainerConfig")) - .isEqualTo(Boolean.TRUE); + assertThat( + dfa.getPropertyValue("containerProperties.noPollThreshold")) + .isEqualTo(2.5f); + assertThat( + dfa.getPropertyValue("containerProperties.idleEventInterval")) + .isEqualTo(1000L); + assertThat( + dfa.getPropertyValue("containerProperties.monitorInterval")) + .isEqualTo(45); + assertThat(dfa + .getPropertyValue("containerProperties.logContainerConfig")) + .isEqualTo(Boolean.TRUE); assertThat(dfa.getPropertyValue("batchListener")).isEqualTo(true); assertThat( context.getBeansOfType(KafkaJaasLoginModuleInitializer.class)) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java index 08a3095d5a..884ccd8331 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,25 +43,25 @@ public class MongoAutoConfigurationTests { @Test public void clientExists() { - this.contextRunner.run((context) -> - assertThat(context).hasSingleBean(MongoClient.class)); + this.contextRunner + .run((context) -> assertThat(context).hasSingleBean(MongoClient.class)); } @Test public void optionsAdded() { this.contextRunner.withPropertyValues("spring.data.mongodb.host:localhost") - .withUserConfiguration(OptionsConfig.class).run((context) -> - assertThat(context.getBean(MongoClient.class).getMongoClientOptions() - .getSocketTimeout()).isEqualTo(300)); + .withUserConfiguration(OptionsConfig.class) + .run((context) -> assertThat(context.getBean(MongoClient.class) + .getMongoClientOptions().getSocketTimeout()).isEqualTo(300)); } @Test public void optionsAddedButNoHost() { this.contextRunner .withPropertyValues("spring.data.mongodb.uri:mongodb://localhost/test") - .withUserConfiguration(OptionsConfig.class).run((context) -> - assertThat(context.getBean(MongoClient.class).getMongoClientOptions() - .getSocketTimeout()).isEqualTo(300)); + .withUserConfiguration(OptionsConfig.class) + .run((context) -> assertThat(context.getBean(MongoClient.class) + .getMongoClientOptions().getSocketTimeout()).isEqualTo(300)); } @Test @@ -69,13 +69,13 @@ public class MongoAutoConfigurationTests { this.contextRunner .withPropertyValues("spring.data.mongodb.uri:mongodb://localhost/test") .withUserConfiguration(SslOptionsConfig.class).run((context) -> { - assertThat(context).hasSingleBean(MongoClient.class); - MongoClient mongo = context.getBean(MongoClient.class); - MongoClientOptions options = mongo.getMongoClientOptions(); - assertThat(options.isSslEnabled()).isTrue(); - assertThat(options.getSocketFactory()) - .isSameAs(context.getBean("mySocketFactory")); - }); + assertThat(context).hasSingleBean(MongoClient.class); + MongoClient mongo = context.getBean(MongoClient.class); + MongoClientOptions options = mongo.getMongoClientOptions(); + assertThat(options.isSslEnabled()).isTrue(); + assertThat(options.getSocketFactory()) + .isSameAs(context.getBean("mySocketFactory")); + }); } @Configuration diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/CustomHibernateJpaAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/CustomHibernateJpaAutoConfigurationTests.java index d06caac3e4..133ee66d47 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/CustomHibernateJpaAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/CustomHibernateJpaAutoConfigurationTests.java @@ -88,10 +88,10 @@ public class CustomHibernateJpaAutoConfigurationTests { .getVendorProperties(); assertThat(hibernateProperties .get("hibernate.implicit_naming_strategy")).isEqualTo( - NamingStrategyConfiguration.implicitNamingStrategy); + NamingStrategyConfiguration.implicitNamingStrategy); assertThat(hibernateProperties .get("hibernate.physical_naming_strategy")).isEqualTo( - NamingStrategyConfiguration.physicalNamingStrategy); + NamingStrategyConfiguration.physicalNamingStrategy); }); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java index 8bc909cdd7..a823ac03dc 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java @@ -77,16 +77,19 @@ public class JpaPropertiesTests { this.contextRunner .withPropertyValues( "spring.jpa.hibernate.naming.implicit-strategy:com.example.Implicit", - "spring.jpa.hibernate.naming.physical-strategy:com.example.Physical" - ).run(assertJpaProperties((properties) -> { - Map hibernateProperties = properties - .getHibernateProperties(new HibernateSettings().ddlAuto("none")); - assertThat(hibernateProperties).contains( - entry("hibernate.implicit_naming_strategy", "com.example.Implicit"), - entry("hibernate.physical_naming_strategy", "com.example.Physical")); - assertThat(hibernateProperties) - .doesNotContainKeys("hibernate.ejb.naming_strategy"); - })); + "spring.jpa.hibernate.naming.physical-strategy:com.example.Physical") + .run(assertJpaProperties((properties) -> { + Map hibernateProperties = properties + .getHibernateProperties( + new HibernateSettings().ddlAuto("none")); + assertThat(hibernateProperties).contains( + entry("hibernate.implicit_naming_strategy", + "com.example.Implicit"), + entry("hibernate.physical_naming_strategy", + "com.example.Physical")); + assertThat(hibernateProperties) + .doesNotContainKeys("hibernate.ejb.naming_strategy"); + })); } @Test @@ -111,54 +114,62 @@ public class JpaPropertiesTests { this.contextRunner .withPropertyValues( "spring.jpa.hibernate.naming.implicit-strategy:com.example.Implicit", - "spring.jpa.hibernate.naming.physical-strategy:com.example.Physical" - ).run(assertJpaProperties((properties) -> { - ImplicitNamingStrategy implicitStrategy = mock(ImplicitNamingStrategy.class); - PhysicalNamingStrategy physicalStrategy = mock(PhysicalNamingStrategy.class); - Map hibernateProperties = properties - .getHibernateProperties(new HibernateSettings().ddlAuto("none") - .implicitNamingStrategy(implicitStrategy) - .physicalNamingStrategy(physicalStrategy)); - assertThat(hibernateProperties).contains( - entry("hibernate.implicit_naming_strategy", implicitStrategy), - entry("hibernate.physical_naming_strategy", physicalStrategy)); - assertThat(hibernateProperties) - .doesNotContainKeys("hibernate.ejb.naming_strategy"); - })); + "spring.jpa.hibernate.naming.physical-strategy:com.example.Physical") + .run(assertJpaProperties((properties) -> { + ImplicitNamingStrategy implicitStrategy = mock( + ImplicitNamingStrategy.class); + PhysicalNamingStrategy physicalStrategy = mock( + PhysicalNamingStrategy.class); + Map hibernateProperties = properties + .getHibernateProperties( + new HibernateSettings().ddlAuto("none") + .implicitNamingStrategy(implicitStrategy) + .physicalNamingStrategy(physicalStrategy)); + assertThat(hibernateProperties).contains( + entry("hibernate.implicit_naming_strategy", implicitStrategy), + entry("hibernate.physical_naming_strategy", + physicalStrategy)); + assertThat(hibernateProperties) + .doesNotContainKeys("hibernate.ejb.naming_strategy"); + })); } - @Test public void hibernatePropertiesCustomizerTakePrecedenceOverStrategyInstancesAndNamingStrategyProperties() { this.contextRunner .withPropertyValues( "spring.jpa.hibernate.naming.implicit-strategy:com.example.Implicit", - "spring.jpa.hibernate.naming.physical-strategy:com.example.Physical" - ).run(assertJpaProperties((properties) -> { - ImplicitNamingStrategy implicitStrategy = mock(ImplicitNamingStrategy.class); - PhysicalNamingStrategy physicalStrategy = mock(PhysicalNamingStrategy.class); - ImplicitNamingStrategy effectiveImplicitStrategy = mock( - ImplicitNamingStrategy.class); - PhysicalNamingStrategy effectivePhysicalStrategy = mock( - PhysicalNamingStrategy.class); - HibernatePropertiesCustomizer customizer = (hibernateProperties) -> { - hibernateProperties.put("hibernate.implicit_naming_strategy", - effectiveImplicitStrategy); - hibernateProperties.put("hibernate.physical_naming_strategy", - effectivePhysicalStrategy); - }; - Map hibernateProperties = properties - .getHibernateProperties(new HibernateSettings().ddlAuto("none") - .implicitNamingStrategy(implicitStrategy) - .physicalNamingStrategy(physicalStrategy) - .hibernatePropertiesCustomizers( - Collections.singleton(customizer))); - assertThat(hibernateProperties).contains( - entry("hibernate.implicit_naming_strategy", effectiveImplicitStrategy), - entry("hibernate.physical_naming_strategy", effectivePhysicalStrategy)); - assertThat(hibernateProperties) - .doesNotContainKeys("hibernate.ejb.naming_strategy"); - })); + "spring.jpa.hibernate.naming.physical-strategy:com.example.Physical") + .run(assertJpaProperties((properties) -> { + ImplicitNamingStrategy implicitStrategy = mock( + ImplicitNamingStrategy.class); + PhysicalNamingStrategy physicalStrategy = mock( + PhysicalNamingStrategy.class); + ImplicitNamingStrategy effectiveImplicitStrategy = mock( + ImplicitNamingStrategy.class); + PhysicalNamingStrategy effectivePhysicalStrategy = mock( + PhysicalNamingStrategy.class); + HibernatePropertiesCustomizer customizer = (hibernateProperties) -> { + hibernateProperties.put("hibernate.implicit_naming_strategy", + effectiveImplicitStrategy); + hibernateProperties.put("hibernate.physical_naming_strategy", + effectivePhysicalStrategy); + }; + Map hibernateProperties = properties + .getHibernateProperties( + new HibernateSettings().ddlAuto("none") + .implicitNamingStrategy(implicitStrategy) + .physicalNamingStrategy(physicalStrategy) + .hibernatePropertiesCustomizers( + Collections.singleton(customizer))); + assertThat(hibernateProperties).contains( + entry("hibernate.implicit_naming_strategy", + effectiveImplicitStrategy), + entry("hibernate.physical_naming_strategy", + effectivePhysicalStrategy)); + assertThat(hibernateProperties) + .doesNotContainKeys("hibernate.ejb.naming_strategy"); + })); } @Test @@ -166,17 +177,20 @@ public class JpaPropertiesTests { this.contextRunner .withPropertyValues( "spring.jpa.properties.hibernate.implicit_naming_strategy:com.example.Implicit", - "spring.jpa.properties.hibernate.physical_naming_strategy:com.example.Physical" - ).run(assertJpaProperties((properties) -> { - Map hibernateProperties = properties - .getHibernateProperties(new HibernateSettings().ddlAuto("none")); - // You can override them as we don't provide any default - assertThat(hibernateProperties).contains( - entry("hibernate.implicit_naming_strategy", "com.example.Implicit"), - entry("hibernate.physical_naming_strategy", "com.example.Physical")); - assertThat(hibernateProperties) - .doesNotContainKeys("hibernate.ejb.naming_strategy"); - })); + "spring.jpa.properties.hibernate.physical_naming_strategy:com.example.Physical") + .run(assertJpaProperties((properties) -> { + Map hibernateProperties = properties + .getHibernateProperties( + new HibernateSettings().ddlAuto("none")); + // You can override them as we don't provide any default + assertThat(hibernateProperties).contains( + entry("hibernate.implicit_naming_strategy", + "com.example.Implicit"), + entry("hibernate.physical_naming_strategy", + "com.example.Physical")); + assertThat(hibernateProperties) + .doesNotContainKeys("hibernate.ejb.naming_strategy"); + })); } @Test @@ -184,8 +198,8 @@ public class JpaPropertiesTests { this.contextRunner.run(assertJpaProperties((properties) -> { Map hibernateProperties = properties .getHibernateProperties(new HibernateSettings().ddlAuto("none")); - assertThat(hibernateProperties) - .containsEntry(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true"); + assertThat(hibernateProperties).containsEntry( + AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true"); })); } @@ -193,19 +207,19 @@ public class JpaPropertiesTests { public void useNewIdGeneratorMappingsFalse() { this.contextRunner .withPropertyValues( - "spring.jpa.hibernate.use-new-id-generator-mappings:false" - ).run(assertJpaProperties((properties) -> { - Map hibernateProperties = properties - .getHibernateProperties(new HibernateSettings().ddlAuto("none")); - assertThat(hibernateProperties) - .containsEntry(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "false"); - })); + "spring.jpa.hibernate.use-new-id-generator-mappings:false") + .run(assertJpaProperties((properties) -> { + Map hibernateProperties = properties + .getHibernateProperties( + new HibernateSettings().ddlAuto("none")); + assertThat(hibernateProperties).containsEntry( + AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "false"); + })); } @Test public void determineDatabaseNoCheckIfDatabaseIsSet() { - this.contextRunner - .withPropertyValues("spring.jpa.database=postgresql") + this.contextRunner.withPropertyValues("spring.jpa.database=postgresql") .run(assertJpaProperties((properties) -> { DataSource dataSource = mockStandaloneDataSource(); Database database = properties.determineDatabase(dataSource); @@ -230,8 +244,7 @@ public class JpaPropertiesTests { @Test public void determineDatabaseWithKnownUrlAndUserConfig() { - this.contextRunner - .withPropertyValues("spring.jpa.database=mysql") + this.contextRunner.withPropertyValues("spring.jpa.database=mysql") .run(assertJpaProperties((properties) -> { Database database = properties .determineDatabase(mockDataSource("jdbc:h2:mem:testdb")); diff --git a/spring-boot-project/spring-boot-test-autoconfigure/pom.xml b/spring-boot-project/spring-boot-test-autoconfigure/pom.xml index d472e15264..d8c8c340e3 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/pom.xml +++ b/spring-boot-project/spring-boot-test-autoconfigure/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 org.springframework.boot @@ -183,6 +184,11 @@ unboundid-ldapsdk test + + de.flapdoodle.embed + de.flapdoodle.embed.mongo + test + io.lettuce lettuce-core @@ -203,11 +209,21 @@ commons-pool2 test + + org.apache.johnzon + johnzon-jsonb + test + org.apache.tomcat.embed tomcat-embed-core true + + org.apache.tomcat.embed + tomcat-embed-el + test + org.aspectj aspectjrt @@ -218,6 +234,11 @@ aspectjweaver test + + org.hibernate.validator + hibernate-validator + test + org.hsqldb hsqldb @@ -228,11 +249,6 @@ jooq test - - org.apache.johnzon - johnzon-jsonb - test - org.mongodb mongodb-driver-async @@ -258,21 +274,6 @@ spring-plugin-core test - - org.hibernate.validator - hibernate-validator - test - - - org.apache.tomcat.embed - tomcat-embed-el - test - - - de.flapdoodle.embed - de.flapdoodle.embed.mongo - test - org.testcontainers testcontainers diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java index 931e41496b..873cde1c95 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java @@ -87,7 +87,8 @@ public class DataNeo4jTestIntegrationTests { public void initialize( ConfigurableApplicationContext configurableApplicationContext) { TestPropertyValues - .of("spring.data.neo4j.uri=bolt://localhost:" + neo4j.getMappedPort(7687)) + .of("spring.data.neo4j.uri=bolt://localhost:" + + neo4j.getMappedPort(7687)) .applyTo(configurableApplicationContext.getEnvironment()); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java index c0a264d3c1..c32a74409d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java @@ -146,9 +146,10 @@ public class RestTemplateBuilder { */ public RestTemplateBuilder detectRequestFactory(boolean detectRequestFactory) { return new RestTemplateBuilder(detectRequestFactory, this.rootUri, - this.messageConverters, this.requestFactorySupplier, this.uriTemplateHandler, - this.errorHandler, this.basicAuthorization, this.restTemplateCustomizers, - this.requestFactoryCustomizers, this.interceptors); + this.messageConverters, this.requestFactorySupplier, + this.uriTemplateHandler, this.errorHandler, this.basicAuthorization, + this.restTemplateCustomizers, this.requestFactoryCustomizers, + this.interceptors); } /** @@ -159,9 +160,10 @@ public class RestTemplateBuilder { */ public RestTemplateBuilder rootUri(String rootUri) { return new RestTemplateBuilder(this.detectRequestFactory, rootUri, - this.messageConverters, this.requestFactorySupplier, this.uriTemplateHandler, - this.errorHandler, this.basicAuthorization, this.restTemplateCustomizers, - this.requestFactoryCustomizers, this.interceptors); + this.messageConverters, this.requestFactorySupplier, + this.uriTemplateHandler, this.errorHandler, this.basicAuthorization, + this.restTemplateCustomizers, this.requestFactoryCustomizers, + this.interceptors); } /** @@ -221,10 +223,10 @@ public class RestTemplateBuilder { Collection> messageConverters) { Assert.notNull(messageConverters, "MessageConverters must not be null"); return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri, - append(this.messageConverters, messageConverters), this.requestFactorySupplier, - this.uriTemplateHandler, this.errorHandler, this.basicAuthorization, - this.restTemplateCustomizers, this.requestFactoryCustomizers, - this.interceptors); + append(this.messageConverters, messageConverters), + this.requestFactorySupplier, this.uriTemplateHandler, this.errorHandler, + this.basicAuthorization, this.restTemplateCustomizers, + this.requestFactoryCustomizers, this.interceptors); } /** @@ -271,9 +273,9 @@ public class RestTemplateBuilder { Collection interceptors) { Assert.notNull(interceptors, "interceptors must not be null"); return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri, - this.messageConverters, this.requestFactorySupplier, this.uriTemplateHandler, - this.errorHandler, this.basicAuthorization, this.restTemplateCustomizers, - this.requestFactoryCustomizers, + this.messageConverters, this.requestFactorySupplier, + this.uriTemplateHandler, this.errorHandler, this.basicAuthorization, + this.restTemplateCustomizers, this.requestFactoryCustomizers, Collections.unmodifiableSet(new LinkedHashSet<>(interceptors))); } @@ -303,9 +305,10 @@ public class RestTemplateBuilder { Collection interceptors) { Assert.notNull(interceptors, "interceptors must not be null"); return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri, - this.messageConverters, this.requestFactorySupplier, this.uriTemplateHandler, - this.errorHandler, this.basicAuthorization, this.restTemplateCustomizers, - this.requestFactoryCustomizers, append(this.interceptors, interceptors)); + this.messageConverters, this.requestFactorySupplier, + this.uriTemplateHandler, this.errorHandler, this.basicAuthorization, + this.restTemplateCustomizers, this.requestFactoryCustomizers, + append(this.interceptors, interceptors)); } /** @@ -333,15 +336,16 @@ public class RestTemplateBuilder { } /** - * Set the {@code Supplier} of {@link ClientHttpRequestFactory} - * that should be called each time we {@link #build()} a new - * {@link RestTemplate} instance. + * Set the {@code Supplier} of {@link ClientHttpRequestFactory} that should be called + * each time we {@link #build()} a new {@link RestTemplate} instance. * @param requestFactorySupplier the supplier for the request factory * @return a new builder instance * @since 2.0.0 */ - public RestTemplateBuilder requestFactory(Supplier requestFactorySupplier) { - Assert.notNull(requestFactorySupplier, "RequestFactory Supplier must not be null"); + public RestTemplateBuilder requestFactory( + Supplier requestFactorySupplier) { + Assert.notNull(requestFactorySupplier, + "RequestFactory Supplier must not be null"); return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri, this.messageConverters, requestFactorySupplier, this.uriTemplateHandler, this.errorHandler, this.basicAuthorization, this.restTemplateCustomizers, @@ -371,9 +375,10 @@ public class RestTemplateBuilder { public RestTemplateBuilder errorHandler(ResponseErrorHandler errorHandler) { Assert.notNull(errorHandler, "ErrorHandler must not be null"); return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri, - this.messageConverters, this.requestFactorySupplier, this.uriTemplateHandler, - errorHandler, this.basicAuthorization, this.restTemplateCustomizers, - this.requestFactoryCustomizers, this.interceptors); + this.messageConverters, this.requestFactorySupplier, + this.uriTemplateHandler, errorHandler, this.basicAuthorization, + this.restTemplateCustomizers, this.requestFactoryCustomizers, + this.interceptors); } /** @@ -385,8 +390,9 @@ public class RestTemplateBuilder { */ public RestTemplateBuilder basicAuthorization(String username, String password) { return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri, - this.messageConverters, this.requestFactorySupplier, this.uriTemplateHandler, - this.errorHandler, new BasicAuthorizationInterceptor(username, password), + this.messageConverters, this.requestFactorySupplier, + this.uriTemplateHandler, this.errorHandler, + new BasicAuthorizationInterceptor(username, password), this.restTemplateCustomizers, this.requestFactoryCustomizers, this.interceptors); } @@ -421,8 +427,8 @@ public class RestTemplateBuilder { Assert.notNull(restTemplateCustomizers, "RestTemplateCustomizers must not be null"); return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri, - this.messageConverters, this.requestFactorySupplier, this.uriTemplateHandler, - this.errorHandler, this.basicAuthorization, + this.messageConverters, this.requestFactorySupplier, + this.uriTemplateHandler, this.errorHandler, this.basicAuthorization, Collections.unmodifiableSet(new LinkedHashSet( restTemplateCustomizers)), this.requestFactoryCustomizers, this.interceptors); @@ -455,8 +461,8 @@ public class RestTemplateBuilder { Collection customizers) { Assert.notNull(customizers, "RestTemplateCustomizers must not be null"); return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri, - this.messageConverters, this.requestFactorySupplier, this.uriTemplateHandler, - this.errorHandler, this.basicAuthorization, + this.messageConverters, this.requestFactorySupplier, + this.uriTemplateHandler, this.errorHandler, this.basicAuthorization, append(this.restTemplateCustomizers, customizers), this.requestFactoryCustomizers, this.interceptors); } @@ -469,8 +475,9 @@ public class RestTemplateBuilder { */ public RestTemplateBuilder setConnectTimeout(int connectTimeout) { return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri, - this.messageConverters, this.requestFactorySupplier, this.uriTemplateHandler, - this.errorHandler, this.basicAuthorization, this.restTemplateCustomizers, + this.messageConverters, this.requestFactorySupplier, + this.uriTemplateHandler, this.errorHandler, this.basicAuthorization, + this.restTemplateCustomizers, append(this.requestFactoryCustomizers, new ConnectTimeoutRequestFactoryCustomizer(connectTimeout)), this.interceptors); @@ -484,8 +491,9 @@ public class RestTemplateBuilder { */ public RestTemplateBuilder setReadTimeout(int readTimeout) { return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri, - this.messageConverters, this.requestFactorySupplier, this.uriTemplateHandler, - this.errorHandler, this.basicAuthorization, this.restTemplateCustomizers, + this.messageConverters, this.requestFactorySupplier, + this.uriTemplateHandler, this.errorHandler, this.basicAuthorization, + this.restTemplateCustomizers, append(this.requestFactoryCustomizers, new ReadTimeoutRequestFactoryCustomizer(readTimeout)), this.interceptors); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java index 5cb72cb449..5e648742f9 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java @@ -123,7 +123,8 @@ public class FailureAnalyzersTests { } - interface AwareFailureAnalyzer extends BeanFactoryAware, EnvironmentAware, FailureAnalyzer { + interface AwareFailureAnalyzer + extends BeanFactoryAware, EnvironmentAware, FailureAnalyzer { } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java index 191ee22bd6..a0052c203c 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java @@ -467,7 +467,9 @@ public class RestTemplateBuilderTests { @Test public void connectTimeoutCanBeConfiguredOnAWrappedRequestFactory() { SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); - this.builder.requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)) + this.builder + .requestFactory( + () -> new BufferingClientHttpRequestFactory(requestFactory)) .setConnectTimeout(1234).build(); assertThat(ReflectionTestUtils.getField(requestFactory, "connectTimeout")) .isEqualTo(1234); @@ -476,7 +478,9 @@ public class RestTemplateBuilderTests { @Test public void readTimeoutCanBeConfiguredOnAWrappedRequestFactory() { SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); - this.builder.requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)) + this.builder + .requestFactory( + () -> new BufferingClientHttpRequestFactory(requestFactory)) .setReadTimeout(1234).build(); assertThat(ReflectionTestUtils.getField(requestFactory, "readTimeout")) .isEqualTo(1234); @@ -486,7 +490,8 @@ public class RestTemplateBuilderTests { public void unwrappingDoesNotAffectRequestFactoryThatIsSetOnTheBuiltTemplate() { SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); RestTemplate template = this.builder - .requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)) + .requestFactory( + () -> new BufferingClientHttpRequestFactory(requestFactory)) .build(); assertThat(template.getRequestFactory()) .isInstanceOf(BufferingClientHttpRequestFactory.class);