fixed tests in spring-5-reactive module
This commit is contained in:
parent
65d2996c10
commit
e09ae1ff51
|
@ -7,8 +7,10 @@ import java.time.Duration;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.http.server.reactive.HttpHandler;
|
import org.springframework.http.server.reactive.HttpHandler;
|
||||||
import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
|
import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
|
||||||
|
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||||
import org.springframework.web.reactive.function.server.RouterFunction;
|
import org.springframework.web.reactive.function.server.RouterFunction;
|
||||||
import org.springframework.web.reactive.function.server.RouterFunctions;
|
import org.springframework.web.reactive.function.server.RouterFunctions;
|
||||||
import org.springframework.web.reactive.function.server.ServerResponse;
|
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||||
|
@ -22,6 +24,7 @@ import reactor.netty.http.server.HttpServer;
|
||||||
|
|
||||||
public class Spring5ReactiveServerClientIntegrationTest {
|
public class Spring5ReactiveServerClientIntegrationTest {
|
||||||
private static DisposableServer disposableServer;
|
private static DisposableServer disposableServer;
|
||||||
|
private static WebTestClient webTestClient;
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
|
@ -37,6 +40,9 @@ public class Spring5ReactiveServerClientIntegrationTest {
|
||||||
ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(httpHandler);
|
ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(httpHandler);
|
||||||
disposableServer = server.handle(adapter)
|
disposableServer = server.handle(adapter)
|
||||||
.bindNow();
|
.bindNow();
|
||||||
|
webTestClient = WebTestClient.bindToServer()
|
||||||
|
.baseUrl("http://localhost:8080")
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
|
@ -44,49 +50,22 @@ public class Spring5ReactiveServerClientIntegrationTest {
|
||||||
disposableServer.disposeNow();
|
disposableServer.disposeNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
// public void givenCheckTask_whenServerHandle_thenServerResponseALiveString() throws Exception {
|
public void givenCheckTask_whenServerHandle_thenServerResponseALiveString() throws Exception {
|
||||||
// WebClient client = WebClient.create("http://localhost:8080");
|
webTestClient.get()
|
||||||
// Mono<String> result = client
|
.uri("/task")
|
||||||
// .get()
|
.exchange()
|
||||||
// .uri("/task")
|
.expectBody(String.class);
|
||||||
// .exchange()
|
}
|
||||||
// .then(response -> response.bodyToMono(String.class));
|
|
||||||
//
|
|
||||||
// assertThat(result.block()).isInstanceOf(String.class);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Test
|
@Test
|
||||||
// public void givenThreeTasks_whenServerHandleTheTasks_thenServerResponseATask() throws Exception {
|
public void givenThreeTasks_whenServerHandleTheTasks_thenServerResponseATask() throws Exception {
|
||||||
// URI uri = URI.create("http://localhost:8080/task/process");
|
webTestClient.post()
|
||||||
// ExchangeFunction exchange = ExchangeFunctions.create(new ReactorClientHttpConnector());
|
.uri("/task/process")
|
||||||
// ClientRequest request = ClientRequest
|
.body(getLatLngs(), Task.class)
|
||||||
// .method(HttpMethod.POST, uri)
|
.exchange()
|
||||||
// .body(BodyInserters.fromPublisher(getLatLngs(), Task.class))
|
.expectBodyList(Task.class);
|
||||||
// .build();
|
}
|
||||||
//
|
|
||||||
// Flux<Task> taskResponse = exchange
|
|
||||||
// .exchange(request)
|
|
||||||
// .flatMap(response -> response.bodyToFlux(Task.class));
|
|
||||||
//
|
|
||||||
// assertThat(taskResponse.blockFirst()).isInstanceOf(Task.class);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Test
|
|
||||||
// public void givenCheckTask_whenServerHandle_thenOragicServerResponseALiveString() throws Exception {
|
|
||||||
// URI uri = URI.create("http://localhost:8080/task");
|
|
||||||
// ExchangeFunction exchange = ExchangeFunctions.create(new ReactorClientHttpConnector());
|
|
||||||
// ClientRequest request = ClientRequest
|
|
||||||
// .method(HttpMethod.GET, uri)
|
|
||||||
// .body(BodyInserters.fromPublisher(getLatLngs(), Task.class))
|
|
||||||
// .build();
|
|
||||||
//
|
|
||||||
// Flux<String> taskResponse = exchange
|
|
||||||
// .exchange(request)
|
|
||||||
// .flatMap(response -> response.bodyToFlux(String.class));
|
|
||||||
//
|
|
||||||
// assertThat(taskResponse.blockFirst()).isInstanceOf(String.class);
|
|
||||||
// }
|
|
||||||
|
|
||||||
private static Flux<Task> getLatLngs() {
|
private static Flux<Task> getLatLngs() {
|
||||||
return Flux.range(0, 3)
|
return Flux.range(0, 3)
|
||||||
|
|
Loading…
Reference in New Issue