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/06/22 11:27:56 UTC
svn commit: r416307 - in /cocoon/trunk/core/cocoon-core/src:
main/java/org/apache/cocoon/util/WildcardMatcherHelper.java
test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java
test/java/org/apache/cocoon/util/test/WildcardHelperTestCase.java
Author: cziegeler
Date: Thu Jun 22 02:27:56 2006
New Revision: 416307
URL: http://svn.apache.org/viewvc?rev=416307&view=rev
Log:
Update test cases
Modified:
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java
cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java
cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/test/WildcardHelperTestCase.java
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java?rev=416307&r1=416306&r2=416307&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java Thu Jun 22 02:27:56 2006
@@ -171,7 +171,7 @@
* @param aStr The extracted substring
*/
private void add(final String aStr) {
- map.put("" + idx++, aStr);
+ map.put(String.valueOf(idx++), aStr);
}
/**
Modified: cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java?rev=416307&r1=416306&r2=416307&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java (original)
+++ cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java Thu Jun 22 02:27:56 2006
@@ -113,14 +113,14 @@
public void test13WildcardURIMatch()
throws Exception {
- Map result = WildcardMatcherHelper.match("/ab/cd*/end", "/ab/cdxx/end");
+ Map result = WildcardMatcherHelper.match("ab/cd*/end", "ab/cdxx/end");
assertNotNull(result);
assertEquals("xx", result.get("1"));
}
public void test14WildcardURIMatch()
throws Exception {
- Map result = WildcardMatcherHelper.match("/a*/cd*/end", "/ab/cdxx/end");
+ Map result = WildcardMatcherHelper.match("a*/cd*/end", "ab/cdxx/end");
assertNotNull(result);
assertEquals("b", result.get("1"));
assertEquals("xx", result.get("2"));
@@ -128,7 +128,7 @@
public void test15WildcardURIMatch()
throws Exception {
- Map result = WildcardMatcherHelper.match("/a**/cd*/end", "/ab/yy/cdxx/end");
+ Map result = WildcardMatcherHelper.match("a**/cd*/end", "ab/yy/cdxx/end");
assertNotNull(result);
assertEquals("b/yy", result.get("1"));
assertEquals("xx", result.get("2"));
@@ -136,13 +136,13 @@
public void test16WildcardURIMatch()
throws Exception {
- Map result = WildcardMatcherHelper.match("/a**/cd*/end/*", "/ab/yy/cdxx/end/foobar/ii");
+ Map result = WildcardMatcherHelper.match("a**/cd*/end/*", "ab/yy/cdxx/end/foobar/ii");
assertNull(result);
}
public void test17WildcardURIMatch()
throws Exception {
- Map result = WildcardMatcherHelper.match("/a**/cd*/end/**", "/ab/yy/cdxx/end/foobar/ii");
+ Map 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"));
@@ -151,7 +151,7 @@
public void test18WildcardURIMatch()
throws Exception {
- Map result = WildcardMatcherHelper.match("/a**cd*/end/**", "/ab/yy/cdxx/end/foobar/ii");
+ Map 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"));
@@ -160,7 +160,7 @@
public void test19WildcardURIMatch()
throws Exception {
- Map result = WildcardMatcherHelper.match("/*/*.xml", "/test/something.xmlbla.xml");
+ Map result = WildcardMatcherHelper.match("*/*.xml", "test/something.xmlbla.xml");
assertNotNull(result);
assertEquals("test", result.get("1"));
assertEquals("something.xmlbla", result.get("2"));
@@ -168,8 +168,20 @@
public void test20WildcardURIMatch()
throws Exception {
- Map result = WildcardMatcherHelper.match("/ab/cd*/end", "/ab/cd/end");
+ Map result = WildcardMatcherHelper.match("ab/cd*/end", "ab/cd/end");
assertNotNull(result);
assertEquals("", 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/"));
}
}
Modified: cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/test/WildcardHelperTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/test/WildcardHelperTestCase.java?rev=416307&r1=416306&r2=416307&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/test/WildcardHelperTestCase.java (original)
+++ cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/test/WildcardHelperTestCase.java Thu Jun 22 02:27:56 2006
@@ -102,6 +102,9 @@
boolean result = WildcardHelper.match(resultMap, "foo/bar/", expr);
assertFalse("Url 'foo/bar/' should not match pattern '*/'.", result);
+ result = WildcardHelper.match(resultMap, "test/foo/bar/", expr);
+ assertFalse("Url 'test/foo/bar/' should not match pattern '*/'.", result);
+
result = WildcardHelper.match(resultMap, "foo/", expr);
assertTrue("Url 'foo/' should match pattern '*/'", result);
}