cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1042827 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
Date Mon, 06 Dec 2010 22:34:15 GMT
Author: sergeyb
Date: Mon Dec  6 22:34:15 2010
New Revision: 1042827

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

........
  r1042821 | sergeyb | 2010-12-06 22:31:21 +0000 (Mon, 06 Dec 2010) | 1 line
  
  [CXF-3168] : checking for spaces around template vars
........

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/model/URITemplate.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec  6 22:34:15 2010
@@ -1 +1 @@
-/cxf/trunk:1041183,1041790,1041993,1042346,1042571,1042724,1042805
+/cxf/trunk:1041183,1041790,1041993,1042346,1042571,1042724,1042805,1042821

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/model/URITemplate.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java?rev=1042827&r1=1042826&r2=1042827&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
Mon Dec  6 22:34:15 2010
@@ -386,7 +386,7 @@ public final class URITemplate {
      * Variable of URITemplate. Variable has either "{varname:pattern}" syntax or "{varname}".
      */
     private static final class Variable extends UriChunk {
-        private static final Pattern VARIABLE_PATTERN = Pattern.compile("(\\w[-\\w\\.]*)(\\:(.+))?");
+        private static final Pattern VARIABLE_PATTERN = Pattern.compile("(\\w[-\\w\\.]*[
]*)(\\:(.+))?");
         private String name;
         private Pattern pattern;
 
@@ -402,12 +402,13 @@ public final class URITemplate {
                 throw new IllegalArgumentException("uriChunk is empty");
             }
             if (CurlyBraceTokenizer.insideBraces(uriChunk)) {
-                uriChunk = CurlyBraceTokenizer.stripBraces(uriChunk);
+                uriChunk = CurlyBraceTokenizer.stripBraces(uriChunk).trim();
                 Matcher matcher = VARIABLE_PATTERN.matcher(uriChunk);
                 if (matcher.matches()) {
                     name = matcher.group(1).trim();
                     if (matcher.group(2) != null && matcher.group(3) != null) {
-                        pattern = Pattern.compile(matcher.group(3).trim());
+                        String patternExpression = matcher.group(3).trim();
+                        pattern = Pattern.compile(patternExpression);
                     }
                     return;
                 }

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java?rev=1042827&r1=1042826&r2=1042827&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
Mon Dec  6 22:34:15 2010
@@ -191,15 +191,30 @@ public class URITemplateTest extends Ass
 
     @Test
     public void testBasicCustomExpression() throws Exception {
-        URITemplate uriTemplate = new URITemplate("/books/{bookId:[^/]+?}");
+        doTestBasicCustomExpression("/books/{bookId:[^/]+?}");
+    }
+    
+    @Test
+    public void testBasicCustomExpressionWithSpaces() throws Exception {
+        doTestBasicCustomExpression("/books/{ bookId : [^/]+? }");
+    }
+    
+    @Test
+    public void testBasicCustomExpressionWithSpaces2() throws Exception {
+        doTestBasicCustomExpression("/books/{ bookId }/");
+    }
+    
+    private void doTestBasicCustomExpression(String expression) {
+        URITemplate uriTemplate = new URITemplate(expression);
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
 
         boolean match = uriTemplate.match("/books/123/chapter/1", values);
         assertTrue(match);
         assertEquals("123", values.getFirst("bookId"));
         String subResourcePath = values.getFirst(URITemplate.FINAL_MATCH_GROUP);
-        assertEquals("/chapter/1", subResourcePath);
+        assertEquals("/chapter/1", subResourcePath);    
     }
+    
 
     @Test
     public void testBasicCustomExpression2() throws Exception {



Mime
View raw message