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