|
18 | 18 | package org.apache.commons.digester3.annotations.failingtests; |
19 | 19 |
|
20 | 20 | import static org.apache.commons.digester3.binder.DigesterLoader.newLoader; |
| 21 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 22 | +import static org.hamcrest.core.Is.is; |
| 23 | +import static org.hamcrest.core.StringStartsWith.startsWith; |
| 24 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
21 | 25 |
|
22 | 26 | import org.apache.commons.digester3.annotations.FromAnnotationsRuleModule; |
23 | 27 | import org.apache.commons.digester3.binder.DigesterLoadingException; |
24 | 28 | import org.junit.Test; |
| 29 | +import org.junit.jupiter.api.function.Executable; |
25 | 30 |
|
26 | 31 | public final class FailingTestCase |
27 | 32 | { |
28 | 33 |
|
29 | 34 | /** |
30 | 35 | * Tests to make sure loader fails |
31 | 36 | */ |
32 | | - @Test(expected = DigesterLoadingException.class) |
| 37 | + @Test |
33 | 38 | public void failsBecauseFailingDigesterLoaderHandlerFactory() { |
34 | 39 |
|
35 | | - newLoader(new FromAnnotationsRuleModule() |
36 | | - { |
| 40 | + // FIXME Simplification once upgraded to Java 1.8 and use lambda |
| 41 | + final Executable testMethod = new Executable() { |
| 42 | + public void execute() throws Throwable { |
| 43 | + newLoader(new FromAnnotationsRuleModule() { |
37 | 44 |
|
38 | | - @Override |
39 | | - protected void configureRules() |
40 | | - { |
41 | | - useAnnotationHandlerFactory( new FailingDigesterLoaderHandlerFactory() ); |
42 | | - bindRulesFrom( BeanWithFakeHandler.class ); |
43 | | - } |
| 45 | + @Override |
| 46 | + protected void configureRules() { |
| 47 | + useAnnotationHandlerFactory(new FailingDigesterLoaderHandlerFactory()); |
| 48 | + bindRulesFrom(BeanWithFakeHandler.class); |
| 49 | + } |
44 | 50 |
|
45 | | - }).newDigester(); |
| 51 | + }).newDigester(); |
| 52 | + } |
| 53 | + }; |
| 54 | + final DigesterLoadingException thrown = assertThrows(DigesterLoadingException.class, testMethod); |
| 55 | + assertThat(thrown.getMessage(), is(startsWith("Digester creation errors:"))); |
46 | 56 | } |
47 | 57 |
|
48 | 58 | } |
0 commit comments