From bde380a095084b15142e9010c3791fac4bd243e6 Mon Sep 17 00:00:00 2001 From: skarpenko Date: Fri, 10 Nov 2023 18:39:44 +0200 Subject: [PATCH] Renamed feign-reactor-webclient to feign-reactor-webclient-netty Added HTTP2 support for Netty client --- .circleci/config.yml | 2 +- feign-reactor-benchmarks/pom.xml | 2 +- .../benchmarks/RealRequestBenchmarks.java | 4 +- feign-reactor-bom/pom.xml | 2 +- feign-reactor-cloud/pom.xml | 2 +- .../reactivefeign/cloud2/BuilderUtils.java | 6 +- .../reactivefeign/cloud2/MetricsTest.java | 16 +-- .../java/reactivefeign/ReactivityTest.java | 36 +++--- .../java11/h2c/ReactivityTest.java | 8 ++ .../jetty/h2c/ReactivityTest.java | 8 ++ feign-reactor-parent/pom.xml | 2 +- feign-reactor-rx2/pom.xml | 2 +- .../reactivefeign/rx2/Rx2ReactiveFeign.java | 4 +- .../reactivefeign/rx2/DefaultMethodTest.java | 4 +- .../reactivefeign/rx2/ReadTimeoutTest.java | 4 +- feign-reactor-spring-cloud-starter/pom.xml | 2 +- feign-reactor-spring-configuration/pom.xml | 20 +++- .../ReactiveFeignAutoConfiguration.java | 8 +- .../ReactiveFeignClientsConfiguration.java | 8 +- .../pom.xml | 2 +- .../cloud2/SampleConfigurationsTest.java | 4 +- .../pom.xml | 2 +- ...veFeignClientUsingConfigurationsTests.java | 6 +- .../feign-reactor-spring-mvc-test/pom.xml | 2 +- .../spring/mvc/MultiPartTest.java | 4 +- .../allfeatures/AllFeaturesMvcWebTest.java | 4 +- .../pom.xml | 3 - .../webclient/client5/h2c/ReactivityTest.java | 7 ++ .../pom.xml | 29 ++++- .../NettyClientHttpConnectorBuilder.java | 21 +++- .../webclient/netty/NettyReactiveOptions.java | 49 +++++--- .../netty/NettyWebReactiveFeign.java | 12 +- .../webclient/BasicFeaturesTest.java | 5 +- .../webclient/CollectionFormatTest.java | 3 +- .../webclient/CompressionTest.java | 6 +- .../webclient/ConnectionTimeoutTest.java | 6 +- .../reactivefeign/webclient/ContractTest.java | 3 +- .../webclient/DefaultMethodTest.java | 10 +- .../webclient/ErrorMapperTest.java | 3 +- .../reactivefeign/webclient/FallbackTest.java | 3 +- .../reactivefeign/webclient/LoggerTest.java | 8 +- .../reactivefeign/webclient/MetricsTest.java | 8 +- .../webclient/MultiPartTest.java | 3 +- .../reactivefeign/webclient/NotFoundTest.java | 3 +- .../webclient/ObjectMapperTest.java | 3 +- .../reactivefeign/webclient/OptionsTest.java | 10 +- .../webclient/ReactivityTest.java | 3 +- .../webclient/RequestInterceptorTest.java | 3 +- .../webclient/ResponseEntityTest.java | 3 +- .../webclient/ResponseMapperTest.java | 3 +- .../reactivefeign/webclient/RetryingTest.java | 3 +- .../reactivefeign/webclient/SmokeTest.java | 3 +- .../webclient/SslVerificationTest.java | 10 +- .../webclient/StatusHandlerTest.java | 3 +- .../allfeatures/AllFeaturesTest.java | 4 +- .../allfeatures/WebClientFeaturesApi.java | 0 .../WebClientFeaturesController.java | 0 .../allfeatures/WebClientFeaturesTest.java | 6 +- .../webclient/h2c/AllFeaturesTest.java | 105 ++++++++++++++++++ .../webclient/h2c/ReactivityTest.java | 51 +++++++++ pom.xml | 2 +- 61 files changed, 422 insertions(+), 136 deletions(-) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/pom.xml (81%) rename {feign-reactor-webclient/src/main/java/reactivefeign/webclient => feign-reactor-webclient-netty/src/main/java/reactivefeign/webclient/netty}/NettyClientHttpConnectorBuilder.java (88%) rename feign-reactor-webclient/src/main/java/reactivefeign/webclient/WebReactiveOptions.java => feign-reactor-webclient-netty/src/main/java/reactivefeign/webclient/netty/NettyReactiveOptions.java (83%) rename feign-reactor-webclient/src/main/java/reactivefeign/webclient/WebReactiveFeign.java => feign-reactor-webclient-netty/src/main/java/reactivefeign/webclient/netty/NettyWebReactiveFeign.java (87%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/BasicFeaturesTest.java (92%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/CollectionFormatTest.java (89%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/CompressionTest.java (76%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/ConnectionTimeoutTest.java (76%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/ContractTest.java (88%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/DefaultMethodTest.java (74%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/ErrorMapperTest.java (89%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/FallbackTest.java (88%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/LoggerTest.java (79%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/MetricsTest.java (74%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/MultiPartTest.java (70%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/NotFoundTest.java (89%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/ObjectMapperTest.java (89%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/OptionsTest.java (75%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/ReactivityTest.java (89%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/RequestInterceptorTest.java (89%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/ResponseEntityTest.java (69%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/ResponseMapperTest.java (89%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/RetryingTest.java (89%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/SmokeTest.java (89%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/SslVerificationTest.java (93%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/StatusHandlerTest.java (89%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/allfeatures/AllFeaturesTest.java (94%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesApi.java (100%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesController.java (100%) rename {feign-reactor-webclient => feign-reactor-webclient-netty}/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesTest.java (94%) create mode 100644 feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/h2c/AllFeaturesTest.java create mode 100644 feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/h2c/ReactivityTest.java diff --git a/.circleci/config.yml b/.circleci/config.yml index 462ce2da..5018bf44 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ version: 2 # use CircleCI 2.0 jobs: # a collection of steps build: environment: - # Configure the JVMto avoid OOM errors + # Configure the JVM to avoid OOM errors _JAVA_OPTIONS: "-Xmx3g" docker: # run the steps with Docker - image: circleci/openjdk:17.0.1-jdk-buster diff --git a/feign-reactor-benchmarks/pom.xml b/feign-reactor-benchmarks/pom.xml index 4179bc30..4c8c8ab2 100644 --- a/feign-reactor-benchmarks/pom.xml +++ b/feign-reactor-benchmarks/pom.xml @@ -32,7 +32,7 @@ com.playtika.reactivefeign - feign-reactor-webclient + feign-reactor-webclient-netty diff --git a/feign-reactor-benchmarks/src/main/java/reactivefeign/benchmarks/RealRequestBenchmarks.java b/feign-reactor-benchmarks/src/main/java/reactivefeign/benchmarks/RealRequestBenchmarks.java index f1b7b97a..7c40bbd4 100644 --- a/feign-reactor-benchmarks/src/main/java/reactivefeign/benchmarks/RealRequestBenchmarks.java +++ b/feign-reactor-benchmarks/src/main/java/reactivefeign/benchmarks/RealRequestBenchmarks.java @@ -24,7 +24,7 @@ import reactivefeign.java11.Java11ReactiveOptions; import reactivefeign.jetty.JettyReactiveFeign; import reactivefeign.jetty.JettyReactiveOptions; -import reactivefeign.webclient.WebReactiveFeign; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; import reactor.core.publisher.Mono; import java.io.IOException; @@ -86,7 +86,7 @@ protected void setup() throws Exception { webClient = WebClient.create(); - webClientFeign = WebReactiveFeign.builder() + webClientFeign = NettyWebReactiveFeign.builder() .target(FeignReactorTestInterface.class, SERVER_URL); jettyHttpClient = new HttpClient(); diff --git a/feign-reactor-bom/pom.xml b/feign-reactor-bom/pom.xml index 91fcb402..0db1d1a3 100644 --- a/feign-reactor-bom/pom.xml +++ b/feign-reactor-bom/pom.xml @@ -58,7 +58,7 @@ com.playtika.reactivefeign - feign-reactor-webclient + feign-reactor-webclient-netty ${project.version} diff --git a/feign-reactor-cloud/pom.xml b/feign-reactor-cloud/pom.xml index cacbc1cb..e0f66122 100644 --- a/feign-reactor-cloud/pom.xml +++ b/feign-reactor-cloud/pom.xml @@ -37,7 +37,7 @@ com.playtika.reactivefeign - feign-reactor-webclient + feign-reactor-webclient-netty test diff --git a/feign-reactor-cloud/src/test/java/reactivefeign/cloud2/BuilderUtils.java b/feign-reactor-cloud/src/test/java/reactivefeign/cloud2/BuilderUtils.java index 7f583bad..83c52358 100644 --- a/feign-reactor-cloud/src/test/java/reactivefeign/cloud2/BuilderUtils.java +++ b/feign-reactor-cloud/src/test/java/reactivefeign/cloud2/BuilderUtils.java @@ -4,7 +4,7 @@ import org.springframework.cloud.circuitbreaker.resilience4j.Resilience4JConfigBuilder; import org.springframework.cloud.client.circuitbreaker.ConfigBuilder; import org.springframework.cloud.client.circuitbreaker.ReactiveCircuitBreakerFactory; -import reactivefeign.webclient.WebReactiveFeign; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; import java.time.Duration; import java.util.concurrent.atomic.AtomicInteger; @@ -16,7 +16,7 @@ public class BuilderUtils { private static final AtomicInteger uniqueCircuitBreakerCounter = new AtomicInteger(); static CloudReactiveFeign.Builder cloudBuilder(){ - return CloudReactiveFeign.builder(WebReactiveFeign.builder()); + return CloudReactiveFeign.builder(NettyWebReactiveFeign.builder()); } static CloudReactiveFeign.Builder cloudBuilder(ReactiveCircuitBreakerFactory circuitBreakerFactory){ @@ -38,7 +38,7 @@ static CloudReactiveFeign.Builder cloudBuilderWithUniqueCircuitBreaker( Consumer customizer, AtomicReference lastCircuitBreakerId) { int uniqueId = uniqueCircuitBreakerCounter.incrementAndGet(); - return CloudReactiveFeign.builder(WebReactiveFeign.builder()) + return CloudReactiveFeign.builder(NettyWebReactiveFeign.builder()) .enableCircuitBreaker(circuitBreakerId -> { String uniqueCircuitBreakerId = circuitBreakerId + "."+uniqueId; if(lastCircuitBreakerId != null) { diff --git a/feign-reactor-cloud/src/test/java/reactivefeign/cloud2/MetricsTest.java b/feign-reactor-cloud/src/test/java/reactivefeign/cloud2/MetricsTest.java index b9427593..2b8ad712 100644 --- a/feign-reactor-cloud/src/test/java/reactivefeign/cloud2/MetricsTest.java +++ b/feign-reactor-cloud/src/test/java/reactivefeign/cloud2/MetricsTest.java @@ -19,21 +19,21 @@ import org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer; import reactivefeign.ReactiveFeignBuilder; import reactivefeign.testcase.IcecreamServiceApi; -import reactivefeign.webclient.WebReactiveOptions; +import reactivefeign.webclient.netty.NettyReactiveOptions; /** * @author Sergii Karpenko */ public class MetricsTest extends reactivefeign.MetricsTest { - private static String serviceName = "MetricsTest-loadBalancingDefaultPolicyRoundRobin"; + private static final String serviceName = "MetricsTest-loadBalancingDefaultPolicyRoundRobin"; - private static ReactiveLoadBalancer.Factory loadBalancerFactory; + private static ReactiveLoadBalancer.Factory loadBalancerFactory; - @BeforeClass - public static void setupServersList() { - loadBalancerFactory = LoadBalancingReactiveHttpClientTest.loadBalancerFactory(serviceName, wireMockRule.port()); - } + @BeforeClass + public static void setupServersList() { + loadBalancerFactory = LoadBalancingReactiveHttpClientTest.loadBalancerFactory(serviceName, wireMockRule.port()); + } @Override protected String getHost() { @@ -55,7 +55,7 @@ protected Target target(){ protected ReactiveFeignBuilder builder(long readTimeoutInMillis) { return BuilderUtils.cloudBuilder() .enableLoadBalancer(loadBalancerFactory) - .options(new WebReactiveOptions.Builder().setReadTimeoutMillis(readTimeoutInMillis).build() + .options(new NettyReactiveOptions.Builder().setReadTimeoutMillis(readTimeoutInMillis).build() ); } diff --git a/feign-reactor-core/src/test/java/reactivefeign/ReactivityTest.java b/feign-reactor-core/src/test/java/reactivefeign/ReactivityTest.java index 4eaa1e46..aabbd2b6 100644 --- a/feign-reactor-core/src/test/java/reactivefeign/ReactivityTest.java +++ b/feign-reactor-core/src/test/java/reactivefeign/ReactivityTest.java @@ -15,12 +15,13 @@ import com.fasterxml.jackson.core.JsonProcessingException; import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.junit.Before; import org.junit.Test; import reactivefeign.testcase.IcecreamServiceApi; import reactivefeign.testcase.domain.OrderGenerator; import reactor.core.publisher.Mono; import reactor.netty.DisposableServer; +import reactor.netty.http.HttpProtocol; import reactor.netty.http.server.HttpServer; import java.time.Duration; @@ -29,7 +30,6 @@ import static org.awaitility.Awaitility.waitAtMost; import static org.hamcrest.CoreMatchers.is; -import static reactor.netty.http.HttpProtocol.H2C; import static reactor.netty.http.HttpProtocol.HTTP11; /** @@ -45,19 +45,25 @@ abstract public class ReactivityTest extends BaseReactorTest { private static DisposableServer server; - @BeforeClass - public static void startServer() throws JsonProcessingException { - byte[] data = TestUtils.MAPPER.writeValueAsString(new OrderGenerator().generate(1)).getBytes(); - - server = HttpServer.create() - .protocol(HTTP11, H2C) - .route(r -> r.get("/icecream/orders/1", - (req, res) -> { - res.header("Content-Type", "application/json"); - return Mono.delay(Duration.ofMillis(DELAY_IN_MILLIS)) - .thenEmpty(res.sendByteArray(Mono.just(data))); - })) - .bindNow(); + @Before + public void startServer() throws JsonProcessingException { + if(server == null) { + byte[] data = TestUtils.MAPPER.writeValueAsString(new OrderGenerator().generate(1)).getBytes(); + + server = HttpServer.create() + .protocol(serverProtocols()) + .route(r -> r.get("/icecream/orders/1", + (req, res) -> { + res.header("Content-Type", "application/json"); + return Mono.delay(Duration.ofMillis(DELAY_IN_MILLIS)) + .thenEmpty(res.sendByteArray(Mono.just(data))); + })) + .bindNow(); + } + } + + protected HttpProtocol[] serverProtocols(){ + return new HttpProtocol[]{HTTP11}; } @AfterClass diff --git a/feign-reactor-java11/src/test/java/reactivefeign/java11/h2c/ReactivityTest.java b/feign-reactor-java11/src/test/java/reactivefeign/java11/h2c/ReactivityTest.java index 39c0b516..7f4dd1f6 100644 --- a/feign-reactor-java11/src/test/java/reactivefeign/java11/h2c/ReactivityTest.java +++ b/feign-reactor-java11/src/test/java/reactivefeign/java11/h2c/ReactivityTest.java @@ -15,11 +15,19 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactor.netty.http.HttpProtocol; import static reactivefeign.java11.h2c.TestUtils.builderHttp2; +import static reactor.netty.http.HttpProtocol.H2C; +import static reactor.netty.http.HttpProtocol.HTTP11; public class ReactivityTest extends reactivefeign.ReactivityTest { + @Override + protected HttpProtocol[] serverProtocols(){ + return new HttpProtocol[]{H2C, HTTP11}; + } + @Override protected ReactiveFeign.Builder builder() { return builderHttp2(); diff --git a/feign-reactor-jetty/src/test/java/reactivefeign/jetty/h2c/ReactivityTest.java b/feign-reactor-jetty/src/test/java/reactivefeign/jetty/h2c/ReactivityTest.java index def22561..3aede20e 100644 --- a/feign-reactor-jetty/src/test/java/reactivefeign/jetty/h2c/ReactivityTest.java +++ b/feign-reactor-jetty/src/test/java/reactivefeign/jetty/h2c/ReactivityTest.java @@ -17,9 +17,17 @@ import reactivefeign.jetty.JettyReactiveFeign; import reactivefeign.jetty.JettyReactiveOptions; import reactivefeign.testcase.IcecreamServiceApi; +import reactor.netty.http.HttpProtocol; + +import static reactor.netty.http.HttpProtocol.H2C; public class ReactivityTest extends reactivefeign.ReactivityTest { + @Override + protected HttpProtocol[] serverProtocols(){ + return new HttpProtocol[]{H2C}; + } + @Override protected ReactiveFeign.Builder builder() { return JettyReactiveFeign.builder().options( diff --git a/feign-reactor-parent/pom.xml b/feign-reactor-parent/pom.xml index 331eb788..ba8b049f 100644 --- a/feign-reactor-parent/pom.xml +++ b/feign-reactor-parent/pom.xml @@ -97,7 +97,7 @@ com.playtika.reactivefeign - feign-reactor-webclient + feign-reactor-webclient-netty ${project.version} diff --git a/feign-reactor-rx2/pom.xml b/feign-reactor-rx2/pom.xml index 0a79d271..d6b472b6 100644 --- a/feign-reactor-rx2/pom.xml +++ b/feign-reactor-rx2/pom.xml @@ -25,7 +25,7 @@ com.playtika.reactivefeign - feign-reactor-webclient + feign-reactor-webclient-netty diff --git a/feign-reactor-rx2/src/main/java/reactivefeign/rx2/Rx2ReactiveFeign.java b/feign-reactor-rx2/src/main/java/reactivefeign/rx2/Rx2ReactiveFeign.java index 71dc1918..b1172307 100644 --- a/feign-reactor-rx2/src/main/java/reactivefeign/rx2/Rx2ReactiveFeign.java +++ b/feign-reactor-rx2/src/main/java/reactivefeign/rx2/Rx2ReactiveFeign.java @@ -19,7 +19,7 @@ import reactivefeign.rx2.client.statushandler.Rx2StatusHandler; import reactivefeign.rx2.methodhandler.Rx2MethodHandlerFactory; import reactivefeign.webclient.WebClientFeignCustomizer; -import reactivefeign.webclient.WebReactiveFeign; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; import reactivefeign.webclient.client.WebReactiveHttpClient; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -52,7 +52,7 @@ public static Builder builder(WebClient.Builder webClientBuilder, WebClie return new Builder<>(webClientBuilder, webClientCustomizer); } - public static class Builder extends WebReactiveFeign.Builder { + public static class Builder extends NettyWebReactiveFeign.Builder { private BackpressureStrategy backpressureStrategy; diff --git a/feign-reactor-rx2/src/test/java/reactivefeign/rx2/DefaultMethodTest.java b/feign-reactor-rx2/src/test/java/reactivefeign/rx2/DefaultMethodTest.java index 5ddaddfd..0c369692 100644 --- a/feign-reactor-rx2/src/test/java/reactivefeign/rx2/DefaultMethodTest.java +++ b/feign-reactor-rx2/src/test/java/reactivefeign/rx2/DefaultMethodTest.java @@ -26,7 +26,7 @@ import reactivefeign.rx2.testcase.IcecreamServiceApi; import reactivefeign.rx2.testcase.domain.IceCreamOrder; import reactivefeign.rx2.testcase.domain.OrderGenerator; -import reactivefeign.webclient.WebReactiveOptions; +import reactivefeign.webclient.netty.NettyReactiveOptions; import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; @@ -95,7 +95,7 @@ public void shouldNotWrapException() { public void shouldOverrideEquals() { IcecreamServiceApi client = builder( - new WebReactiveOptions.Builder() + new NettyReactiveOptions.Builder() .setReadTimeoutMillis(100) .setConnectTimeoutMillis(300) .build()) diff --git a/feign-reactor-rx2/src/test/java/reactivefeign/rx2/ReadTimeoutTest.java b/feign-reactor-rx2/src/test/java/reactivefeign/rx2/ReadTimeoutTest.java index f52be01a..4ce69cd2 100644 --- a/feign-reactor-rx2/src/test/java/reactivefeign/rx2/ReadTimeoutTest.java +++ b/feign-reactor-rx2/src/test/java/reactivefeign/rx2/ReadTimeoutTest.java @@ -20,7 +20,7 @@ import reactivefeign.ReactiveOptions; import reactivefeign.client.ReadTimeoutException; import reactivefeign.rx2.testcase.IcecreamServiceApi; -import reactivefeign.webclient.WebReactiveOptions; +import reactivefeign.webclient.netty.NettyReactiveOptions; import static com.github.tomakehurst.wiremock.client.WireMock.*; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; @@ -48,7 +48,7 @@ public void shouldFailOnReadTimeout() throws InterruptedException { .willReturn(aResponse().withFixedDelay(200))); IcecreamServiceApi client = builder( - new WebReactiveOptions.Builder() + new NettyReactiveOptions.Builder() .setReadTimeoutMillis(100) .setConnectTimeoutMillis(300) .build()) diff --git a/feign-reactor-spring-cloud-starter/pom.xml b/feign-reactor-spring-cloud-starter/pom.xml index ed014fb8..ee20b7d1 100644 --- a/feign-reactor-spring-cloud-starter/pom.xml +++ b/feign-reactor-spring-cloud-starter/pom.xml @@ -25,7 +25,7 @@ com.playtika.reactivefeign - feign-reactor-webclient + feign-reactor-webclient-netty diff --git a/feign-reactor-spring-configuration/pom.xml b/feign-reactor-spring-configuration/pom.xml index 019d50bd..b776d8a7 100644 --- a/feign-reactor-spring-configuration/pom.xml +++ b/feign-reactor-spring-configuration/pom.xml @@ -40,7 +40,7 @@ com.playtika.reactivefeign - feign-reactor-webclient + feign-reactor-webclient-netty true @@ -68,6 +68,24 @@ true + + org.junit.vintage + junit-vintage-engine + test + + + + org.assertj + assertj-core + test + + + + org.mockito + mockito-core + test + + \ No newline at end of file diff --git a/feign-reactor-spring-configuration/src/main/java/reactivefeign/spring/config/ReactiveFeignAutoConfiguration.java b/feign-reactor-spring-configuration/src/main/java/reactivefeign/spring/config/ReactiveFeignAutoConfiguration.java index 4d3b6dde..e12eb8b4 100644 --- a/feign-reactor-spring-configuration/src/main/java/reactivefeign/spring/config/ReactiveFeignAutoConfiguration.java +++ b/feign-reactor-spring-configuration/src/main/java/reactivefeign/spring/config/ReactiveFeignAutoConfiguration.java @@ -14,8 +14,8 @@ import reactivefeign.java11.Java11ReactiveOptions; import reactivefeign.jetty.JettyReactiveFeign; import reactivefeign.jetty.JettyReactiveOptions; -import reactivefeign.webclient.WebReactiveFeign; -import reactivefeign.webclient.WebReactiveOptions; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; +import reactivefeign.webclient.netty.NettyReactiveOptions; import java.util.ArrayList; import java.util.List; @@ -40,13 +40,13 @@ public ReactiveFeignNamedContextFactory reactiveFeignContext() { } @Configuration - @ConditionalOnClass(WebReactiveFeign.class) + @ConditionalOnClass(NettyWebReactiveFeign.class) public class WebClientReactiveFeignClientPropertiesAutoConfiguration { @Bean @ConditionalOnMissingBean @ConfigurationProperties("reactive.feign.client") - public ReactiveFeignClientsProperties webClientReactiveFeignClientProperties() { + public ReactiveFeignClientsProperties webClientReactiveFeignClientProperties() { return new ReactiveFeignClientsProperties<>(); } diff --git a/feign-reactor-spring-configuration/src/main/java/reactivefeign/spring/config/ReactiveFeignClientsConfiguration.java b/feign-reactor-spring-configuration/src/main/java/reactivefeign/spring/config/ReactiveFeignClientsConfiguration.java index 6007f55a..0138dc5d 100644 --- a/feign-reactor-spring-configuration/src/main/java/reactivefeign/spring/config/ReactiveFeignClientsConfiguration.java +++ b/feign-reactor-spring-configuration/src/main/java/reactivefeign/spring/config/ReactiveFeignClientsConfiguration.java @@ -44,7 +44,7 @@ import reactivefeign.jetty.JettyHttpClientFactory; import reactivefeign.jetty.JettyReactiveFeign; import reactivefeign.webclient.WebClientFeignCustomizer; -import reactivefeign.webclient.WebReactiveFeign; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; import java.time.Clock; import java.util.ArrayList; @@ -124,7 +124,7 @@ public ReactiveFeignBuilder reactiveFeignBuilder( } @Configuration - @ConditionalOnClass({WebReactiveFeign.class, WebClient.class}) + @ConditionalOnClass({NettyWebReactiveFeign.class, WebClient.class}) @ConditionalOnProperty(name = {"reactive.feign.jetty", "reactive.feign.java11"}, havingValue = "false", matchIfMissing = true) protected static class ReactiveFeignWebConfiguration { @@ -134,8 +134,8 @@ public ReactiveFeignBuilder reactiveFeignBuilder( WebClient.Builder builder, @Autowired(required = false) WebClientFeignCustomizer webClientCustomizer) { return webClientCustomizer != null - ? WebReactiveFeign.builder(builder, webClientCustomizer) - : WebReactiveFeign.builder(builder); + ? NettyWebReactiveFeign.builder(builder, webClientCustomizer) + : NettyWebReactiveFeign.builder(builder); } } diff --git a/feign-reactor-test/feign-reactor-spring-configuration-cloud2-test/pom.xml b/feign-reactor-test/feign-reactor-spring-configuration-cloud2-test/pom.xml index a85ed030..42ce46b6 100644 --- a/feign-reactor-test/feign-reactor-spring-configuration-cloud2-test/pom.xml +++ b/feign-reactor-test/feign-reactor-spring-configuration-cloud2-test/pom.xml @@ -55,7 +55,7 @@ com.playtika.reactivefeign - feign-reactor-webclient + feign-reactor-webclient-netty test diff --git a/feign-reactor-test/feign-reactor-spring-configuration-cloud2-test/src/test/java/reactivefeign/spring/config/cloud2/SampleConfigurationsTest.java b/feign-reactor-test/feign-reactor-spring-configuration-cloud2-test/src/test/java/reactivefeign/spring/config/cloud2/SampleConfigurationsTest.java index 12d0cc5f..c24f56cf 100644 --- a/feign-reactor-test/feign-reactor-spring-configuration-cloud2-test/src/test/java/reactivefeign/spring/config/cloud2/SampleConfigurationsTest.java +++ b/feign-reactor-test/feign-reactor-spring-configuration-cloud2-test/src/test/java/reactivefeign/spring/config/cloud2/SampleConfigurationsTest.java @@ -47,7 +47,7 @@ import reactivefeign.spring.config.EnableReactiveFeignClients; import reactivefeign.spring.config.ReactiveFeignClient; import reactivefeign.spring.config.ReactiveRetryPolicies; -import reactivefeign.webclient.WebReactiveOptions; +import reactivefeign.webclient.netty.NettyReactiveOptions; import reactor.core.Exceptions; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -297,7 +297,7 @@ protected static class ReactiveFeignSampleConfiguration { @Bean public ReactiveOptions reactiveOptions(){ - return new WebReactiveOptions.Builder().setReadTimeoutMillis(500).build(); + return new NettyReactiveOptions.Builder().setReadTimeoutMillis(500).build(); } @Bean diff --git a/feign-reactor-test/feign-reactor-spring-configuration-test/pom.xml b/feign-reactor-test/feign-reactor-spring-configuration-test/pom.xml index 7aea8052..ca8fbcdb 100644 --- a/feign-reactor-test/feign-reactor-spring-configuration-test/pom.xml +++ b/feign-reactor-test/feign-reactor-spring-configuration-test/pom.xml @@ -32,7 +32,7 @@ com.playtika.reactivefeign - feign-reactor-webclient + feign-reactor-webclient-netty diff --git a/feign-reactor-test/feign-reactor-spring-configuration-test/src/test/java/reactivefeign/spring/config/ReactiveFeignClientUsingConfigurationsTests.java b/feign-reactor-test/feign-reactor-spring-configuration-test/src/test/java/reactivefeign/spring/config/ReactiveFeignClientUsingConfigurationsTests.java index d8ac33d4..4eb76d4d 100644 --- a/feign-reactor-test/feign-reactor-spring-configuration-test/src/test/java/reactivefeign/spring/config/ReactiveFeignClientUsingConfigurationsTests.java +++ b/feign-reactor-test/feign-reactor-spring-configuration-test/src/test/java/reactivefeign/spring/config/ReactiveFeignClientUsingConfigurationsTests.java @@ -34,7 +34,7 @@ import reactivefeign.ReactiveOptions; import reactivefeign.client.ReactiveHttpRequestInterceptor; import reactivefeign.client.ReadTimeoutException; -import reactivefeign.webclient.WebReactiveOptions; +import reactivefeign.webclient.netty.NettyReactiveOptions; import reactor.core.publisher.Mono; import static com.github.tomakehurst.wiremock.client.WireMock.*; @@ -116,7 +116,7 @@ protected static class Application { protected static class DefaultConfiguration { @Bean public ReactiveOptions reactiveFeignOptions(){ - return new WebReactiveOptions.Builder() + return new NettyReactiveOptions.Builder() .setReadTimeoutMillis(5000) .setConnectTimeoutMillis(5000) .build(); @@ -140,7 +140,7 @@ protected static class BarConfiguration { @Primary @Bean public ReactiveOptions options(){ - return new WebReactiveOptions.Builder() + return new NettyReactiveOptions.Builder() .setReadTimeoutMillis(500) .setConnectTimeoutMillis(500) .build(); diff --git a/feign-reactor-test/feign-reactor-spring-mvc-test/pom.xml b/feign-reactor-test/feign-reactor-spring-mvc-test/pom.xml index 01f52602..cda3f029 100644 --- a/feign-reactor-test/feign-reactor-spring-mvc-test/pom.xml +++ b/feign-reactor-test/feign-reactor-spring-mvc-test/pom.xml @@ -43,7 +43,7 @@ com.playtika.reactivefeign - feign-reactor-webclient + feign-reactor-webclient-netty test diff --git a/feign-reactor-test/feign-reactor-spring-mvc-test/src/test/java/reactivefeign/spring/mvc/MultiPartTest.java b/feign-reactor-test/feign-reactor-spring-mvc-test/src/test/java/reactivefeign/spring/mvc/MultiPartTest.java index cc1ca6b2..89ded022 100644 --- a/feign-reactor-test/feign-reactor-spring-mvc-test/src/test/java/reactivefeign/spring/mvc/MultiPartTest.java +++ b/feign-reactor-test/feign-reactor-spring-mvc-test/src/test/java/reactivefeign/spring/mvc/MultiPartTest.java @@ -26,7 +26,7 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.bind.annotation.*; import reactivefeign.BaseReactorTest; -import reactivefeign.webclient.WebReactiveFeign; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -53,7 +53,7 @@ public class MultiPartTest extends BaseReactorTest { @Before public void setUp() { - client = WebReactiveFeign.builder() + client = NettyWebReactiveFeign.builder() .decode404() .contract(new SpringMvcContract(emptyList(), new DefaultFormattingConversionService())) .target(MultipartClient.class, "http://localhost:" + port); diff --git a/feign-reactor-test/feign-reactor-spring-mvc-test/src/test/java/reactivefeign/spring/mvc/allfeatures/AllFeaturesMvcWebTest.java b/feign-reactor-test/feign-reactor-spring-mvc-test/src/test/java/reactivefeign/spring/mvc/allfeatures/AllFeaturesMvcWebTest.java index 8bf93722..2c6d3ee4 100644 --- a/feign-reactor-test/feign-reactor-spring-mvc-test/src/test/java/reactivefeign/spring/mvc/allfeatures/AllFeaturesMvcWebTest.java +++ b/feign-reactor-test/feign-reactor-spring-mvc-test/src/test/java/reactivefeign/spring/mvc/allfeatures/AllFeaturesMvcWebTest.java @@ -19,7 +19,7 @@ import org.junit.Ignore; import org.junit.Test; import reactivefeign.ReactiveFeign; -import reactivefeign.webclient.WebReactiveFeign; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -30,7 +30,7 @@ public class AllFeaturesMvcWebTest extends AllFeaturesMvcTest{ @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } @Test diff --git a/feign-reactor-webclient-apache-client5/pom.xml b/feign-reactor-webclient-apache-client5/pom.xml index 206dd60d..4da2b775 100644 --- a/feign-reactor-webclient-apache-client5/pom.xml +++ b/feign-reactor-webclient-apache-client5/pom.xml @@ -108,19 +108,16 @@ jetty-server test - org.eclipse.jetty jetty-servlet test - org.eclipse.jetty.http2 http2-server test - org.eclipse.jetty jetty-webapp diff --git a/feign-reactor-webclient-apache-client5/src/test/java/reactivefeign/webclient/client5/h2c/ReactivityTest.java b/feign-reactor-webclient-apache-client5/src/test/java/reactivefeign/webclient/client5/h2c/ReactivityTest.java index b56c1f4f..72214fd7 100644 --- a/feign-reactor-webclient-apache-client5/src/test/java/reactivefeign/webclient/client5/h2c/ReactivityTest.java +++ b/feign-reactor-webclient-apache-client5/src/test/java/reactivefeign/webclient/client5/h2c/ReactivityTest.java @@ -15,11 +15,18 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactor.netty.http.HttpProtocol; import static reactivefeign.webclient.client5.h2c.TestUtils.builderHttp2WithRequestTimeout; +import static reactor.netty.http.HttpProtocol.H2C; public class ReactivityTest extends reactivefeign.ReactivityTest { + @Override + protected HttpProtocol[] serverProtocols(){ + return new HttpProtocol[]{H2C}; + } + @Override protected ReactiveFeign.Builder builder() { return builderHttp2WithRequestTimeout(timeToCompleteReactively()); diff --git a/feign-reactor-webclient/pom.xml b/feign-reactor-webclient-netty/pom.xml similarity index 81% rename from feign-reactor-webclient/pom.xml rename to feign-reactor-webclient-netty/pom.xml index 69143c05..efb725ef 100644 --- a/feign-reactor-webclient/pom.xml +++ b/feign-reactor-webclient-netty/pom.xml @@ -9,7 +9,7 @@ 4.0.2 - feign-reactor-webclient + feign-reactor-webclient-netty WebClient with ReactorClientHttpConnector (Netty) @@ -47,6 +47,12 @@ test-jar test + + com.playtika.reactivefeign + feign-reactor-server-configurations + test-jar + test + org.springframework.boot spring-boot-starter-webflux @@ -85,6 +91,27 @@ test + + org.eclipse.jetty + jetty-server + test + + + org.eclipse.jetty + jetty-servlet + test + + + org.eclipse.jetty.http2 + http2-server + test + + + org.eclipse.jetty + jetty-webapp + test + + org.apache.logging.log4j log4j-api diff --git a/feign-reactor-webclient/src/main/java/reactivefeign/webclient/NettyClientHttpConnectorBuilder.java b/feign-reactor-webclient-netty/src/main/java/reactivefeign/webclient/netty/NettyClientHttpConnectorBuilder.java similarity index 88% rename from feign-reactor-webclient/src/main/java/reactivefeign/webclient/NettyClientHttpConnectorBuilder.java rename to feign-reactor-webclient-netty/src/main/java/reactivefeign/webclient/netty/NettyClientHttpConnectorBuilder.java index f2038a69..25cb06d5 100644 --- a/feign-reactor-webclient/src/main/java/reactivefeign/webclient/NettyClientHttpConnectorBuilder.java +++ b/feign-reactor-webclient-netty/src/main/java/reactivefeign/webclient/netty/NettyClientHttpConnectorBuilder.java @@ -1,4 +1,4 @@ -package reactivefeign.webclient; +package reactivefeign.webclient.netty; import io.netty.channel.ChannelOption; import io.netty.handler.ssl.SslContext; @@ -10,6 +10,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.http.client.reactive.ReactorClientHttpConnector; +import reactor.netty.http.HttpProtocol; import reactor.netty.http.HttpResources; import reactor.netty.http.client.HttpClient; import reactor.netty.resources.ConnectionProvider; @@ -23,6 +24,7 @@ import java.util.function.Function; import static java.lang.Boolean.TRUE; +import static reactivefeign.ReactiveOptions.useHttp2; import static reactor.netty.resources.LoopResources.DEFAULT_NATIVE; class NettyClientHttpConnectorBuilder { @@ -32,7 +34,7 @@ class NettyClientHttpConnectorBuilder { private NettyClientHttpConnectorBuilder() { } - public static ClientHttpConnector buildNettyClientHttpConnector(HttpClient httpClient, WebReactiveOptions webOptions) { + public static ClientHttpConnector buildNettyClientHttpConnector(HttpClient httpClient, NettyReactiveOptions webOptions) { if (httpClient == null) { @@ -90,7 +92,7 @@ public static ClientHttpConnector buildNettyClientHttpConnector(HttpClient httpC } }); - WebReactiveOptions.WebProxySettings proxySettings = (WebReactiveOptions.WebProxySettings)webOptions.getProxySettings(); + NettyReactiveOptions.WebProxySettings proxySettings = (NettyReactiveOptions.WebProxySettings)webOptions.getProxySettings(); if (proxySettings != null) { httpClient = httpClient.proxy(typeSpec -> { ProxyProvider.Builder proxyBuilder = typeSpec.type(ProxyProvider.Proxy.HTTP) @@ -116,6 +118,19 @@ public static ClientHttpConnector buildNettyClientHttpConnector(HttpClient httpC httpClient = httpClient.followRedirect(webOptions.isFollowRedirects()); } + HttpProtocol[] protocols; + if(webOptions.getProtocols() != null){ + protocols = webOptions.getProtocols(); + } else { + if(useHttp2(webOptions)){ + protocols = new HttpProtocol[]{HttpProtocol.H2C, HttpProtocol.H2, HttpProtocol.HTTP11}; + } else { + protocols = new HttpProtocol[]{HttpProtocol.HTTP11}; + } + } + + httpClient = httpClient.protocol(protocols); + if(webOptions.getSslContext() != null){ httpClient = httpClient.secure(sslProviderBuilder -> sslProviderBuilder.sslContext(webOptions.getSslContext())); } diff --git a/feign-reactor-webclient/src/main/java/reactivefeign/webclient/WebReactiveOptions.java b/feign-reactor-webclient-netty/src/main/java/reactivefeign/webclient/netty/NettyReactiveOptions.java similarity index 83% rename from feign-reactor-webclient/src/main/java/reactivefeign/webclient/WebReactiveOptions.java rename to feign-reactor-webclient-netty/src/main/java/reactivefeign/webclient/netty/NettyReactiveOptions.java index e329400f..8f0280df 100644 --- a/feign-reactor-webclient/src/main/java/reactivefeign/webclient/WebReactiveOptions.java +++ b/feign-reactor-webclient-netty/src/main/java/reactivefeign/webclient/netty/NettyReactiveOptions.java @@ -11,19 +11,20 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package reactivefeign.webclient; +package reactivefeign.webclient.netty; import io.netty.handler.ssl.SslContext; import reactivefeign.ReactiveOptions; +import reactor.netty.http.HttpProtocol; import reactor.netty.resources.ConnectionProvider; /** * @author Sergii Karpenko * @author Sebastian Nawrocki */ -public class WebReactiveOptions extends ReactiveOptions { +public class NettyReactiveOptions extends ReactiveOptions { - public static final WebReactiveOptions DEFAULT_OPTIONS = (WebReactiveOptions)new WebReactiveOptions.Builder() + public static final NettyReactiveOptions DEFAULT_OPTIONS = (NettyReactiveOptions)new NettyReactiveOptions.Builder() .setReadTimeoutMillis(10000) .setWriteTimeoutMillis(10000) .setConnectTimeoutMillis(5000) @@ -43,17 +44,19 @@ public class WebReactiveOptions extends ReactiveOptions { private final Long connectionMaxLifeTimeMillis; private final Integer pendingAcquireMaxCount; private final Long pendingAcquireTimeoutMillis; - - private WebReactiveOptions(Boolean useHttp2, Long connectTimeoutMillis, - Long readTimeoutMillis, Long writeTimeoutMillis, Long responseTimeoutMillis, - Boolean tryUseCompression, Boolean followRedirects, - ProxySettings proxySettings, - SslContext sslContext, Boolean disableSslValidation, - Boolean metricsEnabled, - ConnectionProvider connectionProvider, - Integer maxConnections, Boolean connectionMetricsEnabled, - Long connectionMaxIdleTimeMillis, Long connectionMaxLifeTimeMillis, - Integer pendingAcquireMaxCount, Long pendingAcquireTimeoutMillis) { + private final HttpProtocol[] protocols; + + private NettyReactiveOptions(Boolean useHttp2, Long connectTimeoutMillis, + Long readTimeoutMillis, Long writeTimeoutMillis, Long responseTimeoutMillis, + Boolean tryUseCompression, Boolean followRedirects, + ProxySettings proxySettings, + SslContext sslContext, Boolean disableSslValidation, + Boolean metricsEnabled, + ConnectionProvider connectionProvider, + Integer maxConnections, Boolean connectionMetricsEnabled, + Long connectionMaxIdleTimeMillis, Long connectionMaxLifeTimeMillis, + Integer pendingAcquireMaxCount, Long pendingAcquireTimeoutMillis, + HttpProtocol[] protocols) { super(useHttp2, connectTimeoutMillis, tryUseCompression, followRedirects, proxySettings); this.readTimeoutMillis = readTimeoutMillis; @@ -69,6 +72,7 @@ private WebReactiveOptions(Boolean useHttp2, Long connectTimeoutMillis, this.connectionMaxLifeTimeMillis = connectionMaxLifeTimeMillis; this.pendingAcquireMaxCount = pendingAcquireMaxCount; this.pendingAcquireTimeoutMillis = pendingAcquireTimeoutMillis; + this.protocols = protocols; } public Long getReadTimeoutMillis() { @@ -123,6 +127,10 @@ public Long getPendingAcquireTimeoutMillis() { return pendingAcquireTimeoutMillis; } + public HttpProtocol[] getProtocols() { + return protocols; + } + public static class Builder extends ReactiveOptions.Builder { private Long readTimeoutMillis; private Long writeTimeoutMillis; @@ -137,6 +145,7 @@ public static class Builder extends ReactiveOptions.Builder { private Long connectionMaxLifeTimeMillis; private Integer pendingAcquireMaxCount; private Long pendingAcquireTimeoutMillis; + private HttpProtocol[] protocols; public Builder() {} @@ -205,8 +214,13 @@ public Builder setPendingAcquireTimeoutMillis(Long pendingAcquireTimeoutMillis) return this; } - public WebReactiveOptions build() { - return new WebReactiveOptions(useHttp2, connectTimeoutMillis, + public Builder setProtocols(HttpProtocol[] protocols) { + this.protocols = protocols; + return this; + } + + public NettyReactiveOptions build() { + return new NettyReactiveOptions(useHttp2, connectTimeoutMillis, readTimeoutMillis, writeTimeoutMillis, responseTimeoutMillis, acceptCompressed, followRedirects, proxySettings, sslContext, disableSslValidation, @@ -214,7 +228,8 @@ public WebReactiveOptions build() { connectionProvider, maxConnections, connectionMetricsEnabled, connectionMaxIdleTimeMillis, connectionMaxLifeTimeMillis, - pendingAcquireMaxCount, pendingAcquireTimeoutMillis); + pendingAcquireMaxCount, pendingAcquireTimeoutMillis, + protocols); } } diff --git a/feign-reactor-webclient/src/main/java/reactivefeign/webclient/WebReactiveFeign.java b/feign-reactor-webclient-netty/src/main/java/reactivefeign/webclient/netty/NettyWebReactiveFeign.java similarity index 87% rename from feign-reactor-webclient/src/main/java/reactivefeign/webclient/WebReactiveFeign.java rename to feign-reactor-webclient-netty/src/main/java/reactivefeign/webclient/netty/NettyWebReactiveFeign.java index 8c57e99e..1902cb04 100644 --- a/feign-reactor-webclient/src/main/java/reactivefeign/webclient/WebReactiveFeign.java +++ b/feign-reactor-webclient-netty/src/main/java/reactivefeign/webclient/netty/NettyWebReactiveFeign.java @@ -11,7 +11,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ -package reactivefeign.webclient; +package reactivefeign.webclient.netty; import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.web.reactive.function.client.WebClient; @@ -20,11 +20,13 @@ import reactivefeign.ReactiveOptions; import reactivefeign.client.ReactiveHttpRequest; import reactivefeign.client.ReadTimeoutException; +import reactivefeign.webclient.CoreWebBuilder; +import reactivefeign.webclient.WebClientFeignCustomizer; import reactor.netty.http.client.HttpClient; import java.util.function.BiFunction; -import static reactivefeign.webclient.NettyClientHttpConnectorBuilder.buildNettyClientHttpConnector; +import static reactivefeign.webclient.netty.NettyClientHttpConnectorBuilder.buildNettyClientHttpConnector; /** @@ -32,7 +34,7 @@ * * @author Sergii Karpenko */ -public class WebReactiveFeign { +public class NettyWebReactiveFeign { public static Builder builder() { return builder(WebClient.builder()); @@ -50,7 +52,7 @@ public static Builder builder(WebClient.Builder webClientBuilder, public static class Builder extends CoreWebBuilder { private HttpClient httpClient; - private WebReactiveOptions options = WebReactiveOptions.DEFAULT_OPTIONS; + private NettyReactiveOptions options = NettyReactiveOptions.DEFAULT_OPTIONS; protected Builder(WebClient.Builder webClientBuilder) { super(webClientBuilder); @@ -67,7 +69,7 @@ public ReactiveFeignBuilder httpClient(HttpClient httpClient){ @Override public Builder options(ReactiveOptions options) { - this.options = (WebReactiveOptions) options; + this.options = (NettyReactiveOptions) options; return this; } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/BasicFeaturesTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/BasicFeaturesTest.java similarity index 92% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/BasicFeaturesTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/BasicFeaturesTest.java index d9208a76..0a01798f 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/BasicFeaturesTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/BasicFeaturesTest.java @@ -20,6 +20,7 @@ import org.springframework.web.reactive.function.client.ExchangeStrategies; import org.springframework.web.reactive.function.client.WebClient; import reactivefeign.ReactiveFeign; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -34,7 +35,7 @@ public class BasicFeaturesTest extends reactivefeign.BasicFeaturesTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } @Override @@ -52,7 +53,7 @@ public void shouldDecodeResponseBodyWhenNoCodecsAvailable() { .builder() .exchangeStrategies(ExchangeStrategies.empty().build()); - WebReactiveFeign.Builder bd = WebReactiveFeign + NettyWebReactiveFeign.Builder bd = NettyWebReactiveFeign .builder(wc); TestClient client = bd.target(TestClient.class, targetUrl); diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/CollectionFormatTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/CollectionFormatTest.java similarity index 89% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/CollectionFormatTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/CollectionFormatTest.java index cb0c753b..c4dfb23f 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/CollectionFormatTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/CollectionFormatTest.java @@ -14,6 +14,7 @@ package reactivefeign.webclient; import reactivefeign.ReactiveFeign; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -22,6 +23,6 @@ public class CollectionFormatTest extends reactivefeign.CollectionFormatTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/CompressionTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/CompressionTest.java similarity index 76% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/CompressionTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/CompressionTest.java index fb1351a6..d088e64e 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/CompressionTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/CompressionTest.java @@ -15,6 +15,8 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyReactiveOptions; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -23,7 +25,7 @@ public class CompressionTest extends reactivefeign.CompressionTest { @Override protected ReactiveFeign.Builder builder(boolean tryUseCompression) { - return WebReactiveFeign.builder().options( - new WebReactiveOptions.Builder().setAcceptCompressed(tryUseCompression).build()); + return NettyWebReactiveFeign.builder().options( + new NettyReactiveOptions.Builder().setAcceptCompressed(tryUseCompression).build()); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ConnectionTimeoutTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ConnectionTimeoutTest.java similarity index 76% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/ConnectionTimeoutTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ConnectionTimeoutTest.java index 937d3949..b1f6b275 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ConnectionTimeoutTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ConnectionTimeoutTest.java @@ -15,6 +15,8 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyReactiveOptions; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -23,8 +25,8 @@ public class ConnectionTimeoutTest extends reactivefeign.ConnectionTimeoutTest { @Override protected ReactiveFeign.Builder builder(long connectTimeoutInMillis) { - return WebReactiveFeign.builder().options( - new WebReactiveOptions.Builder().setConnectTimeoutMillis(connectTimeoutInMillis).build() + return NettyWebReactiveFeign.builder().options( + new NettyReactiveOptions.Builder().setConnectTimeoutMillis(connectTimeoutInMillis).build() ); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ContractTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ContractTest.java similarity index 88% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/ContractTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ContractTest.java index 3348c21e..c524a4ba 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ContractTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ContractTest.java @@ -14,6 +14,7 @@ package reactivefeign.webclient; import reactivefeign.ReactiveFeign; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -22,6 +23,6 @@ public class ContractTest extends reactivefeign.ContractTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/DefaultMethodTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/DefaultMethodTest.java similarity index 74% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/DefaultMethodTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/DefaultMethodTest.java index 7e66a2c9..0f24b071 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/DefaultMethodTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/DefaultMethodTest.java @@ -15,6 +15,8 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyReactiveOptions; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -23,18 +25,18 @@ public class DefaultMethodTest extends reactivefeign.DefaultMethodTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } @Override protected ReactiveFeign.Builder builder(Class apiClass) { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } @Override protected ReactiveFeign.Builder builder(long connectTimeoutInMillis) { - return WebReactiveFeign.builder().options( - new WebReactiveOptions.Builder().setConnectTimeoutMillis(connectTimeoutInMillis).build() + return NettyWebReactiveFeign.builder().options( + new NettyReactiveOptions.Builder().setConnectTimeoutMillis(connectTimeoutInMillis).build() ); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ErrorMapperTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ErrorMapperTest.java similarity index 89% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/ErrorMapperTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ErrorMapperTest.java index 51edc6f7..c6435f12 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ErrorMapperTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ErrorMapperTest.java @@ -15,6 +15,7 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -23,6 +24,6 @@ public class ErrorMapperTest extends reactivefeign.ErrorMapperTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/FallbackTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/FallbackTest.java similarity index 88% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/FallbackTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/FallbackTest.java index 56531978..085919af 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/FallbackTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/FallbackTest.java @@ -14,6 +14,7 @@ package reactivefeign.webclient; import reactivefeign.ReactiveFeign; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -22,6 +23,6 @@ public class FallbackTest extends reactivefeign.FallbackTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/LoggerTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/LoggerTest.java similarity index 79% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/LoggerTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/LoggerTest.java index aa404193..fbd38c1d 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/LoggerTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/LoggerTest.java @@ -15,6 +15,8 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyReactiveOptions; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -28,13 +30,13 @@ protected String appenderPrefix(){ @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } @Override protected ReactiveFeign.Builder builder(long readTimeoutInMillis) { - return WebReactiveFeign.builder().options( - new WebReactiveOptions.Builder().setReadTimeoutMillis(readTimeoutInMillis).build() + return NettyWebReactiveFeign.builder().options( + new NettyReactiveOptions.Builder().setReadTimeoutMillis(readTimeoutInMillis).build() ); } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/MetricsTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/MetricsTest.java similarity index 74% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/MetricsTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/MetricsTest.java index 27ed594b..e621b3e8 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/MetricsTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/MetricsTest.java @@ -15,6 +15,8 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyReactiveOptions; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -23,13 +25,13 @@ public class MetricsTest extends reactivefeign.MetricsTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } @Override protected ReactiveFeign.Builder builder(long readTimeoutInMillis) { - return WebReactiveFeign.builder().options( - new WebReactiveOptions.Builder().setReadTimeoutMillis(readTimeoutInMillis).build() + return NettyWebReactiveFeign.builder().options( + new NettyReactiveOptions.Builder().setReadTimeoutMillis(readTimeoutInMillis).build() ); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/MultiPartTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/MultiPartTest.java similarity index 70% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/MultiPartTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/MultiPartTest.java index 60ac6d9b..919f154a 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/MultiPartTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/MultiPartTest.java @@ -1,12 +1,13 @@ package reactivefeign.webclient; import reactivefeign.ReactiveFeignBuilder; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; public class MultiPartTest extends reactivefeign.MultiPartTest { @Override protected ReactiveFeignBuilder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/NotFoundTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/NotFoundTest.java similarity index 89% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/NotFoundTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/NotFoundTest.java index 939b22fd..293319bf 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/NotFoundTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/NotFoundTest.java @@ -15,6 +15,7 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -23,6 +24,6 @@ public class NotFoundTest extends reactivefeign.NotFoundTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ObjectMapperTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ObjectMapperTest.java similarity index 89% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/ObjectMapperTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ObjectMapperTest.java index 43e15ee0..16328636 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ObjectMapperTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ObjectMapperTest.java @@ -15,6 +15,7 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -23,6 +24,6 @@ public class ObjectMapperTest extends reactivefeign.ObjectMapperTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/OptionsTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/OptionsTest.java similarity index 75% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/OptionsTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/OptionsTest.java index b5ab3069..593bc32f 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/OptionsTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/OptionsTest.java @@ -19,6 +19,8 @@ import reactivefeign.ReactiveFeignBuilder; import reactivefeign.ReactiveOptions; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyReactiveOptions; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -27,14 +29,14 @@ public class OptionsTest extends reactivefeign.OptionsTest { @Override protected ReactiveFeign.Builder builder(long readTimeoutInMillis) { - return WebReactiveFeign.builder().options( - new WebReactiveOptions.Builder().setReadTimeoutMillis(readTimeoutInMillis).build()); + return NettyWebReactiveFeign.builder().options( + new NettyReactiveOptions.Builder().setReadTimeoutMillis(readTimeoutInMillis).build()); } @Override protected ReactiveFeignBuilder builder(boolean followRedirects) { - return WebReactiveFeign.builder().options( - new WebReactiveOptions.Builder().setFollowRedirects(followRedirects).build()); + return NettyWebReactiveFeign.builder().options( + new NettyReactiveOptions.Builder().setFollowRedirects(followRedirects).build()); } @Override diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ReactivityTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ReactivityTest.java similarity index 89% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/ReactivityTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ReactivityTest.java index d720fed5..3937ac59 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ReactivityTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ReactivityTest.java @@ -15,12 +15,13 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; public class ReactivityTest extends reactivefeign.ReactivityTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/RequestInterceptorTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/RequestInterceptorTest.java similarity index 89% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/RequestInterceptorTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/RequestInterceptorTest.java index fa688ca3..d9c3e3af 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/RequestInterceptorTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/RequestInterceptorTest.java @@ -15,6 +15,7 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -23,6 +24,6 @@ public class RequestInterceptorTest extends reactivefeign.RequestInterceptorTest @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ResponseEntityTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ResponseEntityTest.java similarity index 69% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/ResponseEntityTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ResponseEntityTest.java index dee79e77..e8e1ae8d 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ResponseEntityTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ResponseEntityTest.java @@ -1,12 +1,13 @@ package reactivefeign.webclient; import reactivefeign.ReactiveFeignBuilder; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; public class ResponseEntityTest extends reactivefeign.webclient.core.ResponseEntityTest{ @Override protected ReactiveFeignBuilder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ResponseMapperTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ResponseMapperTest.java similarity index 89% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/ResponseMapperTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ResponseMapperTest.java index 1a248079..f33613ce 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/ResponseMapperTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/ResponseMapperTest.java @@ -15,6 +15,7 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -23,6 +24,6 @@ public class ResponseMapperTest extends reactivefeign.ResponseMapperTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/RetryingTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/RetryingTest.java similarity index 89% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/RetryingTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/RetryingTest.java index 0bf931b2..8adf8b5b 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/RetryingTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/RetryingTest.java @@ -15,6 +15,7 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -23,6 +24,6 @@ public class RetryingTest extends reactivefeign.RetryingTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/SmokeTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/SmokeTest.java similarity index 89% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/SmokeTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/SmokeTest.java index 62fd86d5..9a743d9d 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/SmokeTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/SmokeTest.java @@ -15,6 +15,7 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -23,7 +24,7 @@ public class SmokeTest extends reactivefeign.SmokeTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/SslVerificationTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/SslVerificationTest.java similarity index 93% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/SslVerificationTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/SslVerificationTest.java index c1d5efe5..fd30f4c8 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/SslVerificationTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/SslVerificationTest.java @@ -27,6 +27,8 @@ import reactivefeign.testcase.domain.Bill; import reactivefeign.testcase.domain.IceCreamOrder; import reactivefeign.testcase.domain.OrderGenerator; +import reactivefeign.webclient.netty.NettyReactiveOptions; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -60,8 +62,8 @@ private IcecreamServiceApi client(boolean disableSslValidation) { private ReactiveFeign.Builder builder(boolean disableSslValidation) { - return WebReactiveFeign.builder() - .options(new WebReactiveOptions.Builder() + return NettyWebReactiveFeign.builder() + .options(new NettyReactiveOptions.Builder() .setDisableSslValidation(disableSslValidation) .build()); } @@ -99,8 +101,8 @@ public void givenDisabledSslValidationContext_shouldPass() throws JsonProcessing .withHeader("Content-Type", "application/json") .withBody(TestUtils.MAPPER.writeValueAsString(billExpected)))); - IcecreamServiceApi client = WebReactiveFeign.builder() - .options(new WebReactiveOptions.Builder() + IcecreamServiceApi client = NettyWebReactiveFeign.builder() + .options(new NettyReactiveOptions.Builder() .setSslContext(SslContextBuilder.forClient() .trustManager(InsecureTrustManagerFactory.INSTANCE) .build()) diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/StatusHandlerTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/StatusHandlerTest.java similarity index 89% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/StatusHandlerTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/StatusHandlerTest.java index 89d9047d..f96c7582 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/StatusHandlerTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/StatusHandlerTest.java @@ -15,6 +15,7 @@ import reactivefeign.ReactiveFeign; import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -23,6 +24,6 @@ public class StatusHandlerTest extends reactivefeign.StatusHandlerTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } } diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/allfeatures/AllFeaturesTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/allfeatures/AllFeaturesTest.java similarity index 94% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/allfeatures/AllFeaturesTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/allfeatures/AllFeaturesTest.java index b077269c..701125a8 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/allfeatures/AllFeaturesTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/allfeatures/AllFeaturesTest.java @@ -24,7 +24,7 @@ import reactivefeign.ReactiveFeign; import reactivefeign.allfeatures.AllFeaturesFeign; import reactivefeign.allfeatures.AllFeaturesFeignTest; -import reactivefeign.webclient.WebReactiveFeign; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; /** * @author Sergii Karpenko @@ -36,7 +36,7 @@ public class AllFeaturesTest extends AllFeaturesFeignTest { @Override protected ReactiveFeign.Builder builder() { - return WebReactiveFeign.builder(); + return NettyWebReactiveFeign.builder(); } //Netty's WebClient is not able to do this trick diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesApi.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesApi.java similarity index 100% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesApi.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesApi.java diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesController.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesController.java similarity index 100% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesController.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesController.java diff --git a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesTest.java similarity index 94% rename from feign-reactor-webclient/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesTest.java rename to feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesTest.java index cdb87702..014e7dc7 100644 --- a/feign-reactor-webclient/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesTest.java +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/allfeatures/WebClientFeaturesTest.java @@ -2,9 +2,7 @@ import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration; @@ -16,7 +14,7 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.util.MultiValueMapAdapter; -import reactivefeign.webclient.WebReactiveFeign; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; import reactor.core.publisher.Flux; import reactor.test.StepVerifier; @@ -43,7 +41,7 @@ public class WebClientFeaturesTest { @Before public void setUp() { - client = WebReactiveFeign.builder() + client = NettyWebReactiveFeign.builder() .decode404() .target(WebClientFeaturesApi.class, "http://localhost:" + port); } diff --git a/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/h2c/AllFeaturesTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/h2c/AllFeaturesTest.java new file mode 100644 index 00000000..ffc512d6 --- /dev/null +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/h2c/AllFeaturesTest.java @@ -0,0 +1,105 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package reactivefeign.webclient.h2c; + +import org.junit.Ignore; +import org.junit.Test; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration; +import org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import reactivefeign.ReactiveFeign; +import reactivefeign.allfeatures.AllFeaturesFeign; +import reactivefeign.allfeatures.AllFeaturesFeignTest; +import reactivefeign.spring.server.config.TestServerConfigurations; +import reactivefeign.webclient.netty.NettyReactiveOptions; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; +import reactor.netty.http.HttpProtocol; + +import static reactivefeign.spring.server.config.TestServerConfigurations.JETTY_H2C; +import static reactivefeign.spring.server.config.TestServerConfigurations.UNDERTOW_H2C; +import static reactor.netty.http.HttpProtocol.H2C; + +/** + * @author Sergii Karpenko + * + * Tests ReactiveFeign in conjunction with WebFlux rest controller. + */ +@EnableAutoConfiguration(exclude = {ReactiveSecurityAutoConfiguration.class, ReactiveUserDetailsServiceAutoConfiguration.class}) +@ContextConfiguration(classes={TestServerConfigurations.class}) +@ActiveProfiles(JETTY_H2C) +public class AllFeaturesTest extends AllFeaturesFeignTest { + + @Override + protected ReactiveFeign.Builder builder() { + return builderHttp2(); + } + + //TODO doesn't work correctly with Netty + @Ignore + @Test + @Override + public void shouldMirrorStreamingBinaryBodyReactive() throws InterruptedException { + if(getActiveProfiles().contains(UNDERTOW_H2C)){ + return; + } + super.shouldMirrorStreamingBinaryBodyReactive(); + } + + //Apache's WebClient is not able to do this trick + @Ignore + @Test + @Override + public void shouldReturnFirstResultBeforeSecondSent() { + } + + @Ignore + @Test + @Override + public void shouldMirrorStringStreamBody() { + } + + //TODO Check later + @Ignore + @Test + @Override + public void shouldEncodePathParamWithReservedChars() { + } + + //TODO doesn't work correctly with Netty + @Ignore + @Test + @Override + public void shouldRunReactively() { + } + + //TODO doesn't work correctly with Netty + @Ignore + @Test + @Override + public void shouldMirrorBinaryBody() { + } + + private static NettyWebReactiveFeign.Builder builderHttp2() { + return NettyWebReactiveFeign.builder() + .options(new NettyReactiveOptions.Builder() + .setProtocols(new HttpProtocol[]{H2C}) + .build()); + } + +} diff --git a/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/h2c/ReactivityTest.java b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/h2c/ReactivityTest.java new file mode 100644 index 00000000..ad10a532 --- /dev/null +++ b/feign-reactor-webclient-netty/src/test/java/reactivefeign/webclient/h2c/ReactivityTest.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 The Feign Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package reactivefeign.webclient.h2c; + +import org.junit.Ignore; +import org.junit.Test; +import reactivefeign.ReactiveFeign; +import reactivefeign.testcase.IcecreamServiceApi; +import reactivefeign.webclient.netty.NettyReactiveOptions; +import reactivefeign.webclient.netty.NettyWebReactiveFeign; +import reactor.netty.http.HttpProtocol; + +import static reactor.netty.http.HttpProtocol.H2C; + +public class ReactivityTest extends reactivefeign.ReactivityTest { + + //TODO Connection refused: no further information + @Ignore + @Override + @Test + public void shouldRunReactively(){ + } + + @Override + protected HttpProtocol[] serverProtocols(){ + return new HttpProtocol[]{H2C}; + } + + @Override + protected ReactiveFeign.Builder builder() { + return builderHttp2(); + } + private static NettyWebReactiveFeign.Builder builderHttp2() { + return NettyWebReactiveFeign.builder() + .options(new NettyReactiveOptions.Builder() + .setProtocols(new HttpProtocol[]{H2C}) + .build()); + } + +} diff --git a/pom.xml b/pom.xml index d8c9e7b9..99890096 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ feign-reactor-core feign-reactor-webclient-core - feign-reactor-webclient + feign-reactor-webclient-netty feign-reactor-webclient-jetty feign-reactor-webclient-apache-client5 feign-reactor-cloud