Author: sergeyb
Date: Tue Nov 29 11:43:07 2011
New Revision: 1207835
URL: http://svn.apache.org/viewvc?rev=1207835&view=rev
Log:
[CXF-3939] Fixing UriInfo to return the list of matched URIs and resources in
the reverse order
Modified:
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Modified:
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java?rev=1207835&r1=1207834&r2=1207835&view=diff
==============================================================================
---
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java
(original)
+++
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java
Tue Nov 29 11:43:07 2011
@@ -22,6 +22,7 @@ package org.apache.cxf.jaxrs.impl;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
@@ -156,9 +157,9 @@ public class UriInfoImpl implements UriI
public List<Object> getMatchedResources() {
if (stack != null) {
- List<Object> resources = new ArrayList<Object>(stack.size());
+ List<Object> resources = new LinkedList<Object>();
for (MethodInvocationInfo invocation : stack) {
- resources.add(invocation.getRealClass());
+ resources.add(0, invocation.getRealClass());
}
return resources;
}
@@ -173,7 +174,7 @@ public class UriInfoImpl implements UriI
public List<String> getMatchedURIs(boolean decode) {
if (stack != null) {
List<String> objects = new ArrayList<String>();
- List<String> uris = new ArrayList<String>(stack.size());
+ List<String> uris = new LinkedList<String>();
String sum = "";
for (MethodInvocationInfo invocation : stack) {
OperationResourceInfo ori = invocation.getMethodInfo();
@@ -189,7 +190,7 @@ public class UriInfoImpl implements UriI
}
UriBuilder ub = UriBuilder.fromPath(sum);
objects.addAll(invocation.getTemplateValues());
- uris.add(ub.build(objects.toArray()).normalize().getPath());
+ uris.add(0, ub.build(objects.toArray()).normalize().getPath());
}
return uris;
}
Modified:
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=1207835&r1=1207834&r2=1207835&view=diff
==============================================================================
---
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Tue Nov 29 11:43:07 2011
@@ -1583,9 +1583,9 @@ public class JAXRSClientServerBookTest e
public void testUriInfoMatchedResources() throws Exception {
getAndCompare("http://localhost:" + PORT + "/bookstore/"
+
"booksubresource/123/chapters/sub/1/matched-resources",
- "[class org.apache.cxf.systest.jaxrs.BookStore, "
+ "[class org.apache.cxf.systest.jaxrs.Chapter, "
+ "class org.apache.cxf.systest.jaxrs.Book, "
- + "class org.apache.cxf.systest.jaxrs.Chapter]",
+ + "class org.apache.cxf.systest.jaxrs.BookStore]",
"text/plain", "text/plain", 200);
}
@@ -1593,17 +1593,17 @@ public class JAXRSClientServerBookTest e
public void testUriInfoMatchedResourcesWithObject() throws Exception {
getAndCompare("http://localhost:" + PORT + "/bookstore/"
+
"booksubresource/123/chaptersobject/sub/1/matched-resources",
- "[class org.apache.cxf.systest.jaxrs.BookStore, "
+ "[class org.apache.cxf.systest.jaxrs.Chapter, "
+ "class org.apache.cxf.systest.jaxrs.Book, "
- + "class org.apache.cxf.systest.jaxrs.Chapter]",
+ + "class org.apache.cxf.systest.jaxrs.BookStore]",
"text/plain", "text/plain", 200);
}
@Test
public void testUriInfoMatchedUrisDecode() throws Exception {
- String expected = "[/bookstore/booksubresource/123/, "
+ String expected =
"[/bookstore/booksubresource/123/chapters/sub/1/matched!uris, "
+ "/bookstore/booksubresource/123/chapters/sub/1/, "
- +
"/bookstore/booksubresource/123/chapters/sub/1/matched!uris]";
+ + "/bookstore/booksubresource/123/]";
getAndCompare("http://localhost:" + PORT + "/bookstore/"
+
"booksubresource/123/chapters/sub/1/matched%21uris?decode=true",
expected, "text/plain", "text/plain", 200);
@@ -1612,9 +1612,9 @@ public class JAXRSClientServerBookTest e
@Test
public void testUriInfoMatchedUrisNoDecode() throws Exception {
//note '%21' instead of '!'
- String expected = "[/bookstore/booksubresource/123/, "
+ String expected =
"[/bookstore/booksubresource/123/chapters/sub/1/matched%21uris, "
+ "/bookstore/booksubresource/123/chapters/sub/1/, "
- + "/bookstore/booksubresource/123/chapters/sub/1/matched%21uris]";
+ + "/bookstore/booksubresource/123/]";
getAndCompare("http://localhost:" + PORT + "/bookstore/"
+
"booksubresource/123/chapters/sub/1/matched%21uris?decode=false",
expected,