cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r724783 - in /cxf/branches/2.1.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ systests/src/test/...
Date Tue, 09 Dec 2008 17:10:23 GMT
Author: sergeyb
Date: Tue Dec  9 09:10:22 2008
New Revision: 724783

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

........
  r722988 | sergeyb | 2008-12-03 18:04:20 +0000 (Wed, 03 Dec 2008) | 1 line
  
  JAXRS : support for arbitrary regular expressions
........

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
    cxf/branches/2.1.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl
  (props changed)

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec  9 09:10:22 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,723024,723338,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668

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

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

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java?rev=724783&r1=724782&r2=724783&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
Tue Dec  9 09:10:22 2008
@@ -48,6 +48,12 @@
             return g1 < g2 ? 1 : -1;
         }
         
+        int gCustom1 = e1.getURITemplate().getNumberOfGroupsWithCustomExpression();
+        int gCustom2 = e2.getURITemplate().getNumberOfGroupsWithCustomExpression();
+        if (gCustom1 != gCustom2) {
+            // descending order 
+            return gCustom1 < gCustom2 ? 1 : -1;
+        }
         
         int result = JAXRSUtils.compareSortedMediaTypes(
                           e1.getConsumeTypes(), 

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java?rev=724783&r1=724782&r2=724783&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
Tue Dec  9 09:10:22 2008
@@ -21,7 +21,6 @@
 
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -38,68 +37,63 @@
     public static final String TEMPLATE_PARAMETERS = "jaxrs.template.parameters";
     
     public static final String LIMITED_REGEX_SUFFIX = "(/.*)?";
-    public static final String UNLIMITED_REGEX_SUFFIX = "(/)?";
     public static final String FINAL_MATCH_GROUP = "FINAL_MATCH_GROUP";
     
     /**
      * The regular expression for matching URI templates and names.
      */
     private static final Pattern TEMPLATE_NAMES_PATTERN = 
-        Pattern.compile("\\{(\\w[-\\w\\.]*)\\}");
-
-    /**
-     * A URI template is converted into a regular expression by substituting
-     * (.*?) for each occurrence of {\([w- 14 \. ]+?\)} within the URL
-     * template
-     */
-    private static final String PATH_VARIABLE_REGEX = "([^/]+?)";
-    private static final String PATH_UNLIMITED_VARIABLE_REGEX = "(.*?)";
+        Pattern.compile("\\{(\\w[-\\w\\.]*)(\\:(.+?))?\\}");
 
+    private static final String DEFAULT_PATH_VARIABLE_REGEX = "([^/]+?)";
+    
     private final String template;
-    private final List<String> templateVariables;
+    private final List<String> templateVariables = new ArrayList<String>();
+    private final List<String> customTemplateVariables = new ArrayList<String>();
     private final Pattern templateRegexPattern;
     private final String literals;
 
-    public URITemplate(String theTemplate) {
-        this(theTemplate, true);
-    }
     
-    public URITemplate(String theTemplate, boolean limited) {
+    public URITemplate(String theTemplate) {
+        
         this.template = theTemplate;
         
         StringBuilder literalChars = new StringBuilder();
-        StringBuilder stringBuilder = new StringBuilder();
-        List<String> names = new ArrayList<String>();
-
+        StringBuilder patternBuilder = new StringBuilder();
+        
         // compute a regular expression from URI template
         Matcher matcher = TEMPLATE_NAMES_PATTERN.matcher(template);
         int i = 0;
         while (matcher.find()) {
-            literalChars.append(template.substring(i, matcher.start()));
-            copyURITemplateCharacters(template, i, matcher.start(), stringBuilder);
+            templateVariables.add(matcher.group(1).trim());
+            
+            String substr = escapeCharacters(template.substring(i, matcher.start()));
+            literalChars.append(substr);
+            patternBuilder.append(substr);
             i = matcher.end();
-            if (!limited && i == template.length()) {
-                stringBuilder.append(PATH_UNLIMITED_VARIABLE_REGEX);
+            if (matcher.group(2) != null && matcher.group(3) != null) {
+                patternBuilder.append('(');
+                patternBuilder.append(matcher.group(3).trim());
+                patternBuilder.append(')');
+                customTemplateVariables.add(matcher.group(1).trim());
             } else {
-                stringBuilder.append(PATH_VARIABLE_REGEX);
-            }
-            names.add(matcher.group(1));
+                patternBuilder.append(DEFAULT_PATH_VARIABLE_REGEX);
+            } 
         }
-        literalChars.append(template.substring(i, template.length()));
-        copyURITemplateCharacters(template, i, template.length(), stringBuilder);
+        String substr = escapeCharacters(template.substring(i, template.length()));
+        literalChars.append(substr);
+        patternBuilder.append(substr);
 
         literals = literalChars.toString();
-        templateVariables = Collections.unmodifiableList(names);
-
-        int endPos = stringBuilder.length() - 1;
-        boolean endsWithSlash = (endPos >= 0) ? stringBuilder.charAt(endPos) == '/' :
false;
         
+        int endPos = patternBuilder.length() - 1;
+        boolean endsWithSlash = (endPos >= 0) ? patternBuilder.charAt(endPos) == '/' :
false;
         if (endsWithSlash) {
-            stringBuilder.deleteCharAt(endPos);
+            patternBuilder.deleteCharAt(endPos);
         }
-        stringBuilder.append(limited ? LIMITED_REGEX_SUFFIX : UNLIMITED_REGEX_SUFFIX);
+        patternBuilder.append(LIMITED_REGEX_SUFFIX);
         
-        templateRegexPattern = Pattern.compile(stringBuilder.toString());
+        templateRegexPattern = Pattern.compile(patternBuilder.toString());
     }
 
     public String getLiteralChars() {
@@ -114,15 +108,21 @@
         return templateVariables.size();
     }
     
-    private void copyURITemplateCharacters(String templateValue, int start, int end, StringBuilder
b) {
-        for (int i = start; i < end; i++) {
-            char c = templateValue.charAt(i);
-            if (c == '?') {
-                b.append("\\?");
-            } else {
-                b.append(c);
-            }
+    public int getNumberOfGroupsWithCustomExpression() {
+        return customTemplateVariables.size();
+    }
+    
+    private static String escapeCharacters(String expression) {
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < expression.length(); i++) {
+            char ch = expression.charAt(i);
+            sb.append(isReservedCharater(ch) ? "\\" + ch : ch);
         }
+        return sb.toString();
+    }
+    
+    private static boolean isReservedCharater(char ch) {
+        return '.' == ch;
     }
 
     public boolean match(String uri, MultivaluedMap<String, String> templateVariableToValue)
{
@@ -190,6 +190,6 @@
             pathValue = "/" + pathValue;
         }
         
-        return new URITemplate(pathValue, path.limited());
+        return new URITemplate(pathValue);
     }
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java?rev=724783&r1=724782&r2=724783&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriInfoImplTest.java
Tue Dec  9 09:10:22 2008
@@ -122,7 +122,7 @@
         
         // with suffix
         values.clear();
-        new URITemplate("/bar", false).match("/bar", values);
+        new URITemplate("/bar").match("/bar", values);
         
         u = new UriInfoImpl(mockMessage("http://localhost:8080/baz", "/bar"),
                                         values);

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java?rev=724783&r1=724782&r2=724783&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
Tue Dec  9 09:10:22 2008
@@ -35,8 +35,7 @@
 
     @Test
     public void testMatchBasic() throws Exception {
-        URITemplate uriTemplate = new URITemplate("/customers/{id}",
-                                                  false);
+        URITemplate uriTemplate = new URITemplate("/customers/{id}");
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
         
         boolean match = uriTemplate.match("/customers/123/", values);
@@ -47,8 +46,7 @@
     
     @Test
     public void testMatchWithMatrixAndTemplate() throws Exception {
-        URITemplate uriTemplate = new URITemplate("/customers/{id}",
-                                                  false);
+        URITemplate uriTemplate = new URITemplate("/customers/{id}");
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
         
         boolean match = uriTemplate.match("/customers/123;123456/", values);
@@ -59,8 +57,7 @@
     
     @Test
     public void testMatchWithMatrixOnClearPath1() throws Exception {
-        URITemplate uriTemplate = new URITemplate("/customers/{id}",
-                                                  false);
+        URITemplate uriTemplate = new URITemplate("/customers/{id}");
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
         
         boolean match = uriTemplate.match("/customers;123456/123/", values);
@@ -71,8 +68,7 @@
     
     @Test
     public void testMatchWithMatrixOnClearPath2() throws Exception {
-        URITemplate uriTemplate = new URITemplate("/customers/{id}/orders/{order}",
-                                                  false);
+        URITemplate uriTemplate = new URITemplate("/customers/{id}/orders/{order}");
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
         
         assertTrue(uriTemplate.match("/customers;123456/123/orders;456/3", values));
@@ -82,8 +78,7 @@
     
     @Test
     public void testMatchWithMatrixOnClearPath3() throws Exception {
-        URITemplate uriTemplate = new URITemplate("/{id}/customers/",
-                                                  false);
+        URITemplate uriTemplate = new URITemplate("/{id}/customers/");
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
         
         boolean match = uriTemplate.match("/123/customers;123456/", values);
@@ -94,8 +89,7 @@
     
     @Test
     public void testMatchBasicTwoParametersVariation1() throws Exception {
-        URITemplate uriTemplate = new URITemplate("/customers/{name}/{department}",
-                                                  false);
+        URITemplate uriTemplate = new URITemplate("/customers/{name}/{department}");
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
         
         boolean match = uriTemplate.match("/customers/john/CS", values);
@@ -108,8 +102,7 @@
     
     @Test
     public void testMatchBasicTwoParametersVariation2() throws Exception {
-        URITemplate uriTemplate = new URITemplate("/customers/name/{name}/dep/{department}",
-                                                  false);
+        URITemplate uriTemplate = new URITemplate("/customers/name/{name}/dep/{department}");
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
         
         boolean match = uriTemplate.match("/customers/name/john/dep/CS", values);
@@ -123,7 +116,7 @@
     @Test
     public void testURITemplateWithSubResource() throws Exception {
         //So "/customers" is the URITemplate for the root resource class
-        URITemplate uriTemplate = new URITemplate("/customers", true);
+        URITemplate uriTemplate = new URITemplate("/customers");
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
         
         boolean match = uriTemplate.match("/customers/123", values);
@@ -135,7 +128,7 @@
     @Test
     public void testURITemplateWithSubResourceVariation2() throws Exception {
         //So "/customers" is the URITemplate for the root resource class
-        URITemplate uriTemplate = new URITemplate("/customers", true);
+        URITemplate uriTemplate = new URITemplate("/customers");
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
         
         boolean match = uriTemplate.match("/customers/name/john/dep/CS", values);
@@ -150,7 +143,7 @@
      * public Book getBook(@UriParam("bookId") String id)
      */
     public void testURITemplateWithSubResourceVariation3() throws Exception {
-        URITemplate uriTemplate = new URITemplate("/books/{bookId}/", true);
+        URITemplate uriTemplate = new URITemplate("/books/{bookId}/");
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
         
         boolean match = uriTemplate.match("/books/123/chapter/1", values);
@@ -158,4 +151,119 @@
         String subResourcePath = values.getFirst(URITemplate.FINAL_MATCH_GROUP);
         assertEquals("/chapter/1", subResourcePath);
     }
+    
+    @Test
+    public void testBasicCustomExpression() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/books/{bookId:[^/]+?}");
+        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);
+    }
+    
+    @Test
+    public void testBasicCustomExpression2() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/books/{bookId:123}");
+        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);
+    }
+    
+    @Test
+    public void testBasicCustomExpression3() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/books/{bookId:\\d\\d\\d}");
+        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);
+    }
+    
+    @Test
+    public void testEscaping() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/books/a.db");
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        
+        assertTrue(uriTemplate.match("/books/a.db", values));
+        assertFalse(uriTemplate.match("/books/adbc", values));
+        assertFalse(uriTemplate.match("/books/acdb", values));
+
+    }
+    
+    @Test
+    public void testBasicCustomExpression4() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/books/{bookId:...\\.}");
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        
+        assertTrue(uriTemplate.match("/books/123.", values));
+        assertEquals("123.", values.getFirst("bookId"));
+        values.clear();
+        assertTrue(uriTemplate.match("/books/abc.", values));
+        assertEquals("abc.", values.getFirst("bookId"));
+        assertFalse(uriTemplate.match("/books/abcd", values));
+        assertFalse(uriTemplate.match("/books/abc", values));
+    }
+    
+    @Test
+    public void testMultipleExpression2() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/books/{bookId:123}/chapter/{id}");
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        
+        boolean match = uriTemplate.match("/books/123/chapter/1", values);
+        assertTrue(match);
+        assertEquals("123", values.getFirst("bookId"));
+        assertEquals("1", values.getFirst("id"));
+        String subResourcePath = values.getFirst(URITemplate.FINAL_MATCH_GROUP);
+        assertEquals("/", subResourcePath);
+    }
+    
+    @Test
+    public void testFailCustomExpression() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/books/{bookId:124}");
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        
+        boolean match = uriTemplate.match("/books/123/chapter/1", values);
+        assertFalse(match);
+    }
+    
+    @Test
+    public void testBaseTail1() {
+        URITemplate uriTemplate = new URITemplate("/{base:base.+}/{tail}");
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        assertFalse(uriTemplate.match("/base/tails", values));
+        assertTrue(uriTemplate.match("/base1/tails", values));
+        assertEquals("base1", values.getFirst("base"));
+        assertEquals("tails", values.getFirst("tail"));
+    }
+    
+    @Test
+    public void testBaseTail2() {
+        URITemplate uriTemplate = new URITemplate("/{base:.+base}/{tail}");
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        assertFalse(uriTemplate.match("/base/tails", values));
+        assertFalse(uriTemplate.match("/base1/tails", values));
+        assertTrue(uriTemplate.match("/1base/tails", values));
+        assertEquals("1base", values.getFirst("base"));
+        assertEquals("tails", values.getFirst("tail"));
+    }
+    
+    @Test
+    public void testBaseTail3() {
+        URITemplate uriTemplate = new URITemplate("/{base:base.+suffix}/{tail}");
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        assertFalse(uriTemplate.match("/base/tails", values));
+        assertFalse(uriTemplate.match("/base1/tails", values));
+        assertTrue(uriTemplate.match("/base1suffix/tails", values));
+        assertEquals("base1suffix", values.getFirst("base"));
+        assertEquals("tails", values.getFirst("tail"));
+    }
 }

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=724783&r1=724782&r2=724783&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Tue Dec  9 09:10:22 2008
@@ -51,7 +51,7 @@
 
 import org.apache.cxf.helpers.XMLUtils;
 
