Set the spring.cloud.task.closecontext_enable default to false
resolves #364
This commit is contained in:
committed by
Michael Minella
parent
3f316a0170
commit
94e074d841
@@ -47,10 +47,10 @@ Upon completion of all of the `*Runner#run` calls from Spring Boot or the failur
|
||||
`ApplicationContext` (indicated via a `ApplicationFailedEvent`), the task execution is
|
||||
updated in the repository with the results.
|
||||
|
||||
NOTE: At the completion of a task (all `*Runner#run` methods are called and the task
|
||||
repository has been updated) the `ApplicationContext` will be closed by default. This
|
||||
behavior can be overriden by setting the property `spring.cloud.task.closecontext_enable`
|
||||
to false.
|
||||
NOTE: If the application requires the `ApplicationContext` to be closed at the
|
||||
completion of a task (all `*Runner#run` methods are called and the task
|
||||
repository has been updated), set the property `spring.cloud.task.closecontext_enable`
|
||||
to true.
|
||||
|
||||
[[features-task-execution-details]]
|
||||
=== The TaskExecution
|
||||
|
||||
@@ -290,28 +290,3 @@ If you notice, there are three lines of interest in the above output:
|
||||
NOTE: A simple task application can be found in the samples module
|
||||
of the Spring Cloud Task Project
|
||||
https://github.com/spring-cloud/spring-cloud-task/tree/master/spring-cloud-task-samples/timestamp[here].
|
||||
|
||||
|
||||
=== Writing your test
|
||||
|
||||
When writing your unit tests for a Spring Cloud Task application we have to keep
|
||||
in mind that Spring Cloud Task closes the context at the completion of the task
|
||||
as discussed <<features.adoc#features-lifecycle, here>>. If you are using Spring
|
||||
Framework's testing functionality to manage the application context, you'll want to turn
|
||||
off Spring Cloud Task's auto-closing of the context. Add the following
|
||||
line: `@TestPropertySource(properties = {"spring.cloud.task.closecontext_enable=false"})`
|
||||
to your tests will keep the context open. For example:
|
||||
|
||||
```
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@TestPropertySource(properties = {"spring.cloud.task.closecontext_enabled=false"})
|
||||
public class DemoApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
//your test here
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user