Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}

}