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:08 UTC

[cxf] branch 3.5.x-fixes updated (cc07aa8 -> 799660a)

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

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


    from cc07aa8  Update CXF versions for benchmark modules
     new 87f970b  CXF-8630: Remove mockwebserver dependency, use wiremock instead (#885)
     new 799660a  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                                      |  1 +
 parent/pom.xml                                     |  1 -
 rt/rs/microprofile-client/pom.xml                  | 22 +++++---
 .../apache/cxf/microprofile/client/AsyncTest.java  | 61 ++++++++++++++++++----
 4 files changed, 65 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.5.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 799660ad89472302f8ac9fcdcf818f469601aa42
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sat Jan 8 10:23:56 2022 -0500

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

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 9795a5b..214f9b8 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -1,4 +1,5 @@
 origin/master
 
 M a903a5392b3cd2b5925c6afa46f289b3b94a694a
+M c5b7db5a4cceb3df6094ee38215725fd4ecc2b8c
 M d4f4b7712b3c8c5c684fa4fa0a28758d9a27cef3

[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.5.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 87f970b5d2d4bfacdd01a3f93a70a5020020dc51
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)
---
 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 6100251..039d2a8 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -171,7 +171,6 @@
         <cxf.microprofile.openapi.version>2.0</cxf.microprofile.openapi.version>
         <cxf.mina.version>2.1.5</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.2.0</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 c02ae18..d15116b 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());
         });