2020 */
2121
2222import static org .apache .commons .digester3 .binder .DigesterLoader .newLoader ;
23+ import static org .junit .jupiter .api .Assertions .assertThrows ;
2324
2425import java .io .File ;
2526
2627import org .apache .commons .digester3 .binder .AbstractRulesModule ;
2728import org .junit .Test ;
29+ import org .junit .jupiter .api .function .Executable ;
2830import org .xml .sax .ErrorHandler ;
2931import org .xml .sax .SAXParseException ;
3032
@@ -50,26 +52,29 @@ protected void configure()
5052 .parse ( new File ( "src/test/resources/org/apache/commons/digester3/document-with-relative-dtd-error.xml" ) );
5153 }
5254
53- @ Test ( expected = SAXParseException .class )
54- public void testDefaultThrowingErrorHandler ()
55- throws Exception
56- {
55+ @ Test
56+ public void testDefaultThrowingErrorHandler () {
5757 final ErrorHandler customErrorHandler = new DefaultThrowingErrorHandler ();
5858
59- newLoader ( new AbstractRulesModule ()
60- {
61-
59+ // FIXME Simplification once upgraded to Java 1.8 and use lambda
60+ final Executable testMethod = new Executable () {
6261 @ Override
63- protected void configure ()
64- {
65- // do nothing
66- }
62+ public void execute () throws Throwable {
63+ newLoader (new AbstractRulesModule () {
6764
68- } )
69- .setFeature ( "http://xml.org/sax/features/validation" , true )
70- .setErrorHandler ( customErrorHandler )
71- .newDigester ()
72- .parse ( new File ( "src/test/resources/org/apache/commons/digester3/document-with-relative-dtd-error.xml" ) );
65+ @ Override
66+ protected void configure () {
67+ // do nothing
68+ }
69+
70+ })
71+ .setFeature ("http://xml.org/sax/features/validation" , true )
72+ .setErrorHandler (customErrorHandler )
73+ .newDigester ()
74+ .parse (new File ("src/test/resources/org/apache/commons/digester3/document-with-relative-dtd-error.xml" ));
75+ }
76+ };
77+ assertThrows (SAXParseException .class , testMethod );
7378 }
7479
7580}
0 commit comments