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:29:15 UTC

svn commit: r416308 - /cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java

Author: cziegeler
Date: Thu Jun 22 02:29:15 2006
New Revision: 416308

URL: http://svn.apache.org/viewvc?rev=416308&view=rev
Log:
Add failing test

Modified:
    cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java

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=416308&r1=416307&r2=416308&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:29:15 2006
@@ -173,7 +173,14 @@
         assertEquals("", result.get("1"));
     }
 
-    public void testEmptyPattern() throws Exception {
+    public void test21WildcardURIMatch()
+    throws Exception {
+        Map result = WildcardMatcherHelper.match("*/**", "samples/blocks/");
+        assertNotNull(result);
+        assertEquals("", result.get("1"));
+    }
+
+public void testEmptyPattern() throws Exception {
         assertNotNull(WildcardMatcherHelper.match("", ""));
         assertNull(WildcardMatcherHelper.match("", "foo"));
         assertNull(WildcardMatcherHelper.match("", "foo/bar"));



Re: svn commit: r416308 - /cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java

Posted by Carsten Ziegeler <cz...@apache.org>.
Giacomo Pati wrote:

> 
> Ok, looking at those matching sample we need to define how matching is 
> suppose to work. Consider the following sample
> 
> Pattern		String
> **/*/**		foo/bar/baz/buz/
> 
> What is the result you expect for {1}, {2}, and {3} ? Possible values 
> could be:
> 
> {1}="foo"		{2}="bar"	{3}="baz/buz"
> {1}="foo/bar"		{2}="baz"	{3}="buz"
> {1}="foo/bar/baz"	{2}="buz"	{3}=""
> 
> which one do you think is the correct one?
> 
:)

I would expect the first result - shortest matching first :)
But I think, it's not that important what result the matcher delivers as
this pattern is ambiguous. It's important that unambigous patterns (like
*/**) work :)

Carsten

Re: svn commit: r416308 - /cocoon/trunk/core/cocoon-core/src/test/java/org/apach

Posted by Giacomo Pati <gi...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>> Ok, looking at those matching sample we need to define how matching is 
>> suppose to work. Consider the following sample
>> 
>> Pattern		String
>> **/*/**		foo/bar/baz/buz/
>> 
>> What is the result you expect for {1}, {2}, and {3} ? Possible values could 
>> be:
>> 
>> {1}="foo"		{2}="bar"	{3}="baz/buz"
>> {1}="foo/bar"		{2}="baz"	{3}="buz"
>> {1}="foo/bar/baz"	{2}="buz"	{3}=""
>> 
>> which one do you think is the correct one?
>
> If it were the regex (.*)/([^/]*)/(.*) then what would the result be?  Unless 
> there's a compelling reason not to, it might as well behave similarly.  I 
> can't test it myself right now, but I think that regex would give the third 
> option (i.e. as greedy as possible as early as it can be).

Yes, greedy regexp would give the third option. The 
WildcardMatcherHelper will give the 1. option as the algorithm used is 
not greedy.

> However, if in fact that's not the case, shouldn't {3} include the trailing 
> slash?

Yes, you are right.

- -- 
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFEnGyOLNdJvZjjVZARApTRAJ0QKNvUqdci+qMQvOWzIC+hJMptZwCg2dcs
mwZr11HpPBc6VHE/vBzqv2I=
=Oq2K
-----END PGP SIGNATURE-----

Re: svn commit: r416308 - /cocoon/trunk/core/cocoon-core/src/test/java/org/apach

Posted by Andrew Stevens <at...@hotmail.com>.
>From: Giacomo Pati <gi...@apache.org>
>Date: Thu, 22 Jun 2006 14:58:05 +0200 (CEST)
>
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>
>On Thu, 22 Jun 2006, Carsten Ziegeler wrote:
>
>>Date: Thu, 22 Jun 2006 11:59:35 +0200
>>From: Carsten Ziegeler <cz...@apache.org>
>>Reply-To: dev@cocoon.apache.org
>>To: dev@cocoon.apache.org
>>Subject: Re: svn commit: r416308 -
>>     
>>/cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/Wildca
>>     rdMatcherHelperTestCase.java
>>
>>Giacomo Pati wrote:
>>>>>
>>>>>-    public void testEmptyPattern() throws Exception {
>>>>>+    public void test21WildcardURIMatch()
>>>>>+    throws Exception {
>>>>>+        Map result = WildcardMatcherHelper.match("*/**", 
>>>>>"samples/blocks/");
>>>>>+        assertNotNull(result);
>>>>>+        assertEquals("", result.get("1"));
>>>
>>>Oh, if this test succeeds isn't it wrong? Shouldn't {1}be "samples"?
>>>
>>Ups, yep - damn copy-paste. I corrected the test case, but it still
>>fails as the result is null.
>
>Ok, looking at those matching sample we need to define how matching is 
>suppose to work. Consider the following sample
>
>Pattern		String
>**/*/**		foo/bar/baz/buz/
>
>What is the result you expect for {1}, {2}, and {3} ? Possible values could 
>be:
>
>{1}="foo"		{2}="bar"	{3}="baz/buz"
>{1}="foo/bar"		{2}="baz"	{3}="buz"
>{1}="foo/bar/baz"	{2}="buz"	{3}=""
>
>which one do you think is the correct one?

If it were the regex (.*)/([^/]*)/(.*) then what would the result be?  
Unless there's a compelling reason not to, it might as well behave 
similarly.  I can't test it myself right now, but I think that regex would 
give the third option (i.e. as greedy as possible as early as it can be).

However, if in fact that's not the case, shouldn't {3} include the trailing 
slash?


Andrew.



Re: svn commit: r416308 - /cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java

Posted by Giacomo Pati <gi...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On Thu, 22 Jun 2006, Carsten Ziegeler wrote:

> Date: Thu, 22 Jun 2006 11:59:35 +0200
> From: Carsten Ziegeler <cz...@apache.org>
> Reply-To: dev@cocoon.apache.org
> To: dev@cocoon.apache.org
> Subject: Re: svn commit: r416308 -
>     /cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/Wildca
>     rdMatcherHelperTestCase.java
> 
> Giacomo Pati wrote:
>>>>
>>>> -    public void testEmptyPattern() throws Exception {
>>>> +    public void test21WildcardURIMatch()
>>>> +    throws Exception {
>>>> +        Map result = WildcardMatcherHelper.match("*/**", "samples/blocks/");
>>>> +        assertNotNull(result);
>>>> +        assertEquals("", result.get("1"));
>>
>> Oh, if this test succeeds isn't it wrong? Shouldn't {1}be "samples"?
>>
> Ups, yep - damn copy-paste. I corrected the test case, but it still
> fails as the result is null.

