Commit 5045d78 1 parent f572a86 commit 5045d78 Copy full SHA for 5045d78
File tree 3 files changed +90
-1
lines changed
main/java/com/adobe/epubcheck/xml
test/java/com/adobe/epubcheck/cli
3 files changed +90
-1
lines changed Original file line number Diff line number Diff line change 344
344
</execution >
345
345
</executions >
346
346
</plugin >
347
+ <plugin >
348
+ <groupId >org.apache.maven.plugins</groupId >
349
+ <artifactId >maven-failsafe-plugin</artifactId >
350
+ <version >2.22.1</version >
351
+ <executions >
352
+ <execution >
353
+ <goals >
354
+ <goal >integration-test</goal >
355
+ <goal >verify</goal >
356
+ </goals >
357
+ </execution >
358
+ </executions >
359
+ </plugin >
347
360
<plugin >
348
361
<groupId >org.codehaus.mojo</groupId >
349
362
<artifactId >xml-maven-plugin</artifactId >
Original file line number Diff line number Diff line change 28
28
import java .net .URISyntaxException ;
29
29
import java .net .URL ;
30
30
31
+ import javax .xml .transform .TransformerException ;
31
32
import javax .xml .transform .TransformerFactory ;
32
33
33
34
import org .idpf .epubcheck .util .saxon .ColumnNumberFunction ;
54
55
55
56
import net .sf .saxon .Configuration ;
56
57
import net .sf .saxon .TransformerFactoryImpl ;
58
+ import net .sf .saxon .lib .FeatureKeys ;
59
+ import net .sf .saxon .lib .StandardErrorListener ;
57
60
import net .sf .saxon .sxpath .IndependentContext ;
58
61
import net .sf .saxon .sxpath .XPathStaticContext ;
59
62
import net .sf .saxon .trans .SymbolicName ;
60
- import net .sf .saxon .om . StandardNames ;
63
+ import net .sf .saxon .trans . XPathException ;
61
64
62
65
63
66
public class XMLValidator
@@ -193,6 +196,20 @@ public void initTransformerFactory(TransformerFactory factory)
193
196
{
194
197
configuration .registerExtensionFunction (new SystemIdFunction ());
195
198
}
199
+ // Used to silence Saxon's warning about an XPath expression in Jing's built-in Schematron XSLT
200
+ // See issue #859
201
+ factory .setAttribute (FeatureKeys .XSLT_STATIC_ERROR_LISTENER_CLASS , SilencingErrorListener .class .getName ());
202
+ }
203
+ }
204
+ }
205
+
206
+ public static class SilencingErrorListener extends StandardErrorListener {
207
+
208
+ @ Override
209
+ public void warning (TransformerException exception ) {
210
+ XPathException xe = XPathException .makeXPathException (exception );
211
+ if (!"SXWN9000" .equals (xe .getErrorCodeLocalPart ())) {
212
+ super .warning (exception );
196
213
}
197
214
}
198
215
}
Original file line number Diff line number Diff line change
1
+ package com .adobe .epubcheck .cli ;
2
+
3
+ import static org .junit .Assert .assertEquals ;
4
+ import static org .junit .Assert .fail ;
5
+
6
+ import java .io .IOException ;
7
+ import java .io .InputStream ;
8
+
9
+ import org .junit .Test ;
10
+
11
+ import com .google .common .collect .ObjectArrays ;
12
+
13
+ public class CheckerIT
14
+ {
15
+
16
+ private static final String [] cmd = new String [] { "java" , "-jar" , "target/epubcheck.jar" };
17
+ private static String valid30EPUB = "src/test/resources/30/epub/valid/" ;
18
+
19
+ @ Test
20
+ public void testValidEPUB ()
21
+ {
22
+ try
23
+ {
24
+ Process process = run (valid30EPUB + "lorem.epub" );
25
+ InputStream stderr = process .getErrorStream ();
26
+ process .waitFor ();
27
+ assertEmpty (stderr );
28
+ assertEquals (0 , process .exitValue ());
29
+ } catch (Exception e )
30
+ {
31
+ fail (e .getMessage ());
32
+ }
33
+ }
34
+
35
+ private static Process run (String epub )
36
+ {
37
+ ProcessBuilder builder = new ProcessBuilder (ObjectArrays .concat (cmd , epub ));
38
+ try
39
+ {
40
+ return builder .start ();
41
+ } catch (IOException e )
42
+ {
43
+ fail (e .getMessage ());
44
+ return null ;
45
+ }
46
+ }
47
+
48
+ private static void assertEmpty (InputStream inputStream )
49
+ {
50
+ try
51
+ {
52
+ if (inputStream .read () == -1 ) return ;
53
+ fail ("stream is not empty" );
54
+ } catch (IOException e )
55
+ {
56
+ fail (e .getMessage ());
57
+ }
58
+ }
59
+ }
You can’t perform that action at this time.
0 commit comments