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
6b7dfce5
Commit
6b7dfce5
authored
Jun 07, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting
parent
a03ddd33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
WebMvcAutoConfigurationTests.java
.../boot/autoconfigure/web/WebMvcAutoConfigurationTests.java
+10
-9
No files found.
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurationTests.java
View file @
6b7dfce5
...
...
@@ -673,7 +673,8 @@ public class WebMvcAutoConfigurationTests {
.
getBeanNamesForType
(
javax
.
validation
.
Validator
.
class
);
String
[]
springValidatorBeans
=
this
.
context
.
getBeanNamesForType
(
Validator
.
class
);
assertThat
(
jsrValidatorBeans
).
containsExactly
(
"defaultValidator"
);
assertThat
(
springValidatorBeans
).
containsExactly
(
"defaultValidator"
,
"mvcValidator"
);
assertThat
(
springValidatorBeans
).
containsExactly
(
"defaultValidator"
,
"mvcValidator"
);
Validator
validator
=
this
.
context
.
getBean
(
"mvcValidator"
,
Validator
.
class
);
assertThat
(
validator
).
isInstanceOf
(
WebMvcValidator
.
class
);
Object
defaultValidator
=
this
.
context
.
getBean
(
"defaultValidator"
);
...
...
@@ -696,7 +697,8 @@ public class WebMvcAutoConfigurationTests {
@Test
public
void
validatorWithConfigurerDoesNotExposeJsr303
()
{
load
(
MvcJsr303Validator
.
class
,
new
Class
<?>[]
{
ValidationAutoConfiguration
.
class
});
load
(
MvcJsr303Validator
.
class
,
new
Class
<?>[]
{
ValidationAutoConfiguration
.
class
});
assertThat
(
this
.
context
.
getBeansOfType
(
ValidatorFactory
.
class
)).
isEmpty
();
assertThat
(
this
.
context
.
getBeansOfType
(
javax
.
validation
.
Validator
.
class
))
.
isEmpty
();
...
...
@@ -715,7 +717,8 @@ public class WebMvcAutoConfigurationTests {
assertThat
(
this
.
context
.
getBeansOfType
(
javax
.
validation
.
Validator
.
class
))
.
hasSize
(
1
);
String
[]
springValidatorBeans
=
this
.
context
.
getBeanNamesForType
(
Validator
.
class
);
assertThat
(
springValidatorBeans
).
containsExactly
(
"defaultValidator"
,
"mvcValidator"
);
assertThat
(
springValidatorBeans
).
containsExactly
(
"defaultValidator"
,
"mvcValidator"
);
assertThat
(
this
.
context
.
getBean
(
"mvcValidator"
))
.
isSameAs
(
this
.
context
.
getBean
(
MvcValidator
.
class
).
validator
);
// Primary Spring validator is the auto-configured one as the MVC one has been
...
...
@@ -731,13 +734,12 @@ public class WebMvcAutoConfigurationTests {
.
getBeanNamesForType
(
javax
.
validation
.
Validator
.
class
);
String
[]
springValidatorBeans
=
this
.
context
.
getBeanNamesForType
(
Validator
.
class
);
assertThat
(
jsrValidatorBeans
).
containsExactly
(
"defaultValidator"
);
assertThat
(
springValidatorBeans
).
containsExactly
(
"
customSpringValidator"
,
"
defaultValidator"
,
"mvcValidator"
);
assertThat
(
springValidatorBeans
).
containsExactly
(
"customSpringValidator"
,
"defaultValidator"
,
"mvcValidator"
);
Validator
validator
=
this
.
context
.
getBean
(
"mvcValidator"
,
Validator
.
class
);
assertThat
(
validator
).
isInstanceOf
(
WebMvcValidator
.
class
);
Object
defaultValidator
=
this
.
context
.
getBean
(
"defaultValidator"
);
assertThat
(((
WebMvcValidator
)
validator
).
getTarget
())
.
isSameAs
(
defaultValidator
);
assertThat
(((
WebMvcValidator
)
validator
).
getTarget
()).
isSameAs
(
defaultValidator
);
// Primary Spring validator is the one used by MVC behind the scenes
assertThat
(
this
.
context
.
getBean
(
Validator
.
class
)).
isEqualTo
(
defaultValidator
);
}
...
...
@@ -753,8 +755,7 @@ public class WebMvcAutoConfigurationTests {
assertThat
(
springValidatorBeans
).
containsExactly
(
"mvcValidator"
);
Validator
validator
=
this
.
context
.
getBean
(
Validator
.
class
);
assertThat
(
validator
).
isInstanceOf
(
WebMvcValidator
.
class
);
SpringValidatorAdapter
target
=
((
WebMvcValidator
)
validator
)
.
getTarget
();
SpringValidatorAdapter
target
=
((
WebMvcValidator
)
validator
).
getTarget
();
assertThat
(
new
DirectFieldAccessor
(
target
).
getPropertyValue
(
"targetValidator"
))
.
isSameAs
(
this
.
context
.
getBean
(
"customJsr303Validator"
));
}
...
...
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