1   
2   /*
3    * SmartCrawler
4    *
5    * $Id: PatternProviderTest.java,v 1.3 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.extractor;
28  
29  import junit.framework.*;
30  import java.util.ArrayList;
31  import java.util.List;
32  import org.apache.commons.digester.Digester;
33  import org.smartcrawler.extractor.pattern.AbstractPattern;
34  import org.smartcrawler.extractor.pattern.ConcretePattern;
35  
36  /***
37   *
38   *
39   * @author <a href="mailto:pozzad@alice.it">Davide Pozza</a>
40   * @version <tt>$Revision: 1.3 $</tt>
41   */
42  public class PatternProviderTest extends TestCase {
43      
44      /***
45       * 
46       * @param testName 
47       */
48      public PatternProviderTest(String testName) {
49          super(testName);
50      }
51  
52      /***
53       * 
54       * @throws java.lang.Exception 
55       */
56      protected void setUp() throws Exception {
57      }
58  
59      /***
60       * 
61       * @throws java.lang.Exception 
62       */
63      protected void tearDown() throws Exception {
64      }
65  
66      /***
67       * 
68       * @return 
69       */
70      public static Test suite() {
71          TestSuite suite = new TestSuite(PatternProviderTest.class);
72          
73          return suite;
74      }
75  
76  
77      /***
78       * Test of getPatterns method, of class org.smartcrawler.extractor.PatternProvider.
79       */
80      public void testGetPatterns() {
81          System.out.println("testGetPatterns");
82          AbstractPattern expected = new ConcretePattern();
83          expected.setStringPattern("(<//s*[A]//s[^>]*[//n//s]*)(href//s*=//s*([^>|//s]*))[^>]*>"); 
84          expected.setGroup("3"); 
85  
86          AbstractPattern actual = (AbstractPattern)PatternProvider.instance().getPatterns()[0];
87          System.out.println("exp = " + expected);
88          System.out.println("act = " + actual);
89          assertEquals("PatternProvider.getPatterns()", expected, actual);
90      }
91      
92  }