From 3d4068d86fe76aaf7fa10e15d7ad97db31428878 Mon Sep 17 00:00:00 2001 From: John Patrick <142304+nhojpatrick@users.noreply.github.com> Date: Tue, 4 Oct 2022 21:40:58 +0100 Subject: [PATCH 1/2] JUnit Jupiter Api dependency --- core/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/pom.xml b/core/pom.xml index 8e886ddc5..6fc84ac0d 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -55,6 +55,11 @@ 4.13 test + + org.junit.jupiter + junit-jupiter-api + test + 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 2/2] 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