cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject git commit: add the ws scheme handling in jaxrs client's LocalClientState
Date Fri, 06 Jun 2014 12:07:11 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 8b5d78a9e -> ac556b7cf


add the ws scheme handling in jaxrs client's LocalClientState


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

Branch: refs/heads/master
Commit: ac556b7cf7607d30e38ed05fc084b886daa0d087
Parents: 8b5d78a
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Fri Jun 6 14:01:25 2014 +0200
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Fri Jun 6 14:01:25 2014 +0200

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/client/LocalClientState.java   | 10 ++++++----
 .../org/apache/cxf/jaxrs/client/WebClientTest.java  | 16 ++++++++++++++++
 2 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ac556b7c/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 d827707..a70d9b6 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,6 +34,7 @@ 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;
@@ -47,7 +48,7 @@ public class LocalClientState implements ClientState {
     
     public LocalClientState(URI baseURI) {
         this.baseURI = baseURI;
-        if (isHttpScheme(baseURI)) {
+        if (isSupportedScheme(baseURI)) {
             this.currentBuilder = new UriBuilderImpl().uri(baseURI);
         } else {
             this.currentBuilder = new UriBuilderImpl().uri("/");
@@ -130,7 +131,7 @@ public class LocalClientState implements ClientState {
                                 MultivaluedMap<String, String> headers,
                                 MultivaluedMap<String, String> templatesMap) {
         ClientState state = null;
-        if (isHttpScheme(currentURI)) {
+        if (isSupportedScheme(currentURI)) {
             state = new LocalClientState(currentURI);
         } else {
             state = new LocalClientState(baseURI, currentURI);
@@ -149,7 +150,8 @@ public class LocalClientState implements ClientState {
         return state;
     }
     
-    private static boolean isHttpScheme(URI uri) {
-        return !StringUtils.isEmpty(uri.getScheme()) && uri.getScheme().startsWith(HTTP_SCHEME);
+    private static boolean isSupportedScheme(URI uri) {
+        return !StringUtils.isEmpty(uri.getScheme()) 
+            && (uri.getScheme().startsWith(HTTP_SCHEME) || uri.getScheme().startsWith(WS_SCHEME));
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/ac556b7c/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 1570daa..dab2ab7 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
@@ -109,6 +109,22 @@ public class WebClientTest extends Assert {
     }
     
     @Test 
+    public void testBaseCurrentWebSocketPath() {
+        assertEquals(URI.create("ws://foo"), WebClient.create("ws://foo").getBaseURI());
+        assertEquals(URI.create("ws://foo"), WebClient.create("ws://foo").getCurrentURI());
+    }
+    
+    @Test 
+    public void testNewBaseCurrentWebSocketPath() {
+        WebClient wc = WebClient.create("ws://foo");
+        assertEquals(URI.create("ws://foo"), wc.getBaseURI());
+        assertEquals(URI.create("ws://foo"), wc.getCurrentURI());
+        wc.to("ws://bar", false);
+        assertEquals(URI.create("ws://bar"), wc.getBaseURI());
+        assertEquals(URI.create("ws://bar"), wc.getCurrentURI());
+    }
+    
+    @Test 
     public void testEmptyQuery() {
         WebClient wc = WebClient.create("http://foo");
         wc.query("_wadl");


Mime
View raw message