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
f3fa952c
Commit
f3fa952c
authored
Aug 27, 2018
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support WebExceptionHandler in @WebFluxTest
Closes gh-13627
parent
64a0d2f2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
0 deletions
+52
-0
WebFluxTypeExcludeFilter.java
.../autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java
+2
-0
ExampleController1.java
...oconfigure/web/reactive/webclient/ExampleController1.java
+5
-0
ExampleWebExceptionHandler.java
...re/web/reactive/webclient/ExampleWebExceptionHandler.java
+40
-0
WebFluxTestAllControllersIntegrationTests.java
.../webclient/WebFluxTestAllControllersIntegrationTests.java
+5
-0
No files found.
spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/reactive/WebFluxTypeExcludeFilter.java
View file @
f3fa952c
...
...
@@ -32,6 +32,7 @@ import org.springframework.stereotype.Controller;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.reactive.config.WebFluxConfigurer
;
import
org.springframework.web.server.WebExceptionHandler
;
/**
* {@link TypeExcludeFilter} for {@link WebFluxTest @WebFluxTest}.
...
...
@@ -49,6 +50,7 @@ class WebFluxTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
includes
.
add
(
WebFluxConfigurer
.
class
);
includes
.
add
(
Converter
.
class
);
includes
.
add
(
GenericConverter
.
class
);
includes
.
add
(
WebExceptionHandler
.
class
);
DEFAULT_INCLUDES
=
Collections
.
unmodifiableSet
(
includes
);
}
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleController1.java
View file @
f3fa952c
...
...
@@ -36,4 +36,9 @@ public class ExampleController1 {
return
Mono
.
just
(
"one"
);
}
@GetMapping
(
"/one/error"
)
public
Mono
<
String
>
error
()
{
throw
new
RuntimeException
(
"foo"
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/ExampleWebExceptionHandler.java
0 → 100644
View file @
f3fa952c
/*
* Copyright 2012-2018 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
web
.
reactive
.
webclient
;
import
reactor.core.publisher.Mono
;
import
org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.WebExceptionHandler
;
/**
* Example {@link WebExceptionHandler} used with {@link WebFluxTest} tests.
*
* @author Madhura Bhave
*/
@Component
public
class
ExampleWebExceptionHandler
implements
WebExceptionHandler
{
@Override
public
Mono
<
Void
>
handle
(
ServerWebExchange
exchange
,
Throwable
ex
)
{
exchange
.
getResponse
().
setStatusCode
(
HttpStatus
.
BAD_REQUEST
);
return
exchange
.
getResponse
().
setComplete
();
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/reactive/webclient/WebFluxTestAllControllersIntegrationTests.java
View file @
f3fa952c
...
...
@@ -48,4 +48,9 @@ public class WebFluxTestAllControllersIntegrationTests {
.
expectBody
(
String
.
class
).
isEqualTo
(
"two"
);
}
@Test
public
void
webExceptionHandling
()
{
this
.
webClient
.
get
().
uri
(
"/one/error"
).
exchange
().
expectStatus
().
isBadRequest
();
}
}
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