IN PROGRESS - issue BATCH-894: RFC: move ExitStatus up into Core?
Replaced infrastrucure status with local enum and moved ExitStatus into core. TODO: maybe get rid of continuable.
This commit is contained in:
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.core;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.apache.commons.lang.SerializationUtils;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class ExitStatusTests {
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#ExitStatus(boolean, String)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testExitStatusBooleanInt() {
|
||||
ExitStatus status = new ExitStatus(true, "10");
|
||||
assertTrue(status.isContinuable());
|
||||
assertEquals("10", status.getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#ExitStatus(boolean, String)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testExitStatusConstantsContinuable() {
|
||||
ExitStatus status = ExitStatus.CONTINUABLE;
|
||||
assertTrue(status.isContinuable());
|
||||
assertEquals("CONTINUABLE", status.getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#ExitStatus(boolean, String)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testExitStatusConstantsFinished() {
|
||||
ExitStatus status = ExitStatus.FINISHED;
|
||||
assertFalse(status.isContinuable());
|
||||
assertEquals("COMPLETED", status.getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test equality of exit statuses.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testEqualsWithSameProperties() throws Exception {
|
||||
assertEquals(ExitStatus.CONTINUABLE, new ExitStatus(true, "CONTINUABLE"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsSelf() {
|
||||
ExitStatus status = new ExitStatus(true, "test");
|
||||
assertEquals(status, status);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
assertEquals(new ExitStatus(true, "test"), new ExitStatus(true, "test"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test equality of exit statuses.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testEqualsWithNull() throws Exception {
|
||||
assertFalse(ExitStatus.CONTINUABLE.equals(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test equality of exit statuses.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testHashcode() throws Exception {
|
||||
assertEquals(ExitStatus.CONTINUABLE.toString().hashCode(), ExitStatus.CONTINUABLE.hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(boolean)}.
|
||||
*/
|
||||
@Test
|
||||
public void testAndBoolean() {
|
||||
assertTrue(ExitStatus.CONTINUABLE.and(true).isContinuable());
|
||||
assertFalse(ExitStatus.CONTINUABLE.and(false).isContinuable());
|
||||
ExitStatus status = new ExitStatus(false, "CUSTOM_CODE", "CUSTOM_DESCRIPTION");
|
||||
assertTrue(status.and(true).getExitCode() == "CUSTOM_CODE");
|
||||
assertTrue(status.and(true).getExitDescription() == "CUSTOM_DESCRIPTION");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusStillContinuable() {
|
||||
assertTrue(ExitStatus.CONTINUABLE.and(ExitStatus.CONTINUABLE).isContinuable());
|
||||
assertFalse(ExitStatus.CONTINUABLE.and(ExitStatus.FINISHED).isContinuable());
|
||||
assertTrue(ExitStatus.CONTINUABLE.and(ExitStatus.CONTINUABLE).getExitCode().equals(
|
||||
ExitStatus.CONTINUABLE.getExitCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusWhenFinishedAddedToContinuable() {
|
||||
assertEquals(ExitStatus.FINISHED.getExitCode(), ExitStatus.CONTINUABLE.and(ExitStatus.FINISHED).getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusWhenContinuableAddedToFinished() {
|
||||
assertEquals(ExitStatus.FINISHED.getExitCode(), ExitStatus.FINISHED.and(ExitStatus.CONTINUABLE).getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusWhenCustomContinuableAddedToContinuable() {
|
||||
assertEquals("CUSTOM", ExitStatus.CONTINUABLE.and(ExitStatus.CONTINUABLE.replaceExitCode("CUSTOM"))
|
||||
.getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusFailedPlusFinished() {
|
||||
assertEquals("FAILED", ExitStatus.FINISHED.and(ExitStatus.FAILED).getExitCode());
|
||||
assertEquals("FAILED", ExitStatus.FAILED.and(ExitStatus.FINISHED).getExitCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.ExitStatus#and(org.springframework.batch.core.ExitStatus)}
|
||||
* .
|
||||
*/
|
||||
@Test
|
||||
public void testAndExitStatusWhenCustomContinuableAddedToFinished() {
|
||||
assertEquals(ExitStatus.FINISHED.getExitCode(), ExitStatus.FINISHED.and(
|
||||
ExitStatus.CONTINUABLE.replaceExitCode("CUSTOM")).getExitCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitCode() throws Exception {
|
||||
ExitStatus status = ExitStatus.CONTINUABLE.replaceExitCode("FOO");
|
||||
assertTrue(ExitStatus.CONTINUABLE != status);
|
||||
assertTrue(status.isContinuable());
|
||||
assertEquals("FOO", status.getExitCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitCodeToExistingStatus() throws Exception {
|
||||
ExitStatus status = ExitStatus.CONTINUABLE.replaceExitCode("FOO").replaceExitCode("BAR");
|
||||
assertTrue(ExitStatus.CONTINUABLE != status);
|
||||
assertTrue(status.isContinuable());
|
||||
assertEquals("BAR", status.getExitCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitCodeToSameStatus() throws Exception {
|
||||
ExitStatus status = ExitStatus.CONTINUABLE.replaceExitCode(ExitStatus.CONTINUABLE.getExitCode());
|
||||
assertTrue(ExitStatus.CONTINUABLE != status);
|
||||
assertTrue(status.isContinuable());
|
||||
assertEquals(ExitStatus.CONTINUABLE.getExitCode(), status.getExitCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitDescription() throws Exception {
|
||||
ExitStatus status = ExitStatus.CONTINUABLE.addExitDescription("Foo");
|
||||
assertTrue(ExitStatus.CONTINUABLE != status);
|
||||
assertTrue(status.isContinuable());
|
||||
assertEquals("Foo", status.getExitDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitDescriptionToSameStatus() throws Exception {
|
||||
ExitStatus status = ExitStatus.CONTINUABLE.addExitDescription("Foo").addExitDescription("Foo");
|
||||
assertTrue(ExitStatus.CONTINUABLE != status);
|
||||
assertTrue(status.isContinuable());
|
||||
assertEquals("Foo", status.getExitDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddEmptyExitDescription() throws Exception {
|
||||
ExitStatus status = ExitStatus.CONTINUABLE.addExitDescription("Foo").addExitDescription(null);
|
||||
assertEquals("Foo", status.getExitDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddExitCodeWithDescription() throws Exception {
|
||||
ExitStatus status = new ExitStatus(true, "BAR", "Bar").replaceExitCode("FOO");
|
||||
assertEquals("FOO", status.getExitCode());
|
||||
assertEquals("Bar", status.getExitDescription());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnkownIsRunning() throws Exception {
|
||||
assertTrue(ExitStatus.UNKNOWN.isRunning());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerializable() throws Exception {
|
||||
ExitStatus status = ExitStatus.CONTINUABLE.replaceExitCode("FOO");
|
||||
byte[] bytes = SerializationUtils.serialize(status);
|
||||
Object object = SerializationUtils.deserialize(bytes);
|
||||
assertTrue(object instanceof ExitStatus);
|
||||
ExitStatus restored = (ExitStatus) object;
|
||||
assertTrue(restored.isContinuable());
|
||||
assertEquals(status.getExitCode(), restored.getExitCode());
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.SerializationUtils;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.step.tasklet.Tasklet;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.core.AttributeAccessor;
|
||||
|
||||
public class TestTasklet extends AbstractTestComponent implements Tasklet {
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobExecutionException;
|
||||
import org.springframework.batch.core.JobExecutionListener;
|
||||
@@ -57,7 +58,6 @@ import org.springframework.batch.core.repository.dao.StepExecutionDao;
|
||||
import org.springframework.batch.core.repository.support.SimpleJobRepository;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* Tests for DefaultJobLifecycle. MapJobDao and MapStepExecutionDao are used
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.Collections;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
@@ -42,7 +43,6 @@ import org.springframework.batch.core.job.flow.support.state.StepState;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
@@ -38,7 +39,6 @@ import org.springframework.batch.core.job.JobSupport;
|
||||
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Properties;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
@@ -30,7 +31,6 @@ import org.springframework.batch.core.converter.DefaultJobParametersConverter;
|
||||
import org.springframework.batch.core.converter.JobParametersConverter;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.launch.support.ExitCodeMapper;
|
||||
import org.springframework.batch.core.launch.support.SimpleJvmExitCodeMapper;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
public class SimpleJvmExitCodeMapperTests extends TestCase {
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Set;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
@@ -31,7 +32,6 @@ import org.springframework.batch.core.partition.StepExecutionSplitter;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
|
||||
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
public class StepExecutionAggregatorTests {
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobExecutionException;
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.partition.StepExecutionSplitter;
|
||||
import org.springframework.batch.core.step.StepSupport;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.core.task.TaskRejectedException;
|
||||
|
||||
@@ -31,11 +31,11 @@ import javax.sql.DataSource;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -14,11 +14,11 @@ import java.util.Set;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.dao.OptimisticLockingFailureException;
|
||||
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.junit.Test;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -4,9 +4,9 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -20,10 +20,11 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.repeat.RepeatContext;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -44,7 +45,8 @@ public class StepContextRepeatCallbackTests {
|
||||
return ExitStatus.NOOP;
|
||||
}
|
||||
};
|
||||
assertEquals(ExitStatus.NOOP, callback.doInIteration(null));
|
||||
assertEquals(RepeatStatus.FINISHED, callback.doInIteration(null));
|
||||
assertEquals(ExitStatus.NOOP, stepExecution.getExitStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -12,13 +12,13 @@ import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.StepExecutionListener;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -55,10 +55,11 @@ public class AbstractStepTests {
|
||||
events.add("open");
|
||||
}
|
||||
|
||||
protected ExitStatus doExecute(StepExecution context) throws Exception {
|
||||
@Override
|
||||
protected void doExecute(StepExecution context) throws Exception {
|
||||
assertSame(execution, context);
|
||||
events.add("doExecute");
|
||||
return ExitStatus.FINISHED;
|
||||
context.setExitStatus(ExitStatus.FINISHED);
|
||||
}
|
||||
|
||||
protected void close(ExecutionContext ctx) throws Exception {
|
||||
@@ -139,8 +140,7 @@ public class AbstractStepTests {
|
||||
public void testBeanName() throws Exception {
|
||||
AbstractStep step = new AbstractStep() {
|
||||
@Override
|
||||
protected ExitStatus doExecute(StepExecution stepExecution) throws Exception {
|
||||
return null;
|
||||
protected void doExecute(StepExecution stepExecution) throws Exception {
|
||||
}
|
||||
};
|
||||
assertNull(step.getName());
|
||||
@@ -152,8 +152,7 @@ public class AbstractStepTests {
|
||||
public void testName() throws Exception {
|
||||
AbstractStep step = new AbstractStep() {
|
||||
@Override
|
||||
protected ExitStatus doExecute(StepExecution stepExecution) throws Exception {
|
||||
return null;
|
||||
protected void doExecute(StepExecution stepExecution) throws Exception {
|
||||
}
|
||||
};
|
||||
assertNull(step.getName());
|
||||
@@ -196,7 +195,7 @@ public class AbstractStepTests {
|
||||
public void testFailure() throws Exception {
|
||||
tested = new EventTrackingStep() {
|
||||
@Override
|
||||
protected ExitStatus doExecute(StepExecution context) throws Exception {
|
||||
protected void doExecute(StepExecution context) throws Exception {
|
||||
super.doExecute(context);
|
||||
throw new RuntimeException("crash!");
|
||||
}
|
||||
@@ -234,9 +233,9 @@ public class AbstractStepTests {
|
||||
public void testStoppedStep() throws Exception {
|
||||
tested = new EventTrackingStep() {
|
||||
@Override
|
||||
protected ExitStatus doExecute(StepExecution context) throws Exception {
|
||||
protected void doExecute(StepExecution context) throws Exception {
|
||||
context.setTerminateOnly();
|
||||
return super.doExecute(context);
|
||||
super.doExecute(context);
|
||||
}
|
||||
};
|
||||
tested.setJobRepository(repository);
|
||||
@@ -257,7 +256,7 @@ public class AbstractStepTests {
|
||||
assertEquals("close", events.get(i++));
|
||||
assertEquals(7, events.size());
|
||||
|
||||
assertEquals("JOB_INTERRUPTED", execution.getExitStatus().getExitCode());
|
||||
assertEquals("INTERRUPTED", execution.getExitStatus().getExitCode());
|
||||
|
||||
assertTrue("Execution context modifications made by listener should be persisted", repository.saved
|
||||
.containsKey("afterStep"));
|
||||
@@ -270,9 +269,8 @@ public class AbstractStepTests {
|
||||
public void testFailureInSavingExecutionContext() throws Exception {
|
||||
tested = new EventTrackingStep() {
|
||||
@Override
|
||||
protected ExitStatus doExecute(StepExecution context) throws Exception {
|
||||
protected void doExecute(StepExecution context) throws Exception {
|
||||
super.doExecute(context);
|
||||
return ExitStatus.FINISHED;
|
||||
}
|
||||
};
|
||||
repository = new JobRepositoryStub() {
|
||||
|
||||
@@ -28,9 +28,9 @@ import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.launch.EmptyItemWriter;
|
||||
import org.springframework.batch.core.step.JobRepositorySupport;
|
||||
import org.springframework.batch.item.support.ListItemReader;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.repeat.RepeatCallback;
|
||||
import org.springframework.batch.repeat.RepeatOperations;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
|
||||
|
||||
/**
|
||||
@@ -70,10 +70,10 @@ public class RepeatOperationsStepFactoryBeanTests extends TestCase {
|
||||
|
||||
factory.setStepOperations(new RepeatOperations() {
|
||||
|
||||
public ExitStatus iterate(RepeatCallback callback) {
|
||||
public RepeatStatus iterate(RepeatCallback callback) {
|
||||
list = new ArrayList<String>();
|
||||
list.add("foo");
|
||||
return ExitStatus.FINISHED;
|
||||
return RepeatStatus.FINISHED;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import static org.springframework.batch.core.BatchStatus.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
@@ -26,7 +27,6 @@ import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.ItemStreamException;
|
||||
import org.springframework.batch.item.ItemStreamSupport;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
|
||||
import org.springframework.core.AttributeAccessor;
|
||||
import org.springframework.transaction.TransactionException;
|
||||
|
||||
@@ -21,8 +21,8 @@ import static org.junit.Assert.fail;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.step.tasklet.CallableTaskletAdapter;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
public class CallableTaskletAdapterTests {
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.step.tasklet.ConfigurableSystemProcessExitCodeMapper;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* Tests for {@link ConfigurableSystemProcessExitCodeMapper}
|
||||
|
||||
@@ -3,8 +3,8 @@ package org.springframework.batch.core.step.tasklet;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.step.tasklet.SimpleSystemProcessExitCodeMapper;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* Tests for {@link SimpleSystemProcessExitCodeMapper}.
|
||||
|
||||
@@ -19,8 +19,8 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.step.tasklet.MethodInvokingTaskletAdapter;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobInterruptedException;
|
||||
@@ -18,7 +19,6 @@ import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.step.tasklet.SystemCommandException;
|
||||
import org.springframework.batch.core.step.tasklet.SystemCommandTasklet;
|
||||
import org.springframework.batch.core.step.tasklet.SystemProcessExitCodeMapper;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
@@ -54,7 +55,6 @@ import org.springframework.batch.item.ItemStreamException;
|
||||
import org.springframework.batch.item.ItemStreamSupport;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.item.support.ListItemReader;
|
||||
import org.springframework.batch.repeat.ExitStatus;
|
||||
import org.springframework.batch.repeat.policy.DefaultResultCompletionPolicy;
|
||||
import org.springframework.batch.repeat.policy.SimpleCompletionPolicy;
|
||||
import org.springframework.batch.repeat.support.RepeatTemplate;
|
||||
|
||||
Reference in New Issue
Block a user