BATCH-2078: Close application contexts as batch jobs finish

This commit is contained in:
Michael Minella
2014-03-05 11:53:40 -06:00
parent 162d285a4d
commit ac81a97d0d
3 changed files with 57 additions and 0 deletions

View File

@@ -544,6 +544,15 @@ public class JsrJobOperatorTests {
}
@Test
public void testApplicationContextClosingAfterJobSuccessful() throws Exception {
for(int i = 0; i < 3; i++) {
javax.batch.runtime.JobExecution execution = runJob("contextClosingTests", new Properties(), TIMEOUT);
assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus());
}
}
public static class LongRunningBatchlet implements Batchlet {
private boolean stopped = false;
@@ -568,4 +577,25 @@ public class JsrJobOperatorTests {
throw new RuntimeException("blah");
}
}
public static class MustBeClosedBatchlet extends AbstractBatchlet {
public static boolean closed = true;
public MustBeClosedBatchlet() {
if(!closed) {
throw new RuntimeException("Batchlet wasn't closed last time");
}
}
public void close() {
closed = true;
}
@Override
public String process() throws Exception {
closed = false;
return null;
}
}
}