cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r730976 - in /cocoon/cocoon3/trunk: cocoon-docs/ cocoon-docs/src/changes/ cocoon-docs/src/site/ cocoon-docs/src/site/apt/ cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/ cocoon-sitemap/src/test/java/org/apache/cocoon/sitemap/ut...
Date Sat, 03 Jan 2009 12:16:55 GMT
Author: reinhard
Date: Sat Jan  3 04:16:53 2009
New Revision: 730976

URL: http://svn.apache.org/viewvc?rev=730976&view=rev
Log:
Update the WildcardMatcherHelper to the latest version of Cocoon 2.2.

Added:
    cocoon/cocoon3/trunk/cocoon-sitemap/src/test/java/org/apache/cocoon/sitemap/util/
    cocoon/cocoon3/trunk/cocoon-sitemap/src/test/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelperTestCase.java
  (with props)
Modified:
    cocoon/cocoon3/trunk/cocoon-docs/pom.xml
    cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml
    cocoon/cocoon3/trunk/cocoon-docs/src/site/apt/roadmap.apt
    cocoon/cocoon3/trunk/cocoon-docs/src/site/site.xml
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelper.java
    cocoon/cocoon3/trunk/parent/pom.xml

Modified: cocoon/cocoon3/trunk/cocoon-docs/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-docs/pom.xml?rev=730976&r1=730975&r2=730976&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-docs/pom.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-docs/pom.xml Sat Jan  3 04:16:53 2009
@@ -163,7 +163,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-changes-plugin</artifactId>
-        <version>2.0</version>
+        <version>2.1</version>
         <reportSets>
           <reportSet>
             <reports>

Modified: cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml?rev=730976&r1=730975&r2=730976&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-docs/src/changes/changes.xml Sat Jan  3 04:16:53 2009
@@ -22,9 +22,14 @@
   
   $Id$
 -->
-<document>
+<document xmlns="http://maven.apache.org/changes/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
+
   <body>
     <release version="3.0.0-alpha-2" date="2008-00-00" description="unreleased">
+      <action dev="reinhard" type="update">
+        [cocoon-sitemap] Update the WildcardMatcherHelper to the latest version of Cocoon
2.2.
+      </action>
       <action dev="reinhard" type="add">
         [cocoon-rest] The @Inject annotation supports org.apache.cocoon.configuration.Settings
and 
         javax.servlet.ServletContext injections.

Modified: cocoon/cocoon3/trunk/cocoon-docs/src/site/apt/roadmap.apt
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-docs/src/site/apt/roadmap.apt?rev=730976&r1=730975&r2=730976&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-docs/src/site/apt/roadmap.apt (original)
+++ cocoon/cocoon3/trunk/cocoon-docs/src/site/apt/roadmap.apt Sat Jan  3 04:16:53 2009
@@ -7,7 +7,7 @@
 
 Cocoon 3 Roadmap
 
-    Cocoon 3 hasn't been released yet. An initial alpha-1 release is planned in October based
on the current version available in SVN.
+    Cocoon 3 hasn't been released yet. An initial alpha-1 release is planned in December
based on the current version available in SVN.
     If you are interested, any participation is highly appreciated. The tasks listed here
