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:32:04 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes b9c24f41c -> be6842e34


[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/be6842e3
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/be6842e3
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/be6842e3

Branch: refs/heads/3.1.x-fixes
Commit: be6842e3408499bd363a6099e761f96645070550
Parents: b9c24f4
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:47 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/be6842e3/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/be6842e3/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