cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject git commit: fix regression introduced by the change in jaxrs client's LocalClientState's ws scheme handling
Date Wed, 11 Jun 2014 07:43:27 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 4503ba056 -> 5e673228d


fix regression introduced by the change in jaxrs client's LocalClientState's ws scheme handling


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

Branch: refs/heads/master
Commit: 5e673228d95f317c2d9f394011a0b6af6d481d0d
Parents: 4503ba0
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Tue Jun 10 19:54:04 2014 +0200
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Wed Jun 11 09:42:45 2014 +0200

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxrs/client/LocalClientState.java   | 5 +++--
 .../test/java/org/apache/cxf/jaxrs/client/WebClientTest.java | 8 ++++----
 .../cxf/transport/websocket/ahc/AhcWebSocketConduit.java     | 7 ++++++-
 3 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/5e673228/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
index aeddb0c..c764c63 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
@@ -34,7 +34,8 @@ import org.apache.cxf.jaxrs.impl.UriBuilderImpl;
  */
 public class LocalClientState implements ClientState {
     private static final String HTTP_SCHEME = "http";
-    
+    private static final String WS_SCHEME = "ws";
+
     private MultivaluedMap<String, String> requestHeaders = new MetadataMap<String,
String>(false, true);
     private MultivaluedMap<String, String> templates;
     private Response response;
@@ -154,6 +155,6 @@ public class LocalClientState implements ClientState {
     
     private static boolean isSupportedScheme(URI uri) {
         return !StringUtils.isEmpty(uri.getScheme()) 
-            && uri.getScheme().startsWith(HTTP_SCHEME);
+            && (uri.getScheme().startsWith(HTTP_SCHEME) || uri.getScheme().startsWith(WS_SCHEME));
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/5e673228/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
index f0fe6df..7848bf5 100644
--- a/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
+++ b/rt/rs/client/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
@@ -112,20 +112,20 @@ public class WebClientTest extends Assert {
     public void testBaseCurrentWebSocketPath() {
         WebClient wc = WebClient.create("ws://foo");
         assertEquals(URI.create("ws://foo"), wc.getBaseURI());
-        assertEquals(URI.create("/"), wc.getCurrentURI());
+        assertEquals(URI.create("ws://foo"), wc.getCurrentURI());
         wc.path("a");
         assertEquals(URI.create("ws://foo"), wc.getBaseURI());
-        assertEquals(URI.create("/a"), wc.getCurrentURI());
+        assertEquals(URI.create("ws://foo/a"), wc.getCurrentURI());
     }
     
     @Test 
     public void testNewBaseCurrentWebSocketPath() {
         WebClient wc = WebClient.create("ws://foo");
         assertEquals(URI.create("ws://foo"), wc.getBaseURI());
-        assertEquals(URI.create("/"), wc.getCurrentURI());
+        assertEquals(URI.create("ws://foo"), wc.getCurrentURI());
         wc.to("ws://bar", false);
         assertEquals(URI.create("ws://bar"), wc.getBaseURI());
-        assertEquals(URI.create("/"), wc.getCurrentURI());
+        assertEquals(URI.create("ws://bar"), wc.getCurrentURI());
     }
     
     @Test 

http://git-wip-us.apache.org/repos/asf/cxf/blob/5e673228/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/ahc/AhcWebSocketConduit.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/ahc/AhcWebSocketConduit.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/ahc/AhcWebSocketConduit.java
index 3a9ab55..d3f2fe0 100644
--- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/ahc/AhcWebSocketConduit.java
+++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/ahc/AhcWebSocketConduit.java
@@ -113,7 +113,12 @@ public class AhcWebSocketConduit extends URLConnectionHTTPConduit {
 
             entity = message.get(AhcWebSocketConduitRequest.class);
             //REVISIT how we prepare the request
-            entity.setPath(url.getPath() + (String)message.getContextualProperty("org.apache.cxf.request.uri"));
+            String requri = (String)message.getContextualProperty("org.apache.cxf.request.uri");
+            if (requri.startsWith("ws")) {
+                entity.setPath(requri.substring(requri.indexOf(url.getPath())));
+            } else {
+                entity.setPath(url.getPath() + requri);
+            }
             entity.setId(UUID.randomUUID().toString());
             uncorrelatedRequests.put(entity.getId(), new RequestResponse(entity));
         }


Mime
View raw message