|
23 | 23 | import static org.junit.Assert.assertNotSame; |
24 | 24 | import static org.junit.Assert.assertSame; |
25 | 25 | import static org.junit.Assert.assertTrue; |
| 26 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
26 | 27 |
|
27 | 28 | import java.io.IOException; |
28 | 29 | import java.io.Serializable; |
|
45 | 46 | import org.apache.commons.proxy2.util.EchoImpl; |
46 | 47 | import org.apache.commons.proxy2.util.SuffixInterceptor; |
47 | 48 | import org.junit.Test; |
| 49 | +import org.junit.jupiter.api.function.Executable; |
48 | 50 |
|
49 | 51 | @SuppressWarnings("serial") |
50 | 52 | public abstract class AbstractProxyFactoryTestCase extends AbstractTestCase |
@@ -221,18 +223,32 @@ public void testInterceptingProxySerializable() throws Exception |
221 | 223 | assertSerializable(proxy); |
222 | 224 | } |
223 | 225 |
|
224 | | - @Test(expected = IOException.class) |
225 | | - public void testInterceptorProxyWithCheckedException() throws Exception |
| 226 | + @Test |
| 227 | + public void testInterceptorProxyWithCheckedException() |
226 | 228 | { |
227 | 229 | final Echo proxy = factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY); |
228 | | - proxy.ioException(); |
| 230 | + // FIXME Simplification once upgraded to Java 1.8 |
| 231 | + final Executable testMethod = new Executable() { |
| 232 | + @Override |
| 233 | + public void execute() throws Throwable { |
| 234 | + proxy.ioException(); |
| 235 | + } |
| 236 | + }; |
| 237 | + assertThrows(IOException.class, testMethod); |
229 | 238 | } |
230 | 239 |
|
231 | | - @Test(expected = IllegalArgumentException.class) |
232 | | - public void testInterceptorProxyWithUncheckedException() throws Exception |
| 240 | + @Test |
| 241 | + public void testInterceptorProxyWithUncheckedException() |
233 | 242 | { |
234 | 243 | final Echo proxy = factory.createInterceptorProxy(new EchoImpl(), new NoOpMethodInterceptor(), ECHO_ONLY); |
235 | | - proxy.illegalArgument(); |
| 244 | + // FIXME Simplification once upgraded to Java 1.8 |
| 245 | + final Executable testMethod = new Executable() { |
| 246 | + @Override |
| 247 | + public void execute() throws Throwable { |
| 248 | + proxy.illegalArgument(); |
| 249 | + } |
| 250 | + }; |
| 251 | + assertThrows(IllegalArgumentException.class, testMethod); |
236 | 252 | } |
237 | 253 |
|
238 | 254 | @Test |
@@ -326,18 +342,32 @@ public void testPrimitiveParameter() |
326 | 342 | assertEquals(1, echo.echoBack(1)); |
327 | 343 | } |
328 | 344 |
|
329 | | - @Test(expected = IOException.class) |
330 | | - public void testProxyWithCheckedException() throws Exception |
| 345 | + @Test |
| 346 | + public void testProxyWithCheckedException() |
331 | 347 | { |
332 | 348 | final Echo proxy = factory.createDelegatorProxy(new ConstantProvider<Echo>(new EchoImpl()), Echo.class); |
333 | | - proxy.ioException(); |
| 349 | + // FIXME Simplification once upgraded to Java 1.8 |
| 350 | + final Executable testMethod = new Executable() { |
| 351 | + @Override |
| 352 | + public void execute() throws Throwable { |
| 353 | + proxy.ioException(); |
| 354 | + } |
| 355 | + }; |
| 356 | + assertThrows(IOException.class, testMethod); |
334 | 357 | } |
335 | 358 |
|
336 | | - @Test(expected = IllegalArgumentException.class) |
337 | | - public void testProxyWithUncheckedException() throws Exception |
| 359 | + @Test |
| 360 | + public void testProxyWithUncheckedException() |
338 | 361 | { |
339 | 362 | final Echo proxy = factory.createDelegatorProxy(new ConstantProvider<Echo>(new EchoImpl()), Echo.class); |
340 | | - proxy.illegalArgument(); |
| 363 | + // FIXME Simplification once upgraded to Java 1.8 |
| 364 | + final Executable testMethod = new Executable() { |
| 365 | + @Override |
| 366 | + public void execute() throws Throwable { |
| 367 | + proxy.illegalArgument(); |
| 368 | + } |
| 369 | + }; |
| 370 | + assertThrows(IllegalArgumentException.class, testMethod); |
341 | 371 | } |
342 | 372 |
|
343 | 373 | @Test |
|
0 commit comments