From 018c882f2deb2552d6e63baf33ce2869e1e7365e Mon Sep 17 00:00:00 2001 From: John Patrick <142304+nhojpatrick@users.noreply.github.com> Date: Tue, 4 Oct 2022 22:09:36 +0100 Subject: [PATCH] JUnit assertThrows IncludeTest --- .../digester3/xmlrules/IncludeTest.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/core/src/test/java/org/apache/commons/digester3/xmlrules/IncludeTest.java b/core/src/test/java/org/apache/commons/digester3/xmlrules/IncludeTest.java index 66d57850e..1556d015d 100644 --- a/core/src/test/java/org/apache/commons/digester3/xmlrules/IncludeTest.java +++ b/core/src/test/java/org/apache/commons/digester3/xmlrules/IncludeTest.java @@ -20,6 +20,7 @@ import static org.apache.commons.digester3.binder.DigesterLoader.newLoader; import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.StringReader; import java.net.URL; @@ -130,21 +131,17 @@ protected void loadRules() /** * Validates that circular includes are detected and result in an exception */ - @Test( expected = org.apache.commons.digester3.binder.DigesterLoadingException.class ) - public void testCircularInclude() - throws Exception - { + @Test + public void testCircularInclude() { final URL url = ClassLoader.getSystemResource( "org/apache/commons/digester3/xmlrules/testCircularRules.xml" ); - newLoader( new FromXmlRulesModule() - { - - @Override - protected void loadRules() - { - loadXMLRules( url ); - } - }).newDigester(); + assertThrows(org.apache.commons.digester3.binder.DigesterLoadingException.class, () -> + newLoader(new FromXmlRulesModule() { + @Override + protected void loadRules() { + loadXMLRules(url); + } + }).newDigester()); } }