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=87c3fe6b4982ef43ea421000f0cd1eba7b82872a;hpb=58021336ff2b6f6e16a0e070d093b61dee8dbc6f;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 87c3fe6..b9636ce 100644 --- a/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java +++ b/src/test/java/de/juplo/facebook/errors/GraphApiExchangeFilterFunctionIntegrationTest.java @@ -9,13 +9,10 @@ import org.junit.After; import static org.junit.Assert.assertEquals; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.http.client.reactive.ClientHttpConnector; +import org.springframework.http.HttpStatus; import org.springframework.http.client.reactive.JettyClientHttpConnector; -import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.web.reactive.function.client.WebClient; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -25,7 +22,6 @@ import reactor.test.StepVerifier; * * @author Kai Moritz */ -@RunWith(Parameterized.class) public class GraphApiExchangeFilterFunctionIntegrationTest { private static final Logger LOG = @@ -34,19 +30,6 @@ public class GraphApiExchangeFilterFunctionIntegrationTest private MockWebServer server; private WebClient webClient; - @Parameterized.Parameter(0) - public ClientHttpConnector connector; - - @Parameterized.Parameters(name = "webClient [{0}]") - public static Object[][] arguments() - { - return new Object[][] - { - { new JettyClientHttpConnector() }, - { new ReactorClientHttpConnector() } - }; - } - @Before public void setup() @@ -55,9 +38,9 @@ public class GraphApiExchangeFilterFunctionIntegrationTest webClient = WebClient .builder() - .clientConnector(this.connector) + .clientConnector(new JettyClientHttpConnector()) .baseUrl(server.url("/").toString()) - .filter(GraphApiExchangeFilterFunction.INSTANCE) + .filter(new GraphApiExchangeFilterFunction()) .build(); } @@ -71,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" + @@ -109,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)); + } }