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