1 package org.apache.maven.doxia.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.codehaus.plexus.PlexusTestCase;
23
24
25
26
27
28
29
30 public class DoxiaUtilsTest
31 extends PlexusTestCase
32 {
33
34
35
36 public void testIsInternalLink()
37 {
38 String link = "#anchor";
39 assertTrue( "Should be an internal link: " + link,
40 DoxiaUtils.isInternalLink( link ) );
41
42 link = "http://maven.apache.org/index.html#anchor";
43 assertFalse( "Should NOT be an internal link: " + link,
44 DoxiaUtils.isInternalLink( link ) );
45
46 link = "./index.html";
47 assertFalse( "Should NOT be an internal link: " + link,
48 DoxiaUtils.isInternalLink( link ) );
49 }
50
51
52
53
54 public void testIsExternalLink()
55 {
56 String link = "http://maven.apache.org/";
57 assertTrue( "Should be an external link: " + link,
58 DoxiaUtils.isExternalLink( link ) );
59
60 link = "https://maven.apache.org/";
61 assertTrue( "Should be an external link: " + link,
62 DoxiaUtils.isExternalLink( link ) );
63
64 link = "HTTPS://MAVEN.APACHE.ORG/";
65 assertTrue( "Should be an external link: " + link,
66 DoxiaUtils.isExternalLink( link ) );
67
68 link = "ftp:/maven.apache.org/";
69 assertTrue( "Should be an external link: " + link,
70 DoxiaUtils.isExternalLink( link ) );
71
72 link = "mailto:maven@apache.org";
73 assertTrue( "Should be an external link: " + link,
74 DoxiaUtils.isExternalLink( link ) );
75
76 link = "file:/index.html";
77 assertTrue( "Should be an external link: " + link,
78 DoxiaUtils.isExternalLink( link ) );
79
80 link = "index.html";
81 assertFalse( "Should NOT be an external link: " + link,
82 DoxiaUtils.isExternalLink( link ) );
83
84 link = "example.pdf";
85 assertFalse( "Should NOT be an external link: " + link,
86 DoxiaUtils.isExternalLink( link ) );
87
88 link = "./index.html";
89 assertFalse( "Should NOT be an external link: " + link,
90 DoxiaUtils.isExternalLink( link ) );
91
92 link = "../index.html";
93 assertFalse( "Should NOT be an external link: " + link,
94 DoxiaUtils.isExternalLink( link ) );
95
96
97
98 link = "file:\\index.html";
99 assertFalse( "Should NOT be an external link: " + link,
100 DoxiaUtils.isExternalLink( link ) );
101
102 link = ".\\index.html";
103 assertFalse( "Should NOT be an external link: " + link,
104 DoxiaUtils.isExternalLink( link ) );
105
106 link = "..\\index.html";
107 assertFalse( "Should NOT be an external link: " + link,
108 DoxiaUtils.isExternalLink( link ) );
109 }
110
111
112
113
114 public void testIsLocalLink()
115 {
116 String link = "index.html";
117 assertTrue( "Should be a local link: " + link,
118 DoxiaUtils.isLocalLink( link ) );
119
120 link = "./index.html";
121 assertTrue( "Should be a local link: " + link,
122 DoxiaUtils.isLocalLink( link ) );
123
124 link = "../index.html";
125 assertTrue( "Should be a local link: " + link,
126 DoxiaUtils.isLocalLink( link ) );
127
128 link = "#anchor";
129 assertFalse( "Should NOT be a local link: " + link,
130 DoxiaUtils.isLocalLink( link ) );
131
132 }
133
134 }