X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftest%2Fjava%2Fde%2Fjuplo%2Ffacebook%2Ferrors%2FGraphApiExchangeFilterFunctionIntegrationTest.java;h=b9636ce12bb920b7c25352dab0493112f6e4aaa9;hb=f16862b51e98a30710fe20dc867110d48bb03be3;hp=640fa6a8a1c53608f05f1faa1be58310e414a4c9;hpb=fd44e482ceb2606db17fc243c9cd4ed59269ddc9;p=facebook-errors diff --git a/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java b/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java index 640fa6a..b9636ce 100644 --- a/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java +++ b/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java @@ -11,6 +11,8 @@ import org.junit.Before; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.client.reactive.JettyClientHttpConnector; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -36,8 +38,9 @@ public class GraphApiExchangeFilterFunctionIntegrationTest webClient = WebClient .builder() + .clientConnector(new JettyClientHttpConnector()) .baseUrl(server.url("/").toString()) - .filter(GraphApiExchangeFilterFunction.INSTANCE) + .filter(new GraphApiExchangeFilterFunction()) .build(); } @@ -51,12 +54,9 @@ public class GraphApiExchangeFilterFunctionIntegrationTest @Test public void testValidError() { - LOG.info("testValidError"); - - server .enqueue(new MockResponse() - .setStatus("400") + .setResponseCode(HttpStatus.BAD_REQUEST.value()) .setHeader("Content-Type", "application/json") .setBody( "{\n" + @@ -89,4 +89,42 @@ public class GraphApiExchangeFilterFunctionIntegrationTest }) .verify(Duration.ofSeconds(3)); } + + @Test + public void testTest() + { + server + .enqueue(new MockResponse() + .setResponseCode(400) + .setHeader("Content-Type", "text/plain") + .setBody("Hello Spring!")); + + Mono result; + + result = webClient.get() + .uri("/greeting?name=Spring") + .retrieve() + .bodyToMono(String.class); + + StepVerifier.create(result) + .expectError(Exception.class) + .verify(Duration.ofSeconds(3)); + + server + .enqueue(new MockResponse() + .setResponseCode(200) + .setHeader("Content-Type", "text/plain") + .setHeader("Foo", "Bar") + .setBody("Hello Spring!")); + + result = webClient.get() + .uri("/greeting?name=Spring") + .retrieve() + .bodyToMono(String.class); + + StepVerifier.create(result) + .expectNext("Hello Spring!") + .expectComplete() + .verify(Duration.ofSeconds(3)); + } }