Skip to content

Commit 29d765f

Browse files
committed
JUnit5 assertThrows AbstractProxyFactoryTestCase
1 parent 7730c81 commit 29d765f

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

core/src/test/java/org/apache/commons/proxy2/AbstractProxyFactoryTestCase.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static org.junit.Assert.assertNotSame;
2424
import static org.junit.Assert.assertSame;
2525
import static org.junit.Assert.assertTrue;
26+
import static org.junit.jupiter.api.Assertions.assertThrows;
2627

2728
import java.io.IOException;
2829
import java.io.Serializable;
@@ -221,18 +222,18 @@ public void testInterceptingProxySerializable() throws Exception
221222
assertSerializable(proxy);
222223
}
223224

224-
@Test(expected = IOException.class)
225-
public void testInterceptorProxyWithCheckedException() throws Exception
225+
@Test
226+
public void testInterceptorProxyWithCheckedException()
226227
{
227228
final Echo proxy = factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY);
228-
proxy.ioException();
229+
assertThrows(IOException.class, () -> proxy.ioException());
229230
}
230231

231-
@Test(expected = IllegalArgumentException.class)
232-
public void testInterceptorProxyWithUncheckedException() throws Exception
232+
@Test
233+
public void testInterceptorProxyWithUncheckedException()
233234
{
234235
final Echo proxy = factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY);
235-
proxy.illegalArgument();
236+
assertThrows(IllegalArgumentException.class, () -> proxy.illegalArgument());
236237
}
237238

238239
@Test
@@ -326,18 +327,18 @@ public void testPrimitiveParameter()
326327
assertEquals(1, echo.echoBack(1));
327328
}
328329

329-
@Test(expected = IOException.class)
330-
public void testProxyWithCheckedException() throws Exception
330+
@Test
331+
public void testProxyWithCheckedException()
331332
{
332333
final Echo proxy = factory.createDelegatorProxy(new ConstantProvider<Echo>(new EchoImpl()), Echo.class);
333-
proxy.ioException();
334+
assertThrows(IOException.class, () -> proxy.ioException());
334335
}
335336

336-
@Test(expected = IllegalArgumentException.class)
337-
public void testProxyWithUncheckedException() throws Exception
337+
@Test
338+
public void testProxyWithUncheckedException()
338339
{
339340
final Echo proxy = factory.createDelegatorProxy(new ConstantProvider<Echo>(new EchoImpl()), Echo.class);
340-
proxy.illegalArgument();
341+
assertThrows(IllegalArgumentException.class, () -> proxy.illegalArgument());
341342
}
342343

343344
@Test

0 commit comments

Comments
 (0)