| TestSgml.java |
1 /*
2 * TestSgml.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, 8/May/2000
12 *
13 * $Id: TestSgml.java,v 1.31 2004/07/21 17:10:09 akshay Exp $
14 */
15
16 package gate.sgml;
17
18 import java.util.Map;
19
20 import junit.framework.*;
21
22 import gate.*;
23
24 /** Test class for SGML facilities
25 */
26 public class TestSgml extends TestCase
27 {
28 /** Debug flag */
29 private static final boolean DEBUG = false;
30
31 /** Construction */
32 public TestSgml(String name) { super(name); }
33
34 /** Fixture set up */
35 public void setUp() {
36 } // setUp
37
38 public void testSgmlLoading() throws Exception {
39 assertTrue(true);
40
41 // create the markupElementsMap map
42 Map markupElementsMap = null;
43 gate.Document doc = null;
44 /*
45 markupElementsMap = new HashMap();
46 // populate it
47 markupElementsMap.put ("S","Sentence");
48 markupElementsMap.put ("s","Sentence");
49 markupElementsMap.put ("W","Word");
50 markupElementsMap.put ("w","Word");
51 */
52
53 FeatureMap params = Factory.newFeatureMap();
54 params.put(Document.DOCUMENT_URL_PARAMETER_NAME, Gate.getUrl("tests/sgml/Hds.sgm"));
55 params.put(Document.DOCUMENT_MARKUP_AWARE_PARAMETER_NAME, "false");
56 doc = (Document)Factory.createResource("gate.corpora.DocumentImpl",
57 params);
58
59 // get the docFormat that deals with it.
60 // the parameter MimeType doesn't affect right now the behaviour
61 //*
62 gate.DocumentFormat docFormat = gate.DocumentFormat.getDocumentFormat (
63 doc, doc.getSourceUrl()
64 );
65 assertTrue( "Bad document Format was produced. SgmlDocumentFormat was expected",
66 docFormat instanceof gate.corpora.SgmlDocumentFormat
67 );
68
69 // set's the map
70 docFormat.setMarkupElementsMap(markupElementsMap);
71 docFormat.unpackMarkup (doc,"DocumentContent");
72 AnnotationSet annotSet = doc.getAnnotations(
73 GateConstants.ORIGINAL_MARKUPS_ANNOT_SET_NAME);
74 assertEquals("For "+doc.getSourceUrl()+" the number of annotations"+
75 " should be:1022",1022,annotSet.size());
76 // Verfy if all annotations from the default annotation set are consistent
77 gate.corpora.TestDocument.verifyNodeIdConsistency(doc);
78 }// testSgml
79
80 /** Test suite routine for the test runner */
81 public static Test suite() {
82 return new TestSuite(TestSgml.class);
83 } // suite
84
85 } // class TestSgml
86