1   
2   /*
3    * SmartCrawler
4    *
5    * $Id: AbstractFilterTest.java,v 1.1 2005/08/05 13:39:43 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  package org.smartcrawler.filter;
27  
28  import junit.framework.*;
29  import org.smartcrawler.common.Context;
30  import org.smartcrawler.common.ConfigReader;
31  
32  /***
33   * The engine thread which is started by the {@link org.smartcrawler.Crawler}
34   *
35   * @author <a href="mailto:pozzad@alice.it">Davide Pozza</a>
36   * @version <tt>$Revision: 1.1 $</tt>
37   */
38  public class AbstractFilterTest extends TestCase {
39      
40      public AbstractFilterTest(String testName) {
41          super(testName);
42      }
43      
44      protected void setUp() throws Exception {
45      }
46      
47      protected void tearDown() throws Exception {
48      }
49      
50      public static Test suite() {
51          TestSuite suite = new TestSuite(AbstractFilterTest.class);
52          
53          return suite;
54      }
55      
56      /***
57       * Test of getParameters method, of class org.smartcrawler.filter.AbstractFilter.
58       */
59      public void testGetParameters() {
60          System.out.println("testGetParameters()");
61          ConfigReader confReader = new ConfigReader();
62          Context cf = null;
63          try {
64              cf = confReader.readConfig("examples/photosig/conf/photosig-config.xml");
65          } catch (Exception e){
66              fail("Configuration error");
67          }
68          LinkFilter lf = (LinkFilter)cf.getPrecFiltersList().iterator().next();
69          String[] exp = {
70              "http://www.photosig.com/go/photos/browse*?sort=id-d&page=*&id=1",
71              "http://www.photosig.com/go/photos/view*?id=*&forward=browse",
72              "http://photos.photosig.com/photos/*.jpg",
73              "http://photos.photosig.com/photos/*.gif"
74          };
75          String[] act = lf.getParameters("links");
76          
77          assertEquals("AbstractFilter.getParameters()", exp.length, act.length);
78          for (int i = 0; i < exp.length; i++){
79              assertEquals("AbstractFilter.getParameters()", exp[i], act[i]);
80              if (!exp[i].equals(act[i])){
81                  fail("Expected :" + exp[i] + " Actual:" + act[i]);
82              }
83          }
84      }
85      
86      /***
87       * Test of getParameter method, of class org.smartcrawler.filter.AbstractFilter.
88       */
89      public void testGetParameter() {
90          System.out.println("testGetParameter");
91      }
92      
93      /***
94       * Test of setParameters method, of class org.smartcrawler.filter.AbstractFilter.
95       */
96      public void testSetParameters() {
97          System.out.println("testSetParameters");
98      }
99      
100 }