KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > matching > WildcardURIMatcherTestCase


1 /*
2 * Copyright 1999-2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */

16 package org.apache.cocoon.matching;
17
18 import java.util.Map JavaDoc;
19
20 import org.apache.avalon.framework.parameters.Parameters;
21 import org.apache.cocoon.SitemapComponentTestCase;
22
23 public class WildcardURIMatcherTestCase extends SitemapComponentTestCase {
24
25     public void testWildcardURIMatch() throws Exception JavaDoc {
26         getRequest().setRequestURI("/test/foo/bla/end");
27
28         Parameters parameters = new Parameters();
29
30         Map JavaDoc result = match("wildcard-uri", "**", parameters);
31         System.out.println(result);
32         assertNotNull("Test if resource exists", result);
33         assertEquals("Test for **", "test/foo/bla/end", result.get("1"));
34         
35         result = match("wildcard-uri", "**/bla/*", parameters);
36         System.out.println(result);
37         assertNotNull("Test if resource exists", result);
38         assertEquals("Test for **/bla/* {1}", "test/foo", result.get("1"));
39         assertEquals("Test for **/bla/* {2}", "end", result.get("2"));
40     }
41 }
42
Popular Tags