Skip to content

Commit bb7561f

Browse files
committed
JUnit assertThrows Digester171TestCase
1 parent ba2556a commit bb7561f

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

core/src/test/java/org/apache/commons/digester3/Digester171TestCase.java

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
*/
2121

2222
import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
23+
import static org.junit.jupiter.api.Assertions.assertThrows;
2324

2425
import java.io.File;
2526

2627
import org.apache.commons.digester3.binder.AbstractRulesModule;
2728
import org.junit.Test;
29+
import org.junit.jupiter.api.function.Executable;
2830
import org.xml.sax.ErrorHandler;
2931
import 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

Comments
 (0)