cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1081844 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/s...
Date Tue, 15 Mar 2011 16:31:30 GMT
Author: sergeyb
Date: Tue Mar 15 16:31:29 2011
New Revision: 1081844

URL: http://svn.apache.org/viewvc?rev=1081844&view=rev
Log:
Merged revisions 1081842 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1081842 | sergeyb | 2011-03-15 16:29:51 +0000 (Tue, 15 Mar 2011) | 1 line
  
  [CXF-3404] Proper handling of encoded semicolons
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 15 16:31:29 2011
@@ -1 +1 @@
-/cxf/trunk:1081787,1081825
+/cxf/trunk:1081787,1081825,1081842

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java?rev=1081844&r1=1081843&r2=1081844&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
Tue Mar 15 16:31:29 2011
@@ -50,6 +50,7 @@ public class PrimitiveTextProvider 
         
         return InjectionUtils.handleParameter(
                     IOUtils.readStringFromStream(is), 
+                    false,
                     type,
                     ParameterType.REQUEST_BODY, null);
         

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1081844&r1=1081843&r2=1081844&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Tue Mar 15 16:31:29 2011
@@ -269,6 +269,7 @@ public final class InjectionUtils {
     }
     
     public static Object handleParameter(String value, 
+                                         boolean decoded,
                                          Class<?> pClass, 
                                          ParameterType pType,
                                          Message message) {
@@ -278,14 +279,16 @@ public final class InjectionUtils {
         }
         
         if (pType == ParameterType.PATH) {
-            PathSegment ps = new PathSegmentImpl(value, false);    
             if (PathSegment.class.isAssignableFrom(pClass)) {
-                return ps;   
+                return new PathSegmentImpl(value, decoded);   
             } else {
-                value = ps.getPath();                 
+                value = new PathSegmentImpl(value, false).getPath();                 
             }
         }
         
+        value = decodeValue(value, decoded, pType);
+        
+        
         if (pClass.isPrimitive()) {
             try {
                 return PrimitiveUtils.read(value, pClass);
@@ -485,9 +488,9 @@ public final class InjectionUtils {
                             paramValue = InjectionUtils.handleBean(type, processedValues,
                                                             pType, message, decoded);
                         } else {
-                            String value = decodeValue(processedValues.values().iterator().next().get(0),
-                                                       decoded, pType);
-                            paramValue = InjectionUtils.handleParameter(value, type, pType,
message);
+                            paramValue = InjectionUtils.handleParameter(
+                                processedValues.values().iterator().next().get(0), 
+                                decoded, type, pType, message);
                         }
 
                         if (paramValue != null) {
@@ -631,8 +634,8 @@ public final class InjectionUtils {
             List<String> valuesList = values.values().iterator().next();
             valuesList = checkPathSegment(valuesList, realType, pathParam);
             for (int ind = 0; ind < valuesList.size(); ind++) {
-                String value = decodeValue(valuesList.get(ind), decoded, pathParam);
-                Object o = InjectionUtils.handleParameter(value, realType, pathParam, message);
+                Object o = InjectionUtils.handleParameter(valuesList.get(ind), decoded, 
+                                                          realType, pathParam, message);
                 addToCollectionValues(theValues, o, ind);
             }
         }
@@ -707,8 +710,7 @@ public final class InjectionUtils {
                                 : paramValues.get(0);
             }
             if (result != null) {
-                result = decodeValue(result, decoded, pathParam);
-                value = InjectionUtils.handleParameter(result, paramType, pathParam, message);
+                value = InjectionUtils.handleParameter(result, decoded, paramType, pathParam,
message);
             }
         }
         return value;

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1081844&r1=1081843&r2=1081844&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Tue Mar 15 16:31:29 2011
@@ -784,7 +784,7 @@ public final class JAXRSUtils {
             return c;
         }
         
-        return InjectionUtils.handleParameter(c.getValue(), pClass, ParameterType.COOKIE,
m);
+        return InjectionUtils.handleParameter(c.getValue(), false, pClass, ParameterType.COOKIE,
m);
     }
     
     public static <T> T createContextValue(Message m, Type genericType, Class<T>
clazz) {

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java?rev=1081844&r1=1081843&r2=1081844&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/Customer.java
Tue Mar 15 16:31:29 2011
@@ -305,7 +305,8 @@ public class Customer extends AbstractCu
                                 @MatrixParam("p2") String mp2,
                                 @MatrixParam("p3") String mp3,
                                 @MatrixParam("p4") String mp4,
-                                @MatrixParam("p4") List<String> mp4List) {
+                                @MatrixParam("p4") List<String> mp4List,
+                                @MatrixParam("p5") String mp5) {
         // complete
     }
     

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=1081844&r1=1081843&r2=1081844&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
Tue Mar 15 16:31:29 2011
@@ -1003,14 +1003,14 @@ public class JAXRSUtilsTest extends Asse
     @SuppressWarnings("unchecked")
     @Test
     public void testMatrixParameters() throws Exception {
-        Class[] argType = {String.class, String.class, String.class, String.class, List.class};
+        Class[] argType = {String.class, String.class, String.class, String.class, List.class,
String.class};
         Method m = Customer.class.getMethod("testMatrixParam", argType);
         MessageImpl messageImpl = new MessageImpl();
         
-        messageImpl.put(Message.REQUEST_URI, "/foo;p4=0;p3=3/bar;p1=1;p2/baz;p4=4;p4=5");
+        messageImpl.put(Message.REQUEST_URI, "/foo;p4=0;p3=3/bar;p1=1;p2/baz;p4=4;p4=5;p5");
         List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m,
null), 
                                                            null, messageImpl);
-        assertEquals("5 Matrix params should've been identified", 5, params.size());
+        assertEquals("5 Matrix params should've been identified", 6, params.size());
         
         assertEquals("First Matrix Parameter not matched correctly", 
                      "1", params.get(0));
@@ -1025,6 +1025,8 @@ public class JAXRSUtilsTest extends Asse
         assertEquals("0", list.get(0));
         assertEquals("4", list.get(1));
         assertEquals("5", list.get(2));
+        assertEquals("Sixth Matrix Parameter was not matched correctly", 
+                     "", params.get(5));
     }
     
     @Test

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java?rev=1081844&r1=1081843&r2=1081844&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
Tue Mar 15 16:31:29 2011
@@ -88,6 +88,21 @@ public class BookStoreSpring {
     }
     
     @GET
