cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6810] Defaulting a null response code to 202 for one-way non-HTTP requests
Date Tue, 01 Mar 2016 12:11:38 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 35c7bb649 -> bb21c666a


[CXF-6810] Defaulting a null response code to 202 for one-way non-HTTP requests


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/bb21c666
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/bb21c666
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/bb21c666

Branch: refs/heads/3.1.x-fixes
Commit: bb21c666aac06fae8f6e37ba1dd24ffbcd384456
Parents: 35c7bb6
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Mar 1 12:09:46 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Mar 1 12:11:17 2016 +0000

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/client/AbstractClient.java |  5 ++-
 .../cxf/systest/jaxrs/jms/JAXRSJmsTest.java     | 40 ++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/bb21c666/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
----------------------------------------------------------------------
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 d190fc4..d98c34d 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
@@ -604,11 +604,14 @@ public abstract class AbstractClient implements Client {
         }
     }
     
-    private static Integer getResponseCode(Exchange exchange) {
+    private Integer getResponseCode(Exchange exchange) {
         Integer responseCode = (Integer)exchange.get(Message.RESPONSE_CODE);
         if (responseCode == null && exchange.getInMessage() != null) {
             responseCode = (Integer)exchange.getInMessage().get(Message.RESPONSE_CODE);
         }
+        if (responseCode == null && exchange.isOneWay() && !state.getBaseURI().toString().startsWith("http"))
{
+            responseCode = 202;
+        }
         return responseCode;
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/bb21c666/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java
index 49e8e0d..b7e6a21 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java
@@ -37,6 +37,7 @@ import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.naming.Context;
 import javax.naming.InitialContext;
+import javax.ws.rs.core.Response;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
@@ -48,6 +49,7 @@ import org.apache.cxf.systest.jaxrs.Book;
 import org.apache.cxf.systest.jaxrs.JMSBookStore;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.EmbeddedJMSBrokerLauncher;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -94,6 +96,44 @@ public class JAXRSJmsTest extends AbstractBusClientServerTestBase {
     }
     
     @Test
+    public void testPutBookOneWayWithWebClient() throws Exception {
+        // setup the the client
+        String endpointAddressUrlEncoded = "jms:jndi:dynamicQueues/test.jmstransport.text"
+             + "?replyToName=dynamicQueues/test.jmstransport.response"
+             + "&jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+             + "&jndiURL=tcp://localhost:" + JMS_PORT;
+               
+        WebClient client = WebClient.create(endpointAddressUrlEncoded);
+        WebClient.getConfig(client).getRequestContext()
+            .put(org.apache.cxf.message.Message.REQUEST_URI, "/bookstore/oneway");
+        client.header("OnewayRequest", "true");
+        Response r = client.put(new Book("OneWay From WebClient", 129L));
+        assertEquals(202, r.getStatus());
+        assertFalse(r.hasEntity());
+        
+        Context ctx = getContext();
+        ConnectionFactory factory = (ConnectionFactory)ctx.lookup("ConnectionFactory");
+
+        Destination replyToDestination = (Destination)ctx.lookup("dynamicQueues/test.jmstransport.response");
+                
+        Connection connection = null;
+        try {
+            connection = factory.createConnection();
+            connection.start();
+            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            checkBookInResponse(session, replyToDestination, 129L, "OneWay From WebClient");
+            session.close();
+        } finally {
+            try {
+                connection.stop();
+                connection.close();
+            } catch (JMSException ex) {
+                // ignore
+            }
+        }
+    }
+    
+    @Test
     public void testGetBookFromWebClientWithPath() throws Exception {
         // setup the the client
         String endpointAddressUrlEncoded = "jms:jndi:dynamicQueues/test.jmstransport.text"


Mime
View raw message