On Dec 3, 2008, at 9:14 AM, Sergey Beryozkin wrote:
>>> @Path("a.b")
>
>> I need to have this test passing now :
>>
>> URITemplate uriTemplate = new URITemplate("/books/a.b");
>> assertTrue(uriTemplate.match("/books/a.b"));
>> assertFail(uriTemplate.match("/books/abc"));
>
> so I did this test and it works without me modifying any code, the
> resulting regular expression is
>
> "/books/a.b(/.*)?"
>
> This expression requires that only "a.b" is accepted.
>
> So, sorry I'm feeling silly, I'm still in the dark as to why I need
> to escape '.' in the above Path's value if the goal is to ensure
> that only a literal '.' is allowed between 'a' and 'b'.
>
Try assertFail(uriTemplate.match("/books/acb"));
That should fail but will not if you don't escape the '.' in the regex.
/books/abc will fail anyway because of the final 'c' which doesn't
match the final 'b' in the template.
Marc.
---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.