olabusayoT commented on code in PR #1358:
URL: https://github.com/apache/daffodil/pull/1358#discussion_r1828145373
##########
daffodil-japi/src/test/java/org/apache/daffodil/example/TestJavaAPI.java:
##########
@@ -1444,5 +1443,45 @@ public void testJavaAPICompileResource() throws
IOException, ClassNotFoundExcept
}
}
+ @Test
+ public void testJavaAPICompileSource1() throws IOException,
URISyntaxException, InvalidUsageException {
+ org.apache.daffodil.japi.Compiler c = Daffodil.compiler();
+ URI uri = new URI("/test/japi/mySchema1.dfdl.xsd");
+ ProcessorFactory pf = c.compileSource(uri);
+ DataProcessor dp =
pf.onPath("/").withValidationMode(ValidationMode.Full);
+
+ java.io.File file = getResource("/test/japi/myDataBroken.dat");
+ java.io.FileInputStream fis = new java.io.FileInputStream(file);
+ try (InputSourceDataInputStream dis = new
InputSourceDataInputStream(fis)) {
+ JDOMInfosetOutputter outputter = new JDOMInfosetOutputter();
+ ParseResult res = dp.parse(dis, outputter);
+ assertTrue(res.isError());
+
+ Diagnostic d = res.getDiagnostics().get(0);
+ LocationInSchemaFile loc = d.getLocationsInSchemaFiles().get(0);
+ assertTrue(loc.toString().replace("\\", "/").contains("in " +
uri.getPath()));
+ }
+ }
+
+ @Test
+ public void testJavaAPICompileSource2() throws IOException {
+ org.apache.daffodil.japi.Compiler c = Daffodil.compiler();
+ File tempFile = File.createTempFile("testJavaAPI", ".schema");
+ File schemaFile = getResource("/test/japi/mySchema2.dfdl.xsd");
+ FileUtils.copyFile(schemaFile, tempFile);
+ ProcessorFactory pf = c.compileSource(tempFile.toURI());
+ try {
+ if (!pf.isError()) {
+ tempFile.delete();
+ pf.onPath("/");
Review Comment:
the withValidationMode(Full) case is already tested in the first
CompileSource test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]