From 20212a87d9eb37239e69ef7ee58a2c75461e8963 Mon Sep 17 00:00:00 2001 From: John Patrick <142304+nhojpatrick@users.noreply.github.com> Date: Wed, 19 Oct 2022 19:10:42 +0100 Subject: [PATCH 1/2] JUnit v5 api dependency to core --- core/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/pom.xml b/core/pom.xml index 9ab9db15..5f7196f4 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -40,6 +40,11 @@ junit test + + org.junit.jupiter + junit-jupiter-api + test + From f371889233e366c72a5d804799d5e2abb2081d56 Mon Sep 17 00:00:00 2001 From: John Patrick <142304+nhojpatrick@users.noreply.github.com> Date: Wed, 19 Oct 2022 19:12:19 +0100 Subject: [PATCH 2/2] JUnit5 assertThrows InterceptorUtilsTest --- .../interceptor/InterceptorUtilsTest.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/core/src/test/java/org/apache/commons/proxy2/interceptor/InterceptorUtilsTest.java b/core/src/test/java/org/apache/commons/proxy2/interceptor/InterceptorUtilsTest.java index 2f848df2..74a35c0d 100644 --- a/core/src/test/java/org/apache/commons/proxy2/interceptor/InterceptorUtilsTest.java +++ b/core/src/test/java/org/apache/commons/proxy2/interceptor/InterceptorUtilsTest.java @@ -18,6 +18,7 @@ package org.apache.commons.proxy2.interceptor; import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import org.apache.commons.proxy2.Interceptor; import org.apache.commons.proxy2.Invocation; @@ -44,21 +45,21 @@ public void testProvider() throws Throwable assertEquals("Foo!", interceptor.intercept(invocation)); } - @Test(expected = RuntimeException.class) - public void testThrowingExceptionObject() throws Throwable + @Test + public void testThrowingExceptionObject() { - Interceptor interceptor = InterceptorUtils.throwing(new RuntimeException("Oops!")); - Invocation invocation = mockInvocation(Echo.class, "echoBack", String.class).withArguments("World!").build(); - interceptor.intercept(invocation); + final Interceptor interceptor = InterceptorUtils.throwing(new RuntimeException("Oops!")); + final Invocation invocation = mockInvocation(Echo.class, "echoBack", String.class).withArguments("World!").build(); + assertThrows(RuntimeException.class, () -> interceptor.intercept(invocation)); } - @Test(expected = RuntimeException.class) - public void testThrowingProvidedException() throws Throwable + @Test + public void testThrowingProvidedException() { - Interceptor interceptor = InterceptorUtils + final Interceptor interceptor = InterceptorUtils .throwing(ObjectProviderUtils.constant(new RuntimeException("Oops!"))); - Invocation invocation = mockInvocation(Echo.class, "echoBack", String.class).withArguments("World!").build(); - interceptor.intercept(invocation); + final Invocation invocation = mockInvocation(Echo.class, "echoBack", String.class).withArguments("World!").build(); + assertThrows(RuntimeException.class, () -> interceptor.intercept(invocation)); } }