| TestEmail.java |
1 /*
2 * TestEmail.java
3 *
4 * Copyright (c) 1998-2004, 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 * Cristian URSU, 7/Aug/2000
12 *
13 * $Id: TestEmail.java,v 1.24 2004/08/02 16:37:45 valyt Exp $
14 */
15
16 package gate.email;
17
18 import java.util.Map;
19
20 import junit.framework.*;
21
22 import gate.Gate;
23 //import org.w3c.www.mime.*;
24
25
26 /**
27 * Test class for Email facilities
28 */
29 public class TestEmail extends TestCase
30 {
31 /** Debug flag */
32 private static final boolean DEBUG = false;
33
34 /** Construction */
35 public TestEmail(String name) { super(name); }
36
37 /** Fixture set up */
38 public void setUp() {
39 } // setUp
40
41 /** A test */
42 public void testUnpackMarkup() throws Exception{
43 // create the markupElementsMap map
44 Map markupElementsMap = null;
45 gate.Document doc = null;
46 // Gate.init();
47 doc = gate.Factory.newDocument(Gate.getUrl("tests/email/test.eml"), "ISO-8859-1");
48
49 // get a document format that deals with e-mails
50 gate.DocumentFormat docFormat = gate.DocumentFormat.getDocumentFormat(
51 doc, doc.getSourceUrl()
52 );
53 assertTrue( "Bad document Format was produced.EmailDocumentFormat was expected",
54 docFormat instanceof gate.corpora.EmailDocumentFormat
55 );
56
57 docFormat.unpackMarkup (doc,"DocumentContent");
58 // Verfy if all annotations from the default annotation set are consistent
59 gate.corpora.TestDocument.verifyNodeIdConsistency(doc);
60
61 } // testUnpackMarkup()
62
63 public static void main(String[] args) {
64 try{
65 Gate.init();
66 TestEmail testEmail = new TestEmail("");
67 testEmail.testUnpackMarkup();
68
69 }catch(Exception e){
70 e.printStackTrace();
71 }
72 }
73
74 /**
75 * final test
76 */
77 public void testEmail(){
78 EmailDocumentHandler emailDocumentHandler = new EmailDocumentHandler();
79 emailDocumentHandler.testSelf();
80 }// testEmail
81
82 /** Test suite routine for the test runner */
83 public static Test suite() {
84 return new TestSuite(TestEmail.class);
85 } // suite
86
87 } // class TestEmail
88