From 185a72ef074b52dad9ec03738cc8026ead67190a Mon Sep 17 00:00:00 2001 From: John Patrick <142304+nhojpatrick@users.noreply.github.com> Date: Tue, 4 Oct 2022 22:15:28 +0100 Subject: [PATCH] JUnit assertThrows DTDValidationTestCase --- .../digester3/DTDValidationTestCase.java | 81 +++++++++---------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/core/src/test/java/org/apache/commons/digester3/DTDValidationTestCase.java b/core/src/test/java/org/apache/commons/digester3/DTDValidationTestCase.java index baeba3c35..62dc2d59f 100644 --- a/core/src/test/java/org/apache/commons/digester3/DTDValidationTestCase.java +++ b/core/src/test/java/org/apache/commons/digester3/DTDValidationTestCase.java @@ -17,6 +17,7 @@ package org.apache.commons.digester3; import static org.apache.commons.digester3.binder.DigesterLoader.newLoader; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.File; @@ -29,50 +30,44 @@ /** * Tests for entity resolution and dtd validation */ -public class DTDValidationTestCase -{ +public class DTDValidationTestCase { - @Test( expected = SAXParseException.class ) - public void testDigesterDTDError() - throws Exception - { - newLoader( new AbstractRulesModule() { - - @Override - protected void configure() - { - // do nothing - } - - } ) - .setValidating( true ) - .setErrorHandler( new ErrorHandler() - { - - @Override - public void warning( final SAXParseException e ) - throws SAXException - { - throw e; - } - - @Override - public void fatalError( final SAXParseException e ) - throws SAXException - { - throw e; - } - - @Override - public void error( final SAXParseException e ) - throws SAXException - { - throw e; - } - - } ) - .newDigester() - .parse( new File( "src/test/resources/org/apache/commons/digester3/document-with-relative-dtd-error.xml" ) ); + @Test + public void testDigesterDTDError() { + + assertThrows(SAXParseException.class, () -> + newLoader(new AbstractRulesModule() { + + @Override + protected void configure() { + // do nothing + } + + }) + .setValidating(true) + .setErrorHandler(new ErrorHandler() { + + @Override + public void warning(final SAXParseException e) + throws SAXException { + throw e; + } + + @Override + public void fatalError(final SAXParseException e) + throws SAXException { + throw e; + } + + @Override + public void error(final SAXParseException e) + throws SAXException { + throw e; + } + + }) + .newDigester() + .parse(new File("src/test/resources/org/apache/commons/digester3/document-with-relative-dtd-error.xml"))); } @Test