Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 45069 invoked from network); 5 Feb 2010 10:04:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Feb 2010 10:04:23 -0000 Received: (qmail 67622 invoked by uid 500); 5 Feb 2010 10:04:23 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 67540 invoked by uid 500); 5 Feb 2010 10:04:23 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 67531 invoked by uid 99); 5 Feb 2010 10:04:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Feb 2010 10:04:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Feb 2010 10:04:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 08B3B23889FA; Fri, 5 Feb 2010 10:04:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r906885 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java Date: Fri, 05 Feb 2010 10:04:01 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100205100402.08B3B23889FA@eris.apache.org> Author: sergeyb Date: Fri Feb 5 10:04:01 2010 New Revision: 906885 URL: http://svn.apache.org/viewvc?rev=906885&view=rev Log: Merged revisions 906882 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r906882 | sergeyb | 2010-02-05 09:48:13 +0000 (Fri, 05 Feb 2010) | 1 line CXF-2652 : UriInfo.getAbsolutePath was failing if encoded chars were included in the original request URI ........ Modified: cxf/branches/2.2.x-fixes/ (props changed) cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java Propchange: cxf/branches/2.2.x-fixes/ ------------------------------------------------------------------------------ svn:mergeinfo = /cxf/trunk:906882 Propchange: cxf/branches/2.2.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java?rev=906885&r1=906884&r2=906885&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java (original) +++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java Fri Feb 5 10:04:01 2010 @@ -88,7 +88,12 @@ } public String getPath(boolean decode) { - return doGetPath(decode, true); + String value = doGetPath(decode, true); + if (value.length() > 1 && value.startsWith("/")) { + return value.substring(1); + } else { + return value; + } } public List getPathSegments() { @@ -192,7 +197,7 @@ if (MessageUtils.isRequestor(message)) { return address; } - String path = doGetPath(true, false); + String path = doGetPath(false, false); if (path.startsWith("/") && address.endsWith("/")) { address = address.substring(0, address.length() - 1); } Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java?rev=906885&r1=906884&r2=906885&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java (original) +++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java Fri Feb 5 10:04:01 2010 @@ -60,6 +60,20 @@ } @Test + public void testGetAbsolutePathWithEncodedChars() { + + UriInfoImpl u = new UriInfoImpl(mockMessage("http://localhost:8080/baz%20foo", "/bar"), + null); + assertEquals("Wrong absolute path", "http://localhost:8080/baz%20foo/bar", + u.getAbsolutePath().toString()); + u = new UriInfoImpl(mockMessage("http://localhost:8080/baz/%20foo", "/bar%20foo"), + null); + assertEquals("Wrong absolute path", "http://localhost:8080/baz/%20foo/bar%20foo", + u.getAbsolutePath().toString()); + + } + + @Test public void testGetQueryParameters() { UriInfoImpl u = new UriInfoImpl(mockMessage("http://localhost:8080/baz", "/bar"), null); @@ -87,10 +101,20 @@ @Test public void testGetRequestURI() { - UriInfo u = new UriInfoImpl(mockMessage("http://localhost:8080/baz/bar", "/baz/bar", "n=1%202"), + UriInfo u = new UriInfoImpl(mockMessage("http://localhost:8080/baz/bar", "/foo", "n=1%202"), + null); + + assertEquals("Wrong request uri", "http://localhost:8080/baz/bar/foo?n=1%202", + u.getRequestUri().toString()); + } + + @Test + public void testGetRequestURIWithEncodedChars() { + + UriInfo u = new UriInfoImpl(mockMessage("http://localhost:8080/baz/bar", "/foo/%20bar", "n=1%202"), null); - assertEquals("Wrong request uri", "http://localhost:8080/baz/bar?n=1%202", + assertEquals("Wrong request uri", "http://localhost:8080/baz/bar/foo/%20bar?n=1%202", u.getRequestUri().toString()); } @@ -150,7 +174,7 @@ UriInfoImpl u = new UriInfoImpl(mockMessage("http://localhost:8080/bar/baz", "/baz"), null); - assertEquals("Wrong path", "/baz", u.getPath()); + assertEquals("Wrong path", "baz", u.getPath()); u = new UriInfoImpl(mockMessage("http://localhost:8080/bar/baz", "/bar/baz"), null); @@ -162,11 +186,11 @@ u = new UriInfoImpl(mockMessage("http://localhost:8080/baz", "/baz/bar%201"), null); - assertEquals("Wrong path", "/bar 1", u.getPath()); + assertEquals("Wrong path", "bar 1", u.getPath()); u = new UriInfoImpl(mockMessage("http://localhost:8080/baz", "/baz/bar%201"), null); - assertEquals("Wrong path", "/bar%201", u.getPath(false)); + assertEquals("Wrong path", "bar%201", u.getPath(false)); }