Polish
This commit is contained in:
parent
a62a27e686
commit
25609c060e
|
@ -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 {
|
||||
|
|
|
@ -131,8 +131,7 @@ public class MetricsEndpoint {
|
|||
return availableTags;
|
||||
}
|
||||
|
||||
private void mergeAvailableTags(Map<String, Set<String>> availableTags,
|
||||
Meter meter) {
|
||||
private void mergeAvailableTags(Map<String, Set<String>> availableTags, Meter meter) {
|
||||
meter.getId().getTags().forEach((tag) -> {
|
||||
Set<String> value = Collections.singleton(tag.getValue());
|
||||
availableTags.merge(tag.getKey(), value, this::merge);
|
||||
|
|
|
@ -720,6 +720,11 @@
|
|||
<artifactId>johnzon-jsonb</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-jasper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
|
@ -750,20 +755,15 @@
|
|||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-jasper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>testcontainers</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<String, Object> hibernateProperties);
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ public class HibernateSettings {
|
|||
|
||||
public HibernateSettings hibernatePropertiesCustomizers(
|
||||
Collection<HibernatePropertiesCustomizer> hibernatePropertiesCustomizers) {
|
||||
this.hibernatePropertiesCustomizers = new ArrayList<>();
|
||||
this.hibernatePropertiesCustomizers.addAll(hibernatePropertiesCustomizers);
|
||||
this.hibernatePropertiesCustomizers = new ArrayList<>(
|
||||
hibernatePropertiesCustomizers);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,11 +224,10 @@ public class JpaProperties {
|
|||
else {
|
||||
result.remove("hibernate.hbm2ddl.auto");
|
||||
}
|
||||
Collection<HibernatePropertiesCustomizer> hibernatePropertiesCustomizers =
|
||||
settings.getHibernatePropertiesCustomizers();
|
||||
if (!ObjectUtils.isEmpty(hibernatePropertiesCustomizers)) {
|
||||
hibernatePropertiesCustomizers.forEach((customizer)
|
||||
-> customizer.customize(result));
|
||||
Collection<HibernatePropertiesCustomizer> customizers = settings
|
||||
.getHibernatePropertiesCustomizers();
|
||||
if (!ObjectUtils.isEmpty(customizers)) {
|
||||
customizers.forEach((customizer) -> customizer.customize(result));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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"));
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -183,6 +184,11 @@
|
|||
<artifactId>unboundid-ldapsdk</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.flapdoodle.embed</groupId>
|
||||
<artifactId>de.flapdoodle.embed.mongo</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.lettuce</groupId>
|
||||
<artifactId>lettuce-core</artifactId>
|
||||
|
@ -203,11 +209,21 @@
|
|||
<artifactId>commons-pool2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.johnzon</groupId>
|
||||
<artifactId>johnzon-jsonb</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-core</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-el</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
|
@ -218,6 +234,11 @@
|
|||
<artifactId>aspectjweaver</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
|
@ -228,11 +249,6 @@
|
|||
<artifactId>jooq</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.johnzon</groupId>
|
||||
<artifactId>johnzon-jsonb</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver-async</artifactId>
|
||||
|
@ -258,21 +274,6 @@
|
|||
<artifactId>spring-plugin-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-el</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.flapdoodle.embed</groupId>
|
||||
<artifactId>de.flapdoodle.embed.mongo</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>testcontainers</artifactId>
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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<? extends HttpMessageConverter<?>> 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<ClientHttpRequestInterceptor> 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<? extends ClientHttpRequestInterceptor> 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<ClientHttpRequestFactory> requestFactorySupplier) {
|
||||
Assert.notNull(requestFactorySupplier, "RequestFactory Supplier must not be null");
|
||||
public RestTemplateBuilder requestFactory(
|
||||
Supplier<ClientHttpRequestFactory> 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<RestTemplateCustomizer>(
|
||||
restTemplateCustomizers)),
|
||||
this.requestFactoryCustomizers, this.interceptors);
|
||||
|
@ -455,8 +461,8 @@ public class RestTemplateBuilder {
|
|||
Collection<? extends RestTemplateCustomizer> 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);
|
||||
|
|
|
@ -123,7 +123,8 @@ public class FailureAnalyzersTests {
|
|||
|
||||
}
|
||||
|
||||
interface AwareFailureAnalyzer extends BeanFactoryAware, EnvironmentAware, FailureAnalyzer {
|
||||
interface AwareFailureAnalyzer
|
||||
extends BeanFactoryAware, EnvironmentAware, FailureAnalyzer {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue