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
84901fa5
Commit
84901fa5
authored
Aug 22, 2018
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OnClassCondition report should only include relevant condition
Closes gh-11086
parent
b03f8e4a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
OnClassCondition.java
...mework/boot/autoconfigure/condition/OnClassCondition.java
+1
-1
ConditionalOnClassTests.java
...boot/autoconfigure/condition/ConditionalOnClassTests.java
+16
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnClassCondition.java
View file @
84901fa5
...
@@ -158,7 +158,7 @@ class OnClassCondition extends SpringBootCondition
...
@@ -158,7 +158,7 @@ class OnClassCondition extends SpringBootCondition
MultiValueMap
<
String
,
Object
>
attributes
=
metadata
MultiValueMap
<
String
,
Object
>
attributes
=
metadata
.
getAllAnnotationAttributes
(
annotationType
.
getName
(),
true
);
.
getAllAnnotationAttributes
(
annotationType
.
getName
(),
true
);
if
(
attributes
==
null
)
{
if
(
attributes
==
null
)
{
return
Collections
.
emptyList
()
;
return
null
;
}
}
List
<
String
>
candidates
=
new
ArrayList
<>();
List
<
String
>
candidates
=
new
ArrayList
<>();
addAll
(
candidates
,
attributes
.
get
(
"value"
));
addAll
(
candidates
,
attributes
.
get
(
"value"
));
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnClassTests.java
View file @
84901fa5
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
condition
;
package
org
.
springframework
.
boot
.
autoconfigure
.
condition
;
import
java.util.Collection
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.test.context.assertj.AssertableApplicationContext
;
import
org.springframework.boot.test.context.assertj.AssertableApplicationContext
;
...
@@ -68,6 +70,20 @@ public class ConditionalOnClassTests {
...
@@ -68,6 +70,20 @@ public class ConditionalOnClassTests {
.
run
(
this
::
hasBarBean
);
.
run
(
this
::
hasBarBean
);
}
}
@Test
public
void
onClassConditionOutputShouldNotContainConditionalOnMissingClassInMessage
()
{
this
.
contextRunner
.
withUserConfiguration
(
BasicConfiguration
.
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
(
"@ConditionalOnMissingClass did not find unwanted class"
);
});
}
private
void
hasBarBean
(
AssertableApplicationContext
context
)
{
private
void
hasBarBean
(
AssertableApplicationContext
context
)
{
assertThat
(
context
).
hasBean
(
"bar"
);
assertThat
(
context
).
hasBean
(
"bar"
);
assertThat
(
context
.
getBean
(
"bar"
)).
isEqualTo
(
"bar"
);
assertThat
(
context
.
getBean
(
"bar"
)).
isEqualTo
(
"bar"
);
...
...
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