cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1069814 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Fri, 11 Feb 2011 14:33:00 GMT
Author: sergeyb
Date: Fri Feb 11 14:33:00 2011
New Revision: 1069814

URL: http://svn.apache.org/viewvc?rev=1069814&view=rev
Log:
[CXF-3330] Escaping literal pluses in URITemplate

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.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/model/URITemplate.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java?rev=1069814&r1=1069813&r2=1069814&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
Fri Feb 11 14:33:00 2011
@@ -40,7 +40,7 @@ public final class URITemplate {
     public static final String LIMITED_REGEX_SUFFIX = "(/.*)?";
     public static final String FINAL_MATCH_GROUP = "FINAL_MATCH_GROUP";
     private static final String DEFAULT_PATH_VARIABLE_REGEX = "([^/]+?)";
-    private static final String CHARACTERS_TO_ESCAPE = ".*";
+    private static final String CHARACTERS_TO_ESCAPE = ".*+";
 
     private final String template;
     private final List<String> variables = new ArrayList<String>();

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java?rev=1069814&r1=1069813&r2=1069814&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
Fri Feb 11 14:33:00 2011
@@ -260,7 +260,45 @@ public class URITemplateTest extends Ass
         assertFalse(uriTemplate.match("/books/a", values));
         assertFalse(uriTemplate.match("/books/ac", values));
     }
+    
+    @Test
+    public void testValueWithLiteralPlus() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/books/ab+");
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+
+        assertTrue(uriTemplate.match("/books/ab+", values));
+        assertFalse(uriTemplate.match("/books/abb", values));
+        assertFalse(uriTemplate.match("/books/ab", values));
+        assertFalse(uriTemplate.match("/books/a", values));
+    }
+    
+    @Test
+    public void testValueWithManyLiteralPluses() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/books/ab+++++");
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
 
+        assertTrue(uriTemplate.match("/books/ab+++++", values));
+        assertFalse(uriTemplate.match("/books/ab++++++", values));
+        assertFalse(uriTemplate.match("/books/ab++++", values));
+        assertFalse(uriTemplate.match("/books/ab+++", values));
+        assertFalse(uriTemplate.match("/books/ab++", values));
+        assertFalse(uriTemplate.match("/books/ab+", values));
+        assertFalse(uriTemplate.match("/books/ab", values));
+        assertFalse(uriTemplate.match("/books/a", values));
+    }
+
+    @Test
+    public void testValueWithRegExPlus() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/books/{regex:ab+\\+}");
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+
+        assertTrue(uriTemplate.match("/books/ab+", values));
+        assertFalse(uriTemplate.match("/books/abb", values));
+        assertFalse(uriTemplate.match("/books/abb", values));
+        assertFalse(uriTemplate.match("/books/abc", values));
+        assertFalse(uriTemplate.match("/books/a", values));
+    }
+    
     @Test
     public void testEncodedSpace() throws Exception {
         URITemplate uriTemplate = new URITemplate("/1 2/%203");

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1069814&r1=1069813&r2=1069814&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Fri
Feb 11 14:33:00 2011
@@ -162,6 +162,13 @@ public class BookStore {
     }
     
     @GET
+    @Path("name-in-query")
+    @Produces("application/xml")
+    public Book getBookFromQuery(@QueryParam("name") String name) {
+        return new Book(name, 321L);
+    }
+    
+    @GET
     @Path("propagate-exception2")
     public Book propogateException2() throws BookNotFoundFault {
         PhaseInterceptorChain.getCurrentMessage().put("org.apache.cxf.propagate.exception",
Boolean.FALSE);

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=1069814&r1=1069813&r2=1069814&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
Fri Feb 11 14:33:00 2011
@@ -67,6 +67,18 @@ public class JAXRSClientServerBookTest e
     }
     
     @Test
+    public void testGetBookWithNameInQuery() throws Exception {
+        
+        String endpointAddress =
+            "http://localhost:" + PORT + "/bookstore/name-in-query"; 
+        WebClient wc = WebClient.create(endpointAddress);
+        String name = "Many        spaces";
+        wc.query("name", name);
+        Book b = wc.get(Book.class);
+        assertEquals(name, b.getName());
+    }
+    
+    @Test
     public void testPostAnd401WithText() throws Exception {
         
         String endpointAddress =



Mime
View raw message