You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2022/01/08 15:24:34 UTC

[cxf] branch 3.4.x-fixes updated (71ede62 -> 013015c)

This is an automated email from the ASF dual-hosted git repository.

reta pushed a change to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from 71ede62  Update CXF versions for benchmark modules
     new 6c0afc8  CXF-8630: Remove mockwebserver dependency, use wiremock instead (#885)
     new 013015c  Recording .gitmergeinfo Changes

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitmergeinfo                                      |  3 ++
 parent/pom.xml                                     |  1 -
 rt/rs/microprofile-client/pom.xml                  | 22 +++++---
 .../apache/cxf/microprofile/client/AsyncTest.java  | 61 ++++++++++++++++++----
 4 files changed, 67 insertions(+), 20 deletions(-)

[cxf] 02/02: Recording .gitmergeinfo Changes

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 013015c02b040ffcb00dec7a392bf0799fbf2b12
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sat Jan 8 10:24:23 2022 -0500

    Recording .gitmergeinfo Changes
---
 .gitmergeinfo | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 8852b6a..844428c 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -53,6 +53,7 @@ B 68d8f69052a37b3639043e0b7ea9dc301ca1cac2
 B 69bde238c2118718272bf6fc672e565d16d7a6d4
 B 6f02a585e82415826dc30c2b598df1ab1b187586
 B 75fb6bb56d82f72771a9ee6ecab5d36168303f51
+B 799660ad89472302f8ac9fcdcf818f469601aa42
 B 7cfda87f43d41fddb0e2d0e2501cb3918807e88f
 B 7dcda069b57ee9732a2fb089df35c91c040527f0
 B 7f49050d5a01af413486ae488594cf89b5bbe9ca
@@ -201,6 +202,7 @@ M 80bfaa1fbb9302ca257db211b36c3f0622356d56
 M 81d82da19ed43bbeaae12a7eda052a64890ec970
 M 840666d155ce5593801d1b9228e5bcf7f720eb7f
 M 866c6b91e3690672b2955ee190bff317fb75084b
+M 87f970b5d2d4bfacdd01a3f93a70a5020020dc51
 M 88907f141ee80792627da3cc7846d1562f6c0238
 M 8ae6440a00f066652c37e6f1d122b52c5a6c7b49
 M 8b3d74cb9bdf0be862f3180ff2f101fb3d9c888b
@@ -260,6 +262,7 @@ M c4225cad3036a36f3a7f8c4a46a7633a92989a93
 M c741a057830f5a661ad51869b11704253a272a89
 M c7786d4e78999cb08fd668b24a7fac480bf7b5e0
 M ca5d02bf9581a28971c8b8d021732972dce5377e
+M cc07aa8a16ea65b446e1b1988135234e91ae49bd
 M cc4f758e89da58b2f47c95fb68df186e0533ca74
 M ccb76b7c2c02b0f295405fd9bb0b585544c40869
 M cd5a10c84dc5f37ee724e8e5015ed4b44a4463c8

[cxf] 01/02: CXF-8630: Remove mockwebserver dependency, use wiremock instead (#885)

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 6c0afc89a95a130c693fa16b0f82664ae5edbe01
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sat Jan 8 10:23:05 2022 -0500

    CXF-8630: Remove mockwebserver dependency, use wiremock instead (#885)
    
    (cherry picked from commit d967092c6e4c7ca62c0b23a34c07141f79519161)
    (cherry picked from commit 87f970b5d2d4bfacdd01a3f93a70a5020020dc51)
---
 parent/pom.xml                                     |  1 -
 rt/rs/microprofile-client/pom.xml                  | 22 +++++---
 .../apache/cxf/microprofile/client/AsyncTest.java  | 61 ++++++++++++++++++----
 3 files changed, 64 insertions(+), 20 deletions(-)

diff --git a/parent/pom.xml b/parent/pom.xml
index 919ae91..d091940 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -173,7 +173,6 @@
         <cxf.microprofile.openapi.version>2.0</cxf.microprofile.openapi.version>
         <cxf.mina.version>2.1.3</cxf.mina.version>
         <cxf.mockito.version>4.2.0</cxf.mockito.version>
-        <cxf.mockwebserver.version>4.9.3</cxf.mockwebserver.version>
         <cxf.msv.version>2013.6.1</cxf.msv.version>
         <cxf.neethi.version>3.1.1</cxf.neethi.version>
         <cxf.netty.version.range>[4,5)</cxf.netty.version.range>
diff --git a/rt/rs/microprofile-client/pom.xml b/rt/rs/microprofile-client/pom.xml
index 634ba05..2d00c44 100644
--- a/rt/rs/microprofile-client/pom.xml
+++ b/rt/rs/microprofile-client/pom.xml
@@ -182,16 +182,22 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-          <groupId>org.apache.commons</groupId>
-          <artifactId>commons-jcs-jcache</artifactId>
-          <version>${cxf.commons-jcs-jcache.version}</version>
-          <scope>test</scope>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-jcs-jcache</artifactId>
+            <version>${cxf.commons-jcs-jcache.version}</version>
+            <scope>test</scope>
         </dependency>
         <dependency>
-          <groupId>com.squareup.okhttp3</groupId>
-          <artifactId>mockwebserver</artifactId>
-          <version>${cxf.mockwebserver.version}</version>
-          <scope>test</scope>
+            <groupId>com.github.tomakehurst</groupId>
+            <artifactId>wiremock</artifactId>
+            <version>${cxf.wiremock.version}</version>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.xmlunit</groupId>
+                    <artifactId>xmlunit-core</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
     </dependencies>
 
diff --git a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/AsyncTest.java b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/AsyncTest.java
index fc4905c..64dfa2f 100644
--- a/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/AsyncTest.java
+++ b/rt/rs/microprofile-client/src/test/java/org/apache/cxf/microprofile/client/AsyncTest.java
@@ -19,27 +19,69 @@
 package org.apache.cxf.microprofile.client;
 
 import java.net.URI;
+import java.util.Queue;
+import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.CompletionStage;
 import java.util.concurrent.TimeUnit;
 
-import okhttp3.mockwebserver.MockResponse;
-import okhttp3.mockwebserver.MockWebServer;
+import com.github.tomakehurst.wiremock.common.FileSource;
+import com.github.tomakehurst.wiremock.extension.Parameters;
+import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
+import com.github.tomakehurst.wiremock.http.Request;
+import com.github.tomakehurst.wiremock.http.Response;
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+
 import org.apache.cxf.microprofile.client.mock.AsyncClient;
 import org.apache.cxf.microprofile.client.mock.NotFoundExceptionMapper;
 import org.eclipse.microprofile.rest.client.RestClientBuilder;
 
+import org.junit.Rule;
 import org.junit.Test;
 
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.notFound;
+import static com.github.tomakehurst.wiremock.client.WireMock.ok;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 public class AsyncTest {
+    @SuppressWarnings("unchecked")
+    @Rule
+    public WireMockRule wireMockRule = new WireMockRule(wireMockConfig()
+        .extensions(SimpleTransformer.class));
+    
+    public static class SimpleTransformer extends ResponseTransformer {
+        private final Queue<String> queue = new ArrayBlockingQueue<>(2);
+        
+        public SimpleTransformer() {
+            queue.add("Hello");
+            queue.add("World");
+        }
+        
+        @Override
+        public Response transform(Request request, Response response, FileSource fileSource, Parameters parameters) {
+            return Response.Builder
+                .like(response)
+                .but().body(queue.poll())
+                .build();
+        }
+
+        @Override
+        public boolean applyGlobally() {
+            return false;
+        }
 
+        @Override
+        public String getName() {
+            return "enqueue-transformer";
+        }
+    }
+    
     @Test
     public void testAsyncClient() throws Exception {
-        MockWebServer mockWebServer = new MockWebServer();
-        URI uri = mockWebServer.url("/").uri();
+        URI uri = URI.create(wireMockRule.baseUrl());
         AsyncClient client = RestClientBuilder.newBuilder()
                                               .baseUri(uri)
                                               .connectTimeout(5, TimeUnit.SECONDS)
@@ -47,8 +89,7 @@ public class AsyncTest {
                                               .build(AsyncClient.class);
         assertNotNull(client);
 
-        mockWebServer.enqueue(new MockResponse().setBody("Hello"));
-        mockWebServer.enqueue(new MockResponse().setBody("World"));
+        wireMockRule.stubFor(get("/").willReturn(ok().withTransformers("enqueue-transformer")));
 
         String combined = client.get().thenCombine(client.get(), (a, b) -> {
             return a + " " + b;
@@ -59,18 +100,16 @@ public class AsyncTest {
 
     @Test
     public void testAsyncClientCanMapExceptionResponses() throws Exception {
-        MockWebServer mockWebServer = new MockWebServer();
-        URI uri = mockWebServer.url("/").uri();
-
+        URI uri = URI.create(wireMockRule.baseUrl());
         AsyncClient client = RestClientBuilder.newBuilder()
                                               .baseUri(uri)
                                               .connectTimeout(5, TimeUnit.SECONDS)
                                               .readTimeout(5, TimeUnit.SECONDS)
                                               .register(NotFoundExceptionMapper.class)
                                               .build(AsyncClient.class);
-        mockWebServer.enqueue(new MockResponse().setResponseCode(404));
+        wireMockRule.stubFor(get("/").willReturn(notFound()));
 
-        CompletionStage cs = client.get().exceptionally(t -> {
+        CompletionStage<?> cs = client.get().exceptionally(t -> {
             Throwable t2 = t.getCause();
             return t.getClass().getSimpleName() + ":" + (t2 == null ? "null" : t2.getClass().getSimpleName());
         });