File tree Expand file tree Collapse file tree
src/test/java/com/baeldung/httpclient/readresponsebodystring Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4343 <version >${spring-boot.version} </version >
4444 <scope >test</scope >
4545 </dependency >
46+ <!-- Webclient -->
47+ <dependency >
48+ <groupId >org.springframework.boot</groupId >
49+ <artifactId >spring-boot-starter-webflux</artifactId >
50+ <version >${spring-boot.version} </version >
51+ </dependency >
4652 </dependencies >
4753
4854 <build >
Original file line number Diff line number Diff line change 1+ package com .baeldung .httpclient .readresponsebodystring ;
2+
3+ import org .junit .Test ;
4+ import org .springframework .web .reactive .function .client .WebClient ;
5+ import reactor .core .publisher .Mono ;
6+
7+ public class SpringWebClientUnitTest {
8+ public static final String DUMMY_URL = "https://postman-echo.com/get" ;
9+
10+ @ Test
11+ public void whenUseWebClientRetrieve_thenCorrect () {
12+ WebClient webClient = WebClient .create (DUMMY_URL );
13+ Mono <String > body = webClient .get ().retrieve ().bodyToMono (String .class );
14+ String s = body .block ();
15+ System .out .println (s );
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments