cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6906] Checking the query part if the URI contains templates
Date Tue, 17 May 2016 10:31:16 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 76a22608d -> 1bf3adcbe


[CXF-6906] Checking the query part if the URI contains templates


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

Branch: refs/heads/master
Commit: 1bf3adcbeb1b3846d48347fb758a34f99cc6d932
Parents: 76a2260
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue May 17 11:31:01 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue May 17 11:31:01 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java    | 10 ++++++++++
 .../org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java     |  8 +++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1bf3adcb/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
index e9084ad..b18eac3 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
@@ -920,7 +920,17 @@ public class UriBuilderImpl extends UriBuilder implements Cloneable {
             }
             
         }
+        String rawQuery = null;
+        index = uri.indexOf("?");
+        if (index != -1) {
+            rawQuery = uri.substring(index + 1);
+            uri = uri.substring(0, index);
+        }
         setPathAndMatrix(uri);
+        if (rawQuery != null) {
+            query = JAXRSUtils.getStructuredParams(rawQuery, "&", false, true);
+        }
+        
         return this;
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/1bf3adcb/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
index f574701..c0dcb47 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
@@ -270,7 +270,13 @@ public class UriBuilderImplTest extends Assert {
     public void testResolveTemplateInQuery() {
         String uri = UriBuilder.fromPath("my/path").queryParam("qp",
             "{param}").resolveTemplate("param", "value").toTemplate();
-        assertEquals("my/path?qp=value", uri.toString());        
+        assertEquals("my/path?qp=value", uri);        
+    }
+    
+    @Test
+    public void testResolveTemplateInQuery2() {
+        String uri = UriBuilder.fromUri("my/path?qp={param}").resolveTemplate("param", "value").toTemplate();
+        assertEquals("my/path?qp=value", uri);        
     }
 
     @Test(expected = IllegalArgumentException.class)


Mime
View raw message