From 24852e3cf86c71287eb4cbb9316e76eb129833cd Mon Sep 17 00:00:00 2001 From: Michael Minella Date: Wed, 2 Apr 2014 10:49:09 -0500 Subject: [PATCH] Added wait in JsrJobOperatorTests#testApplicationContextClosingAfterJobSuccessful to give application context a chance to shut down before re-running the job --- .../core/jsr/launch/JsrJobOperatorTests.java | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/launch/JsrJobOperatorTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/launch/JsrJobOperatorTests.java index cb118f498..4849ec387 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/launch/JsrJobOperatorTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/jsr/launch/JsrJobOperatorTests.java @@ -15,35 +15,6 @@ */ package org.springframework.batch.core.jsr.launch; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.springframework.batch.core.jsr.JsrTestUtils.restartJob; -import static org.springframework.batch.core.jsr.JsrTestUtils.runJob; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Properties; -import java.util.Set; - -import javax.batch.api.AbstractBatchlet; -import javax.batch.api.Batchlet; -import javax.batch.operations.JobExecutionIsRunningException; -import javax.batch.operations.JobOperator; -import javax.batch.operations.JobRestartException; -import javax.batch.operations.JobStartException; -import javax.batch.operations.NoSuchJobException; -import javax.batch.operations.NoSuchJobExecutionException; -import javax.batch.operations.NoSuchJobInstanceException; -import javax.batch.runtime.BatchRuntime; -import javax.batch.runtime.BatchStatus; - import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -64,6 +35,34 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.core.task.SyncTaskExecutor; +import javax.batch.api.AbstractBatchlet; +import javax.batch.api.Batchlet; +import javax.batch.operations.JobExecutionIsRunningException; +import javax.batch.operations.JobOperator; +import javax.batch.operations.JobRestartException; +import javax.batch.operations.JobStartException; +import javax.batch.operations.NoSuchJobException; +import javax.batch.operations.NoSuchJobExecutionException; +import javax.batch.operations.NoSuchJobInstanceException; +import javax.batch.runtime.BatchRuntime; +import javax.batch.runtime.BatchStatus; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.springframework.batch.core.jsr.JsrTestUtils.restartJob; +import static org.springframework.batch.core.jsr.JsrTestUtils.runJob; + public class JsrJobOperatorTests { private JobOperator jsrJobOperator; @@ -550,6 +549,9 @@ public class JsrJobOperatorTests { javax.batch.runtime.JobExecution execution = runJob("contextClosingTests", new Properties(), TIMEOUT); assertEquals(BatchStatus.COMPLETED, execution.getBatchStatus()); + + // Added to allow time for the context to finish closing before running the job again + Thread.sleep(1000l); } }