1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 package org.smartcrawler.common;
28
29 import junit.framework.*;
30 import java.net.MalformedURLException;
31 import java.net.URL;
32 import org.apache.log4j.Logger;
33
34 /***
35 *
36 *
37 * @author <a href="mailto:pozzad@alice.it">Davide Pozza</a>
38 * @version <tt>$Revision: 1.4 $</tt>
39 */
40 public class LinkTest extends TestCase {
41
42 /***
43 *
44 * @param testName
45 */
46 public LinkTest(String testName) {
47 super(testName);
48 }
49
50 /***
51 *
52 * @throws java.lang.Exception
53 */
54 protected void setUp() throws Exception {
55 }
56
57 /***
58 *
59 * @throws java.lang.Exception
60 */
61 protected void tearDown() throws Exception {
62 }
63
64 /***
65 *
66 * @return
67 */
68 public static Test suite() {
69 TestSuite suite = new TestSuite(LinkTest.class);
70
71 return suite;
72 }
73
74 /***
75 * Test of getURL method, of class org.smartcrawler.common.Link.
76 */
77 public void testGetURLH() {
78 System.out.println("testGetURL");
79 Link link = null;
80 try {
81 link = new Link("http://smartcrawler.sourceforge.net/index.htm#section");
82 } catch (Exception e) {}
83 String actual = link.getURL().getHost();
84 String expected = "smartcrawler.sourceforge.net";
85
86
87 assertEquals("link.getURL().getHost()", expected, actual);
88
89
90
91 }
92
93 /***
94 * Test of toString method, of class org.smartcrawler.common.Link.
95 */
96 public void testToStringWithFragment() {
97 System.out.println("testToStringWithFragment");
98 Link link = null;
99 try {
100 link = new Link("http://smartcrawler.sourceforge.net/index.htm#section");
101 } catch (Exception e) {}
102 String actual = link.toString();
103 String expected = "http://smartcrawler.sourceforge.net/index.htm";
104
105
106 assertEquals("Link.toString()", expected, actual);
107
108
109 }
110 public void testToStringWithPort() {
111 System.out.println("testToStringWithPort");
112 Link link = null;
113 try {
114 link = new Link("http://smartcrawler.sourceforge.net:80/index.htm?param=value");
115 } catch (Exception e) {}
116 String actual = link.toString();
117 String expected = "http://smartcrawler.sourceforge.net/index.htm?param=value";
118
119
120 assertEquals("Link.toString()", expected, actual);
121
122
123 }
124 public void testToStringWithHost() {
125 System.out.println("testToStringWithHost");
126 Link link = null;
127 try {
128 link = new Link("http://smartcrawler.sourceforge.net");
129 } catch (Exception e) {}
130 String actual = link.toString();
131 String expected = "http://smartcrawler.sourceforge.net";
132
133
134 assertEquals("Link.toString()", expected, actual);
135
136
137 }
138
139 /***
140 * Test of getPath method, of class org.smartcrawler.common.Link.
141 */
142 public void testGetPath() {
143 System.out.println("testGetPath");
144
145
146
147 }
148
149 /***
150 * Test of getHost method, of class org.smartcrawler.common.Link.
151 */
152 public void testGetHost() {
153 System.out.println("testGetHost");
154
155
156
157 }
158
159 /***
160 * Test of equals method, of class org.smartcrawler.common.Link.
161 */
162 public void testEquals() {
163 System.out.println("testEquals");
164
165
166
167 }
168
169 /***
170 * Test of hashCode method, of class org.smartcrawler.common.Link.
171 */
172 public void testHashCode() {
173 System.out.println("testHashCode");
174
175
176
177 }
178
179 /***
180 * Test of toString method, of class org.smartcrawler.common.Link.
181 */
182 public void testToString() {
183 System.out.println("testToString");
184
185
186
187 }
188
189 }