+    @Path("/semicolon{id}")
+    @Produces("application/xml")
+    public Book getBookWithSemicoln(@PathParam("id") String name) {
+        return new Book(name, 333L);
+    }
+    
+    @GET
+    @Path("/semicolon2{id}")
+    @Produces("application/xml")
+    public Book getBookWithSemicolnAndMatrixParam(@PathParam("id") String name,
+                                                  @MatrixParam("a") String matrixParam) {
+        return new Book(name + matrixParam, 333L);
+    }
+    
+    @GET
     @Path("/bookinfo")
     public Book getBookByUriInfo() throws Exception {
         MultivaluedMap<String, String> params = ui.getQueryParameters();

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java?rev=1081844&r1=1081843&r2=1081844&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
Tue Mar 15 16:31:29 2011
@@ -38,7 +38,7 @@ public class JAXRSClientServerProxySprin
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", 
-                   launchServer(BookServerProxySpring.class, true));
+                   launchServer(BookServerProxySpring.class));
     }
     
     @Test

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=1081844&r1=1081843&r2=1081844&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
Tue Mar 15 16:31:29 2011
@@ -55,7 +55,7 @@ public class JAXRSClientServerSpringBook
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", 
-                   launchServer(BookServerSpring.class, true));
+                   launchServer(BookServerSpring.class));
     }
     
     @Test
@@ -77,6 +77,28 @@ public class JAXRSClientServerSpringBook
     }
     
     @Test
+    public void testGetBookWithEncodedSemicolon() throws Exception {
+        String endpointAddress =
+            "http://localhost:" + PORT + "/the/thebooks/bookstore/semicolon%3B"; 
+        WebClient client = WebClient.create(endpointAddress);
+        WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(1000000);
+        Book book = client.get(Book.class);
+        assertEquals(333L, book.getId());
+        assertEquals(";", book.getName());
+    }
+    
+    @Test
+    public void testGetBookWithEncodedSemicolonAndMatrixParam() throws Exception {
+        String endpointAddress =
+            "http://localhost:" + PORT + "/the/thebooks/bookstore/semicolon2%3B;a=b"; 
+        WebClient client = WebClient.create(endpointAddress);
+        WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(1000000);
+        Book book = client.get(Book.class);
+        assertEquals(333L, book.getId());
+        assertEquals(";b", book.getName());
+    }
+    
+    @Test
     public void testGetBookXSLTHtml() throws Exception {
 
         String endpointAddress =



Mime
View raw message