|
23 | 23 | import org.springframework.beans.factory.BeanCreationException;
|
24 | 24 | import org.springframework.beans.factory.annotation.Autowired;
|
25 | 25 | import org.springframework.beans.factory.annotation.Value;
|
| 26 | +import org.springframework.context.annotation.Bean; |
| 27 | +import org.springframework.context.annotation.Configuration; |
26 | 28 | import org.springframework.test.context.ContextConfiguration;
|
27 | 29 |
|
28 | 30 | import java.util.Optional;
|
@@ -322,20 +324,9 @@ void shouldThrowWhenGlueScopedSpringBeanAreUsedOutsideLifecycle() {
|
322 | 324 | }
|
323 | 325 |
|
324 | 326 | @Test
|
325 |
| - void shouldBeStoppableWhenFacedWithInvalidConfiguration() { |
| 327 | + void shouldBeStoppableWhenFacedWithBrokenContextConfiguration() { |
326 | 328 | final ObjectFactory factory = new SpringFactory();
|
327 |
| - factory.addClass(WithEmptySpringAnnotations.class); |
328 |
| - |
329 |
| - IllegalStateException exception = assertThrows(IllegalStateException.class, factory::start); |
330 |
| - assertThat(exception.getMessage(), |
331 |
| - containsString("DelegatingSmartContextLoader was unable to detect defaults")); |
332 |
| - assertDoesNotThrow(factory::stop); |
333 |
| - } |
334 |
| - |
335 |
| - @Test |
336 |
| - void shouldBeStoppableWhenFacedWithMissingContextConfiguration() { |
337 |
| - final ObjectFactory factory = new SpringFactory(); |
338 |
| - factory.addClass(WithoutContextConfiguration.class); |
| 329 | + factory.addClass(WithBrokenContextConfiguration.class); |
339 | 330 |
|
340 | 331 | IllegalStateException exception = assertThrows(IllegalStateException.class, factory::start);
|
341 | 332 | assertThat(exception.getMessage(), containsString("Failed to load ApplicationContext"));
|
@@ -392,13 +383,17 @@ public String getProperty() {
|
392 | 383 | }
|
393 | 384 |
|
394 | 385 | @CucumberContextConfiguration
|
395 |
| - @ContextConfiguration |
396 |
| - public static class WithEmptySpringAnnotations { |
| 386 | + public static class WithBrokenContextConfiguration { |
397 | 387 |
|
398 |
| - } |
| 388 | + @Configuration |
| 389 | + public static class BrokenConfiguration { |
399 | 390 |
|
400 |
| - @CucumberContextConfiguration |
401 |
| - public static class WithoutContextConfiguration { |
| 391 | + @Bean |
| 392 | + public Object brokenBean() { |
| 393 | + throw new RuntimeException("Oops!"); |
| 394 | + } |
| 395 | + |
| 396 | + } |
402 | 397 |
|
403 | 398 | }
|
404 | 399 |
|
|
0 commit comments