gate.xml
Class TestXml

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by gate.xml.TestXml
All Implemented Interfaces:
junit.framework.Test

public class TestXml
extends junit.framework.TestCase

Test class for XML facilities


Field Summary
private static boolean DEBUG
          Debug flag
private static String workingEncoding
          The encoding used in our tests
 
Constructor Summary
TestXml(String name)
          Construction
 
Method Summary
private  Map addAnnotSet2Map(AnnotationSet annotSet, Map id2AnnMap)
           
private  Map buildID2AnnotMap(Document aDoc)
          Scans a target Doc for all Annotations and builds a map (from anot ID to annot) in the process I also checks to see if there are two annotations with the same ID.
private  Map buildMatchesMap(Document doc)
          Builds a Map based on the matches feature of some annotations.
private  void compareAnnot(Annotation origAnn, Annotation reloadedAnnot)
          Thes if two annotatiosn are the same, except their features.
private  void helperBuildMatchesMap(AnnotationSet sourceAnnotSet, Map aMap)
          This is a helper metod.
private  void runCompleteTestWithAFormat(URL url, String urlDescription)
           
 void setUp()
          Fixture set up
static junit.framework.Test suite()
          Test suite routine for the test runner
 void testAnnotationConsistencyForSaveAsXml()
           
 void testGateDocumentToAndFromXmlWithDifferentKindOfFormats()
           
 void testUnpackMarkup()
          A test
protected  void verifyAnnotationIDGenerator(Document aDoc)
          This method tests if the generator for new Annotation IDs is greather than the maximum Annotation ID present in the GATE document.
private  void verifyIDConsistency(Map origAnnotMap, Map reloadedAnnMap)
          Verifies if the two maps hold annotations with the same ID.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
Debug flag

See Also:
Constant Field Values

workingEncoding

private static String workingEncoding
The encoding used in our tests

Constructor Detail

TestXml

public TestXml(String name)
Construction

Method Detail

setUp

public void setUp()
Fixture set up

Overrides:
setUp in class junit.framework.TestCase

testGateDocumentToAndFromXmlWithDifferentKindOfFormats

public void testGateDocumentToAndFromXmlWithDifferentKindOfFormats()
                                                            throws Exception
Throws:
Exception

runCompleteTestWithAFormat

private void runCompleteTestWithAFormat(URL url,
                                        String urlDescription)
                                 throws Exception
Throws:
Exception

testUnpackMarkup

public void testUnpackMarkup()
                      throws Exception
A test

Throws:
Exception

testAnnotationConsistencyForSaveAsXml

public void testAnnotationConsistencyForSaveAsXml()
                                           throws Exception
Throws:
Exception

buildMatchesMap

private Map buildMatchesMap(Document doc)
Builds a Map based on the matches feature of some annotations. The goal is to use this map to validate the annotations from the reloaded document. In case no Annot has the matches feat, will return an Empty MAP

Parameters:
doc - The document of which annotations will be used to construct the map
Returns:
A Map from Annot ID -> Lists of Annot IDs

helperBuildMatchesMap

private void helperBuildMatchesMap(AnnotationSet sourceAnnotSet,
                                   Map aMap)
This is a helper metod. It scans an annotation set and adds the ID of the annotations which have the matches feature to the map.

Parameters:
sourceAnnotSet - The annotation set investigated
aMap -

verifyAnnotationIDGenerator

protected void verifyAnnotationIDGenerator(Document aDoc)
This method tests if the generator for new Annotation IDs is greather than the maximum Annotation ID present in the GATE document. In oter words, it ensures that new Annotations will receive an UNIQUE ID.

Parameters:
aDoc - The GATE document being tested

verifyIDConsistency

private void verifyIDConsistency(Map origAnnotMap,
                                 Map reloadedAnnMap)
Verifies if the two maps hold annotations with the same ID. The only thing not checked are the features, as some of them could be lost in the serialization/deserialization process

Parameters:
origAnnotMap - A map by ID, containing the original annotations
reloadedAnnMap - A map by ID, containing the recreated annotations

compareAnnot

private void compareAnnot(Annotation origAnn,
                          Annotation reloadedAnnot)
Thes if two annotatiosn are the same, except their features.

Parameters:
origAnn -
reloadedAnnot -

addAnnotSet2Map

private Map addAnnotSet2Map(AnnotationSet annotSet,
                            Map id2AnnMap)

buildID2AnnotMap

private Map buildID2AnnotMap(Document aDoc)
Scans a target Doc for all Annotations and builds a map (from anot ID to annot) in the process I also checks to see if there are two annotations with the same ID.

Parameters:
aDoc - The GATE doc to be scaned
Returns:
a Map ID2Annot

suite

public static junit.framework.Test suite()
Test suite routine for the test runner