are only suggestions. If you have other ideas, please
     join us on our {{{mail-lists.html} developer's mailing list}}). 
     
@@ -15,8 +15,6 @@
 
     These tasks are a good starting point for everybody who wants to contribute to Cocoon
3.
     
-    * A stateless forms framework optimized for RESTful web applications. (cocoon-rest) (reinhard/steven)
-
     * Improved error handling (review exception handling in general) and error reporting
(cocoon-sitemap)
     
     * Improved error handling in XSLT transformer (cocoon-pipeline)
@@ -31,6 +29,8 @@
     
     * Support annotation-based REST controller URL mapping similar to JSR311 (cocoon-rest)
     
+    * Use Java 5 regular expressions in <<<org.apache.cocoon.sitemap.util.WildcardMatcherHelper>>>
(cocoon-sitemap)
+    
 * Advanced unscheduled features
     
     * In the case of a conditional GET a pipeline doesn't need to be executed in every case.

@@ -40,6 +40,8 @@
     
     * Improve caching when the servlet protocol is used (cocoon-servlet/cocoon-sitemap)
     
+    * Cleanup pipeline configuration and object model:
+    
     * Using SAX buffers in servlet protocol (cocoon-servlet, cocoon-servlet-service-fw-impl)
     
     * review package structure for OSGi (all)
@@ -59,3 +61,5 @@
     
     * Provide adapters that enable the mix of different component types in the same pipeline
(cocoon-pipeline)
     
+    * A stateless forms framework optimized for RESTful web applications. (cocoon-rest) (reinhard/steven)
   
+    

Modified: cocoon/cocoon3/trunk/cocoon-docs/src/site/site.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-docs/src/site/site.xml?rev=730976&r1=730975&r2=730976&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-docs/src/site/site.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-docs/src/site/site.xml Sat Jan  3 04:16:53 2009
@@ -38,7 +38,7 @@
       <item name="Team list" href="team-list.html" />
       <item name="Mailing lists" href="mail-lists.html" />
       <item name="Building" href="building.html" />
-      <item name="API" href="api-docs.html" />
+      <item name="API" href="apidocs/index.html" />
       <item name="Issue Tracking" href="https://issues.apache.org/jira/browse/COCOON3"
/>
       <item name="Download" href="download.html" />
     </menu>

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelper.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelper.java?rev=730976&r1=730975&r2=730976&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelper.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelper.java
Sat Jan  3 04:16:53 2009
@@ -1,20 +1,18 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ *      http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.cocoon.sitemap.util;
 
@@ -24,18 +22,14 @@
 import com.sun.org.apache.regexp.internal.RE;
 import com.sun.org.apache.regexp.internal.RECompiler;
 import com.sun.org.apache.regexp.internal.REProgram;
-import com.sun.org.apache.regexp.internal.RESyntaxException;
 
 /**
- * This class is an utility class that perform wildcard-patterns matching and
- * isolation.
+ * This class is an utility class that perform wildcard-patterns matching and isolation.
  * 
  * @version $Id$
  */
 public class WildcardMatcherHelper {
-
-    // ~ Static fields/initializers
-    // -----------------------------------------------------------------
+    // ~ Static fields/initializers -----------------------------------------------------------------
 
     /** Default path separator: "/" */
     public static final char ESC = '\\';
@@ -46,48 +40,37 @@
     /** Default path separator: "/" */
     public static final char STAR = '*';
 
-    // ~ Methods
-    // ------------------------------------------------------------------------------------
+    // ~ Methods ------------------------------------------------------------------------------------
 
     /**
-     * Match a pattern agains a string and isolates wildcard replacement into a
-     * <code>Map</code>. <br>
+     * Match a pattern agains a string and isolates wildcard replacement into a <code>Map</code>.
<br>
      * Here is how the matching algorithm works:
      * 
      * <ul>
-     * <li> The '*' character, meaning that zero or more characters (excluding
-     * the path separator '/') are to be matched. </li>
-     * <li> The '**' sequence, meaning that zero or more characters (including
-     * the path separator '/') are to be matched. </li>
-     * <li> The '\*' sequence is honored as a literal '*' character, not a
-     * wildcard </li>
+     * <li> The '*' character, meaning that zero or more characters (excluding the
path separator '/') are to be
+     * matched. </li>
+     * <li> The '**' sequence, meaning that zero or more characters (including the
path separator '/') are to be
+     * matched. </li>
+     * <li> The '\*' sequence is honored as a litteral '*' character, not a wildcard
</li>
      * </ul>
      * <br>
-     * When more than two '*' characters, not separated by another character,
-     * are found their value is considered as '**' and immediate succeeding '*'
-     * are skipped. <br>
-     * The '**' wildcard is greedy and thus the following sample matches as
-     * {"foo/bar","baz","bug"}:
+     * When more than two '*' characters, not separated by another character, are found their
value is considered as
+     * '**' and immediate succeeding '*' are skipped. <br>
+     * The '**' wildcard is greedy and thus the following sample matches as {"foo/bar","baz","bug"}:
      * <dl>
      * <dt>pattern</dt>
-     * <dd>STAR,STAR,PATHSEP,STAR,PATHSEP,STAR,STAR (why can't I express it
-     * literally?)</dt>
+     * <dd>STAR,STAR,PATHSEP,STAR,PATHSEP,STAR,STAR (why can't I express it litterally?)</dt>
      * <dt>string</dt>
      * <dd>foo/bar/baz/bug</dt>
      * </dl>
-     * The first '**' in the pattern will suck up as much as possible without
-     * making the match fail.
+     * The first '**' in the pattern will suck up as much as possible without making the
match fail.
      * 
-     * @param pat
-     *            The pattern string.
-     * @param str
-     *            The string to math agains the pattern
+     * @param pat The pattern string.
+     * @param str The string to math agains the pattern
      * 
-     * @return a <code>Map</code> containing the representation of the
-     *         extracted pattern. The extracted patterns are keys in the
-     *         <code>Map</code> from left to right beginning with "1" for te
-     *         left most, "2" for the next, a.s.o. The key "0" is the string
-     *         itself. If the return value is null, string does not match to the
+     * @return a <code>Map</code> containing the representation of the extracted
pattern. The extracted patterns are
+     *         keys in the <code>Map</code> from left to right beginning with
"1" for te left most, "2" for the next,
+     *         a.s.o. The key "0" is the string itself. If the return value is null, string
does not match to the
      *         pattern .
      */
     public static Map<String, String> match(final String pat, final String str) {
@@ -117,43 +100,30 @@
     /** Cache for compiled pattern matchers */
     private static final Map<String, Matcher> cache = new HashMap<String, Matcher>();
 
-    // ~ Inner Classes
-    // ------------------------------------------------------------------------------
+    // ~ Inner Classes ------------------------------------------------------------------------------
 
     /**
      * The private matcher class
      */
     private static class Matcher {
 
-        /**
-         * Regexp to split constant parts from front and back leaving wildcards
-         * in the middle.
-         */
+        /** Regexp to split constant parts from front and back leaving wildcards in the middle.
*/
         private static final REProgram splitter;
 
         static {
             final String fixedRE = "([^*\\\\]*)";
             final String wcardRE = "(.*[*\\\\])";
             final String splitRE = "^" + fixedRE + wcardRE + fixedRE + "$";
-
-            try {
-                splitter = new RECompiler().compile(splitRE);
-            } catch (RESyntaxException e) {
-                throw new RuntimeException(e);
-            }
+            splitter = new RECompiler().compile(splitRE);
         }
 
         /** Wildcard types to short-cut simple '*' and "**' matches. */
         private static final int WC_CONST = 0;
-
         private static final int WC_STAR = 1;
-
         private static final int WC_STARSTAR = 2;
-
         private static final int WC_REGEXP = 3;
 
-        // ~ Instance fields
-        // ------------------------------------------------------------------------
+        // ~ Instance fields ------------------------------------------------------------------------
 
         // All fields declared final to emphasize requirement to be thread-safe.
 
@@ -169,34 +139,29 @@
         /** Wildcard type of pattern. */
         private final int wctype;
 
-        /**
-         * Compiled regexp equivalent to wildcard pattern between prefix and
-         * suffix.
-         */
+        /** Compiled regexp equivalent to wildcard pattern between prefix and suffix. */
         private final REProgram regexp;
 
-        // ~ Constructors
-        // ---------------------------------------------------------------------------
+        // ~ Constructors ---------------------------------------------------------------------------
 
         /**
          * Creates a new Matcher object.
          * 
-         * @param pat
-         *            The pattern
-         * @param str
-         *            The string
+         * @param pat The pattern
+         * @param str The string
          */
         Matcher(final String pat) {
             RE re = new RE(splitter);
 
             if (re.match(pat)) {
+
                 // Split pattern into (foo/)(*)(/bar).
+
                 this.prefix = re.getParen(1);
                 String wildcard = re.getParen(2);
                 String tail = re.getParen(3);
 
-                // If wildcard ends with \ then add the first char of postfix to
-                // wildcard.
+                // If wildcard ends with \ then add the first char of postfix to wildcard.
                 if (tail.length() != 0 && wildcard.charAt(wildcard.length() - 1)
== ESC) {
                     wildcard = wildcard + tail.substring(0, 1);
                     this.suffix = tail.substring(1);
@@ -205,6 +170,7 @@
                 }
 
                 // Use short-cuts for single * or ** wildcards
+
                 if (wildcard.equals("*")) {
                     this.wctype = WC_STAR;
                     this.regexp = null;
@@ -226,17 +192,16 @@
             this.fixlen = this.prefix.length() + this.suffix.length();
         }
 
-        // ~ Methods
-        // --------------------------------------------------------------------------------
+        // ~ Methods --------------------------------------------------------------------------------
 
         /**
          * Match string against pattern.
          * 
-         * @param str
-         *            The string
+         * @param str The string
          * @return list of wildcard matches, null if match failed
          */
         String[] getMatches(final String str) {
+
             // Protect against 'foo' matching 'foo*foo'.
             if (str.length() < this.fixlen) {
                 return null;
@@ -287,11 +252,10 @@
     /**
      * Compile wildcard pattern into regexp pattern.
      * 
-     * @param pat
-     *            The wildcard pattern
+     * @param pat The wildcard pattern
      * @return compiled regexp program.
      */
-    static REProgram compileRegexp(String pat) {
+    private static REProgram compileRegexp(String pat) {
         StringBuffer repat = new StringBuffer(pat.length() * 6);
         repat.append('^');
 
@@ -315,10 +279,8 @@
                 continue;
             }
 
-            // Match ESC+ESC and ESC+STAR as literal ESC and STAR which needs to
-            // be escaped
-            // in regexp. Match ESC+other as two characters ESC+other where
-            // other may also
+            // Match ESC+ESC and ESC+STAR as literal ESC and STAR which needs to be escaped
+            // in regexp. Match ESC+other as two characters ESC+other where other may also
             // need to be escaped in regexp.
             if (ch == ESC) {
                 ch = wcpat[++i];
@@ -337,10 +299,6 @@
         }
         repat.append('$');
 
-        try {
-            return new RECompiler().compile(repat.toString());
-        } catch (RESyntaxException e) {
-            throw new RuntimeException(e);
-        }
+        return new RECompiler().compile(repat.toString());
     }
 }

Added: cocoon/cocoon3/trunk/cocoon-sitemap/src/test/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelperTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/test/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelperTestCase.java?rev=730976&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/test/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelperTestCase.java
(added)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/test/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelperTestCase.java
Sat Jan  3 04:16:53 2009
@@ -0,0 +1,288 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.sitemap.util;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Id$
+ */
+public class WildcardMatcherHelperTestCase extends TestCase {
+
+    // ~ Methods ------------------------------------------------------------------------------------
+
+    public void test01WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("test", "test");
+        assertNotNull(result);
+        assertEquals("test", result.get("0"));
+        assertNull(result.get("1"));
+    }
+
+    public void test02WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("end", "enp");
+        assertNull(result);
+    }
+
+    public void test03WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("/t\\*d", "/t*d");
+        assertNotNull(result);
+        assertEquals("/t*d", result.get("0"));
+    }
+
+    public void test04WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("\\*d", "*d");
+        assertNotNull(result);
+        assertEquals("*d", result.get("0"));
+    }
+
+    public void test05WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("**", "*d");
+        assertNotNull(result);
+        assertEquals("*d", result.get("0"));
+        assertEquals("*d", result.get("1"));
+    }
+
+    public void test06WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("foo**", "foo*d");
+        assertNotNull(result);
+        assertEquals("foo*d", result.get("0"));
+        assertEquals("*d", result.get("1"));
+    }
+
+    public void test07WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("end", "en");
+        assertNull(result);
+    }
+
+    public void test08WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("en", "end");
+        assertNull(result);
+    }
+
+    public void test09WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("end**", "end");
+        assertNotNull(result);
+        assertEquals("", result.get("1"));
+    }
+
+    public void test10WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("end**end", "endendend");
+        assertNotNull(result);
+        assertEquals("end", result.get("1"));
+    }
+
+    public void test11WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("end**end", "endxxend");
+        assertNotNull(result);
+        assertEquals("xx", result.get("1"));
+    }
+
+    public void test12WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("*/end", "xx/end");
+        assertNotNull(result);
+        assertEquals("xx", result.get("1"));
+    }
+
+    public void test13WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("ab/cd*/end", "ab/cdxx/end");
+        assertNotNull(result);
+        assertEquals("xx", result.get("1"));
+    }
+
+    public void test14WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("a*/cd*/end", "ab/cdxx/end");
+        assertNotNull(result);
+        assertEquals("b", result.get("1"));
+        assertEquals("xx", result.get("2"));
+    }
+
+    public void test15WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("a**/cd*/end", "ab/yy/cdxx/end");
+        assertNotNull(result);
+        assertEquals("b/yy", result.get("1"));
+        assertEquals("xx", result.get("2"));
+    }
+
+    public void test16WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("a**/cd*/end/*", "ab/yy/cdxx/end/foobar/ii");
+        assertNull(result);
+    }
+
+    public void test17WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("a**/cd*/end/**",
"ab/yy/cdxx/end/foobar/ii");
+        assertNotNull(result);
+        assertEquals("b/yy", result.get("1"));
+        assertEquals("xx", result.get("2"));
+        assertEquals("foobar/ii", result.get("3"));
+    }
+
+    public void test18WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("a**cd*/end/**", "ab/yy/cdxx/end/foobar/ii");
+        assertNotNull(result);
+        assertEquals("b/yy/", result.get("1"));
+        assertEquals("xx", result.get("2"));
+        assertEquals("foobar/ii", result.get("3"));
+    }
+
+    public void test19WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("*/*.xml", "test/something.xmlbla.xml");
+        assertNotNull(result);
+        assertEquals("test", result.get("1"));
+        assertEquals("something.xmlbla", result.get("2"));
+    }
+
+    public void test20WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("ab/cd*/end", "ab/cd/end");
+        assertNotNull(result);
+        assertEquals("", result.get("1"));
+    }
+
+    public void test21WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("*/**", "samples/blocks/");
+        assertNotNull(result);
+        assertEquals("samples", result.get("1"));
+        assertEquals("blocks/", result.get("2"));
+    }
+
+    public void test22WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("*/**", "samples/");
+        assertNotNull(result);
+        assertEquals("samples", result.get("1"));
+        assertEquals("", result.get("2"));
+    }
+
+    public void test23WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("**favicon.ico", "samples/");
+        assertNull(result);
+    }
+
+    public void test24WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("**favicon.ico", "samples1234/");
+        assertNull(result);
+    }
+
+    public void test25WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("**favicon.ico", "samples123/");
+        assertNull(result);
+    }
+
+    public void test26WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("**/*/**", "foo/bar/baz/bug");
+        assertNotNull(result);
+        assertEquals("foo/bar", result.get("1"));
+        assertEquals("baz", result.get("2"));
+        assertEquals("bug", result.get("3"));
+    }
+
+    public void test27WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("end*end*end*end",
"endXXendYendend");
+        assertNotNull(result);
+        assertEquals("XX", result.get("1"));
+        assertEquals("Y", result.get("2"));
+        assertEquals("", result.get("3"));
+    }
+
+    public void test28WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("end*end*end*end",
"endendendend");
+        assertNotNull(result);
+        assertEquals("", result.get("1"));
+        assertEquals("", result.get("2"));
+        assertEquals("", result.get("3"));
+    }
+
+    public void test29WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("end**end**end**end",
"endXXendYendend");
+        assertNotNull(result);
+        assertEquals("XX", result.get("1"));
+        assertEquals("Y", result.get("2"));
+        assertEquals("", result.get("3"));
+    }
+
+    public void test30WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("end**end**end**end",
"endendendend");
+        assertNotNull(result);
+        assertEquals("", result.get("1"));
+        assertEquals("", result.get("2"));
+        assertEquals("", result.get("3"));
+    }
+
+    public void test31WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("*/", "test/foo/bar");
+        assertNull(result);
+    }
+
+    public void test32WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("**/*.html", "foo/bar/baz.html");
+        assertNotNull(result);
+        assertEquals("baz", result.get("2"));
+        assertEquals("foo/bar", result.get("1"));
+    }
+
+    public void test33WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("*.html", "menu/baz.html");
+        assertNull(result);
+    }
+
+    public void test34WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("*.html", "baz.html");
+        assertNotNull(result);
+        assertEquals("baz", result.get("1"));
+    }
+
+    public void test35WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("menu/**/foo_*_bar.*",
"menu//foo_baz_bar.html");
+        assertNotNull(result);
+        assertEquals("", result.get("1"));
+        assertEquals("baz", result.get("2"));
+        assertEquals("html", result.get("3"));
+    }
+
+    public void test36WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("menu/**/foo/*", "menu/bar/baz.xml");
+        assertNull(result);
+    }
+
+    public void test37WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("menu/*.xml", "menu/foo/bar.xml");
+        assertNull(result);
+    }
+
+    public void test38WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("\\\\foo\\*\\n\\0\\",
"\\foo*\\n\\0\\");
+        assertNotNull(result);
+    }
+
+    public void test39WildcardURIMatch() throws Exception {
+        Map<String, String> result = WildcardMatcherHelper.match("menu/*.simple.xml",
"menu/37.simple.xml");
+        assertNotNull(result);
+        assertEquals("37", result.get("1"));
+    }
+
+    public void testEmptyPattern() throws Exception {
+        assertNotNull(WildcardMatcherHelper.match("", ""));
+        assertNull(WildcardMatcherHelper.match("", "foo"));
+        assertNull(WildcardMatcherHelper.match("", "foo/bar"));
+    }
+
+    public void testEndPattern() throws Exception {
+        assertNotNull(WildcardMatcherHelper.match("*/", "foo/"));
+        assertNull(WildcardMatcherHelper.match("*/", "foo/bar/"));
+        assertNull(WildcardMatcherHelper.match("*/", "test/foo/bar/"));
+    }
+}
\ No newline at end of file

Propchange: cocoon/cocoon3/trunk/cocoon-sitemap/src/test/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelperTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sitemap/src/test/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelperTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sitemap/src/test/java/org/apache/cocoon/sitemap/util/WildcardMatcherHelperTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: cocoon/cocoon3/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/parent/pom.xml?rev=730976&r1=730975&r2=730976&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/parent/pom.xml (original)
+++ cocoon/cocoon3/trunk/parent/pom.xml Sat Jan  3 04:16:53 2009
@@ -198,6 +198,11 @@
         <version>1.1.1</version>
       </dependency> 
       <dependency>
+        <groupId>jakarta-regexp</groupId>
+        <artifactId>jakarta-regexp</artifactId>
+        <version>1.4</version>
+      </dependency>      
+      <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>servlet-api</artifactId>
         <version>2.4</version>



Mime
View raw message