-@Path("/bookstore/")
+@Path("/bookstore")
 public class BookStore {
 
     private Map<Long, Book> books = new HashMap<Long, Book>();
@@ -139,6 +139,12 @@
     }
     
     @GET
+    @Path("books/custom/{bookId:\\d\\d\\d}")
+    public Book getBookCustom(@PathParam("bookId") String id) throws BookNotFoundFault {
+        return doGetBook(id);
+    }
+    
+    @GET
     @Path("/books/query")
     public Book getBookQuery(@QueryParam("bookId") long id) throws BookNotFoundFault {
         return doGetBook(Long.toString(id));

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=724783&r1=724782&r2=724783&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Tue Dec  9 09:10:22 2008
@@ -185,6 +185,13 @@
     }
     
     @Test
+    public void testGetBookCustomExpression() throws Exception {
+        getAndCompareAsStrings("http://localhost:9080/bookstore/books/custom/123",
+                               "resources/expected_get_book123.txt",
+                               "application/xml", 200);
+    }
+    
+    @Test
     public void testGetBook123() throws Exception {
         getAndCompareAsStrings("http://localhost:9080/bookstore/books/123",
                                "resources/expected_get_book123.txt",

Propchange: cxf/branches/2.1.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec  9 09:10:22 2008
@@ -1 +1 @@
-/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl:722412,724485,724668
+/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl:722412,722988,724485,724668



Mime
View raw message