Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
25609c06
Commit
25609c06
authored
Jan 04, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
a62a27e6
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
220 additions
and
184 deletions
+220
-184
CloudFoundryWebAnnotationEndpointDiscoverer.java
...dfoundry/CloudFoundryWebAnnotationEndpointDiscoverer.java
+2
-1
MetricsEndpoint.java
...springframework/boot/actuate/metrics/MetricsEndpoint.java
+1
-2
pom.xml
spring-boot-project/spring-boot-autoconfigure/pom.xml
+9
-9
ConcurrentKafkaListenerContainerFactoryConfigurer.java
...ka/ConcurrentKafkaListenerContainerFactoryConfigurer.java
+4
-2
KafkaProperties.java
...ngframework/boot/autoconfigure/kafka/KafkaProperties.java
+2
-1
HibernatePropertiesCustomizer.java
.../autoconfigure/orm/jpa/HibernatePropertiesCustomizer.java
+2
-1
HibernateSettings.java
...amework/boot/autoconfigure/orm/jpa/HibernateSettings.java
+2
-2
JpaProperties.java
...ngframework/boot/autoconfigure/orm/jpa/JpaProperties.java
+4
-5
KafkaAutoConfigurationTests.java
...boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java
+12
-8
MongoAutoConfigurationTests.java
...boot/autoconfigure/mongo/MongoAutoConfigurationTests.java
+16
-16
CustomHibernateJpaAutoConfigurationTests.java
...ure/orm/jpa/CustomHibernateJpaAutoConfigurationTests.java
+2
-2
JpaPropertiesTests.java
...mework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java
+88
-75
pom.xml
spring-boot-project/spring-boot-test-autoconfigure/pom.xml
+22
-21
DataNeo4jTestIntegrationTests.java
...toconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java
+2
-1
RestTemplateBuilder.java
.../springframework/boot/web/client/RestTemplateBuilder.java
+42
-34
FailureAnalyzersTests.java
...ringframework/boot/diagnostics/FailureAnalyzersTests.java
+2
-1
RestTemplateBuilderTests.java
...ngframework/boot/web/client/RestTemplateBuilderTests.java
+8
-3
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebAnnotationEndpointDiscoverer.java
View file @
25609c06
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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
{
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java
View file @
25609c06
...
...
@@ -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
);
...
...
spring-boot-project/spring-boot-autoconfigure/pom.xml
View file @
25609c06
...
...
@@ -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>
...
...
@@ -751,18 +756,13 @@
<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>
<groupId>
org.testcontainers
</groupId>
<artifactId>
testcontainers
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.
testcontainers
</groupId>
<artifactId>
testcontainers
</artifactId>
<groupId>
org.
yaml
</groupId>
<artifactId>
snakeyaml
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/ConcurrentKafkaListenerContainerFactoryConfigurer.java
View file @
25609c06
...
...
@@ -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
);
}
}
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java
View file @
25609c06
...
...
@@ -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
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernatePropertiesCustomizer.java
View file @
25609c06
...
...
@@ -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
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java
View file @
25609c06
...
...
@@ -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
;
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java
View file @
25609c06
...
...
@@ -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
;
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationTests.java
View file @
25609c06
...
...
@@ -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
))
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfigurationTests.java
View file @
25609c06
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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
)
.
get
MongoClientOptions
().
get
SocketTimeout
()).
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
)
.
get
MongoClientOptions
().
get
SocketTimeout
()).
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
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/CustomHibernateJpaAutoConfigurationTests.java
View file @
25609c06
...
...
@@ -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
);
});
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java
View file @
25609c06
...
...
@@ -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"
));
...
...
spring-boot-project/spring-boot-test-autoconfigure/pom.xml
View file @
25609c06
<?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>
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/neo4j/DataNeo4jTestIntegrationTests.java
View file @
25609c06
...
...
@@ -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
());
}
...
...
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java
View file @
25609c06
...
...
@@ -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
.
requestFactory
Customizers
,
this
.
interceptors
);
append
(
this
.
messageConverters
,
messageConverters
),
this
.
requestFactorySupplier
,
this
.
uriTemplateHandler
,
this
.
errorHandler
,
this
.
basicAuthorization
,
this
.
restTemplate
Customizers
,
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
.
re
stTemplateCustomizers
,
this
.
re
questFactoryCustomizers
,
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
);
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersTests.java
View file @
25609c06
...
...
@@ -123,7 +123,8 @@ public class FailureAnalyzersTests {
}
interface
AwareFailureAnalyzer
extends
BeanFactoryAware
,
EnvironmentAware
,
FailureAnalyzer
{
interface
AwareFailureAnalyzer
extends
BeanFactoryAware
,
EnvironmentAware
,
FailureAnalyzer
{
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java
View file @
25609c06
...
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment