-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: silence a Saxon warning (Schematron XSLT)
The Schematron XSLT built in Jing as an `/..` XPath expression which always evaluates to the empty sequence. Saxon 9.8 consequently raises a SXWN9000 warning, when the validators are created (statically, during EPUBCheck's intializations). This PR initalizes Jing's transformer factory with a static error listener that ignores this warning. This is tested as an integration test (since the warning is produced on the standard error stream at initialization time), run via the Maven failsafe plugin. Fixes #859
- Loading branch information
Showing
3 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.adobe.epubcheck.cli; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import org.junit.Test; | ||
|
||
import com.google.common.collect.ObjectArrays; | ||
|
||
public class CheckerIT | ||
{ | ||
|
||
private static final String[] cmd = new String[] { "java", "-jar", "target/epubcheck.jar" }; | ||
private static String valid30EPUB = "src/test/resources/30/epub/valid/"; | ||
|
||
@Test | ||
public void testValidEPUB() | ||
{ | ||
try | ||
{ | ||
Process process = run(valid30EPUB + "lorem.epub"); | ||
InputStream stderr = process.getErrorStream(); | ||
process.waitFor(); | ||
assertEmpty(stderr); | ||
assertEquals(0, process.exitValue()); | ||
} catch (Exception e) | ||
{ | ||
fail(e.getMessage()); | ||
} | ||
} | ||
|
||
private static Process run(String epub) | ||
{ | ||
ProcessBuilder builder = new ProcessBuilder(ObjectArrays.concat(cmd, epub)); | ||
try | ||
{ | ||
return builder.start(); | ||
} catch (IOException e) | ||
{ | ||
fail(e.getMessage()); | ||
return null; | ||
} | ||
} | ||
|
||
private static void assertEmpty(InputStream inputStream) | ||
{ | ||
try | ||
{ | ||
if (inputStream.read() == -1) return; | ||
fail("stream is not empty"); | ||
} catch (IOException e) | ||
{ | ||
fail(e.getMessage()); | ||
} | ||
} | ||
} |