(URL url, String urlDescription)
| 102 | }// testGateDocumentToAndFromXmlWithDifferentKindOfFormats |
| 103 | |
| 104 | private void runCompleteTestWithAFormat(URL url, String urlDescription) |
| 105 | throws Exception{ |
| 106 | // Load the xml Key Document and unpack it |
| 107 | gate.Document keyDocument = null; |
| 108 | |
| 109 | FeatureMap params = Factory.newFeatureMap(); |
| 110 | params.put(Document.DOCUMENT_URL_PARAMETER_NAME, url); |
| 111 | params.put(Document.DOCUMENT_MARKUP_AWARE_PARAMETER_NAME, "false"); |
| 112 | keyDocument = (Document)Factory.createResource("gate.corpora.DocumentImpl", |
| 113 | params); |
| 114 | |
| 115 | assertTrue("Coudn't create a GATE document instance for " + |
| 116 | url.toString() + |
| 117 | " Can't continue." , keyDocument != null); |
| 118 | |
| 119 | gate.DocumentFormat keyDocFormat = null; |
| 120 | keyDocFormat = gate.DocumentFormat.getDocumentFormat( |
| 121 | keyDocument, keyDocument.getSourceUrl() |
| 122 | ); |
| 123 | |
| 124 | assertTrue("Fail to recognize " + |
| 125 | url.toString() + |
| 126 | " as being " + urlDescription + " !", keyDocFormat != null); |
| 127 | |
| 128 | // Unpack the markup |
| 129 | keyDocFormat.unpackMarkup(keyDocument); |
| 130 | // Verfy if all annotations from the default annotation set are consistent |
| 131 | gate.corpora.TestDocument.verifyNodeIdConsistency(keyDocument); |
| 132 | |
| 133 | // Verifies if the maximum annotation ID on the GATE doc is less than the |
| 134 | // Annotation ID generator of the document. |
| 135 | verifyAnnotationIDGenerator(keyDocument); |
| 136 | |
| 137 | // Save the size of the document and the number of annotations |
| 138 | long keyDocumentSize = keyDocument.getContent().size().longValue(); |
| 139 | int keyDocumentAnnotationSetSize = keyDocument.getAnnotations().size(); |
| 140 | |
| 141 | |
| 142 | // Export the Gate document called keyDocument as XML, into a temp file, |
| 143 | // using the working encoding |
| 144 | File xmlFile = null; |
| 145 | xmlFile = Files.writeTempFile(keyDocument.toXml(), workingEncoding ); |
| 146 | assertTrue("The temp GATE XML file is null. Can't continue.",xmlFile != null); |
| 147 | |
| 148 | // Load the XML Gate document form the tmp file into memory |
| 149 | gate.Document gateDoc = null; |
| 150 | gateDoc = gate.Factory.newDocument(xmlFile.toURI().toURL(), workingEncoding); |
| 151 | |
| 152 | assertTrue("Coudn't create a GATE document instance for " + |
| 153 | xmlFile.toURI().toURL().toString() + |
| 154 | " Can't continue." , gateDoc != null); |
| 155 | |
| 156 | gate.DocumentFormat gateDocFormat = null; |
| 157 | gateDocFormat = |
| 158 | DocumentFormat.getDocumentFormat(gateDoc,gateDoc.getSourceUrl()); |
| 159 | |
| 160 | assertTrue("Fail to recognize " + |
| 161 | xmlFile.toURI().toURL().toString() + |
no test coverage detected