gate.jape.functest
Class BaseJapeTests

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by gate.jape.functest.BaseJapeTests
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
TestConstraints, TestJape

public abstract class BaseJapeTests
extends junit.framework.TestCase

Tests for Constraint predicate logic


Nested Class Summary
static interface BaseJapeTests.AnnotationCreator
          Callback interface used in the doTest method.
static class BaseJapeTests.BaseAnnotationCreator
           
 
Field Summary
protected static String DEFAULT_DATA_FILE
           
private static org.apache.log4j.Logger logger
           
static TransducerType transducerType
          JAPE Transducer under test.
 
Constructor Summary
BaseJapeTests(String name)
           
 
Method Summary
protected static void compareEndOffsets(Set<Annotation> res, int... endOffsets)
           
protected static void compareResults(String[] expectedResults, Set<Annotation> actualResults)
          Compares 2 ordered sets of annotations by comparison of the rules that created them.
protected static void compareStartOffsets(Set<Annotation> res, int... startOffsets)
           
private static Resource createOntology(String ontologyURL)
           
protected  Set<Annotation> doTest(Document doc, String japeResourcePath, BaseJapeTests.AnnotationCreator ac, String ontologyURL)
           
protected  Set<Annotation> doTest(String docResourcePath, String japeResourcePath, BaseJapeTests.AnnotationCreator ac)
           
protected  Set<Annotation> doTest(String docResourcePath, String japeResourcePath, BaseJapeTests.AnnotationCreator ac, String ontologyURL)
           
private static void registerCREOLE(File plugInDir)
           
private  Set<Annotation> runTransducer(Document doc, String japeFile, String ontologyURL)
          Executes transducer with the provided parameters and returns transduced annotations ordered
protected static void setUpGate()
          Initializes GATE and sets up plug-ins.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, 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

transducerType

public static final TransducerType transducerType
JAPE Transducer under test. CHANGE THIS to test another Transducer


logger

private static final org.apache.log4j.Logger logger

DEFAULT_DATA_FILE

protected static final String DEFAULT_DATA_FILE
See Also:
Constant Field Values
Constructor Detail

BaseJapeTests

public BaseJapeTests(String name)
Method Detail

setUpGate

protected static void setUpGate()
Initializes GATE and sets up plug-ins. The operation is idempotent.


registerCREOLE

private static void registerCREOLE(File plugInDir)
                            throws GateException
Throws:
GateException

createOntology

private static Resource createOntology(String ontologyURL)
                                throws MalformedURLException
Throws:
MalformedURLException

runTransducer

private Set<Annotation> runTransducer(Document doc,
                                      String japeFile,
                                      String ontologyURL)
                               throws MalformedURLException,
                                      ResourceInstantiationException,
                                      ExecutionException
Executes transducer with the provided parameters and returns transduced annotations ordered

Parameters:
doc - a GATE document with initial annotations
japeFile - a file with the JAPE grammar
ontologyURL - optional ontology URL. Might be null.
Returns:
an ordered set of transduced annotations
Throws:
MalformedURLException
ResourceInstantiationException
ExecutionException

doTest

protected Set<Annotation> doTest(String docResourcePath,
                                 String japeResourcePath,
                                 BaseJapeTests.AnnotationCreator ac,
                                 String ontologyURL)
                          throws Exception
Throws:
Exception

doTest

protected Set<Annotation> doTest(String docResourcePath,
                                 String japeResourcePath,
                                 BaseJapeTests.AnnotationCreator ac)
                          throws Exception
Throws:
Exception

doTest

protected Set<Annotation> doTest(Document doc,
                                 String japeResourcePath,
                                 BaseJapeTests.AnnotationCreator ac,
                                 String ontologyURL)
                          throws Exception
Throws:
Exception

compareResults

protected static void compareResults(String[] expectedResults,
                                     Set<Annotation> actualResults)
Compares 2 ordered sets of annotations by comparison of the rules that created them.


compareStartOffsets

protected static final void compareStartOffsets(Set<Annotation> res,
                                                int... startOffsets)

compareEndOffsets

protected static final void compareEndOffsets(Set<Annotation> res,
                                              int... endOffsets)