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
3585d204
Commit
3585d204
authored
Feb 01, 2021
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include IDialect beans in WebFluxTest and WebMvcTest
Fixes gh-24149
parent
187258aa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
19 deletions
+49
-19
build.gradle
...-boot-project/spring-boot-test-autoconfigure/build.gradle
+1
-0
WebFluxTypeExcludeFilter.java
.../autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java
+12
-7
WebMvcTypeExcludeFilter.java
...st/autoconfigure/web/servlet/WebMvcTypeExcludeFilter.java
+4
-10
WebFluxTypeExcludeFilterTests.java
...configure/web/reactive/WebFluxTypeExcludeFilterTests.java
+16
-1
WebMvcTypeExcludeFilterTests.java
...toconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java
+16
-1
No files found.
spring-boot-project/spring-boot-test-autoconfigure/build.gradle
View file @
3585d204
...
...
@@ -78,6 +78,7 @@ dependencies {
testImplementation
(
"org.testcontainers:mongodb"
)
testImplementation
(
"org.testcontainers:neo4j"
)
testImplementation
(
"org.testcontainers:testcontainers"
)
testImplementation
(
"org.thymeleaf:thymeleaf"
)
testRuntimeOnly
(
"org.junit.platform:junit-platform-launcher"
)
}
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java
View file @
3585d204
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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,14 +21,13 @@ import java.util.Collections;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
com.fasterxml.jackson.databind.Module
;
import
org.springframework.boot.context.TypeExcludeFilter
;
import
org.springframework.boot.jackson.JsonComponent
;
import
org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter
;
import
org.springframework.core.convert.converter.Converter
;
import
org.springframework.core.convert.converter.GenericConverter
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.reactive.config.WebFluxConfigurer
;
...
...
@@ -45,6 +44,9 @@ public final class WebFluxTypeExcludeFilter extends StandardAnnotationCustomizab
private
static
final
Class
<?>[]
NO_CONTROLLERS
=
{};
private
static
final
String
[]
OPTIONAL_INCLUDES
=
{
"com.fasterxml.jackson.databind.Module"
,
"org.thymeleaf.dialect.IDialect"
};
private
static
final
Set
<
Class
<?>>
DEFAULT_INCLUDES
;
static
{
...
...
@@ -56,10 +58,13 @@ public final class WebFluxTypeExcludeFilter extends StandardAnnotationCustomizab
includes
.
add
(
GenericConverter
.
class
);
includes
.
add
(
WebExceptionHandler
.
class
);
includes
.
add
(
WebFilter
.
class
);
try
{
includes
.
add
(
Module
.
class
);
}
catch
(
Throwable
ex
)
{
for
(
String
optionalInclude
:
OPTIONAL_INCLUDES
)
{
try
{
includes
.
add
(
ClassUtils
.
forName
(
optionalInclude
,
null
));
}
catch
(
Exception
ex
)
{
// Ignore
}
}
DEFAULT_INCLUDES
=
Collections
.
unmodifiableSet
(
includes
);
}
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilter.java
View file @
3585d204
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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,8 +21,6 @@ import java.util.Collections;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
com.fasterxml.jackson.databind.Module
;
import
org.springframework.boot.context.TypeExcludeFilter
;
import
org.springframework.boot.jackson.JsonComponent
;
import
org.springframework.boot.test.autoconfigure.filter.StandardAnnotationCustomizableTypeExcludeFilter
;
...
...
@@ -51,8 +49,9 @@ public final class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizabl
private
static
final
Class
<?>[]
NO_CONTROLLERS
=
{};
private
static
final
String
[]
OPTIONAL_INCLUDES
=
{
"org.springframework.security.config.annotation.web.WebSecurityConfigurer"
};
private
static
final
String
[]
OPTIONAL_INCLUDES
=
{
"com.fasterxml.jackson.databind.Module"
,
"org.springframework.security.config.annotation.web.WebSecurityConfigurer"
,
"org.thymeleaf.dialect.IDialect"
};
private
static
final
Set
<
Class
<?>>
DEFAULT_INCLUDES
;
...
...
@@ -70,11 +69,6 @@ public final class WebMvcTypeExcludeFilter extends StandardAnnotationCustomizabl
includes
.
add
(
Converter
.
class
);
includes
.
add
(
GenericConverter
.
class
);
includes
.
add
(
HandlerInterceptor
.
class
);
try
{
includes
.
add
(
Module
.
class
);
}
catch
(
Throwable
ex
)
{
}
for
(
String
optionalInclude
:
OPTIONAL_INCLUDES
)
{
try
{
includes
.
add
(
ClassUtils
.
forName
(
optionalInclude
,
null
));
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilterTests.java
View file @
3585d204
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -20,6 +20,7 @@ import java.io.IOException;
import
com.fasterxml.jackson.databind.module.SimpleModule
;
import
org.junit.jupiter.api.Test
;
import
org.thymeleaf.dialect.IDialect
;
import
reactor.core.publisher.Mono
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
...
...
@@ -59,6 +60,7 @@ class WebFluxTypeExcludeFilterTests {
assertThat
(
excludes
(
filter
,
ExampleRepository
.
class
)).
isTrue
();
assertThat
(
excludes
(
filter
,
ExampleWebFilter
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleModule
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleDialect
.
class
)).
isFalse
();
}
@Test
...
...
@@ -72,6 +74,7 @@ class WebFluxTypeExcludeFilterTests {
assertThat
(
excludes
(
filter
,
ExampleRepository
.
class
)).
isTrue
();
assertThat
(
excludes
(
filter
,
ExampleWebFilter
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleModule
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleDialect
.
class
)).
isFalse
();
}
@Test
...
...
@@ -85,6 +88,7 @@ class WebFluxTypeExcludeFilterTests {
assertThat
(
excludes
(
filter
,
ExampleRepository
.
class
)).
isTrue
();
assertThat
(
excludes
(
filter
,
ExampleWebFilter
.
class
)).
isTrue
();
assertThat
(
excludes
(
filter
,
ExampleModule
.
class
)).
isTrue
();
assertThat
(
excludes
(
filter
,
ExampleDialect
.
class
)).
isTrue
();
}
@Test
...
...
@@ -98,6 +102,7 @@ class WebFluxTypeExcludeFilterTests {
assertThat
(
excludes
(
filter
,
ExampleRepository
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleWebFilter
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleModule
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleDialect
.
class
)).
isFalse
();
}
@Test
...
...
@@ -111,6 +116,7 @@ class WebFluxTypeExcludeFilterTests {
assertThat
(
excludes
(
filter
,
ExampleRepository
.
class
)).
isTrue
();
assertThat
(
excludes
(
filter
,
ExampleWebFilter
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleModule
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleDialect
.
class
)).
isFalse
();
}
private
boolean
excludes
(
WebFluxTypeExcludeFilter
filter
,
Class
<?>
type
)
throws
IOException
{
...
...
@@ -185,4 +191,13 @@ class WebFluxTypeExcludeFilterTests {
}
static
class
ExampleDialect
implements
IDialect
{
@Override
public
String
getName
()
{
return
"example"
;
}
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java
View file @
3585d204
/*
* Copyright 2012-202
0
the original author or authors.
* Copyright 2012-202
1
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.
...
...
@@ -20,6 +20,7 @@ import java.io.IOException;
import
com.fasterxml.jackson.databind.module.SimpleModule
;
import
org.junit.jupiter.api.Test
;
import
org.thymeleaf.dialect.IDialect
;
import
org.springframework.context.annotation.ComponentScan.Filter
;
import
org.springframework.context.annotation.FilterType
;
...
...
@@ -59,6 +60,7 @@ class WebMvcTypeExcludeFilterTests {
assertThat
(
excludes
(
filter
,
ExampleWebSecurityConfigurer
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleHandlerInterceptor
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleModule
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleDialect
.
class
)).
isFalse
();
}
@Test
...
...
@@ -74,6 +76,7 @@ class WebMvcTypeExcludeFilterTests {
assertThat
(
excludes
(
filter
,
ExampleWebSecurityConfigurer
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleHandlerInterceptor
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleModule
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleDialect
.
class
)).
isFalse
();
}
@Test
...
...
@@ -89,6 +92,7 @@ class WebMvcTypeExcludeFilterTests {
assertThat
(
excludes
(
filter
,
ExampleWebSecurityConfigurer
.
class
)).
isTrue
();
assertThat
(
excludes
(
filter
,
ExampleHandlerInterceptor
.
class
)).
isTrue
();
assertThat
(
excludes
(
filter
,
ExampleModule
.
class
)).
isTrue
();
assertThat
(
excludes
(
filter
,
ExampleDialect
.
class
)).
isTrue
();
}
@Test
...
...
@@ -103,6 +107,7 @@ class WebMvcTypeExcludeFilterTests {
assertThat
(
excludes
(
filter
,
ExampleRepository
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleHandlerInterceptor
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleModule
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleDialect
.
class
)).
isFalse
();
}
@Test
...
...
@@ -118,6 +123,7 @@ class WebMvcTypeExcludeFilterTests {
assertThat
(
excludes
(
filter
,
ExampleWebSecurityConfigurer
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleHandlerInterceptor
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleModule
.
class
)).
isFalse
();
assertThat
(
excludes
(
filter
,
ExampleDialect
.
class
)).
isFalse
();
}
private
boolean
excludes
(
WebMvcTypeExcludeFilter
filter
,
Class
<?>
type
)
throws
IOException
{
...
...
@@ -195,4 +201,13 @@ class WebMvcTypeExcludeFilterTests {
}
static
class
ExampleDialect
implements
IDialect
{
@Override
public
String
getName
()
{
return
"example"
;
}
}
}
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