use of gate.corpora.DocumentImpl in project gate-core by GateNLP.
the class TestRepositioningInfo method testRepositioningInfo.
// tearDown
/**
* This method tests if Repositinioning Information works.
* It creates a document using an xml file with preserveOriginalContent
* and collectRepositioningInfo options keeping true and which has all
* sorts of special entities like &, " etc. + it contains both
* kind of unix and dos stype new line characters. It then saves the
* document to the temporary location on the disk using
* "save preserving document format" option and then compares the contents of
* both the original and the temporary document to see if they are equal.
* @throws java.lang.Exception
*/
public void testRepositioningInfo() throws Exception {
// here we need to save the document to the file
String encoding = ((DocumentImpl) doc).getEncoding();
File outputFile = File.createTempFile("test-inline1", "xml");
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
writer.write(doc.toXml(null, true));
writer.flush();
writer.close();
Reader readerForSource = new BomStrippingInputStreamReader(new URL(testFile).openStream(), encoding);
Reader readerForDesti = new BomStrippingInputStreamReader(new FileInputStream(outputFile), encoding);
while (true) {
int input1 = readerForSource.read();
int input2 = readerForDesti.read();
if (input1 < 0 || input2 < 0) {
assertTrue(input1 < 0 && input2 < 0);
readerForSource.close();
readerForDesti.close();
outputFile.delete();
return;
} else {
assertEquals(input1, input2);
}
}
}
Aggregations