1   /*
2    *  TestGazetteer.java
3    *
4    *  Copyright (c) 1998-2005, The University of Sheffield.
5    *
6    *  This file is part of GATE (see http://gate.ac.uk/), and is free
7    *  software, licenced under the GNU Library General Public License,
8    *  Version 2, June 1991 (in the distribution as file licence.html,
9    *  and also available at http://gate.ac.uk/gate/licence.html).
10   *
11   *  Valentin Tablan, 25/10/2000
12   *
13   *  $Id: TestGazetteer.java,v 1.16 2005/01/11 13:51:32 ian Exp $
14   */
15  
16  package gate.creole.gazetteer;
17  
18  import java.net.URL;
19  
20  import junit.framework.*;
21  
22  import gate.*;
23  import gate.corpora.TestDocument;
24  
25  public class TestGazetteer extends TestCase {
26  
27    public TestGazetteer(String name) {
28      super(name);
29    }
30  
31    /** Fixture set up */
32    public void setUp() throws Exception {
33    }
34  
35    public void tearDown() throws Exception {
36    } // tearDown
37  
38    /** Test the default tokeniser */
39    public void testDefaultGazetteer() throws Exception {
40      //get a document
41      Document doc = Factory.newDocument(
42        new URL(TestDocument.getTestServerName() + "tests/doc0.html")
43      );
44  
45      //create a default gazetteer
46      DefaultGazetteer gaz = (DefaultGazetteer) Factory.createResource(
47                            "gate.creole.gazetteer.DefaultGazetteer");
48  
49      //runtime stuff
50      gaz.setDocument(doc);
51      gaz.setAnnotationSetName("GazetteerAS");
52      gaz.execute();
53      assertTrue(!doc.getAnnotations("GazetteerAS").isEmpty());
54    }
55  
56    /** Test suite routine for the test runner */
57    public static Test suite() {
58      return new TestSuite(TestGazetteer.class);
59    } // suite
60  
61    public static void main(String[] args) {
62      try{
63        Gate.init();
64        TestGazetteer testGaz = new TestGazetteer("");
65        testGaz.setUp();
66        testGaz.testDefaultGazetteer();
67        testGaz.tearDown();
68      } catch(Exception e) {
69        e.printStackTrace();
70      }
71    } // main
72  
73  } // TestGazetteer
74