BAEL-4698 Added HTTP Response Body as String with WebClient (#11083)
This commit is contained in:
parent
5247181211
commit
aee4c48bdd
|
@ -43,6 +43,12 @@
|
|||
<version>${spring-boot.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Webclient -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.baeldung.httpclient.readresponsebodystring;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public class SpringWebClientUnitTest {
|
||||
public static final String DUMMY_URL = "https://postman-echo.com/get";
|
||||
|
||||
@Test
|
||||
public void whenUseWebClientRetrieve_thenCorrect() {
|
||||
WebClient webClient = WebClient.create(DUMMY_URL);
|
||||
Mono<String> body = webClient.get().retrieve().bodyToMono(String.class);
|
||||
String s = body.block();
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue