cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r941648 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/client/WebClient.java test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
Date Thu, 06 May 2010 10:38:11 GMT
Author: sergeyb
Date: Thu May  6 10:38:10 2010
New Revision: 941648

URL: http://svn.apache.org/viewvc?rev=941648&view=rev
Log:
CXF-2801: adding WebClient resetQuery and fragment methods

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=941648&r1=941647&r2=941648&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Thu
May  6 10:38:10 2010
@@ -447,6 +447,16 @@ public class WebClient extends AbstractC
     }
     
     /**
+     * Updates the current URI fragment
+     * @param name fragment name
+     * @return updated WebClient
+     */
+    public WebClient fragment(String name) {
+        getCurrentBuilder().fragment(name);
+        return this;
+    }
+    
+    /**
      * Moves WebClient to a new baseURI or forwards to new currentURI  
      * @param newAddress new URI
      * @param forward if true then currentURI will be based on baseURI  
@@ -489,6 +499,15 @@ public class WebClient extends AbstractC
         return this;
     }
     
+    /**
+     * Resets the current query
+     * @return updated WebClient
+     */
+    public WebClient resetQuery() {
+        getCurrentBuilder().replaceQuery(null);
+        return this;
+    }
+    
     @Override
     public WebClient type(MediaType ct) {
         return (WebClient)super.type(ct);

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java?rev=941648&r1=941647&r2=941648&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
Thu May  6 10:38:10 2010
@@ -154,6 +154,25 @@ public class WebClientTest extends Asser
     }
     
     @Test
+    public void testResetQueryAndBack() {
+        WebClient wc = WebClient.create(URI.create("http://foo"));
+        wc.path("bar").path("baz").query("foo", "bar");
+        assertEquals(URI.create("http://foo"), wc.getBaseURI());
+        assertEquals(URI.create("http://foo/bar/baz?foo=bar"), wc.getCurrentURI());
+        wc.resetQuery().back(false);
+        assertEquals(URI.create("http://foo/bar"), wc.getCurrentURI());
+    }
+    
+    @Test
+    public void testFragment() {
+        WebClient wc = WebClient.create(URI.create("http://foo"));
+        wc.path("bar").path("baz").query("foo", "bar").fragment("1");
+        assertEquals(URI.create("http://foo"), wc.getBaseURI());
+        assertEquals(URI.create("http://foo/bar/baz?foo=bar#1"), wc.getCurrentURI());
+    }
+    
+    
+    @Test
     public void testPathWithTemplates() {
         WebClient wc = WebClient.create(URI.create("http://foo"));
         assertEquals(URI.create("http://foo"), wc.getBaseURI());



Mime
View raw message