BATCH-1915: Change minimum compiler level to 1.6 and use @Override everywhere
This commit is contained in:
@@ -25,6 +25,7 @@ public class JobExecutionExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobExecutionException(msg);
|
||||
}
|
||||
@@ -32,6 +33,7 @@ public class JobExecutionExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobExecutionException(msg, t);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public class JobInterruptedExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobInterruptedException(msg);
|
||||
}
|
||||
@@ -32,6 +33,7 @@ public class JobInterruptedExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new RuntimeException(msg, t);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class DuplicateJobExceptionTests extends AbstractExceptionTests {
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new DuplicateJobException(msg);
|
||||
}
|
||||
@@ -37,6 +38,7 @@ public class DuplicateJobExceptionTests extends AbstractExceptionTests {
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
|
||||
* java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new DuplicateJobException(msg, t);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class ApplicationContextJobFactoryTests {
|
||||
}
|
||||
|
||||
private static class StubApplicationContextFactory implements ApplicationContextFactory {
|
||||
@Override
|
||||
public ConfigurableApplicationContext createApplicationContext() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
context.registerSingleton("job", JobSupport.class);
|
||||
@@ -36,6 +37,7 @@ public class ApplicationContextJobFactoryTests {
|
||||
}
|
||||
|
||||
private static class PostProcessingApplicationContextFactory implements ApplicationContextFactory {
|
||||
@Override
|
||||
public ConfigurableApplicationContext createApplicationContext() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
context.registerSingleton("job", JobSupport.class);
|
||||
@@ -48,6 +50,7 @@ public class ApplicationContextJobFactoryTests {
|
||||
|
||||
private static class TestBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof JobSupport) {
|
||||
((JobSupport) bean).setName("bar");
|
||||
@@ -55,6 +58,7 @@ public class ApplicationContextJobFactoryTests {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@@ -40,10 +40,12 @@ public class JobFactoryRegistrationListenerTests {
|
||||
public void testBind() throws Exception {
|
||||
listener.setJobRegistry(registry);
|
||||
listener.bind(new JobFactory() {
|
||||
@Override
|
||||
public Job createJob() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJobName() {
|
||||
return "foo";
|
||||
}
|
||||
@@ -60,10 +62,12 @@ public class JobFactoryRegistrationListenerTests {
|
||||
public void testUnbind() throws Exception {
|
||||
testBind();
|
||||
listener.unbind(new JobFactory() {
|
||||
@Override
|
||||
public Job createJob() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJobName() {
|
||||
return "foo";
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public class DecisionJobParserTests {
|
||||
}
|
||||
|
||||
public static class TestDecider implements JobExecutionDecider {
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
return new FlowExecutionStatus("FOO");
|
||||
}
|
||||
|
||||
@@ -10,18 +10,22 @@ import org.springframework.batch.repeat.RepeatStatus;
|
||||
*/
|
||||
public class DummyCompletionPolicy implements CompletionPolicy {
|
||||
|
||||
@Override
|
||||
public boolean isComplete(RepeatContext context, RepeatStatus result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(RepeatContext context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepeatContext start(RepeatContext parent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(RepeatContext context) {
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.springframework.batch.item.ItemProcessor;
|
||||
*/
|
||||
public class DummyItemProcessor implements ItemProcessor<Object,Object> {
|
||||
|
||||
@Override
|
||||
public Object process(Object item) throws Exception {
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.springframework.batch.item.UnexpectedInputException;
|
||||
*/
|
||||
public class DummyItemReader implements ItemReader<Object> {
|
||||
|
||||
@Override
|
||||
public Object read() throws Exception, UnexpectedInputException, ParseException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.springframework.batch.item.ItemWriter;
|
||||
*/
|
||||
public class DummyItemWriter implements ItemWriter<Object> {
|
||||
|
||||
@Override
|
||||
public void write(List<? extends Object> items) throws Exception {
|
||||
}
|
||||
|
||||
|
||||
@@ -37,43 +37,54 @@ public class DummyJobRepository implements JobRepository, BeanNameAware {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JobExecution createJobExecution(String jobName, JobParameters jobParameters)
|
||||
throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStepExecutionCount(JobInstance jobInstance, String stepName) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(JobExecution jobExecution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExecutionContext(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateExecutionContext(JobExecution jobExecution) {
|
||||
}
|
||||
|
||||
|
||||
@@ -33,16 +33,20 @@ public class DummyPlatformTransactionManager implements PlatformTransactionManag
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit(TransactionStatus status) throws TransactionException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback(TransactionStatus status) throws TransactionException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,14 +10,17 @@ import org.springframework.retry.RetryListener;
|
||||
*/
|
||||
public class DummyRetryListener implements RetryListener {
|
||||
|
||||
@Override
|
||||
public <T> boolean open(RetryContext context, RetryCallback<T> callback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void close(RetryContext context, RetryCallback<T> callback, Throwable throwable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void onError(RetryContext context, RetryCallback<T> callback, Throwable throwable) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,22 +28,27 @@ public class DummyStep implements Step, BeanNameAware {
|
||||
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
System.out.println("EXECUTING " + getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartLimit() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowStartIfComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.batch.repeat.RepeatStatus;
|
||||
*/
|
||||
public class DummyTasklet implements Tasklet {
|
||||
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.batch.repeat.RepeatStatus;
|
||||
*/
|
||||
public class FailingTasklet extends NameStoringTasklet {
|
||||
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
super.execute(contribution, chunkContext);
|
||||
throw new RuntimeException();
|
||||
|
||||
@@ -137,6 +137,7 @@ public class FlowStepParserTests {
|
||||
|
||||
int count = 0;
|
||||
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
if (count++ < 2) {
|
||||
return new FlowExecutionStatus("OK");
|
||||
|
||||
@@ -31,6 +31,7 @@ public class InterruptibleTasklet extends NameStoringTasklet {
|
||||
|
||||
private volatile boolean started = false;
|
||||
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
if (!started) {
|
||||
super.execute(contribution, chunkContext);
|
||||
|
||||
@@ -42,6 +42,7 @@ public class JobRegistryJobParserTests implements ApplicationContextAware {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@@ -35,10 +35,12 @@ public class NameStoringTasklet extends StepExecutionListenerSupport implements
|
||||
private String stepName = null;
|
||||
private List<String> stepNamesList = null;
|
||||
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
stepName = stepExecution.getStepName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
if (stepNamesList != null) {
|
||||
stepNamesList.add(stepName);
|
||||
|
||||
@@ -88,6 +88,7 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
|
||||
private List<String> savedStepNames = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
@@ -229,6 +230,7 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
|
||||
public static class CustomPartitionHandler implements PartitionHandler {
|
||||
|
||||
@Override
|
||||
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
|
||||
throws Exception {
|
||||
return Arrays.asList(stepExecution);
|
||||
@@ -238,6 +240,7 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
|
||||
public static class CustomStepExecutionAggregator implements StepExecutionAggregator {
|
||||
|
||||
@Override
|
||||
public void aggregate(StepExecution result, Collection<StepExecution> executions) {
|
||||
result.getJobExecution().getExecutionContext().put("foo", "bar");
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ public class PartitionStepWithFlowParserTests {
|
||||
public static class Decider implements JobExecutionDecider {
|
||||
|
||||
int count = 0;
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
if (count++<2) {
|
||||
return new FlowExecutionStatus("OK");
|
||||
|
||||
@@ -40,6 +40,7 @@ public class SplitInterruptedJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
final JobExecution jobExecution = createJobExecution();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
job.execute(jobExecution);
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ public class StopJobParserTests extends AbstractJobParserTests {
|
||||
}
|
||||
|
||||
public static class TestDecider implements JobExecutionDecider {
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
return new FlowExecutionStatus("FOO");
|
||||
}
|
||||
|
||||
@@ -6,10 +6,12 @@ import org.springframework.batch.core.StepExecutionListener;
|
||||
|
||||
public class TestCustomStatusListener extends AbstractTestComponent implements StepExecutionListener {
|
||||
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
return new ExitStatus("FOO").and(stepExecution.getExitStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
executed = true;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.springframework.batch.core.JobParametersIncrementer;
|
||||
|
||||
public class TestIncrementer implements JobParametersIncrementer{
|
||||
|
||||
@Override
|
||||
public JobParameters getNext(JobParameters parameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.springframework.batch.core.annotation.AfterRead;
|
||||
|
||||
public class TestListener extends AbstractTestComponent implements StepExecutionListener {
|
||||
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
return null;
|
||||
}
|
||||
@@ -16,6 +17,7 @@ public class TestListener extends AbstractTestComponent implements StepExecution
|
||||
return stepExecution.getExitStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
executed = true;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.springframework.batch.item.ItemProcessor;
|
||||
|
||||
public class TestProcessor extends AbstractTestComponent implements ItemProcessor<String, String>{
|
||||
|
||||
@Override
|
||||
public String process(String item) throws Exception {
|
||||
executed = true;
|
||||
return item;
|
||||
|
||||
@@ -32,6 +32,7 @@ public class TestReader extends AbstractTestComponent implements ItemReader<Stri
|
||||
this.opened = opened;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read() throws Exception, UnexpectedInputException, ParseException {
|
||||
executed = true;
|
||||
synchronized (items) {
|
||||
@@ -43,13 +44,16 @@ public class TestReader extends AbstractTestComponent implements ItemReader<Stri
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws ItemStreamException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(ExecutionContext executionContext) throws ItemStreamException {
|
||||
opened = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ExecutionContext executionContext) throws ItemStreamException {
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,17 @@ import org.springframework.retry.RetryListener;
|
||||
|
||||
public class TestRetryListener extends AbstractTestComponent implements RetryListener {
|
||||
|
||||
@Override
|
||||
public <T> void close(RetryContext context, RetryCallback<T> callback,
|
||||
Throwable throwable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void onError(RetryContext context, RetryCallback<T> callback,
|
||||
Throwable throwable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> boolean open(RetryContext context, RetryCallback<T> callback) {
|
||||
executed = true;
|
||||
return true;
|
||||
|
||||
@@ -9,6 +9,7 @@ public class TestTasklet extends AbstractTestComponent implements Tasklet {
|
||||
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution,
|
||||
ChunkContext chunkContext) throws Exception {
|
||||
executed = true;
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.springframework.batch.item.ItemWriter;
|
||||
|
||||
public class TestWriter extends AbstractTestComponent implements ItemWriter<String> {
|
||||
|
||||
@Override
|
||||
public void write(List<? extends String> items) throws Exception {
|
||||
executed = true;
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ public class MapJobExplorerIntegrationTests {
|
||||
SimpleJob job = new SimpleJob("job");
|
||||
TaskletStep step = new TaskletStep("step");
|
||||
step.setTasklet(new Tasklet() {
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
while (block) {
|
||||
Thread.sleep(100L);
|
||||
|
||||
@@ -158,6 +158,7 @@ public class ExtendedAbstractJobTests {
|
||||
setName("StubStep");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
stepExecution.getJobExecution().getExecutionContext().put(key, value);
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator {
|
||||
*
|
||||
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
if (this.name == null) {
|
||||
this.name = name;
|
||||
@@ -101,6 +102,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator {
|
||||
*
|
||||
* @see org.springframework.batch.core.domain.IJob#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -145,6 +147,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator {
|
||||
*
|
||||
* @see org.springframework.batch.core.domain.IJob#isRestartable()
|
||||
*/
|
||||
@Override
|
||||
public boolean isRestartable() {
|
||||
return restartable;
|
||||
}
|
||||
@@ -156,11 +159,13 @@ public class JobSupport implements BeanNameAware, Job, StepLocator {
|
||||
* org.springframework.batch.core.domain.Job#run(org.springframework.batch
|
||||
* .core.domain.JobExecution)
|
||||
*/
|
||||
@Override
|
||||
public void execute(JobExecution execution) throws UnexpectedJobExecutionException {
|
||||
throw new UnsupportedOperationException(
|
||||
"JobSupport does not provide an implementation of execute(). Use a smarter subclass.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]";
|
||||
}
|
||||
@@ -170,18 +175,22 @@ public class JobSupport implements BeanNameAware, Job, StepLocator {
|
||||
*
|
||||
* @see org.springframework.batch.core.Job#getJobParametersIncrementer()
|
||||
*/
|
||||
@Override
|
||||
public JobParametersIncrementer getJobParametersIncrementer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JobParametersValidator getJobParametersValidator() {
|
||||
return jobParametersValidator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getStepNames() {
|
||||
return steps.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Step getStep(String stepName) throws NoSuchStepException {
|
||||
final Step step = steps.get(stepName);
|
||||
if (step == null) {
|
||||
|
||||
@@ -110,12 +110,14 @@ public class SimpleJobTests {
|
||||
|
||||
step1 = new StubStep("TestStep1", jobRepository);
|
||||
step1.setCallback(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("default");
|
||||
}
|
||||
});
|
||||
step2 = new StubStep("TestStep2", jobRepository);
|
||||
step2.setCallback(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("default");
|
||||
}
|
||||
@@ -173,18 +175,22 @@ public class SimpleJobTests {
|
||||
|
||||
Step testStep = new Step() {
|
||||
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
stepExecution.setExitStatus(customStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowStartIfComplete() {
|
||||
return false;
|
||||
}
|
||||
@@ -213,10 +219,12 @@ public class SimpleJobTests {
|
||||
@Test
|
||||
public void testRunNormallyWithListener() throws Exception {
|
||||
job.setJobExecutionListeners(new JobExecutionListenerSupport[] { new JobExecutionListenerSupport() {
|
||||
@Override
|
||||
public void beforeJob(JobExecution jobExecution) {
|
||||
list.add("before");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("after");
|
||||
}
|
||||
@@ -291,6 +299,7 @@ public class SimpleJobTests {
|
||||
@Test
|
||||
public void testFailedWithListener() throws Exception {
|
||||
job.setJobExecutionListeners(new JobExecutionListenerSupport[] { new JobExecutionListenerSupport() {
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("afterJob");
|
||||
}
|
||||
@@ -478,6 +487,7 @@ public class SimpleJobTests {
|
||||
|
||||
step1 = new StubStep("interruptStep", jobRepository) {
|
||||
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException,
|
||||
UnexpectedJobExecutionException {
|
||||
stepExecution.getJobExecution().stop();
|
||||
@@ -574,6 +584,7 @@ public class SimpleJobTests {
|
||||
* @seeorg.springframework.batch.core.step.StepSupport#execute(org.
|
||||
* springframework.batch.core.StepExecution)
|
||||
*/
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException,
|
||||
UnexpectedJobExecutionException {
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ public class SimpleStepHandlerTests {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
stepExecution.setStatus(BatchStatus.COMPLETED);
|
||||
stepExecution.setExitStatus(ExitStatus.COMPLETED);
|
||||
|
||||
@@ -143,6 +143,7 @@ public class FlowJobBuilderTests {
|
||||
public void testBuildDecision() throws Exception {
|
||||
JobExecutionDecider decider = new JobExecutionDecider() {
|
||||
private int count = 0;
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
count++;
|
||||
return count<2 ? new FlowExecutionStatus("ONGOING") : FlowExecutionStatus.COMPLETED;
|
||||
|
||||
@@ -450,6 +450,7 @@ public class FlowJobTests {
|
||||
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
JobExecutionDecider decider = new JobExecutionDecider() {
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
assertNotNull(stepExecution);
|
||||
return new FlowExecutionStatus("SWITCH");
|
||||
@@ -490,6 +491,7 @@ public class FlowJobTests {
|
||||
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
JobExecutionDecider decider = new JobExecutionDecider() {
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
assertNotNull(stepExecution);
|
||||
throw new RuntimeException("Foo");
|
||||
@@ -675,6 +677,7 @@ public class FlowJobTests {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
stepExecution.setStatus(BatchStatus.COMPLETED);
|
||||
stepExecution.setExitStatus(ExitStatus.COMPLETED);
|
||||
|
||||
@@ -179,6 +179,7 @@ public class FlowStepTests {
|
||||
this.fail = fail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
BatchStatus status = BatchStatus.COMPLETED;
|
||||
ExitStatus exitStatus = ExitStatus.COMPLETED;
|
||||
|
||||
@@ -46,6 +46,7 @@ public class StateSupport extends AbstractState {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEndState() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -32,32 +32,40 @@ import org.springframework.batch.core.repository.JobRestartException;
|
||||
*/
|
||||
public class JobFlowExecutorSupport implements FlowExecutor {
|
||||
|
||||
@Override
|
||||
public String executeStep(Step step) throws JobInterruptedException, JobRestartException,
|
||||
StartLimitExceededException {
|
||||
return ExitStatus.COMPLETED.getExitCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JobExecution getJobExecution() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StepExecution getStepExecution() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(FlowExecution result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abandonStepExecution() {
|
||||
}
|
||||
|
||||
public void updateJobExecutionStatus(FlowExecutionStatus status) {
|
||||
@Override
|
||||
public void updateJobExecutionStatus(FlowExecutionStatus status) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRestart() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addExitStatus(String code) {
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class EmptyItemWriter<T> implements ItemWriter<T>, InitializingBean {
|
||||
|
||||
List<Object> list;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
list = TransactionAwareProxyFactory.createTransactionalList();
|
||||
}
|
||||
@@ -47,6 +48,7 @@ public class EmptyItemWriter<T> implements ItemWriter<T>, InitializingBean {
|
||||
this.failurePoint = failurePoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(List<? extends T> items) {
|
||||
for (T data : items) {
|
||||
if (!failed && list.size() == failurePoint) {
|
||||
|
||||
@@ -26,6 +26,7 @@ public class JobExecutionNotFailedExceptionTests extends AbstractExceptionTests
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobExecutionNotFailedException(msg);
|
||||
}
|
||||
@@ -33,6 +34,7 @@ public class JobExecutionNotFailedExceptionTests extends AbstractExceptionTests
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobExecutionNotFailedException(msg, t);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class JobInstanceAlreadyExistsExceptionTests extends AbstractExceptionTes
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobInstanceAlreadyExistsException(msg);
|
||||
}
|
||||
@@ -34,6 +35,7 @@ public class JobInstanceAlreadyExistsExceptionTests extends AbstractExceptionTes
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobInstanceAlreadyExistsException(msg, t);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public class JobParametersNotFoundExceptionTests extends AbstractExceptionTests
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobParametersNotFoundException(msg);
|
||||
}
|
||||
@@ -33,6 +34,7 @@ public class JobParametersNotFoundExceptionTests extends AbstractExceptionTests
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobParametersNotFoundException(msg, t);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class NoSuchJobExceptionTests extends AbstractExceptionTests {
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new NoSuchJobException(msg);
|
||||
}
|
||||
@@ -37,6 +38,7 @@ public class NoSuchJobExceptionTests extends AbstractExceptionTests {
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
|
||||
* java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new NoSuchJobException(msg, t);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class NoSuchJobExecutionExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new NoSuchJobExecutionException(msg);
|
||||
}
|
||||
@@ -34,6 +35,7 @@ public class NoSuchJobExecutionExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new NoSuchJobExecutionException(msg, t);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class NoSuchJobInstanceExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new NoSuchJobInstanceException(msg);
|
||||
}
|
||||
@@ -34,6 +35,7 @@ public class NoSuchJobInstanceExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new NoSuchJobInstanceException(msg, t);
|
||||
}
|
||||
|
||||
@@ -162,6 +162,7 @@ public class SimpleJobLauncherTests {
|
||||
public void testTaskExecutor() throws Exception {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
jobLauncher.setTaskExecutor(new TaskExecutor() {
|
||||
@Override
|
||||
public void execute(Runnable task) {
|
||||
list.add("execute");
|
||||
task.run();
|
||||
@@ -176,6 +177,7 @@ public class SimpleJobLauncherTests {
|
||||
|
||||
final List<String> list = new ArrayList<String>();
|
||||
jobLauncher.setTaskExecutor(new TaskExecutor() {
|
||||
@Override
|
||||
public void execute(Runnable task) {
|
||||
list.add("execute");
|
||||
throw new TaskRejectedException("Planned failure");
|
||||
@@ -207,6 +209,7 @@ public class SimpleJobLauncherTests {
|
||||
@Test
|
||||
public void testRunWithException() throws Exception {
|
||||
job = new JobSupport() {
|
||||
@Override
|
||||
public void execute(JobExecution execution) {
|
||||
execution.setExitStatus(ExitStatus.FAILED);
|
||||
throw new RuntimeException("foo");
|
||||
@@ -224,6 +227,7 @@ public class SimpleJobLauncherTests {
|
||||
@Test
|
||||
public void testRunWithError() throws Exception {
|
||||
job = new JobSupport() {
|
||||
@Override
|
||||
public void execute(JobExecution execution) {
|
||||
execution.setExitStatus(ExitStatus.FAILED);
|
||||
throw new Error("foo");
|
||||
@@ -278,4 +282,4 @@ public class SimpleJobLauncherTests {
|
||||
private boolean contains(String str, String searchStr) {
|
||||
return str.indexOf(searchStr) != -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ public class CommandLineJobRunnerTests {
|
||||
StubJobLauncher.jobExecution = jobExecution;
|
||||
stdin = System.in;
|
||||
System.setIn(new InputStream() {
|
||||
@Override
|
||||
public int read() {
|
||||
return -1;
|
||||
}
|
||||
@@ -140,10 +141,12 @@ public class CommandLineJobRunnerTests {
|
||||
@Test
|
||||
public void testWithInvalidStdin() throws Throwable {
|
||||
System.setIn(new InputStream() {
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
throw new IOException("Planned");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return -1;
|
||||
}
|
||||
@@ -160,10 +163,12 @@ public class CommandLineJobRunnerTests {
|
||||
|
||||
int index = 0;
|
||||
|
||||
@Override
|
||||
public int available() {
|
||||
return input.length - index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return index<input.length-1 ? (int) input[index++] : -1;
|
||||
}
|
||||
@@ -181,10 +186,12 @@ public class CommandLineJobRunnerTests {
|
||||
|
||||
int index = 0;
|
||||
|
||||
@Override
|
||||
public int available() {
|
||||
return input.length - index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return index<input.length-1 ? (int) input[index++] : -1;
|
||||
}
|
||||
@@ -356,6 +363,7 @@ public class CommandLineJobRunnerTests {
|
||||
|
||||
private static int status;
|
||||
|
||||
@Override
|
||||
public void exit(int status) {
|
||||
StubSystemExiter.status = status;
|
||||
}
|
||||
@@ -375,6 +383,7 @@ public class CommandLineJobRunnerTests {
|
||||
|
||||
private static boolean destroyed = false;
|
||||
|
||||
@Override
|
||||
public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException {
|
||||
|
||||
StubJobLauncher.jobParameters = jobParameters;
|
||||
@@ -407,10 +416,12 @@ public class CommandLineJobRunnerTests {
|
||||
|
||||
static JobExecution jobExecution;
|
||||
|
||||
@Override
|
||||
public Set<JobExecution> findRunningJobExecutions(String jobName) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JobExecution getJobExecution(Long executionId) {
|
||||
if (jobExecution != null) {
|
||||
return jobExecution;
|
||||
@@ -418,6 +429,7 @@ public class CommandLineJobRunnerTests {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JobExecution> getJobExecutions(JobInstance jobInstance) {
|
||||
if (jobInstance.getId() == 0) {
|
||||
return Arrays.asList(createJobExecution(jobInstance, BatchStatus.FAILED));
|
||||
@@ -451,10 +463,12 @@ public class CommandLineJobRunnerTests {
|
||||
return jobExecution;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JobInstance getJobInstance(Long instanceId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JobInstance> getJobInstances(String jobName, int start, int count) {
|
||||
if (jobInstances == null) {
|
||||
return new ArrayList<JobInstance>();
|
||||
@@ -464,10 +478,12 @@ public class CommandLineJobRunnerTests {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StepExecution getStepExecution(Long jobExecutionId, Long stepExecutionId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getJobNames() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -480,11 +496,13 @@ public class CommandLineJobRunnerTests {
|
||||
|
||||
static boolean called = false;
|
||||
|
||||
@Override
|
||||
public JobParameters getJobParameters(Properties properties) {
|
||||
called = true;
|
||||
return delegate.getJobParameters(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties getProperties(JobParameters params) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public class ScheduledJobParametersFactoryTests extends TestCase {
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ public class SimpleJobOperatorTests {
|
||||
@Override
|
||||
public JobParametersIncrementer getJobParametersIncrementer() {
|
||||
return new JobParametersIncrementer() {
|
||||
@Override
|
||||
public JobParameters getNext(JobParameters parameters) {
|
||||
return jobParameters;
|
||||
}
|
||||
@@ -93,6 +94,7 @@ public class SimpleJobOperatorTests {
|
||||
jobOperator = new SimpleJobOperator();
|
||||
|
||||
jobOperator.setJobRegistry(new MapJobRegistry() {
|
||||
@Override
|
||||
public Job getJob(String name) throws NoSuchJobException {
|
||||
if (name.equals("foo")) {
|
||||
return job;
|
||||
@@ -107,6 +109,7 @@ public class SimpleJobOperatorTests {
|
||||
});
|
||||
|
||||
jobOperator.setJobLauncher(new JobLauncher() {
|
||||
@Override
|
||||
public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException,
|
||||
JobRestartException, JobInstanceAlreadyCompleteException {
|
||||
return new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 999L);
|
||||
|
||||
@@ -30,6 +30,7 @@ public class SimpleJvmExitCodeMapperTests extends TestCase {
|
||||
private SimpleJvmExitCodeMapper ecm;
|
||||
private SimpleJvmExitCodeMapper ecm2;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
ecm = new SimpleJvmExitCodeMapper();
|
||||
Map<String, Integer> ecmMap = new HashMap<String, Integer>();
|
||||
@@ -45,6 +46,7 @@ public class SimpleJvmExitCodeMapperTests extends TestCase {
|
||||
ecm2.setMapping(ecm2Map);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public class StubJobLauncher implements JobLauncher {
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JobExecution run(Job job, JobParameters jobParameters)
|
||||
throws JobExecutionAlreadyRunningException {
|
||||
lastRunCalled = RUN_JOB_IDENTIFIER;
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.springframework.batch.core.JobParametersIncrementer;
|
||||
|
||||
public class TestJobParametersIncrementer implements JobParametersIncrementer {
|
||||
|
||||
@Override
|
||||
public JobParameters getNext(JobParameters parameters) {
|
||||
return new JobParametersBuilder().addString("foo", "spam").toJobParameters();
|
||||
}
|
||||
|
||||
@@ -40,10 +40,12 @@ public class CompositeJobExecutionListenerTests extends TestCase {
|
||||
*/
|
||||
public void testSetListeners() {
|
||||
listener.setListeners(Arrays.asList(new JobExecutionListenerSupport() {
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("fail");
|
||||
}
|
||||
}, new JobExecutionListenerSupport() {
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("continue");
|
||||
}
|
||||
@@ -59,6 +61,7 @@ public class CompositeJobExecutionListenerTests extends TestCase {
|
||||
*/
|
||||
public void testSetListener() {
|
||||
listener.register(new JobExecutionListenerSupport() {
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("fail");
|
||||
}
|
||||
@@ -74,6 +77,7 @@ public class CompositeJobExecutionListenerTests extends TestCase {
|
||||
*/
|
||||
public void testOpen() {
|
||||
listener.register(new JobExecutionListenerSupport() {
|
||||
@Override
|
||||
public void beforeJob(JobExecution stepExecution) {
|
||||
list.add("foo");
|
||||
}
|
||||
|
||||
@@ -41,11 +41,13 @@ public class CompositeStepExecutionListenerTests extends TestCase {
|
||||
*/
|
||||
public void testSetListeners() {
|
||||
listener.setListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() {
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
list.add("fail");
|
||||
return ExitStatus.FAILED;
|
||||
}
|
||||
}, new StepExecutionListenerSupport() {
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
list.add("continue");
|
||||
return ExitStatus.EXECUTING;
|
||||
@@ -62,6 +64,7 @@ public class CompositeStepExecutionListenerTests extends TestCase {
|
||||
*/
|
||||
public void testSetListener() {
|
||||
listener.register(new StepExecutionListenerSupport() {
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
list.add("fail");
|
||||
return ExitStatus.FAILED;
|
||||
@@ -78,6 +81,7 @@ public class CompositeStepExecutionListenerTests extends TestCase {
|
||||
*/
|
||||
public void testOpen() {
|
||||
listener.register(new StepExecutionListenerSupport() {
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
list.add("foo");
|
||||
}
|
||||
|
||||
@@ -125,6 +125,7 @@ public class JobListenerFactoryBeanTests {
|
||||
public void foo(JobExecution execution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 3;
|
||||
}
|
||||
@@ -242,10 +243,12 @@ public class JobListenerFactoryBeanTests {
|
||||
|
||||
boolean afterJobCalled = false;
|
||||
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
afterJobCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeJob(JobExecution jobExecution) {
|
||||
beforeJobCalled = true;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ public class OrderedCompositeTests {
|
||||
public void testAddOrdered() {
|
||||
list.setItems(Arrays.asList((Object) "1"));
|
||||
list.add(new Ordered() {
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
@@ -75,11 +76,13 @@ public class OrderedCompositeTests {
|
||||
public void testAddMultipleOrdered() {
|
||||
list.setItems(Arrays.asList((Object) "1"));
|
||||
list.add(new Ordered() {
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
list.add(new Ordered() {
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
@@ -94,11 +97,13 @@ public class OrderedCompositeTests {
|
||||
public void testAddDuplicateOrdered() {
|
||||
list.setItems(Arrays.asList((Object) "1"));
|
||||
list.add(new Ordered() {
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
list.add(new Ordered() {
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
}
|
||||
@@ -112,6 +117,7 @@ public class OrderedCompositeTests {
|
||||
@Test
|
||||
public void testAddAnnotationOrdered() {
|
||||
list.add(new Ordered() {
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -191,6 +191,7 @@ public class StepListenerFactoryBeanTests {
|
||||
public void foo(StepExecution execution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 3;
|
||||
}
|
||||
@@ -208,6 +209,7 @@ public class StepListenerFactoryBeanTests {
|
||||
public void foo(StepExecution execution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
}
|
||||
};
|
||||
@@ -236,6 +238,7 @@ public class StepListenerFactoryBeanTests {
|
||||
ProxyFactory factory = new ProxyFactory();
|
||||
factory.addInterface(DataSource.class);
|
||||
factory.addAdvice(new MethodInterceptor() {
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
return null;
|
||||
}
|
||||
@@ -252,6 +255,7 @@ public class StepListenerFactoryBeanTests {
|
||||
public void foo(StepExecution execution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
}
|
||||
};
|
||||
@@ -377,6 +381,7 @@ public class StepListenerFactoryBeanTests {
|
||||
|
||||
int callcount = 0;
|
||||
|
||||
@Override
|
||||
@AfterStep
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
Assert.notNull(stepExecution);
|
||||
@@ -384,6 +389,7 @@ public class StepListenerFactoryBeanTests {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
callcount++;
|
||||
}
|
||||
@@ -395,12 +401,14 @@ public class StepListenerFactoryBeanTests {
|
||||
|
||||
int callcount = 0;
|
||||
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
Assert.notNull(stepExecution);
|
||||
callcount++;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
callcount++;
|
||||
}
|
||||
@@ -515,14 +523,17 @@ public class StepListenerFactoryBeanTests {
|
||||
onWriteErrorCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSkipInProcess(String item, Throwable t) {
|
||||
onSkipInProcessCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSkipInRead(Throwable t) {
|
||||
onSkipInReadCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSkipInWrite(Integer item, Throwable t) {
|
||||
onSkipInWriteCalled = true;
|
||||
}
|
||||
|
||||
@@ -103,25 +103,30 @@ public class StepListenerMethodInterceptorTests {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Method getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getArguments() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessibleObject getStaticPart() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getThis() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object proceed() throws Throwable {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public class ExampleItemReader implements ItemReader<String>, ItemStream {
|
||||
/**
|
||||
* Reads next record from input
|
||||
*/
|
||||
@Override
|
||||
public String read() throws Exception {
|
||||
if (index >= input.length || index >= max) {
|
||||
return null;
|
||||
@@ -61,13 +62,16 @@ public class ExampleItemReader implements ItemReader<String>, ItemStream {
|
||||
return input[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws ItemStreamException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(ExecutionContext executionContext) throws ItemStreamException {
|
||||
index = (int) executionContext.getLong("POSITION", min);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ExecutionContext executionContext) throws ItemStreamException {
|
||||
executionContext.putLong("POSITION", index);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class ExampleItemWriter implements ItemWriter<String> {
|
||||
/**
|
||||
* @see ItemWriter#write(List)
|
||||
*/
|
||||
@Override
|
||||
public void write(List<? extends String> data) throws Exception {
|
||||
log.info(data);
|
||||
items.addAll(data);
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.batch.item.ExecutionContext;
|
||||
*/
|
||||
public class MinMaxPartitioner extends SimplePartitioner {
|
||||
|
||||
@Override
|
||||
public Map<String, ExecutionContext> partition(int gridSize) {
|
||||
Map<String, ExecutionContext> partition = super.partition(gridSize);
|
||||
int total = 8; // The number of items in the ExampleItemReader
|
||||
|
||||
@@ -57,6 +57,7 @@ public class PartitionStepTests {
|
||||
public void testVanillaStepExecution() throws Exception {
|
||||
step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner()));
|
||||
step.setPartitionHandler(new PartitionHandler() {
|
||||
@Override
|
||||
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
|
||||
throws Exception {
|
||||
Set<StepExecution> executions = stepSplitter.split(stepExecution, 2);
|
||||
@@ -81,6 +82,7 @@ public class PartitionStepTests {
|
||||
public void testFailedStepExecution() throws Exception {
|
||||
step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner()));
|
||||
step.setPartitionHandler(new PartitionHandler() {
|
||||
@Override
|
||||
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
|
||||
throws Exception {
|
||||
Set<StepExecution> executions = stepSplitter.split(stepExecution, 2);
|
||||
@@ -106,6 +108,7 @@ public class PartitionStepTests {
|
||||
final AtomicBoolean started = new AtomicBoolean(false);
|
||||
step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner()));
|
||||
step.setPartitionHandler(new PartitionHandler() {
|
||||
@Override
|
||||
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
|
||||
throws Exception {
|
||||
Set<StepExecution> executions = stepSplitter.split(stepExecution, 2);
|
||||
@@ -152,6 +155,7 @@ public class PartitionStepTests {
|
||||
public void testStoppedStepExecution() throws Exception {
|
||||
step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner()));
|
||||
step.setPartitionHandler(new PartitionHandler() {
|
||||
@Override
|
||||
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
|
||||
throws Exception {
|
||||
Set<StepExecution> executions = stepSplitter.split(stepExecution, 2);
|
||||
@@ -183,6 +187,7 @@ public class PartitionStepTests {
|
||||
});
|
||||
step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner()));
|
||||
step.setPartitionHandler(new PartitionHandler() {
|
||||
@Override
|
||||
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
|
||||
throws Exception {
|
||||
return Arrays.asList(stepExecution);
|
||||
|
||||
@@ -59,6 +59,7 @@ public class SimpleStepExecutionSplitterTests {
|
||||
final Map<String, ExecutionContext> map = Collections.singletonMap("foo", new ExecutionContext());
|
||||
SimpleStepExecutionSplitter splitter = new SimpleStepExecutionSplitter(jobRepository, true, step.getName(),
|
||||
new Partitioner() {
|
||||
@Override
|
||||
public Map<String, ExecutionContext> partition(int gridSize) {
|
||||
return map;
|
||||
}
|
||||
@@ -79,10 +80,12 @@ public class SimpleStepExecutionSplitterTests {
|
||||
@Test
|
||||
public void testRememberPartitionNames() throws Exception {
|
||||
class CustomPartitioner implements Partitioner, PartitionNameProvider {
|
||||
@Override
|
||||
public Map<String, ExecutionContext> partition(int gridSize) {
|
||||
return Collections.singletonMap("foo", new ExecutionContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getPartitionNames(int gridSize) {
|
||||
return Arrays.asList("foo");
|
||||
}
|
||||
|
||||
@@ -34,10 +34,12 @@ public class TaskExecutorPartitionHandlerTests {
|
||||
|
||||
private StepExecutionSplitter stepExecutionSplitter = new StepExecutionSplitter() {
|
||||
|
||||
@Override
|
||||
public String getStepName() {
|
||||
return stepExecution.getStepName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<StepExecution> split(StepExecution stepExecution, int gridSize) throws JobExecutionException {
|
||||
HashSet<StepExecution> result = new HashSet<StepExecution>();
|
||||
for (int i = gridSize; i-- > 0;) {
|
||||
@@ -92,6 +94,7 @@ public class TaskExecutorPartitionHandlerTests {
|
||||
public void testTaskExecutorFailure() throws Exception {
|
||||
handler.setGridSize(2);
|
||||
handler.setTaskExecutor(new TaskExecutor() {
|
||||
@Override
|
||||
public void execute(Runnable task) {
|
||||
if (count > 0) {
|
||||
throw new TaskRejectedException("foo");
|
||||
|
||||
@@ -26,6 +26,7 @@ public class JobExecutionAlreadyRunningExceptionTests extends AbstractExceptionT
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobExecutionAlreadyRunningException(msg);
|
||||
}
|
||||
@@ -33,6 +34,7 @@ public class JobExecutionAlreadyRunningExceptionTests extends AbstractExceptionT
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobExecutionAlreadyRunningException(msg, t);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public class JobInstanceAlreadyCompleteExceptionTests extends AbstractExceptionT
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobInstanceAlreadyCompleteException(msg);
|
||||
}
|
||||
@@ -33,6 +34,7 @@ public class JobInstanceAlreadyCompleteExceptionTests extends AbstractExceptionT
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobInstanceAlreadyCompleteException(msg, t);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public class JobRestartExceptionTests extends AbstractExceptionTests {
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobRestartException(msg);
|
||||
}
|
||||
@@ -36,6 +37,7 @@ public class JobRestartExceptionTests extends AbstractExceptionTests {
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
|
||||
* java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobRestartException(msg, t);
|
||||
}
|
||||
|
||||
@@ -41,19 +41,23 @@ public class JdbcJobDaoQueryTests extends TestCase {
|
||||
* (non-Javadoc)
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
jobExecutionDao = new JdbcJobExecutionDao();
|
||||
jobExecutionDao.setJobExecutionIncrementer(new DataFieldMaxValueIncrementer() {
|
||||
|
||||
@Override
|
||||
public int nextIntValue() throws DataAccessException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long nextLongValue() throws DataAccessException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String nextStringValue() throws DataAccessException {
|
||||
return "bar";
|
||||
}
|
||||
@@ -64,6 +68,7 @@ public class JdbcJobDaoQueryTests extends TestCase {
|
||||
public void testTablePrefix() throws Exception {
|
||||
jobExecutionDao.setTablePrefix("FOO_");
|
||||
jobExecutionDao.setJdbcTemplate(new JdbcTemplate() {
|
||||
@Override
|
||||
public int update(String sql, Object[] args, int[] argTypes) throws DataAccessException {
|
||||
list.add(sql);
|
||||
return 1;
|
||||
|
||||
@@ -37,6 +37,7 @@ public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
|
||||
@Autowired
|
||||
private JobExecutionDao jobExecutionDao;
|
||||
|
||||
@Override
|
||||
protected JobInstanceDao getJobInstanceDao() {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "BATCH_JOB_EXECUTION_CONTEXT",
|
||||
"BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION",
|
||||
|
||||
@@ -15,10 +15,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@ContextConfiguration(locations = "sql-dao-test.xml")
|
||||
public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
|
||||
|
||||
@Override
|
||||
protected StepExecutionDao getStepExecutionDao() {
|
||||
return (StepExecutionDao) applicationContext.getBean("stepExecutionDao");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JobRepository getJobRepository() {
|
||||
deleteFromTables("BATCH_JOB_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION", "BATCH_JOB_EXECUTION",
|
||||
"BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE");
|
||||
|
||||
@@ -69,6 +69,7 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
|
||||
|
||||
// Implementation of the high-concurrency code
|
||||
final Runnable codeUnderTest = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
JobExecution jobExecution = new JobExecution(new JobInstance((long) -1, new JobParameters(), "mapJob"));
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.junit.runners.JUnit4;
|
||||
@RunWith(JUnit4.class)
|
||||
public class MapJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
|
||||
|
||||
@Override
|
||||
protected JobInstanceDao getJobInstanceDao() {
|
||||
return new MapJobInstanceDao();
|
||||
}
|
||||
|
||||
@@ -18,10 +18,12 @@ import org.springframework.batch.core.repository.support.SimpleJobRepository;
|
||||
@RunWith(JUnit4.class)
|
||||
public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
|
||||
|
||||
@Override
|
||||
protected StepExecutionDao getStepExecutionDao() {
|
||||
return new MapStepExecutionDao();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JobRepository getJobRepository() {
|
||||
return new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(), new MapStepExecutionDao(),
|
||||
new MapExecutionContextDao());
|
||||
|
||||
@@ -62,6 +62,7 @@ public class TablePrefixTests {
|
||||
|
||||
public static class TestTasklet implements Tasklet {
|
||||
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
return RepeatStatus.FINISHED;
|
||||
}
|
||||
|
||||
@@ -332,14 +332,17 @@ public class JobRepositoryFactoryBeanTests {
|
||||
|
||||
private static class StubIncrementer implements DataFieldMaxValueIncrementer {
|
||||
|
||||
@Override
|
||||
public int nextIntValue() throws DataAccessException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long nextLongValue() throws DataAccessException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String nextStringValue() throws DataAccessException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -58,10 +58,11 @@ public class SimpleJobRepositoryProxyTests {
|
||||
|
||||
private boolean invoked;
|
||||
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
invoked = true;
|
||||
return invocation.proceed();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public class Foo {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Foo[id=" +id +",name=" + name + ",value=" + value + "]";
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
public class FooRowMapper implements RowMapper {
|
||||
|
||||
@Override
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
|
||||
Foo foo = new Foo();
|
||||
|
||||
@@ -88,6 +88,7 @@ public class ListPreparedStatementSetterTests {
|
||||
final List<String> results = new ArrayList<String>();
|
||||
jdbcTemplate.query("SELECT NAME from T_FOOS where ID > ? and ID < ?", pss,
|
||||
new RowCallbackHandler() {
|
||||
@Override
|
||||
public void processRow(ResultSet rs) throws SQLException {
|
||||
results.add(rs.getString(1));
|
||||
}
|
||||
@@ -133,6 +134,7 @@ public class ListPreparedStatementSetterTests {
|
||||
public static class FooStoringItemWriter implements ItemWriter<Foo> {
|
||||
private List<Foo> foos = new ArrayList<Foo>();
|
||||
|
||||
@Override
|
||||
public void write(List<? extends Foo> items) throws Exception {
|
||||
foos.addAll(items);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ public class StepExecutionSimpleCompletionPolicyTests extends TestCase {
|
||||
* mock step context
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
JobParameters jobParameters = new JobParametersBuilder().addLong("commit.interval", 2L).toJobParameters();
|
||||
|
||||
@@ -45,6 +45,7 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware {
|
||||
|
||||
private int beanCount;
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||
}
|
||||
@@ -80,6 +81,7 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware {
|
||||
final String value = "foo" + i;
|
||||
final Long id = 123L + i;
|
||||
FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
StepExecution stepExecution = new StepExecution(value, new JobExecution(0L), id);
|
||||
ExecutionContext executionContext = stepExecution.getExecutionContext();
|
||||
@@ -119,6 +121,7 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
final String value = "foo" + i;
|
||||
FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
ExecutionContext executionContext = stepExecution.getExecutionContext();
|
||||
executionContext.put("foo", value);
|
||||
|
||||
@@ -13,6 +13,7 @@ public class JobStartupRunner implements InitializingBean {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
StepExecution stepExecution = new StepExecution("step", new JobExecution(1L), 0L);
|
||||
step.execute(stepExecution);
|
||||
|
||||
@@ -40,6 +40,7 @@ public class StepScopeClassIntegrationTests implements BeanFactoryAware {
|
||||
|
||||
private int beanCount;
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public class StepScopePerformanceTests implements ApplicationContextAware {
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext)
|
||||
throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
|
||||
@@ -61,6 +61,7 @@ public class StepScopePlaceholderIntegrationTests implements BeanFactoryAware {
|
||||
|
||||
private int beanCount;
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ public class StepScopeProxyTargetClassIntegrationTests implements BeanFactoryAwa
|
||||
|
||||
private int beanCount;
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ public class StepScopeTests {
|
||||
StepSynchronizationManager.close();
|
||||
try {
|
||||
scope.get("foo", new ObjectFactory() {
|
||||
@Override
|
||||
public Object getObject() throws BeansException {
|
||||
return foo;
|
||||
}
|
||||
@@ -80,6 +81,7 @@ public class StepScopeTests {
|
||||
public void testGetWithNothingAlreadyThere() {
|
||||
final String foo = "bar";
|
||||
Object value = scope.get("foo", new ObjectFactory() {
|
||||
@Override
|
||||
public Object getObject() throws BeansException {
|
||||
return foo;
|
||||
}
|
||||
@@ -92,6 +94,7 @@ public class StepScopeTests {
|
||||
public void testGetWithSomethingAlreadyThere() {
|
||||
context.setAttribute("foo", "bar");
|
||||
Object value = scope.get("foo", new ObjectFactory() {
|
||||
@Override
|
||||
public Object getObject() throws BeansException {
|
||||
return null;
|
||||
}
|
||||
@@ -105,6 +108,7 @@ public class StepScopeTests {
|
||||
context.setAttribute("foo", "bar");
|
||||
StepContext context = StepSynchronizationManager.register(new StepExecution("bar", new JobExecution(0L)));
|
||||
Object value = scope.get("foo", new ObjectFactory() {
|
||||
@Override
|
||||
public Object getObject() throws BeansException {
|
||||
return "spam";
|
||||
}
|
||||
@@ -133,6 +137,7 @@ public class StepScopeTests {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
context.setAttribute("foo", "bar");
|
||||
scope.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("foo");
|
||||
}
|
||||
@@ -149,11 +154,13 @@ public class StepScopeTests {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
context.setAttribute("foo", "bar");
|
||||
scope.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("foo");
|
||||
}
|
||||
});
|
||||
scope.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("bar");
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class TestCollaborator implements Collaborator, Serializable {
|
||||
|
||||
private List<String> list;
|
||||
|
||||
@Override
|
||||
public List<String> getList() {
|
||||
return list;
|
||||
}
|
||||
@@ -20,6 +21,7 @@ public class TestCollaborator implements Collaborator, Serializable {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collaborator getParent() {
|
||||
return parent;
|
||||
}
|
||||
@@ -28,6 +30,7 @@ public class TestCollaborator implements Collaborator, Serializable {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ public class TestDisposableCollaborator extends TestCollaborator implements Disp
|
||||
|
||||
public static volatile String message = "none";
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
message = (message.equals("none") ? "" : message + ",") + getName() + ":destroyed";
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ public class TestStep implements Step {
|
||||
context = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
context = StepSynchronizationManager.getContext();
|
||||
setContextFromCollaborator();
|
||||
@@ -42,14 +43,17 @@ public class TestStep implements Step {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "foo";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartLimit() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowStartIfComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ public class StepContextTests {
|
||||
public void testDestructionCallbackSunnyDay() throws Exception {
|
||||
context.setAttribute("foo", "FOO");
|
||||
context.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("bar");
|
||||
}
|
||||
@@ -93,6 +94,7 @@ public class StepContextTests {
|
||||
@Test
|
||||
public void testDestructionCallbackMissingAttribute() throws Exception {
|
||||
context.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("bar");
|
||||
}
|
||||
@@ -108,12 +110,14 @@ public class StepContextTests {
|
||||
context.setAttribute("foo", "FOO");
|
||||
context.setAttribute("bar", "BAR");
|
||||
context.registerDestructionCallback("bar", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("spam");
|
||||
throw new RuntimeException("fail!");
|
||||
}
|
||||
});
|
||||
context.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("bar");
|
||||
throw new RuntimeException("fail!");
|
||||
|
||||
@@ -45,6 +45,7 @@ public class StepSynchronizationManagerTests {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
StepContext context = StepSynchronizationManager.register(stepExecution);
|
||||
context.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("foo");
|
||||
}
|
||||
@@ -69,6 +70,7 @@ public class StepSynchronizationManagerTests {
|
||||
StepContext context = StepSynchronizationManager.register(stepExecution);
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(2);
|
||||
FutureTask<StepContext> task = new FutureTask<StepContext>(new Callable<StepContext>() {
|
||||
@Override
|
||||
public StepContext call() throws Exception {
|
||||
try {
|
||||
StepSynchronizationManager.register(stepExecution);
|
||||
@@ -93,6 +95,7 @@ public class StepSynchronizationManagerTests {
|
||||
StepContext context = StepSynchronizationManager.register(stepExecution);
|
||||
final List<String> list = new ArrayList<String>();
|
||||
context.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("foo");
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware {
|
||||
|
||||
private int beanCount;
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||
}
|
||||
@@ -79,6 +80,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
final String value = "foo" + i;
|
||||
FutureTask<String> task = new FutureTask<String>(new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
attributes.set(Collections.singletonMap("foo", value));
|
||||
try {
|
||||
@@ -105,6 +107,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware {
|
||||
|
||||
private Object root;
|
||||
|
||||
@Override
|
||||
public Object getContext() {
|
||||
return root;
|
||||
}
|
||||
@@ -129,6 +132,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware {
|
||||
|
||||
private Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ public class ContextFactorySupport implements ContextFactory {
|
||||
*
|
||||
* @see org.springframework.batch.core.scope.util.ContextFactory#getContext()
|
||||
*/
|
||||
@Override
|
||||
public Object getContext() {
|
||||
return this;
|
||||
}
|
||||
@@ -18,6 +19,7 @@ public class ContextFactorySupport implements ContextFactory {
|
||||
*
|
||||
* @see org.springframework.batch.core.scope.util.ContextFactory#getContextId()
|
||||
*/
|
||||
@Override
|
||||
public String getContextId() {
|
||||
return getContext()+"#"+(count ++);
|
||||
}
|
||||
|
||||
@@ -210,6 +210,7 @@ public class MultipleContextPlaceholderTargetSourceTests {
|
||||
|
||||
private Object root;
|
||||
|
||||
@Override
|
||||
public Object getContext() {
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public class PlaceholderTargetSourceCustomEditorTests extends ContextFactorySupp
|
||||
|
||||
private Date date = new Date(1L);
|
||||
|
||||
@Override
|
||||
public Object getContext() {
|
||||
return this;
|
||||
}
|
||||
@@ -48,6 +49,7 @@ public class PlaceholderTargetSourceCustomEditorTests extends ContextFactorySupp
|
||||
public Foo() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user