Author: sergeyb Date: Sat Jul 16 23:29:58 2011 New Revision: 1147506 URL: http://svn.apache.org/viewvc?rev=1147506&view=rev Log: Merged revisions 1147505 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.4.x-fixes
................ r1147505 | sergeyb | 2011-07-17 00:27:13 +0100 (Sun, 17 Jul 2011) | 9 lines 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.3.x-fixes/ (props changed) cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Propchange: cxf/branches/2.3.x-fixes/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sat Jul 16 23:29:58 2011 @@ -1,2 +1,2 @@ -/cxf/branches/2.4.x-fixes:1144979 -/cxf/trunk:1144977 +/cxf/branches/2.4.x-fixes:1144979,1147505 +/cxf/trunk:1144977,1147504 Propchange: cxf/branches/2.3.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1147506&r1=1147505&r2=1147506&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java (original) +++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java Sat Jul 16 23:29:58 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); @@ -180,6 +182,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.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1147506&r1=1147505&r2=1147506&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original) +++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Sat Jul 16 23:29:58 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.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1147506&r1=1147505&r2=1147506&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original) +++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Sat Jul 16 23:29:58 2011 @@ -529,8 +529,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(); @@ -538,6 +539,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",
