|
1 | 1 | /* |
2 | | - * Copyright 2016-2019 the original author or authors. |
| 2 | + * Copyright 2016-2021 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
23 | 23 | import java.util.List; |
24 | 24 | import java.util.Map; |
25 | 25 |
|
| 26 | +import org.junit.jupiter.api.Assertions; |
26 | 27 | import org.junit.jupiter.api.BeforeEach; |
27 | 28 | import org.junit.jupiter.api.Test; |
28 | 29 |
|
@@ -339,6 +340,27 @@ public void testOrderConfiguration() { |
339 | 340 | }); |
340 | 341 | } |
341 | 342 |
|
| 343 | + @Test |
| 344 | + public void singleStepBatchJobSkip() { |
| 345 | + ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner() |
| 346 | + .withConfiguration(AutoConfigurations.of( |
| 347 | + EventJobExecutionConfiguration.class, |
| 348 | + PropertyPlaceholderAutoConfiguration.class, |
| 349 | + TestSupportBinderAutoConfiguration.class, |
| 350 | + SimpleTaskAutoConfiguration.class, SingleTaskConfiguration.class)) |
| 351 | + .withUserConfiguration( |
| 352 | + BatchEventAutoConfiguration.JobExecutionListenerConfiguration.class) |
| 353 | + .withPropertyValues("--spring.cloud.task.closecontext_enabled=false", |
| 354 | + "--spring.main.web-environment=false", "spring.batch.job.jobName=FOO"); |
| 355 | + applicationContextRunner.run((context) -> { |
| 356 | + NoSuchBeanDefinitionException exception = Assertions.assertThrows(NoSuchBeanDefinitionException.class, () -> { |
| 357 | + context.getBean("jobExecutionEventsListener"); |
| 358 | + }); |
| 359 | + assertThat(exception.getMessage()).contains( |
| 360 | + String.format("No bean named 'jobExecutionEventsListener' available")); |
| 361 | + }); |
| 362 | + } |
| 363 | + |
342 | 364 | private void testDisabledConfiguration(String property, String disabledListener) { |
343 | 365 | String disabledPropertyArg = (property != null) ? "--" + property + "=false" : ""; |
344 | 366 | ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner() |
|
0 commit comments