| TestSgml |

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

| TestSgml |