1   
2   /*
3    * SmartCrawler
4    *
5    * $Id: LinkTest.java,v 1.4 2005/07/14 13:42:29 vincool Exp $
6    * Copyright 2005 Davide Pozza
7    *
8    * This program is free software; you can redistribute it
9    * and/or modify it under the terms of the GNU General Public
10   * License as published by the Free Software Foundation;
11   * either version 2 of the License, or (at your option) any
12   * later version.
13   *
14   * This program is distributed in the hope that it will be
15   * useful, but WITHOUT ANY WARRANTY; without even the implied
16   * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
17   * PURPOSE. See the GNU General Public License for more
18   * details.
19   *
20   * You should have received a copy of the GNU General Public
21   * License along with this program; if not, write to the Free
22   * Software Foundation, Inc., 59 Temple Place, Suite 330,
23   * Boston, MA 02111-1307 USA
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          //System.out.println("exp=" + expected);
86          //System.out.println("act=" + actual);
87          assertEquals("link.getURL().getHost()", expected, actual);
88          
89          // TODO add your test code below by replacing the default call to fail.
90          //fail("The test case is empty.");
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         //System.out.println("exp=" + expected);
105         //System.out.println("act=" + actual);
106         assertEquals("Link.toString()", expected, actual);
107         // TODO add your test code below by replacing the default call to fail.
108         //fail("The test case is empty.");
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         //System.out.println("exp=" + expected);
119         //System.out.println("act=" + actual);
120         assertEquals("Link.toString()", expected, actual);
121         // TODO add your test code below by replacing the default call to fail.
122         //fail("The test case is empty.");
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         //System.out.println("exp=" + expected);
133         //System.out.println("act=" + actual);
134         assertEquals("Link.toString()", expected, actual);
135         // TODO add your test code below by replacing the default call to fail.
136         //fail("The test case is empty.");
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         // TODO add your test code below by replacing the default call to fail.
146         //fail("The test case is empty.");
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         // TODO add your test code below by replacing the default call to fail.
156         //fail("The test case is empty.");
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         // TODO add your test code below by replacing the default call to fail.
166         //fail("The test case is empty.");
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         // TODO add your test code below by replacing the default call to fail.
176         //fail("The test case is empty.");
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         // TODO add your test code below by replacing the default call to fail.
186         //fail("The test case is empty.");
187     }
188     
189 }