Questions tagged [webtestclient]
36 questions
1
vote
1 answer
Spring boot Web test client mock multipart file not working
MockMultipartFile file = new MockMultipartFile("files",
"Test.txt",
"text/plain",
this.getClass().getResourceAsStream("/Test.txt"));
webTestClient.post()
…

SURAKSHA VR
- 13
- 3
1
vote
1 answer
WebTestClient with MockWebServer hangs
I have a spring boot application that exposes a rest api using "spring-boot-starter-webflux".
My application calls other rest services when one of my endpoint is called.
I'm trying to make an integration test using WebTestClient to mimic the client…

Vito De Tullio
- 2,332
- 3
- 33
- 52
1
vote
2 answers
Spring RequestContextHolder and WebTestClient
I'm using Spring RequestContextHolder in the controller and it works fine. But in the unit test I get java.lang.IllegalStateException using WebTestClient. Here is an example:
package demo.reactive.controller;
import…

Joao Moreira
- 17
- 1
- 5
1
vote
1 answer
Testing Server Sent Events (SSE) with WebTestClient
I wanted to know what would be the best way to test SSE?
What I want to test is I want to check if message that I have sent (using Kafka) will be the same I receive in SSE.
I have read that I can do that using WebTestClient, but what I do not…

Cre8or
- 71
- 1
- 8
1
vote
0 answers
Spring rest docs using webTestClient with StepVerifier (Reactive endpoints)
I am trying to create unit tests for my controllers using webTestClient. I need to generate api documentation using Spring rest docs. I used to create my assets using StepVerifier (Endpoints returning Mono of Flux)
Is there anyway of using…

CRISTIAN ROMERO MATESANZ
- 1,502
- 3
- 14
- 26
1
vote
0 answers
Testing Reactive Spring webflux using WebTestClient application context
I am trying to test the following spring webflux Kotlin application with the WebTestClient and Junit 5:
@SpringBootApplication
class ReactiveKataApplication
fun main(args: Array) {
…

Opentuned
- 1,477
- 17
- 21
1
vote
1 answer
Connection refused in integration test after migration from `@WebFluxTest` to `@SpringBootTest`
I do the migration from a Spring Boot reactive to mvc. I migrated controllers and now I try to migrate integration tests.
Controller's tests are annotated like this and if I run test it works.
@RunWith(SpringRunner.class)
@WebFluxTest
public class…

Vitalii
- 10,091
- 18
- 83
- 151
0
votes
1 answer
How to mock FilePart type field of entity using WebTestClient
While trying unit test for controller, i have used MultipartBodyBuilder. Also saw from here.
The MultipartBodyBuilder.part for file gives DefaultPart while the type of the field of the customer entity is FilePart which gives the below:
> POST…

arafat
- 25
- 8
0
votes
0 answers
Object fails to get deserialized when returning back to WebFluxTest context
I am writing unit tests for my API controller,
on one of the tests - i am facing a problem of deserializing an object when it returns from the endpoint, when debugging it in the controller's function i see that everything goes as expected but the…

eyal tamsot
- 11
- 3
0
votes
0 answers
Test flux endpoint with WebTestClient
I am experiencing a problem doing an integration test on a responsive endpoint using spring and Flux.
Specifically, it is a simple chat mechanism.
I have one endpoint that exposes a Flux object of Messages and a second endpoint that, via post,…

Giane
- 85
- 1
- 9
0
votes
0 answers
Speed up integeration tests withVirtualTime - stream of Flux.range with .delayElements
I have Controller that returns Flux of Strings - basically returns stream of data (Strings containing current time), Strings are delayed 1 second using on .delayElements(Duration.ofSeconds(1)) on Flux
Controller:
@GetMapping(value =…

Levijatanu
- 371
- 2
- 17
0
votes
0 answers
WebclientTest giving bad format error with local date in query parameters
I am developing a complete reactive springboot application with webflux. While covering the unit test cases, I noticed an error, which functionally works absolutely correct. The following unit test case returns 400 Bad Format during execution
I am…
0
votes
0 answers
How to do integration test for web client?
I have a method which returns Mono. So I try to user step verifier to do a integrate test.
public Mono process(InputBody body) {
retrun webClient
.post()
.uri("/submit")
.body(Mono.just(body), InputBody .class)
…

D.Anush
- 147
- 6
- 15
0
votes
2 answers
Mock Spring Security unit testing WebTestClient
I am trying to write unit test cases for Mycontroller using WebTestClient in my web-flux Spring boot application.
It is always returning 401 while try to execute my unit test case. I already go through some old answers of stackoverflow but no…

Shubham Garg
- 11
- 3
0
votes
1 answer
WebTestClient All negative unit test cases passed
I am trying to write unit tests using WebTestClient in my Spring boot application.
But when tried to run, all controller test cases passed including some negative test cases.
Below is my MainApplication, Controller and ControllerTest code for your…

Shubham Garg
- 75
- 8