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.extractor;
28
29 import junit.framework.*;
30 import org.smartcrawler.common.Link;
31 import org.smartcrawler.common.SCLogger;
32
33
34 /***
35 *
36 *
37 * @author <a href="mailto:pozzad@alice.it">Davide Pozza</a>
38 * @version <tt>$Revision: 1.2 $</tt>
39 */
40 public class LinkBuilderImplTest extends TestCase {
41
42 static {
43 SCLogger.initialize();
44 }
45
46 /***
47 *
48 * @param testName
49 */
50 public LinkBuilderImplTest(String testName) {
51 super(testName);
52 }
53
54 /***
55 *
56 * @throws java.lang.Exception
57 */
58 protected void setUp() throws Exception {
59 }
60
61 /***
62 *
63 * @throws java.lang.Exception
64 */
65 protected void tearDown() throws Exception {
66 }
67
68 /***
69 *
70 * @return
71 */
72 public static Test suite() {
73 TestSuite suite = new TestSuite(LinkBuilderImplTest.class);
74
75 return suite;
76 }
77
78 /***
79 * Test of buildLink method, of class org.smartcrawler.extractor.LinkBuilderImpl.
80 */
81 public void testBuildLink_Absolute() {
82 System.out.println("testBuildLink_Absolute");
83 Link link = null;
84 try {
85 link = new Link("smartcrawler.sourceforge.net/test/testpage.html");
86 } catch (Exception e) {}
87 LinkBuilder lb = new LinkBuilderImpl(link);
88
89 HtmlURL htmlURL = new HtmlURLImpl("/index.htm");
90 Link actual = null;
91 Link expected = null;
92 try {
93 expected = new Link("http://smartcrawler.sourceforge.net/index.htm");
94 actual = lb.buildLink(htmlURL);
95 } catch (Exception e) {}
96 assertEquals("LinkBuilderImpl.buildLink(\"/index.htm\")", expected, actual);
97 }
98 /***
99 * Test of buildLink method, of class org.smartcrawler.extractor.LinkBuilderImpl.
100 */
101 public void testBuildLink_Relative_1() {
102 System.out.println("testBuildLink_Relative_1");
103 Link link = null;
104 try {
105 link = new Link("smartcrawler.sourceforge.net/test/testpage.html");
106 } catch (Exception e) {}
107 LinkBuilder lb = new LinkBuilderImpl(link);
108
109 HtmlURL htmlURL = new HtmlURLImpl("index.htm");
110 Link actual = null;
111 Link expected = null;
112 try {
113 expected = new Link("http://smartcrawler.sourceforge.net/test/index.htm");
114 actual = lb.buildLink(htmlURL);
115 } catch (Exception e) {}
116 assertEquals("LinkBuilderImpl.buildLink(\"index.htm\")", expected, actual);
117 }
118 /***
119 * Test of buildLink method, of class org.smartcrawler.extractor.LinkBuilderImpl.
120 */
121 public void testBuildLink_Relative_2() {
122 System.out.println("testBuildLink_Relative_2");
123 Link link = null;
124 try {
125 link = new Link("smartcrawler.sourceforge.net/test/testpage.html");
126 } catch (Exception e) {}
127 LinkBuilder lb = new LinkBuilderImpl(link);
128
129 HtmlURL htmlURL = new HtmlURLImpl("../index.htm");
130 Link actual = null;
131 Link expected = null;
132 try {
133 expected = new Link("http://smartcrawler.sourceforge.net/index.htm");
134 actual = lb.buildLink(htmlURL);
135 } catch (Exception e) {}
136 assertEquals("LinkBuilderImpl.buildLink(\"../index.htm\")", expected, actual);
137 }
138 /***
139 * Test of buildLink method, of class org.smartcrawler.extractor.LinkBuilderImpl.
140 */
141 public void testBuildLink_Relative_3() {
142 System.out.println("testBuildLink_Relative_3");
143 Link link = null;
144 try {
145 link = new Link("smartcrawler.sourceforge.net/test/testpage.html");
146 } catch (Exception e) {}
147 LinkBuilder lb = new LinkBuilderImpl(link);
148
149 HtmlURL htmlURL = new HtmlURLImpl("./index.htm");
150 Link actual = null;
151 Link expected = null;
152 try {
153 expected = new Link("http://smartcrawler.sourceforge.net/test/index.htm");
154 actual = lb.buildLink(htmlURL);
155 } catch (Exception e) {}
156 assertEquals("LinkBuilderImpl.buildLink(\"./index.htm\")", expected, actual);
157 }
158
159 }