Ok, looking at those matching sample we need to define how matching is 
suppose to work. Consider the following sample

Pattern		String
**/*/**		foo/bar/baz/buz/

What is the result you expect for {1}, {2}, and {3} ? Possible values 
could be:

{1}="foo"		{2}="bar"	{3}="baz/buz"
{1}="foo/bar"		{2}="baz"	{3}="buz"
{1}="foo/bar/baz"	{2}="buz"	{3}=""

which one do you think is the correct one?

I probably need to consider reversing the algorithm anyway (scanning 
from start to end instead from end to start)

- -- 
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFEmpPiLNdJvZjjVZARAjVNAKCiL60U1bw/WlWny9hVPpBXUl3H9gCg2KB2
L63tsrcfNDFnrer3/QYfDL0=
=rG/R
-----END PGP SIGNATURE-----

Re: svn commit: r416308 - /cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java

Posted by Carsten Ziegeler <cz...@apache.org>.
Giacomo Pati wrote:
>>>
>>> -    public void testEmptyPattern() throws Exception {
>>> +    public void test21WildcardURIMatch()
>>> +    throws Exception {
>>> +        Map result = WildcardMatcherHelper.match("*/**", "samples/blocks/");
>>> +        assertNotNull(result);
>>> +        assertEquals("", result.get("1"));
> 
> Oh, if this test succeeds isn't it wrong? Shouldn't {1}be "samples"?
> 
Ups, yep - damn copy-paste. I corrected the test case, but it still
fails as the result is null.

Carsten
-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

Re: svn commit: r416308 - /cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java

Posted by Giacomo Pati <gi...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 22 Jun 2006, cziegeler@apache.org wrote:

> Date: Thu, 22 Jun 2006 09:29:15 -0000
> From: cziegeler@apache.org
> Reply-To: dev@cocoon.apache.org
> To: cvs@cocoon.apache.org
> Subject: svn commit: r416308 -
>     /cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/Wildca
>     rdMatcherHelperTestCase.java
> 
> Author: cziegeler
> Date: Thu Jun 22 02:29:15 2006
> New Revision: 416308
>
> URL: http://svn.apache.org/viewvc?rev=416308&view=rev
> Log:
> Add failing test
>
> Modified:
>    cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java
>
> 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=416308&r1=416307&r2=416308&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:29:15 2006
> @@ -173,7 +173,14 @@
>         assertEquals("", result.get("1"));
>     }
>
> -    public void testEmptyPattern() throws Exception {
> +    public void test21WildcardURIMatch()
> +    throws Exception {
> +        Map result = WildcardMatcherHelper.match("*/**", "samples/blocks/");
> +        assertNotNull(result);
> +        assertEquals("", result.get("1"));

Oh, if this test succeeds isn't it wrong? Shouldn't {1}be "samples"?

- -- 
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFEmmXpLNdJvZjjVZARAla+AKCyhmOo7IcNO3nOTZzonBOalaQI0gCgt++X
E2DitKHZWw/myEd1Swc7UWo=
=hVTj
-----END PGP SIGNATURE-----

Re: svn commit: r416308 - /cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java

Posted by Giacomo Pati <gi...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 22 Jun 2006, cziegeler@apache.org wrote:

> Date: Thu, 22 Jun 2006 09:29:15 -0000
> From: cziegeler@apache.org
> Reply-To: dev@cocoon.apache.org
> To: cvs@cocoon.apache.org
> Subject: svn commit: r416308 -
>     /cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/Wildca
>     rdMatcherHelperTestCase.java
> 
> Author: cziegeler
> Date: Thu Jun 22 02:29:15 2006
> New Revision: 416308
>
> URL: http://svn.apache.org/viewvc?rev=416308&view=rev
> Log:
> Add failing test
>
> Modified:
>    cocoon/trunk/core/cocoon-core/src/test/java/org/apache/cocoon/util/WildcardMatcherHelperTestCase.java
>
> 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=416308&r1=416307&r2=416308&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:29:15 2006
> @@ -173,7 +173,14 @@
>         assertEquals("", result.get("1"));
>     }
>
> -    public void testEmptyPattern() throws Exception {
> +    public void test21WildcardURIMatch()
> +    throws Exception {
> +        Map result = WildcardMatcherHelper.match("*/**", "samples/blocks/");
> +        assertNotNull(result);
> +        assertEquals("", result.get("1"));

Oh, if this test succeeds isn't it wrong? Shouldn't {1}be "samples"?

- -- 
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFEmmXpLNdJvZjjVZARAla+AKCyhmOo7IcNO3nOTZzonBOalaQI0gCgt++X
E2DitKHZWw/myEd1Swc7UWo=
=hVTj
-----END PGP SIGNATURE-----