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
f6b06523
Commit
f6b06523
authored
Dec 05, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.4.x' into 1.5.x
parents
887a206b
64da63aa
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
105 additions
and
47 deletions
+105
-47
AbstractNestedCondition.java
...boot/autoconfigure/condition/AbstractNestedCondition.java
+1
-1
OnBootstrapHostsCondition.java
...ot/autoconfigure/couchbase/OnBootstrapHostsCondition.java
+14
-16
AllNestedConditionsTests.java
...oot/autoconfigure/condition/AllNestedConditionsTests.java
+17
-0
AnyNestedConditionTests.java
...boot/autoconfigure/condition/AnyNestedConditionTests.java
+17
-0
NoneNestedConditionsTests.java
...ot/autoconfigure/condition/NoneNestedConditionsTests.java
+17
-0
OnBootstrapHostsConditionTests.java
...toconfigure/couchbase/OnBootstrapHostsConditionTests.java
+0
-1
ImportsContextCustomizer.java
...framework/boot/test/context/ImportsContextCustomizer.java
+35
-25
ArtifactsLibrariesTests.java
...g/springframework/boot/maven/ArtifactsLibrariesTests.java
+4
-4
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/AbstractNestedCondition.java
View file @
f6b06523
...
@@ -195,7 +195,7 @@ abstract class AbstractNestedCondition extends SpringBootCondition
...
@@ -195,7 +195,7 @@ abstract class AbstractNestedCondition extends SpringBootCondition
metadata
);
metadata
);
}
}
return
new
ConditionOutcome
(
condition
.
matches
(
this
.
context
,
metadata
),
return
new
ConditionOutcome
(
condition
.
matches
(
this
.
context
,
metadata
),
(
ConditionMessage
)
null
);
ConditionMessage
.
empty
()
);
}
}
public
ConditionOutcome
getUltimateOutcome
()
{
public
ConditionOutcome
getUltimateOutcome
()
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/OnBootstrapHostsCondition.java
View file @
f6b06523
...
@@ -28,6 +28,8 @@ import org.springframework.boot.bind.RelaxedDataBinder;
...
@@ -28,6 +28,8 @@ import org.springframework.boot.bind.RelaxedDataBinder;
import
org.springframework.boot.bind.RelaxedNames
;
import
org.springframework.boot.bind.RelaxedNames
;
import
org.springframework.context.annotation.ConditionContext
;
import
org.springframework.context.annotation.ConditionContext
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.PropertySources
;
import
org.springframework.core.type.AnnotatedTypeMetadata
;
import
org.springframework.core.type.AnnotatedTypeMetadata
;
import
org.springframework.validation.DataBinder
;
import
org.springframework.validation.DataBinder
;
...
@@ -41,20 +43,19 @@ class OnBootstrapHostsCondition extends SpringBootCondition {
...
@@ -41,20 +43,19 @@ class OnBootstrapHostsCondition extends SpringBootCondition {
@Override
@Override
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
public
ConditionOutcome
getMatchOutcome
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
AnnotatedTypeMetadata
metadata
)
{
ConfigurableEnvironment
environment
=
(
ConfigurableEnvironment
)
context
Environment
environment
=
context
.
getEnvironment
();
.
getEnvironment
();
PropertyResolver
resolver
=
new
PropertyResolver
(
PropertyResolver
resolver
=
new
PropertyResolver
(
environment
,
"spring.couchbase"
);
((
ConfigurableEnvironment
)
environment
).
getPropertySources
(),
"spring.couchbase"
);
Map
.
Entry
<
String
,
Object
>
entry
=
resolver
.
resolveProperty
(
"bootstrap-hosts"
);
Map
.
Entry
<
String
,
Object
>
entry
=
resolver
.
resolveProperty
(
"bootstrap-hosts"
);
if
(
entry
!=
null
)
{
if
(
entry
!=
null
)
{
return
ConditionOutcome
.
match
(
return
ConditionOutcome
.
match
(
ConditionMessage
ConditionMessage
.
forCondition
(
OnBootstrapHostsCondition
.
class
.
getName
())
.
forCondition
(
OnBootstrapHostsCondition
.
class
.
getName
())
.
found
(
"property"
).
items
(
"spring.couchbase.bootstrap-hosts"
));
.
found
(
"property"
).
items
(
"spring.couchbase.bootstrap-hosts"
));
}
else
{
return
ConditionOutcome
.
noMatch
(
ConditionMessage
.
forCondition
(
OnBootstrapHostsCondition
.
class
.
getName
())
.
didNotFind
(
"property"
).
items
(
"spring.couchbase.bootstrap-hosts"
));
}
}
return
ConditionOutcome
.
noMatch
(
ConditionMessage
.
forCondition
(
OnBootstrapHostsCondition
.
class
.
getName
())
.
didNotFind
(
"property"
).
items
(
"spring.couchbase.bootstrap-hosts"
));
}
}
private
static
class
PropertyResolver
{
private
static
class
PropertyResolver
{
...
@@ -63,12 +64,11 @@ class OnBootstrapHostsCondition extends SpringBootCondition {
...
@@ -63,12 +64,11 @@ class OnBootstrapHostsCondition extends SpringBootCondition {
private
final
Map
<
String
,
Object
>
content
;
private
final
Map
<
String
,
Object
>
content
;
PropertyResolver
(
ConfigurableEnvironment
environment
,
String
prefix
)
{
PropertyResolver
(
PropertySources
propertySources
,
String
prefix
)
{
this
.
prefix
=
prefix
;
this
.
prefix
=
prefix
;
this
.
content
=
new
HashMap
<
String
,
Object
>();
this
.
content
=
new
HashMap
<
String
,
Object
>();
DataBinder
binder
=
new
RelaxedDataBinder
(
this
.
content
,
this
.
prefix
);
DataBinder
binder
=
new
RelaxedDataBinder
(
this
.
content
,
this
.
prefix
);
binder
.
bind
(
new
PropertySourcesPropertyValues
(
binder
.
bind
(
new
PropertySourcesPropertyValues
(
propertySources
));
environment
.
getPropertySources
()));
}
}
Map
.
Entry
<
String
,
Object
>
resolveProperty
(
String
name
)
{
Map
.
Entry
<
String
,
Object
>
resolveProperty
(
String
name
)
{
...
@@ -89,5 +89,3 @@ class OnBootstrapHostsCondition extends SpringBootCondition {
...
@@ -89,5 +89,3 @@ class OnBootstrapHostsCondition extends SpringBootCondition {
}
}
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/AllNestedConditionsTests.java
View file @
f6b06523
...
@@ -21,8 +21,11 @@ import org.junit.Test;
...
@@ -21,8 +21,11 @@ import org.junit.Test;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Condition
;
import
org.springframework.context.annotation.ConditionContext
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.type.AnnotatedTypeMetadata
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
@@ -94,6 +97,20 @@ public class AllNestedConditionsTests {
...
@@ -94,6 +97,20 @@ public class AllNestedConditionsTests {
}
}
@Conditional
(
NonSpringBootCondition
.
class
)
static
class
SubclassC
{
}
}
static
class
NonSpringBootCondition
implements
Condition
{
@Override
public
boolean
matches
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
return
true
;
}
}
}
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/AnyNestedConditionTests.java
View file @
f6b06523
...
@@ -21,8 +21,11 @@ import org.junit.Test;
...
@@ -21,8 +21,11 @@ import org.junit.Test;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Condition
;
import
org.springframework.context.annotation.ConditionContext
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.type.AnnotatedTypeMetadata
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
@@ -98,6 +101,20 @@ public class AnyNestedConditionTests {
...
@@ -98,6 +101,20 @@ public class AnyNestedConditionTests {
}
}
@Conditional
(
NonSpringBootCondition
.
class
)
static
class
SubclassC
{
}
}
static
class
NonSpringBootCondition
implements
Condition
{
@Override
public
boolean
matches
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
return
false
;
}
}
}
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/NoneNestedConditionsTests.java
View file @
f6b06523
...
@@ -21,8 +21,11 @@ import org.junit.Test;
...
@@ -21,8 +21,11 @@ import org.junit.Test;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Condition
;
import
org.springframework.context.annotation.ConditionContext
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.context.annotation.Conditional
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.type.AnnotatedTypeMetadata
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
@@ -94,6 +97,20 @@ public class NoneNestedConditionsTests {
...
@@ -94,6 +97,20 @@ public class NoneNestedConditionsTests {
}
}
@Conditional
(
NonSpringBootCondition
.
class
)
static
class
SubClassC
{
}
}
static
class
NonSpringBootCondition
implements
Condition
{
@Override
public
boolean
matches
(
ConditionContext
context
,
AnnotatedTypeMetadata
metadata
)
{
return
false
;
}
}
}
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/OnBootstrapHostsConditionTests.java
View file @
f6b06523
...
@@ -73,7 +73,6 @@ public class OnBootstrapHostsConditionTests {
...
@@ -73,7 +73,6 @@ public class OnBootstrapHostsConditionTests {
assertThat
(
this
.
context
.
containsBean
(
"foo"
)).
isTrue
();
assertThat
(
this
.
context
.
containsBean
(
"foo"
)).
isTrue
();
}
}
private
void
load
(
Class
<?>
config
,
String
...
environment
)
{
private
void
load
(
Class
<?>
config
,
String
...
environment
)
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
environment
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
environment
);
...
...
spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java
View file @
f6b06523
...
@@ -276,45 +276,55 @@ class ImportsContextCustomizer implements ContextCustomizer {
...
@@ -276,45 +276,55 @@ class ImportsContextCustomizer implements ContextCustomizer {
return
(
obj
!=
null
&&
getClass
().
equals
(
obj
.
getClass
())
return
(
obj
!=
null
&&
getClass
().
equals
(
obj
.
getClass
())
&&
this
.
annotations
.
equals
(((
ContextCustomizerKey
)
obj
).
annotations
));
&&
this
.
annotations
.
equals
(((
ContextCustomizerKey
)
obj
).
annotations
));
}
}
}
private
interface
AnnotationFilter
{
/**
* Filter used to limit considered annotations.
boolean
isIgnored
(
Annotation
annotation
);
*/
private
interface
AnnotationFilter
{
}
boolean
isIgnored
(
Annotation
annotation
);
private
static
final
class
JavaLangAnnotationFilter
implements
AnnotationFilter
{
}
@Override
/**
public
boolean
isIgnored
(
Annotation
annotation
)
{
* {@link AnnotationFilter} for {@literal java.lang} annotations.
return
AnnotationUtils
.
isInJavaLangAnnotationPackage
(
annotation
);
*/
}
private
static
final
class
JavaLangAnnotationFilter
implements
AnnotationFilter
{
@Override
public
boolean
isIgnored
(
Annotation
annotation
)
{
return
AnnotationUtils
.
isInJavaLangAnnotationPackage
(
annotation
);
}
}
private
static
final
class
KotlinAnnotationFilter
implements
AnnotationFilter
{
}
@Override
/**
public
boolean
isIgnored
(
Annotation
annotation
)
{
* {@link AnnotationFilter} for Kotlin annotations.
return
"kotlin.Metadata"
.
equals
(
annotation
.
annotationType
().
getName
())
*/
||
isInKotlinAnnotationPackage
(
annotation
);
private
static
final
class
KotlinAnnotationFilter
implements
AnnotationFilter
{
}
private
boolean
isInKotlinAnnotationPackage
(
Annotation
annotation
)
{
@Override
return
annotation
.
annotationType
().
getName
()
public
boolean
isIgnored
(
Annotation
annotation
)
{
.
startsWith
(
"kotlin.annotation."
);
return
"kotlin.Metadata"
.
equals
(
annotation
.
annotationType
().
getName
())
}
||
isInKotlinAnnotationPackage
(
annotation
);
}
private
boolean
isInKotlinAnnotationPackage
(
Annotation
annotation
)
{
return
annotation
.
annotationType
().
getName
().
startsWith
(
"kotlin.annotation."
);
}
}
private
static
final
class
SpockAnnotationFilter
implements
AnnotationFilter
{
}
@Override
/**
public
boolean
isIgnored
(
Annotation
annotation
)
{
* {@link AnnotationFilter} for Spock annotations.
return
annotation
.
annotationType
().
getName
()
*/
.
startsWith
(
"org.spockframework."
);
private
static
final
class
SpockAnnotationFilter
implements
AnnotationFilter
{
}
@Override
public
boolean
isIgnored
(
Annotation
annotation
)
{
return
annotation
.
annotationType
().
getName
()
.
startsWith
(
"org.spockframework."
);
}
}
}
}
...
...
spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/ArtifactsLibrariesTests.java
View file @
f6b06523
...
@@ -128,10 +128,10 @@ public class ArtifactsLibrariesTests {
...
@@ -128,10 +128,10 @@ public class ArtifactsLibrariesTests {
this
.
libs
=
new
ArtifactsLibraries
(
this
.
artifacts
,
null
,
mock
(
Log
.
class
));
this
.
libs
=
new
ArtifactsLibraries
(
this
.
artifacts
,
null
,
mock
(
Log
.
class
));
this
.
libs
.
doWithLibraries
(
this
.
callback
);
this
.
libs
.
doWithLibraries
(
this
.
callback
);
verify
(
this
.
callback
,
times
(
2
)).
library
(
this
.
libraryCaptor
.
capture
());
verify
(
this
.
callback
,
times
(
2
)).
library
(
this
.
libraryCaptor
.
capture
());
assertThat
(
this
.
libraryCaptor
.
getAllValues
().
get
(
0
).
getName
())
.
isEqualTo
(
assertThat
(
this
.
libraryCaptor
.
getAllValues
().
get
(
0
).
getName
())
"g1-artifact-1.0.jar"
);
.
isEqualTo
(
"g1-artifact-1.0.jar"
);
assertThat
(
this
.
libraryCaptor
.
getAllValues
().
get
(
1
).
getName
())
.
isEqualTo
(
assertThat
(
this
.
libraryCaptor
.
getAllValues
().
get
(
1
).
getName
())
"g2-artifact-1.0.jar"
);
.
isEqualTo
(
"g2-artifact-1.0.jar"
);
}
}
}
}
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