KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > util > SimpleUrlPatternTest


1 package info.magnolia.cms.util;
2
3 import junit.framework.TestCase;
4
5
6 /**
7  * Tests for info.magnolia.cms.util.SimpleUrlPattern
8  * @author Fabrizio Giustina
9  * @version $Revision: 6341 $ ($Author: philipp $)
10  */

11 public class SimpleUrlPatternTest extends TestCase {
12
13     /**
14      * Test without wildcards.
15      */

16     public void testNoWildcardsMatch() {
17         assertTrue(new SimpleUrlPattern("/test/url.html").match("/test/url.html"));
18     }
19
20     /**
21      * Test without wildcards.
22      */

23     public void testNoWildcardsNoMatch() {
24         assertFalse(new SimpleUrlPattern("/test/url.html").match("/test/secondurl.html"));
25     }
26
27     /**
28      * Test with the <code>*</code> wildcard.
29      */

30     public void testStarMatch() {
31         assertTrue(new SimpleUrlPattern("/test/*.html").match("/test/url.html"));
32     }
33
34     /**
35      * Test with the <code>*</code> wildcard.
36      */

37     public void testStarNoMatch() {
38         assertFalse(new SimpleUrlPattern("/test/*.html").match("/other/url.html"));
39     }
40
41     /**
42      * Test with the <code>*</code> wildcard.
43      */

44     public void testStarMatch2() {
45         assertTrue(new SimpleUrlPattern("/*/*.html").match("/test/url.html"));
46     }
47
48     /**
49      * Test with the <code>*</code> wildcard.
50      */

51     public void testStarNoMatch2() {
52         assertFalse(new SimpleUrlPattern("/*/*.html").match("/test/url.jsp"));
53     }
54
55     /**
56      * Test with the <code>*</code> wildcard.
57      */

58     public void testStarMatch3() {
59         assertTrue(new SimpleUrlPattern("/**/*.html").match("/test/url.html"));
60     }
61
62     /**
63      * Test with the <code>*</code> wildcard.
64      */

65     public void testStarNoMatch3() {
66         assertFalse(new SimpleUrlPattern("/**/*.html").match("/test/url.jsp"));
67     }
68
69     /**
70      * Test with the <code>*</code> wildcard.
71      */

72     public void testStarMatch4() {
73         assertTrue(new SimpleUrlPattern("/**/*.html").match("/test/dir/dir/url.html"));
74     }
75
76     /**
77      * Test with the <code>*</code> wildcard.
78      */

79     public void testStarNoMatch4() {
80         assertFalse(new SimpleUrlPattern("/**/*.html").match("/test/dir/dir/url.jsp"));
81     }
82
83     /**
84      * Test with the <code>?</code> wildcard.
85      */

86     public void testQuestionMarkMatch() {
87         assertTrue(new SimpleUrlPattern("/test/num?page.html").match("/test/num2page.html"));
88     }
89
90     /**
91      * Test with the <code>*</code> and <code>?</code> wildcards.
92      */

93     public void testWildcardsMatch() {
94         assertTrue(new SimpleUrlPattern("/*/num?page.html").match("/*/num2page.html"));
95     }
96
97 }
98
Popular Tags