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 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 }