You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2011/07/17 01:27:14 UTC

svn commit: r1147505 - in /cxf/branches/2.4.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/

Author: sergeyb
Date: Sat Jul 16 23:27:13 2011
New Revision: 1147505

URL: http://svn.apache.org/viewvc?rev=1147505&view=rev
Log:
Merged revisions 1147504 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1147504 | sergeyb | 2011-07-17 00:24:23 +0100 (Sun, 17 Jul 2011) | 1 line
  
  [CXF-3660] Fixing JAXRS proxies to ignore single slash path values
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jul 16 23:27:13 2011
@@ -1 +1 @@
-/cxf/trunk:1144977,1145682,1146773
+/cxf/trunk:1144977,1145682,1146773,1147504

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1147505&r1=1147504&r2=1147505&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java (original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java Sat Jul 16 23:27:13 2011
@@ -72,6 +72,7 @@ public class ClientProxyImpl extends Abs
 
     private static final Logger LOG = LogUtils.getL7dLogger(ClientProxyImpl.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ClientProxyImpl.class);
+    private static final String SLASH = "/";
     
     private ClassResourceInfo cri;
     private boolean inheritHeaders;
@@ -141,9 +142,10 @@ public class ClientProxyImpl extends Abs
         
         UriBuilder builder = getCurrentBuilder().clone(); 
         if (isRoot) {
-            builder.path(ori.getClassResourceInfo().getURITemplate().getValue());
+            addNonEmptyPath(builder, ori.getClassResourceInfo().getURITemplate().getValue());
         }
-        builder.path(ori.getURITemplate().getValue());
+        addNonEmptyPath(builder, ori.getURITemplate().getValue());
+        
         handleMatrixes(types, params, builder);
         handleQueries(types, params, builder);
         
@@ -187,6 +189,12 @@ public class ClientProxyImpl extends Abs
         
     }
 
+    private void addNonEmptyPath(UriBuilder builder, String pathValue) {
+        if (!SLASH.equals(pathValue)) {
+            builder.path(pathValue);
+        }
+    }
+    
     private static MultivaluedMap<ParameterType, Parameter> getParametersInfo(OperationResourceInfo ori) {
         MultivaluedMap<ParameterType, Parameter> map = 
             new MetadataMap<ParameterType, Parameter>();

Modified: cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1147505&r1=1147504&r2=1147505&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Sat Jul 16 23:27:13 2011
@@ -65,6 +65,7 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.StreamingOutput;
 import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -95,6 +96,8 @@ public class BookStore {
     private HttpHeaders httpHeaders;
     @Context 
     private SecurityContext securityContext;
+    @Context 
+    private UriInfo ui;
     
     public BookStore() {
         init();
@@ -122,7 +125,16 @@ public class BookStore {
     @POST
     @Path("emptypost")
     public void emptypost() {
-        System.out.println("empty post");
+        String uri = ui.getAbsolutePath().toString();
+        System.out.println(uri);
+        if (uri.endsWith("/")) {
+            throw new WebApplicationException(400);
+        }
+    }
+    
+    @POST
+    public void emptypostNoPath() {
+        emptypost();
     }
     
     @GET

Modified: cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1147505&r1=1147504&r2=1147505&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Sat Jul 16 23:27:13 2011
@@ -597,8 +597,9 @@ public class JAXRSClientServerBookTest e
     
     @Test
     public void testEmptyPostProxy() throws Exception {
+        String address = "http://localhost:" + PORT;
         JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); 
-        bean.setAddress("http://localhost:" + PORT);
+        bean.setAddress(address);
         bean.setResourceClass(BookStore.class);
         BookStore store = bean.create(BookStore.class);
         store.emptypost();
@@ -606,6 +607,17 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testEmptyPostProxy2() throws Exception {
+        String address = "http://localhost:" + PORT;
+        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+        bean.setAddress(address);
+        bean.setResourceClass(BookStore.class);
+        BookStore store = bean.create(BookStore.class);
+        store.emptypostNoPath();
+        assertEquals(204, WebClient.client(store).getResponse().getStatus());
+    }
+    
+    @Test
     public void testGetBookByEncodedQuery() throws Exception {
         getAndCompareAsStrings("http://localhost:" + PORT + "/bookstore/bookquery?"
                                + "urlid=http%3A%2F%2Ftest.com%2Frss%2F123",