You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/05/30 17:30:09 UTC
svn commit: r410303 -
/cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/matching/WildcardURIMatcherTestCase.java
Author: cziegeler
Date: Tue May 30 08:30:08 2006
New Revision: 410303
URL: http://svn.apache.org/viewvc?rev=410303&view=rev
Log:
Add testcase that show a bug in the wildcard matcher!
Modified:
cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/matching/WildcardURIMatcherTestCase.java
Modified: cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/matching/WildcardURIMatcherTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/matching/WildcardURIMatcherTestCase.java?rev=410303&r1=410302&r2=410303&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/matching/WildcardURIMatcherTestCase.java (original)
+++ cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/matching/WildcardURIMatcherTestCase.java Tue May 30 08:30:08 2006
@@ -16,47 +16,47 @@
package org.apache.cocoon.matching;
import java.util.Map;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
+
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.SitemapComponentTestCase;
public class WildcardURIMatcherTestCase extends SitemapComponentTestCase {
- /**
- * Run this test suite from commandline
- *
- * @param args commandline arguments (ignored)
- */
- public static void main( String[] args ) {
- TestRunner.run(suite());
- }
-
- /** Create a test suite.
- * This test suite contains all test cases of this class.
- * @return the Test object containing all test cases.
- */
- public static Test suite() {
- TestSuite suite = new TestSuite(WildcardURIMatcherTestCase.class);
- return suite;
- }
-
public void testWildcardURIMatch() throws Exception {
getRequest().setRequestURI("/test/foo/bla/end");
- Parameters parameters = new Parameters();
+ final Parameters parameters = new Parameters();
Map result = match("wildcard-uri", "**", parameters);
- System.out.println(result);
assertNotNull("Test if resource exists", result);
assertEquals("Test for **", "test/foo/bla/end", result.get("1"));
result = match("wildcard-uri", "**/bla/*", parameters);
- System.out.println(result);
assertNotNull("Test if resource exists", result);
assertEquals("Test for **/bla/* {1}", "test/foo", result.get("1"));
assertEquals("Test for **/bla/* {2}", "end", result.get("2"));
}
+
+ public void testWildcardURIMatchSimplePattern() throws Exception {
+ getRequest().setRequestURI("/test");
+
+ final Parameters parameters = new Parameters();
+
+ Map result = match("wildcard-uri", "*", parameters);
+ assertNotNull("Test if resource exists", result);
+ assertEquals("Test for *", "test", result.get("1"));
+ }
+
+ public void testWildcardURIMatchDoublePattern() throws Exception {
+ getRequest().setRequestURI("/test/something.xmlbla.xml");
+
+ final Parameters parameters = new Parameters();
+
+ Map result = match("wildcard-uri", "*/*.xml", parameters);
+ assertNotNull("Test if resource exists", result);
+ assertEquals("Test for */*.xml", "test", result.get("1"));
+ assertEquals("Test for */*.xml", "something.xmlbla", result.get("2"));
+ }
+
}