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/15 19:51:02 UTC

[cxf] branch 3.4.x-fixes updated: CXF-8635: Fix org.apache.cxf.jaxrs.client.logging.RESTLoggingTest.testSlf4 (#889)

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


The following commit(s) were added to refs/heads/3.4.x-fixes by this push:
     new c9c03a8  CXF-8635: Fix org.apache.cxf.jaxrs.client.logging.RESTLoggingTest.testSlf4 (#889)
c9c03a8 is described below

commit c9c03a8917fc251e036a877f4a266f9734543198
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Sat Jan 15 11:49:45 2022 -0500

    CXF-8635: Fix org.apache.cxf.jaxrs.client.logging.RESTLoggingTest.testSlf4 (#889)
    
    (cherry picked from commit 0cd2e514c7776974cc51f98684a232c1da9a84e5)
    (cherry picked from commit d06a4fe0185d69c4ddce392038c74a17ecefde0a)
---
 .../apache/cxf/jaxrs/client/AbstractClient.java    |  3 +--
 .../apache/cxf/systest/http/HTTPConduitTest.java   | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
index 123d30f..dd42e67 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
@@ -440,8 +440,7 @@ public abstract class AbstractClient implements Client {
             return currentResponseBuilder;
         }
         
-        String reasonPhrase = (String)MessageUtils.getContextualProperty(
-                   responseMessage, HTTPConduit.HTTP_RESPONSE_MESSAGE, null);
+        final String reasonPhrase = (String)responseMessage.get(HTTPConduit.HTTP_RESPONSE_MESSAGE);
         if (reasonPhrase != null) {
             currentResponseBuilder.status(status, reasonPhrase);
         }
diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java b/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
index bbd2f8a..5bfb348 100644
--- a/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
+++ b/systests/transports/src/test/java/org/apache/cxf/systest/http/HTTPConduitTest.java
@@ -38,6 +38,7 @@ import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.frontend.ClientProxy;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.transport.http.HTTPConduit;
 import org.apache.hello_world.Greeter;
 import org.apache.hello_world.services.SOAPService;
 
@@ -45,7 +46,10 @@ import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.nullValue;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -170,9 +174,26 @@ public class HTTPConduitTest extends AbstractBusClientServerTestBase {
     }
 
     @Test
+    public void testResponseMessage() throws Exception {
+        startServer("Mortimer");
+        Greeter mortimer = getMortimerGreeter();
+        Client client = ClientProxy.getClient(mortimer);
+        client.getRequestContext().put(HTTPConduit.SET_HTTP_RESPONSE_MESSAGE, true);
+        
+        String answer = mortimer.sayHi();
+        answer = mortimer.sayHi();
+        answer = mortimer.sayHi();
+        assertTrue("Unexpected answer: " + answer,
+                "Bonjour from Mortimer".equals(answer));
+        assertProxyRequestCount(3);
+        assertThat(client.getResponseContext().get(HTTPConduit.HTTP_RESPONSE_MESSAGE), equalTo("OK"));
+    }
+    
+    @Test
     public void testBasicConnection() throws Exception {
         startServer("Mortimer");
         Greeter mortimer = getMortimerGreeter();
+        Client client = ClientProxy.getClient(mortimer);
 
         String answer = mortimer.sayHi();
         answer = mortimer.sayHi();
@@ -180,6 +201,7 @@ public class HTTPConduitTest extends AbstractBusClientServerTestBase {
         assertTrue("Unexpected answer: " + answer,
                 "Bonjour from Mortimer".equals(answer));
         assertProxyRequestCount(3);
+        assertThat(client.getResponseContext().get(HTTPConduit.HTTP_RESPONSE_MESSAGE), nullValue());
     }
 
     @Test