01 /*
02 * TestTokeniser.java
03 *
04 * Copyright (c) 1995-2010, The University of Sheffield. See the file
05 * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
06 *
07 * This file is part of GATE (see http://gate.ac.uk/), and is free
08 * software, licenced under the GNU Library General Public License,
09 * Version 2, June 1991 (in the distribution as file licence.html,
10 * and also available at http://gate.ac.uk/gate/licence.html).
11 *
12 * Valentin Tablan, 25/10/2000
13 *
14 * $Id: TestTokeniser.java 12006 2009-12-01 17:24:28Z thomas_heitz $
15 */
16
17
18 package gate.creole.tokeniser;
19
20 import java.net.URL;
21
22 import junit.framework.*;
23
24 import gate.*;
25 import gate.corpora.TestDocument;
26
27 public class TestTokeniser extends TestCase{
28
29 public TestTokeniser(String name) {
30 super(name);
31 }
32
33 /** Fixture set up */
34 public void setUp() throws Exception {
35 }
36
37 public void tearDown() throws Exception {
38 } // tearDown
39
40 /** Test the default tokeniser */
41 public void testDefaultTokeniser() throws Exception {
42 //get a document
43 Document doc = Factory.newDocument(
44 new URL(TestDocument.getTestServerName() + "tests/doc0.html")
45 );
46 //create a default tokeniser
47 DefaultTokeniser tokeniser = (DefaultTokeniser) Factory.createResource(
48 "gate.creole.tokeniser.DefaultTokeniser");
49
50 tokeniser.setDocument(doc);
51 tokeniser.setAnnotationSetName("TokeniserAS");
52 tokeniser.execute();
53 assertTrue(! doc.getAnnotations("TokeniserAS").isEmpty());
54 }
55
56 /** Test suite routine for the test runner */
57 public static Test suite() {
58 return new TestSuite(TestTokeniser.class);
59 } // suite
60
61 public static void main(String[] args) {
62 try{
63 Gate.init();
64 TestTokeniser testTokeniser1 = new TestTokeniser("");
65 testTokeniser1.setUp();
66 testTokeniser1.testDefaultTokeniser();
67 testTokeniser1.tearDown();
68 }catch(Exception e){
69 e.printStackTrace();
70 }
71 }
72 }
|