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 c8636bd62aace0b979d264909ffa053951c3ea6a Mon Sep 17 00:00:00 2001
From: John Patrick <142304+nhojpatrick@users.noreply.github.com>
Date: Wed, 14 Oct 2020 23:02:29 +0100
Subject: [PATCH 2/2] JUnit assertThrows FailingTestCase
---
.../failingtests/FailingTestCase.java | 24 +++++++++++--------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/core/src/test/java/org/apache/commons/digester3/annotations/failingtests/FailingTestCase.java b/core/src/test/java/org/apache/commons/digester3/annotations/failingtests/FailingTestCase.java
index ff170b894..ef448736a 100644
--- a/core/src/test/java/org/apache/commons/digester3/annotations/failingtests/FailingTestCase.java
+++ b/core/src/test/java/org/apache/commons/digester3/annotations/failingtests/FailingTestCase.java
@@ -18,6 +18,10 @@
package org.apache.commons.digester3.annotations.failingtests;
import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.StringStartsWith.startsWith;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import org.apache.commons.digester3.annotations.FromAnnotationsRuleModule;
import org.apache.commons.digester3.binder.DigesterLoadingException;
@@ -29,20 +33,20 @@ public final class FailingTestCase
/**
* Tests to make sure loader fails
*/
- @Test(expected = DigesterLoadingException.class)
+ @Test
public void failsBecauseFailingDigesterLoaderHandlerFactory() {
- newLoader(new FromAnnotationsRuleModule()
- {
+ final DigesterLoadingException thrown = assertThrows(DigesterLoadingException.class, () ->
+ newLoader(new FromAnnotationsRuleModule() {
- @Override
- protected void configureRules()
- {
- useAnnotationHandlerFactory( new FailingDigesterLoaderHandlerFactory() );
- bindRulesFrom( BeanWithFakeHandler.class );
- }
+ @Override
+ protected void configureRules() {
+ useAnnotationHandlerFactory(new FailingDigesterLoaderHandlerFactory());
+ bindRulesFrom(BeanWithFakeHandler.class);
+ }
- }).newDigester();
+ }).newDigester());
+ assertThat(thrown.getMessage(), is(startsWith("Digester creation errors:")));
}
}