From fa56955f8d77b17bad1968f46b9894c7e2bec8f7 Mon Sep 17 00:00:00 2001 From: dhgarrette Date: Sat, 14 Feb 2009 19:34:51 +0000 Subject: [PATCH] BATCH-1064: Changed BatchStatus.FAILED to BatchStatus.INCOMPLETE where necessary --- .../org/springframework/batch/core/job/AbstractJob.java | 9 ++++----- .../springframework/batch/core/step/AbstractStep.java | 4 ++-- .../batch/core/step/tasklet/TaskletStep.java | 2 +- .../springframework/batch/core/job/SimpleJobTests.java | 4 ++-- .../batch/core/step/AbstractStepTests.java | 2 +- .../batch/core/step/item/TaskletStepExceptionTests.java | 2 +- .../core/step/tasklet/StepExecutorInterruptionTests.java | 4 ++-- .../batch/core/step/tasklet/TaskletStepTests.java | 2 +- .../batch/sample/JobOperatorFunctionalTests.java | 9 ++++----- 9 files changed, 18 insertions(+), 20 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java index da8bc990a..3d696e6cd 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/job/AbstractJob.java @@ -241,8 +241,8 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, In // The job was already stopped before we even got this far. Deal // with it in the same way as any other interruption. - execution.setStatus(BatchStatus.FAILED); - execution.setExitStatus(ExitStatus.COMPLETED); + execution.setExitStatus(ExitStatus.FAILED); + execution.setStatus(BatchStatus.INCOMPLETE); } @@ -293,7 +293,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, In * @return the {@link StepExecution} corresponding to this step * * @throws JobInterruptedException if the {@link JobExecution} has been - * interrupted, and in particular if {@link BatchStatus#FAILED} or + * interrupted, and in particular if {@link BatchStatus#INCOMPLETE} or * {@link BatchStatus#STOPPING} is detected * @throws StartLimitExceededException if the start limit has been exceeded * for this step @@ -331,8 +331,7 @@ public abstract class AbstractJob implements Job, StepLocator, BeanNameAware, In jobRepository.updateExecutionContext(execution); - if (currentStepExecution.getStatus() == BatchStatus.FAILED - || currentStepExecution.getStatus() == BatchStatus.STOPPING) { + if (currentStepExecution.getStatus() == BatchStatus.STOPPING) { throw new JobInterruptedException("Job interrupted by step execution"); } diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java index 9fe46a36b..34a3f77a6 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java @@ -194,7 +194,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw // Check if someone is trying to stop us if (stepExecution.isTerminateOnly()) { - stepExecution.setStatus(BatchStatus.FAILED); + stepExecution.setStatus(BatchStatus.INCOMPLETE); throw new JobInterruptedException("JobExecution interrupted."); } @@ -263,7 +263,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw return BatchStatus.UNKNOWN; } else if (e instanceof JobInterruptedException || e.getCause() instanceof JobInterruptedException) { - return BatchStatus.FAILED; + return BatchStatus.INCOMPLETE; } else { return BatchStatus.INCOMPLETE; diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java index 9504be53b..90124f9bf 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/tasklet/TaskletStep.java @@ -257,7 +257,7 @@ public class TaskletStep extends AbstractStep { locked = true; } catch (InterruptedException e) { - stepExecution.setStatus(BatchStatus.FAILED); + stepExecution.setStatus(BatchStatus.INCOMPLETE); Thread.currentThread().interrupt(); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java index 47d3282a5..9b90030a5 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/job/SimpleJobTests.java @@ -352,7 +352,7 @@ public class SimpleJobTests { job.execute(jobExecution); assertEquals(0, list.size()); - checkRepository(BatchStatus.FAILED, ExitStatus.NOOP); + checkRepository(BatchStatus.INCOMPLETE, ExitStatus.NOOP); ExitStatus exitStatus = jobExecution.getExitStatus(); assertEquals(ExitStatus.NOOP.getExitCode(), exitStatus.getExitCode()); } @@ -548,7 +548,7 @@ public class SimpleJobTests { } if (exception instanceof JobInterruptedException) { stepExecution.setExitStatus(ExitStatus.FAILED); - stepExecution.setStatus(BatchStatus.FAILED); + stepExecution.setStatus(BatchStatus.STOPPING); stepExecution.addFailureException(exception); return; } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/AbstractStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/AbstractStepTests.java index 8fbc8c7a3..614e51f51 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/AbstractStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/AbstractStepTests.java @@ -242,7 +242,7 @@ public class AbstractStepTests { tested.setStepExecutionListeners(new StepExecutionListener[] { listener1, listener2 }); tested.execute(execution); - assertEquals(BatchStatus.FAILED, execution.getStatus()); + assertEquals(BatchStatus.INCOMPLETE, execution.getStatus()); Throwable expected = execution.getFailureExceptions().get(0); assertEquals("JobExecution interrupted.", expected.getMessage()); diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java index ec545d345..f652e0280 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/item/TaskletStepExceptionTests.java @@ -80,7 +80,7 @@ public class TaskletStepExceptionTests { public void testInterrupted() throws Exception { taskletStep.setStepExecutionListeners(new StepExecutionListener[] { new InterruptionListener() }); taskletStep.execute(stepExecution); - assertEquals(FAILED, stepExecution.getStatus()); + assertEquals(INCOMPLETE, stepExecution.getStatus()); } @Test diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java index fbd60a0d8..cf69346ed 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/StepExecutorInterruptionTests.java @@ -114,7 +114,7 @@ public class StepExecutorInterruptionTests extends TestCase { assertTrue("Timed out waiting for step to be interrupted.", count < 1000); assertFalse(processingThread.isAlive()); - assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); + assertEquals(BatchStatus.INCOMPLETE, stepExecution.getStatus()); } @@ -170,7 +170,7 @@ public class StepExecutorInterruptionTests extends TestCase { assertTrue("Timed out waiting for step to be interrupted.", count < 1000); assertFalse(processingThread.isAlive()); - assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); + assertEquals(BatchStatus.INCOMPLETE, stepExecution.getStatus()); } diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java index c693800a7..98edb8118 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/step/tasklet/TaskletStepTests.java @@ -541,7 +541,7 @@ public class TaskletStepTests { stepExecution.setExecutionContext(foobarEc); step.execute(stepExecution); - assertEquals(BatchStatus.FAILED, stepExecution.getStatus()); + assertEquals(BatchStatus.INCOMPLETE, stepExecution.getStatus()); String msg = stepExecution.getExitStatus().getExitDescription(); assertTrue("Message does not contain 'JobInterruptedException': " + msg, contains(msg, "JobInterruptedException")); diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobOperatorFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobOperatorFunctionalTests.java index a5d45f418..2618599f2 100644 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobOperatorFunctionalTests.java +++ b/spring-batch-samples/src/test/java/org/springframework/batch/sample/JobOperatorFunctionalTests.java @@ -3,8 +3,6 @@ package org.springframework.batch.sample; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.springframework.batch.core.BatchStatus.STARTED; -import static org.springframework.batch.core.BatchStatus.FAILED; import java.util.List; import java.util.Map; @@ -15,6 +13,7 @@ import org.apache.commons.logging.LogFactory; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.batch.core.BatchStatus; import org.springframework.batch.core.Job; import org.springframework.batch.core.JobParametersBuilder; import org.springframework.batch.core.configuration.ListableJobRegistry; @@ -79,7 +78,7 @@ public class JobOperatorFunctionalTests { Thread.sleep(1000); assertTrue(tested.getRunningExecutions(job.getName()).contains(executionId)); - assertTrue(tested.getSummary(executionId).contains(STARTED.toString())); + assertTrue(tested.getSummary(executionId).contains(BatchStatus.STARTED.toString())); tested.stop(executionId); @@ -91,12 +90,12 @@ public class JobOperatorFunctionalTests { } assertFalse(tested.getRunningExecutions(job.getName()).contains(executionId)); - assertTrue(tested.getSummary(executionId).contains(FAILED.toString())); + assertTrue(tested.getSummary(executionId).contains(BatchStatus.INCOMPLETE.toString())); // there is just a single step in the test job Map summaries = tested.getStepExecutionSummaries(executionId); assertEquals(1, summaries.size()); - assertTrue(summaries.values().toString().contains(FAILED.toString())); + assertTrue(summaries.values().toString().contains(BatchStatus.INCOMPLETE.toString())); } @Test