1   /*
2    *  TestTokeniser.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: TestTokeniser.java,v 1.18 2005/01/11 13:51:33 ian Exp $
14   */
15  
16  
17  package gate.creole.tokeniser;
18  
19  import java.net.URL;
20  
21  import junit.framework.*;
22  
23  import gate.*;
24  import gate.corpora.TestDocument;
25  
26  public class TestTokeniser extends TestCase{
27  
28    public TestTokeniser(String name) {
29      super(name);
30    }
31  
32    /** Fixture set up */
33    public void setUp() throws Exception {
34    }
35  
36    public void tearDown() throws Exception {
37    } // tearDown
38  
39    /** Test the default tokeniser */
40    public void testDefaultTokeniser() throws Exception {
41      //get a document
42      Document doc = Factory.newDocument(
43        new URL(TestDocument.getTestServerName() + "tests/doc0.html")
44      );
45      //create a default tokeniser
46     DefaultTokeniser tokeniser = (DefaultTokeniser) Factory.createResource(
47                            "gate.creole.tokeniser.DefaultTokeniser");
48  
49      tokeniser.setDocument(doc);
50      tokeniser.setAnnotationSetName("TokeniserAS");
51      tokeniser.execute();
52      assertTrue(! doc.getAnnotations("TokeniserAS").isEmpty());
53    }
54  
55    /** Test suite routine for the test runner */
56    public static Test suite() {
57      return new TestSuite(TestTokeniser.class);
58    } // suite
59  
60    public static void main(String[] args) {
61      try{
62        Gate.init();
63        TestTokeniser testTokeniser1 = new TestTokeniser("");
64        testTokeniser1.setUp();
65        testTokeniser1.testDefaultTokeniser();
66        testTokeniser1.tearDown();
67      }catch(Exception e){
68        e.printStackTrace();
69      }
70    }
71  }
72