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-7351] Also supporting the loose vars at the method level
Date Wed, 03 May 2017 10:19:17 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes b394a90f0 -> 1f9fee17b


[CXF-7351] Also supporting the loose vars at the method level


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

Branch: refs/heads/3.1.x-fixes
Commit: 1f9fee17b91b19c25375156c39dddbc0e1e477f2
Parents: b394a90
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Wed May 3 11:02:29 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed May 3 11:19:01 2017 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/utils/JAXRSUtils.java  | 26 ++++++++------------
 .../systest/jaxrs/JAXRSUriInfoMatchTest.java    | 14 +++++++++++
 2 files changed, 24 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1f9fee17/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index f397dbd..8492e37 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -1776,17 +1776,8 @@ public final class JAXRSUtils {
             values = Collections.emptyList();
         } else {
             values = new ArrayList<String>(params.size() - 1);
-            URITemplate rootTemplate = ori.getClassResourceInfo().getURITemplate();
-            if (rootTemplate != null) {
-                for (String var : rootTemplate.getVariables()) {
-                    addTemplateVarValues(values, params, var);
-                }
-            }
-            for (Parameter pm : ori.getParameters()) {
-                if (pm.getType() == ParameterType.PATH) {
-                    addTemplateVarValues(values, params, pm.getName());
-                }
-            }
+            addTemplateVarValues(values, params, ori.getClassResourceInfo().getURITemplate());
+            addTemplateVarValues(values, params, ori.getURITemplate());
         }
         Class<?> realClass = ori.getClassResourceInfo().getServiceClass();
         stack.push(new MethodInvocationInfo(ori, realClass, values));
@@ -1794,12 +1785,15 @@ public final class JAXRSUtils {
 
     private static void addTemplateVarValues(List<String> values, 
                                              MultivaluedMap<String, String> params,
-                                             String var) {
-        List<String> paramValues = params.get(var);
-        if (paramValues != null) {
-            values.addAll(paramValues);
+                                             URITemplate template) {
+        if (template != null) {
+            for (String var : template.getVariables()) {
+                List<String> paramValues = params.get(var);
+                if (paramValues != null) {
+                    values.addAll(paramValues);
+                }
+            }
         }
-        
     }
 
     public static String logMessageHandlerProblem(String name, Class<?> cls, MediaType
ct) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/1f9fee17/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSUriInfoMatchTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSUriInfoMatchTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSUriInfoMatchTest.java
index 5972a94..5b21a5d 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSUriInfoMatchTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSUriInfoMatchTest.java
@@ -72,6 +72,15 @@ public class JAXRSUriInfoMatchTest extends AbstractClientServerTestBase
{
         assertEquals("/my/resource/1/matched/uris/param,/my/resource/1", data);
     }
     @Test
+    public void testMatchedUrisParam2() throws Exception {
+        WebClient wc = WebClient.create("http://localhost:" + PORT 
+                                        + "/match/my/resource/1/matched/uris/param/2");
+        WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(100000000L);
+        wc.accept("text/plain");
+        String data = wc.get(String.class);
+        assertEquals("/my/resource/1/matched/uris/param/2,/my/resource/1", data);
+    }
+    @Test
     public void testMatchedResources() throws Exception {
         WebClient wc = WebClient.create("http://localhost:" + PORT + "/match/my/resource/1/matched/resources");
         WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(100000000L);
@@ -99,6 +108,11 @@ public class JAXRSUriInfoMatchTest extends AbstractClientServerTestBase
{
             return concat(uriInfo.getMatchedURIs());
         }
         @GET
+        @Path("matched/uris/param/{param2}")
+        public Object getMatchedUrisParam2() {
+            return concat(uriInfo.getMatchedURIs());
+        }
+        @GET
         @Path("matched/resources")
         public Object getMatchedResources() {
             return concat(uriInfo.getMatchedResources());


Mime
View raw message