Refactored task end event to be Spring Boot's ApplicationReadyEvent

In testing and other use cases, the ability to keep a context open
beyond the end of a task can be useful.  This change provides the
ability to keep the context alive once a task has completed while also
explicitly shutting the context down (by default) once a task has ended.

Resolves spring-cloud/spring-cloud-task#102
This commit is contained in:
Michael Minella
2016-04-05 11:44:09 -05:00
parent 3d3b90812e
commit 0a56672171
9 changed files with 88 additions and 107 deletions

View File

@@ -61,6 +61,8 @@ import static org.junit.Assert.assertEquals;
*/
public class TaskBatchExecutionListenerTests {
public static final String[] ARGS = new String[] {"--spring.cloud.task.closecontext.enable=false"};
private ConfigurableApplicationContext applicationContext;
@After
@@ -76,7 +78,7 @@ public class TaskBatchExecutionListenerTests {
PropertyPlaceholderAutoConfiguration.class,
EmbeddedDataSourceConfiguration.class,
BatchAutoConfiguration.class,
TaskBatchAutoConfiguration.class}, new String[0]);
TaskBatchAutoConfiguration.class}, ARGS);
TaskExplorer taskExplorer = this.applicationContext.getBean(TaskExplorer.class);
@@ -94,7 +96,7 @@ public class TaskBatchExecutionListenerTests {
PropertyPlaceholderAutoConfiguration.class,
EmbeddedDataSourceConfiguration.class,
BatchAutoConfiguration.class,
TaskBatchAutoConfiguration.class}, new String[0]);
TaskBatchAutoConfiguration.class}, ARGS);
TaskExplorer taskExplorer = this.applicationContext.getBean(TaskExplorer.class);
@@ -112,7 +114,7 @@ public class TaskBatchExecutionListenerTests {
PropertyPlaceholderAutoConfiguration.class,
EmbeddedDataSourceConfiguration.class,
BatchAutoConfiguration.class,
TaskBatchAutoConfiguration.class}, new String[0]);
TaskBatchAutoConfiguration.class}, ARGS);
TaskExplorer taskExplorer = this.applicationContext.getBean(TaskExplorer.class);
@@ -128,7 +130,7 @@ public class TaskBatchExecutionListenerTests {
this.applicationContext = SpringApplication.run(new Object[] {JobConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
BatchAutoConfiguration.class,
TaskBatchAutoConfiguration.class}, new String[0]);
TaskBatchAutoConfiguration.class}, ARGS);
TaskExplorer taskExplorer = this.applicationContext.getBean(TaskExplorer.class);
@@ -145,7 +147,7 @@ public class TaskBatchExecutionListenerTests {
this.applicationContext = SpringApplication.run(new Object[] {MultipleJobConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
BatchAutoConfiguration.class,
TaskBatchAutoConfiguration.class}, new String[0]);
TaskBatchAutoConfiguration.class}, ARGS);
TaskExplorer taskExplorer = this.applicationContext.getBean(TaskExplorer.class);