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
32bd845a
Commit
32bd845a
authored
Feb 11, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.2.x'
Closes gh-20116
parents
85eb279b
b4d118e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
OnBeanCondition.java
...amework/boot/autoconfigure/condition/OnBeanCondition.java
+4
-4
ConditionalOnBeanTests.java
.../boot/autoconfigure/condition/ConditionalOnBeanTests.java
+13
-0
ConditionalOnMissingBeanTests.java
...utoconfigure/condition/ConditionalOnMissingBeanTests.java
+13
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java
View file @
32bd845a
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
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.
...
...
@@ -387,7 +387,7 @@ class OnBeanCondition extends FilteringSpringBootCondition implements Configurat
private
final
ClassLoader
classLoader
;
private
final
Class
<?>
annotationType
;
private
final
Class
<?
extends
Annotation
>
annotationType
;
private
final
Set
<
String
>
names
;
...
...
@@ -581,11 +581,11 @@ class OnBeanCondition extends FilteringSpringBootCondition implements Configurat
}
ConditionMessage
.
Builder
message
()
{
return
ConditionMessage
.
forCondition
(
ConditionalOnBean
.
class
,
this
);
return
ConditionMessage
.
forCondition
(
this
.
annotationType
,
this
);
}
ConditionMessage
.
Builder
message
(
ConditionMessage
message
)
{
return
message
.
andCondition
(
ConditionalOnBean
.
class
,
this
);
return
message
.
andCondition
(
this
.
annotationType
,
this
);
}
@Override
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnBeanTests.java
View file @
32bd845a
...
...
@@ -21,6 +21,7 @@ import java.lang.annotation.ElementType;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.function.Consumer
;
...
...
@@ -29,6 +30,7 @@ import org.junit.jupiter.api.Test;
import
org.springframework.beans.factory.FactoryBean
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistry
;
import
org.springframework.beans.factory.support.RootBeanDefinition
;
import
org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport.ConditionAndOutcomes
;
import
org.springframework.boot.test.context.assertj.AssertableApplicationContext
;
import
org.springframework.boot.test.context.runner.ApplicationContextRunner
;
import
org.springframework.context.ConfigurableApplicationContext
;
...
...
@@ -134,6 +136,17 @@ class ConditionalOnBeanTests {
assertThat
(
context
.
getBean
(
"bar"
)).
isEqualTo
(
"bar"
);
}
@Test
void
onBeanConditionOutputShouldNotContainConditionalOnMissingBeanClassInMessage
()
{
this
.
contextRunner
.
withUserConfiguration
(
OnBeanNameConfiguration
.
class
).
run
((
context
)
->
{
Collection
<
ConditionAndOutcomes
>
conditionAndOutcomes
=
ConditionEvaluationReport
.
get
(
context
.
getSourceApplicationContext
().
getBeanFactory
()).
getConditionAndOutcomesBySource
()
.
values
();
String
message
=
conditionAndOutcomes
.
iterator
().
next
().
iterator
().
next
().
getOutcome
().
getMessage
();
assertThat
(
message
).
doesNotContain
(
"@ConditionalOnMissingBean"
);
});
}
@Test
void
conditionEvaluationConsidersChangeInTypeWhenBeanIsOverridden
()
{
this
.
contextRunner
.
withAllowBeanDefinitionOverriding
(
true
).
withUserConfiguration
(
OriginalDefinition
.
class
,
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingBeanTests.java
View file @
32bd845a
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
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.
...
...
@@ -21,6 +21,7 @@ import java.lang.annotation.ElementType;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.function.Consumer
;
...
...
@@ -136,6 +137,17 @@ public class ConditionalOnMissingBeanTests {
});
}
@Test
void
testOnMissingBeanConditionOutputShouldNotContainConditionalOnBeanClassInMessage
()
{
this
.
contextRunner
.
withUserConfiguration
(
OnBeanNameConfiguration
.
class
).
run
((
context
)
->
{
Collection
<
ConditionEvaluationReport
.
ConditionAndOutcomes
>
conditionAndOutcomes
=
ConditionEvaluationReport
.
get
(
context
.
getSourceApplicationContext
().
getBeanFactory
()).
getConditionAndOutcomesBySource
()
.
values
();
String
message
=
conditionAndOutcomes
.
iterator
().
next
().
iterator
().
next
().
getOutcome
().
getMessage
();
assertThat
(
message
).
doesNotContain
(
"@ConditionalOnBean"
);
});
}
@Test
void
testOnMissingBeanConditionWithFactoryBean
()
{
this
.
contextRunner
...
...
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