BATCH-1915: Reformatting
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -25,7 +25,7 @@ public class JobExecutionExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobExecutionException(msg);
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class JobExecutionExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobExecutionException(msg, t);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -25,7 +25,7 @@ public class JobInterruptedExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobInterruptedException(msg);
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class JobInterruptedExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new RuntimeException(msg, t);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -16,11 +16,10 @@
|
||||
package org.springframework.batch.core.configuration;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
import org.springframework.batch.core.configuration.DuplicateJobException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DuplicateJobExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
@@ -28,7 +27,7 @@ public class DuplicateJobExceptionTests extends AbstractExceptionTests {
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new DuplicateJobException(msg);
|
||||
}
|
||||
@@ -38,7 +37,7 @@ public class DuplicateJobExceptionTests extends AbstractExceptionTests {
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
|
||||
* java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new DuplicateJobException(msg, t);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ApplicationContextJobFactoryTests {
|
||||
}
|
||||
|
||||
private static class StubApplicationContextFactory implements ApplicationContextFactory {
|
||||
@Override
|
||||
@Override
|
||||
public ConfigurableApplicationContext createApplicationContext() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
context.registerSingleton("job", JobSupport.class);
|
||||
@@ -37,7 +37,7 @@ public class ApplicationContextJobFactoryTests {
|
||||
}
|
||||
|
||||
private static class PostProcessingApplicationContextFactory implements ApplicationContextFactory {
|
||||
@Override
|
||||
@Override
|
||||
public ConfigurableApplicationContext createApplicationContext() {
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
context.registerSingleton("job", JobSupport.class);
|
||||
@@ -50,7 +50,7 @@ public class ApplicationContextJobFactoryTests {
|
||||
|
||||
private static class TestBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof JobSupport) {
|
||||
((JobSupport) bean).setName("bar");
|
||||
@@ -58,7 +58,7 @@ public class ApplicationContextJobFactoryTests {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.support;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.Job;
|
||||
@@ -23,7 +23,7 @@ import org.springframework.batch.core.configuration.JobFactory;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class JobFactoryRegistrationListenerTests {
|
||||
|
||||
@@ -40,12 +40,12 @@ public class JobFactoryRegistrationListenerTests {
|
||||
public void testBind() throws Exception {
|
||||
listener.setJobRegistry(registry);
|
||||
listener.bind(new JobFactory() {
|
||||
@Override
|
||||
@Override
|
||||
public Job createJob() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getJobName() {
|
||||
return "foo";
|
||||
}
|
||||
@@ -56,18 +56,18 @@ public class JobFactoryRegistrationListenerTests {
|
||||
/**
|
||||
* Test method for
|
||||
* {@link org.springframework.batch.core.configuration.support.JobFactoryRegistrationListener#unbind(org.springframework.batch.core.configuration.JobFactory, java.util.Map)}.
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testUnbind() throws Exception {
|
||||
testBind();
|
||||
listener.unbind(new JobFactory() {
|
||||
@Override
|
||||
@Override
|
||||
public Job createJob() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getJobName() {
|
||||
return "foo";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -35,7 +35,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -58,7 +58,7 @@ public class DecisionJobParserTests {
|
||||
}
|
||||
|
||||
public static class TestDecider implements JobExecutionDecider {
|
||||
@Override
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
return new FlowExecutionStatus("FOO");
|
||||
}
|
||||
|
||||
@@ -10,22 +10,22 @@ import org.springframework.batch.repeat.RepeatStatus;
|
||||
*/
|
||||
public class DummyCompletionPolicy implements CompletionPolicy {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isComplete(RepeatContext context, RepeatStatus result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isComplete(RepeatContext context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public RepeatContext start(RepeatContext parent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void update(RepeatContext context) {
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.springframework.batch.item.ItemProcessor;
|
||||
*/
|
||||
public class DummyItemProcessor implements ItemProcessor<Object,Object> {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object process(Object item) throws Exception {
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.springframework.batch.item.UnexpectedInputException;
|
||||
*/
|
||||
public class DummyItemReader implements ItemReader<Object> {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object read() throws Exception, UnexpectedInputException, ParseException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.springframework.batch.item.ItemWriter;
|
||||
*/
|
||||
public class DummyItemWriter implements ItemWriter<Object> {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void write(List<? extends Object> items) throws Exception {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2009 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -37,54 +37,54 @@ public class DummyJobRepository implements JobRepository, BeanNameAware {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void add(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public JobExecution createJobExecution(String jobName, JobParameters jobParameters)
|
||||
throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public JobExecution getLastJobExecution(String jobName, JobParameters jobParameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public StepExecution getLastStepExecution(JobInstance jobInstance, String stepName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int getStepExecutionCount(JobInstance jobInstance, String stepName) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isJobInstanceExists(String jobName, JobParameters jobParameters) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void update(JobExecution jobExecution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void update(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void updateExecutionContext(StepExecution stepExecution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void updateExecutionContext(JobExecution jobExecution) {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2009 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -33,20 +33,20 @@ public class DummyPlatformTransactionManager implements PlatformTransactionManag
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void commit(TransactionStatus status) throws TransactionException {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void rollback(TransactionStatus status) throws TransactionException {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,16 +10,16 @@ import org.springframework.retry.RetryListener;
|
||||
*/
|
||||
public class DummyRetryListener implements RetryListener {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public <T> boolean open(RetryContext context, RetryCallback<T> callback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public <T> void close(RetryContext context, RetryCallback<T> callback, Throwable throwable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public <T> void onError(RetryContext context, RetryCallback<T> callback, Throwable throwable) {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2009 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -28,27 +28,27 @@ public class DummyStep implements Step, BeanNameAware {
|
||||
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
System.out.println("EXECUTING " + getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int getStartLimit() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isAllowStartIfComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.springframework.batch.repeat.RepeatStatus;
|
||||
*/
|
||||
public class DummyTasklet implements Tasklet {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -23,13 +23,13 @@ import org.springframework.batch.repeat.RepeatStatus;
|
||||
* This tasklet will call
|
||||
* {@link NameStoringTasklet#execute(StepContribution, ChunkContext)} and then
|
||||
* throw an exeception.
|
||||
*
|
||||
*
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
*/
|
||||
public class FailingTasklet extends NameStoringTasklet {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
super.execute(contribution, chunkContext);
|
||||
throw new RuntimeException();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -40,7 +40,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -137,7 +137,7 @@ public class FlowStepParserTests {
|
||||
|
||||
int count = 0;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
if (count++ < 2) {
|
||||
return new FlowExecutionStatus("OK");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -23,15 +23,15 @@ import org.springframework.batch.repeat.RepeatStatus;
|
||||
* This tasklet will call
|
||||
* {@link NameStoringTasklet#execute(StepContribution, ChunkContext)} and then
|
||||
* return CONTINUABLE, so it needs to be interrupted for it to stop.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*/
|
||||
public class InterruptibleTasklet extends NameStoringTasklet {
|
||||
|
||||
|
||||
private volatile boolean started = false;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
if (!started) {
|
||||
super.execute(contribution, chunkContext);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -36,17 +36,17 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class JobRegistryJobParserTests implements ApplicationContextAware {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ListableJobLocator jobRegistry;
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOneStep() throws Exception {
|
||||
assertEquals(2, applicationContext.getBeanNamesForType(Job.class).length);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -26,7 +26,7 @@ import org.springframework.batch.repeat.RepeatStatus;
|
||||
|
||||
/**
|
||||
* This class will store the step name when it is executed.
|
||||
*
|
||||
*
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -35,12 +35,12 @@ public class NameStoringTasklet extends StepExecutionListenerSupport implements
|
||||
private String stepName = null;
|
||||
private List<String> stepNamesList = null;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
stepName = stepExecution.getStepName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
if (stepNamesList != null) {
|
||||
stepNamesList.add(stepName);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -28,7 +28,11 @@ import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.core.*;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.partition.PartitionHandler;
|
||||
import org.springframework.batch.core.partition.StepExecutionSplitter;
|
||||
import org.springframework.batch.core.partition.support.PartitionStep;
|
||||
@@ -88,7 +92,7 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
|
||||
private List<String> savedStepNames = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
@@ -152,7 +156,7 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
for (StepExecution se : jobExecution.getStepExecutions()) {
|
||||
String stepExecutionName = se.getStepName();
|
||||
// the partitioned step
|
||||
if (stepExecutionName.equalsIgnoreCase("j3s1")) {
|
||||
if (stepExecutionName.equalsIgnoreCase("j3s1")) {
|
||||
PartitionStep partitionStep = (PartitionStep) this.applicationContext.getBean(stepExecutionName);
|
||||
// prove that the reference in the {@link
|
||||
// TaskExecutorPartitionHandler} is the step configured inline
|
||||
@@ -187,7 +191,7 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
for (StepExecution se : jobExecution.getStepExecutions()) {
|
||||
String stepExecutionName = se.getStepName();
|
||||
if (stepExecutionName.equalsIgnoreCase("j4s1")) { // the partitioned
|
||||
// step
|
||||
// step
|
||||
PartitionStep partitionStep = (PartitionStep) this.applicationContext.getBean(stepExecutionName);
|
||||
|
||||
// prove that the reference in the {@link
|
||||
@@ -227,23 +231,23 @@ public class PartitionStepParserTests implements ApplicationContextAware {
|
||||
Collections.sort(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static class CustomPartitionHandler implements PartitionHandler {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
|
||||
throws Exception {
|
||||
return Arrays.asList(stepExecution);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static class CustomStepExecutionAggregator implements StepExecutionAggregator {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void aggregate(StepExecution result, Collection<StepExecution> executions) {
|
||||
result.getJobExecution().getExecutionContext().put("foo", "bar");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -73,7 +73,7 @@ public class PartitionStepWithFlowParserTests {
|
||||
public void testRepeatedFlowStep() throws Exception {
|
||||
assertNotNull(job1);
|
||||
JobExecution jobExecution = jobRepository.createJobExecution(job1.getName(), new JobParametersBuilder()
|
||||
.addLong("gridSize", 1L).toJobParameters());
|
||||
.addLong("gridSize", 1L).toJobParameters());
|
||||
job1.execute(jobExecution);
|
||||
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
|
||||
Collections.sort(savedStepNames);
|
||||
@@ -95,10 +95,10 @@ public class PartitionStepWithFlowParserTests {
|
||||
public static class Decider implements JobExecutionDecider {
|
||||
|
||||
int count = 0;
|
||||
@Override
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
if (count++<2) {
|
||||
return new FlowExecutionStatus("OK");
|
||||
return new FlowExecutionStatus("OK");
|
||||
}
|
||||
return new FlowExecutionStatus("END");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -40,12 +40,12 @@ public class SplitInterruptedJobParserTests extends AbstractJobParserTests {
|
||||
|
||||
final JobExecution jobExecution = createJobExecution();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
job.execute(jobExecution);
|
||||
}
|
||||
}).start();
|
||||
|
||||
|
||||
Thread.sleep(100L);
|
||||
jobExecution.setStatus(BatchStatus.STOPPING);
|
||||
Thread.sleep(200L);
|
||||
@@ -54,7 +54,7 @@ public class SplitInterruptedJobParserTests extends AbstractJobParserTests {
|
||||
Thread.sleep(200L);
|
||||
}
|
||||
assertTrue("Timed out waiting for job to stop: "+jobExecution, count<10);
|
||||
|
||||
|
||||
assertEquals(BatchStatus.STOPPED, jobExecution.getStatus());
|
||||
assertEquals(ExitStatus.STOPPED.getExitCode(), jobExecution.getExitStatus().getExitCode());
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -31,7 +31,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -74,7 +74,7 @@ public class StopJobParserTests extends AbstractJobParserTests {
|
||||
}
|
||||
|
||||
public static class TestDecider implements JobExecutionDecider {
|
||||
@Override
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
return new FlowExecutionStatus("FOO");
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@ import org.springframework.batch.core.StepExecutionListener;
|
||||
|
||||
public class TestCustomStatusListener extends AbstractTestComponent implements StepExecutionListener {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
return new ExitStatus("FOO").and(stepExecution.getExitStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
executed = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.springframework.batch.core.JobParametersIncrementer;
|
||||
|
||||
public class TestIncrementer implements JobParametersIncrementer{
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public JobParameters getNext(JobParameters parameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.springframework.batch.core.annotation.AfterRead;
|
||||
|
||||
public class TestListener extends AbstractTestComponent implements StepExecutionListener {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
return null;
|
||||
}
|
||||
@@ -17,14 +17,14 @@ public class TestListener extends AbstractTestComponent implements StepExecution
|
||||
return stepExecution.getExitStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
executed = true;
|
||||
}
|
||||
|
||||
|
||||
@AfterRead
|
||||
public void logItem(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.springframework.batch.item.ItemProcessor;
|
||||
|
||||
public class TestProcessor extends AbstractTestComponent implements ItemProcessor<String, String>{
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String process(String item) throws Exception {
|
||||
executed = true;
|
||||
return item;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class TestReader extends AbstractTestComponent implements ItemReader<Stri
|
||||
this.opened = opened;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String read() throws Exception, UnexpectedInputException, ParseException {
|
||||
executed = true;
|
||||
synchronized (items) {
|
||||
@@ -44,16 +44,16 @@ public class TestReader extends AbstractTestComponent implements ItemReader<Stri
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void close() throws ItemStreamException {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void open(ExecutionContext executionContext) throws ItemStreamException {
|
||||
opened = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void update(ExecutionContext executionContext) throws ItemStreamException {
|
||||
}
|
||||
|
||||
|
||||
@@ -6,17 +6,17 @@ import org.springframework.retry.RetryListener;
|
||||
|
||||
public class TestRetryListener extends AbstractTestComponent implements RetryListener {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public <T> void close(RetryContext context, RetryCallback<T> callback,
|
||||
Throwable throwable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public <T> void onError(RetryContext context, RetryCallback<T> callback,
|
||||
Throwable throwable) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public <T> boolean open(RetryContext context, RetryCallback<T> callback) {
|
||||
executed = true;
|
||||
return true;
|
||||
|
||||
@@ -8,18 +8,18 @@ import org.springframework.batch.repeat.RepeatStatus;
|
||||
public class TestTasklet extends AbstractTestComponent implements Tasklet {
|
||||
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution,
|
||||
ChunkContext chunkContext) throws Exception {
|
||||
executed = true;
|
||||
return RepeatStatus.FINISHED;
|
||||
}
|
||||
return RepeatStatus.FINISHED;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.batch.item.ItemWriter;
|
||||
|
||||
public class TestWriter extends AbstractTestComponent implements ItemWriter<String> {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void write(List<? extends String> items) throws Exception {
|
||||
executed = true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -24,7 +24,6 @@ import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.explore.JobExplorer;
|
||||
import org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean;
|
||||
import org.springframework.batch.core.job.SimpleJob;
|
||||
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
@@ -37,7 +36,7 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class MapJobExplorerIntegrationTests {
|
||||
|
||||
@@ -57,7 +56,7 @@ public class MapJobExplorerIntegrationTests {
|
||||
SimpleJob job = new SimpleJob("job");
|
||||
TaskletStep step = new TaskletStep("step");
|
||||
step.setTasklet(new Tasklet() {
|
||||
@Override
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
while (block) {
|
||||
Thread.sleep(100L);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -41,13 +41,13 @@ import org.springframework.batch.core.step.StepSupport;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ExtendedAbstractJobTests {
|
||||
|
||||
private AbstractJob job;
|
||||
private JobRepository jobRepository;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean();
|
||||
@@ -118,7 +118,7 @@ public class ExtendedAbstractJobTests {
|
||||
assertTrue(e.getMessage().contains("JobRepository"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testValidatorWithNotNullParameters() throws Exception {
|
||||
JobExecution execution = jobRepository.createJobExecution("job", new JobParameters());
|
||||
@@ -147,7 +147,7 @@ public class ExtendedAbstractJobTests {
|
||||
*/
|
||||
@Test
|
||||
public void testHandleStep() throws Exception {
|
||||
|
||||
|
||||
class StubStep extends StepSupport {
|
||||
|
||||
static final String value = "message for next steps";
|
||||
@@ -158,12 +158,12 @@ public class ExtendedAbstractJobTests {
|
||||
setName("StubStep");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
stepExecution.getJobExecution().getExecutionContext().put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean();
|
||||
factory.afterPropertiesSet();
|
||||
JobRepository repository = (JobRepository) factory.getObject();
|
||||
@@ -186,12 +186,12 @@ public class ExtendedAbstractJobTests {
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
private static class StubJob extends AbstractJob {
|
||||
/**
|
||||
* @param name
|
||||
* @param jobRepository
|
||||
* @param jobRepository
|
||||
*/
|
||||
private StubJob(String name, JobRepository jobRepository) {
|
||||
super(name);
|
||||
@@ -218,7 +218,7 @@ public class ExtendedAbstractJobTests {
|
||||
public Step getStep(String stepName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Collection<String> getStepNames() {
|
||||
return Collections.<String> emptySet();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -37,7 +37,7 @@ import org.springframework.util.ClassUtils;
|
||||
* representing the configuration of a job specified by a developer. It should
|
||||
* be noted that restart policy is applied to the job as a whole and not to a
|
||||
* step.
|
||||
*
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@@ -63,7 +63,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator {
|
||||
/**
|
||||
* Convenience constructor to immediately add name (which is mandatory but
|
||||
* not final).
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public JobSupport(String name) {
|
||||
@@ -77,10 +77,10 @@ public class JobSupport implements BeanNameAware, Job, StepLocator {
|
||||
* if it is present. Care is needed with bean definition inheritance - if a
|
||||
* parent bean has a name, then its children need an explicit name as well,
|
||||
* otherwise they will not be unique.
|
||||
*
|
||||
*
|
||||
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public void setBeanName(String name) {
|
||||
if (this.name == null) {
|
||||
this.name = name;
|
||||
@@ -90,7 +90,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator {
|
||||
/**
|
||||
* Set the name property. Always overrides the default value if this object
|
||||
* is a Spring bean.
|
||||
*
|
||||
*
|
||||
* @see #setBeanName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
@@ -99,14 +99,14 @@ public class JobSupport implements BeanNameAware, Job, StepLocator {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.springframework.batch.core.domain.IJob#getName()
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param jobParametersValidator the jobParametersValidator to set
|
||||
*/
|
||||
@@ -116,9 +116,9 @@ public class JobSupport implements BeanNameAware, Job, StepLocator {
|
||||
|
||||
public void setSteps(List<Step> steps) {
|
||||
this.steps.clear();
|
||||
for (Step step : steps) {
|
||||
this.steps.put(step.getName(), step);
|
||||
}
|
||||
for (Step step : steps) {
|
||||
this.steps.put(step.getName(), step);
|
||||
}
|
||||
}
|
||||
|
||||
public void addStep(Step step) {
|
||||
@@ -127,7 +127,7 @@ public class JobSupport implements BeanNameAware, Job, StepLocator {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.springframework.batch.core.domain.IJob#getStartLimit()
|
||||
*/
|
||||
public int getStartLimit() {
|
||||
@@ -144,58 +144,58 @@ public class JobSupport implements BeanNameAware, Job, StepLocator {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.springframework.batch.core.domain.IJob#isRestartable()
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public boolean isRestartable() {
|
||||
return restartable;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see
|
||||
* org.springframework.batch.core.domain.Job#run(org.springframework.batch
|
||||
* .core.domain.JobExecution)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public void execute(JobExecution execution) throws UnexpectedJobExecutionException {
|
||||
throw new UnsupportedOperationException(
|
||||
"JobSupport does not provide an implementation of execute(). Use a smarter subclass.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String toString() {
|
||||
return ClassUtils.getShortName(getClass()) + ": [name=" + name + "]";
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see org.springframework.batch.core.Job#getJobParametersIncrementer()
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public JobParametersIncrementer getJobParametersIncrementer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public JobParametersValidator getJobParametersValidator() {
|
||||
return jobParametersValidator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getStepNames() {
|
||||
return steps.keySet();
|
||||
}
|
||||
@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) {
|
||||
throw new NoSuchStepException("Step ["+stepName+"] does not exist for job with name ["+getName()+"]");
|
||||
}
|
||||
return step;
|
||||
}
|
||||
@Override
|
||||
public Step getStep(String stepName) throws NoSuchStepException {
|
||||
final Step step = steps.get(stepName);
|
||||
if (step == null) {
|
||||
throw new NoSuchStepException("Step ["+stepName+"] does not exist for job with name ["+getName()+"]");
|
||||
}
|
||||
return step;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -64,7 +64,7 @@ import org.springframework.batch.item.ExecutionContext;
|
||||
/**
|
||||
* Tests for DefaultJobLifecycle. MapJobDao and MapStepExecutionDao are used
|
||||
* instead of a mock repository to test that status is being stored correctly.
|
||||
*
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*/
|
||||
public class SimpleJobTests {
|
||||
@@ -110,14 +110,14 @@ public class SimpleJobTests {
|
||||
|
||||
step1 = new StubStep("TestStep1", jobRepository);
|
||||
step1.setCallback(new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("default");
|
||||
}
|
||||
});
|
||||
step2 = new StubStep("TestStep2", jobRepository);
|
||||
step2.setCallback(new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("default");
|
||||
}
|
||||
@@ -175,22 +175,22 @@ public class SimpleJobTests {
|
||||
|
||||
Step testStep = new Step() {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
stepExecution.setExitStatus(customStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getName() {
|
||||
return "test";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int getStartLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isAllowStartIfComplete() {
|
||||
return false;
|
||||
}
|
||||
@@ -219,12 +219,12 @@ public class SimpleJobTests {
|
||||
@Test
|
||||
public void testRunNormallyWithListener() throws Exception {
|
||||
job.setJobExecutionListeners(new JobExecutionListenerSupport[] { new JobExecutionListenerSupport() {
|
||||
@Override
|
||||
@Override
|
||||
public void beforeJob(JobExecution jobExecution) {
|
||||
list.add("before");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("after");
|
||||
}
|
||||
@@ -299,7 +299,7 @@ public class SimpleJobTests {
|
||||
@Test
|
||||
public void testFailedWithListener() throws Exception {
|
||||
job.setJobExecutionListeners(new JobExecutionListenerSupport[] { new JobExecutionListenerSupport() {
|
||||
@Override
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("afterJob");
|
||||
}
|
||||
@@ -487,9 +487,9 @@ public class SimpleJobTests {
|
||||
|
||||
step1 = new StubStep("interruptStep", jobRepository) {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException,
|
||||
UnexpectedJobExecutionException {
|
||||
UnexpectedJobExecutionException {
|
||||
stepExecution.getJobExecution().stop();
|
||||
super.execute(stepExecution);
|
||||
}
|
||||
@@ -580,13 +580,13 @@ public class SimpleJobTests {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @seeorg.springframework.batch.core.step.StepSupport#execute(org.
|
||||
* springframework.batch.core.StepExecution)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException,
|
||||
UnexpectedJobExecutionException {
|
||||
UnexpectedJobExecutionException {
|
||||
|
||||
passedInJobContext = new ExecutionContext(stepExecution.getJobExecution().getExecutionContext());
|
||||
passedInStepContext = new ExecutionContext(stepExecution.getExecutionContext());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2009 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -32,7 +32,7 @@ import org.springframework.batch.core.step.StepSupport;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SimpleStepHandlerTests {
|
||||
|
||||
@@ -77,7 +77,7 @@ public class SimpleStepHandlerTests {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
stepExecution.setStatus(BatchStatus.COMPLETED);
|
||||
stepExecution.setExitStatus(ExitStatus.COMPLETED);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class FlowJobBuilderTests {
|
||||
private StepSupport step1 = new StepSupport("step1") {
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException,
|
||||
UnexpectedJobExecutionException {
|
||||
UnexpectedJobExecutionException {
|
||||
stepExecution.upgradeStatus(BatchStatus.COMPLETED);
|
||||
stepExecution.setExitStatus(ExitStatus.COMPLETED);
|
||||
jobRepository.update(stepExecution);
|
||||
@@ -58,7 +58,7 @@ public class FlowJobBuilderTests {
|
||||
private StepSupport fails = new StepSupport("fails") {
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException,
|
||||
UnexpectedJobExecutionException {
|
||||
UnexpectedJobExecutionException {
|
||||
stepExecution.upgradeStatus(BatchStatus.FAILED);
|
||||
stepExecution.setExitStatus(ExitStatus.FAILED);
|
||||
jobRepository.update(stepExecution);
|
||||
@@ -68,7 +68,7 @@ public class FlowJobBuilderTests {
|
||||
private StepSupport step2 = new StepSupport("step2") {
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException,
|
||||
UnexpectedJobExecutionException {
|
||||
UnexpectedJobExecutionException {
|
||||
stepExecution.upgradeStatus(BatchStatus.COMPLETED);
|
||||
stepExecution.setExitStatus(ExitStatus.COMPLETED);
|
||||
jobRepository.update(stepExecution);
|
||||
@@ -78,7 +78,7 @@ public class FlowJobBuilderTests {
|
||||
private StepSupport step3 = new StepSupport("step3") {
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException,
|
||||
UnexpectedJobExecutionException {
|
||||
UnexpectedJobExecutionException {
|
||||
stepExecution.upgradeStatus(BatchStatus.COMPLETED);
|
||||
stepExecution.setExitStatus(ExitStatus.COMPLETED);
|
||||
jobRepository.update(stepExecution);
|
||||
@@ -143,7 +143,7 @@ public class FlowJobBuilderTests {
|
||||
public void testBuildDecision() throws Exception {
|
||||
JobExecutionDecider decider = new JobExecutionDecider() {
|
||||
private int count = 0;
|
||||
@Override
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
count++;
|
||||
return count<2 ? new FlowExecutionStatus("ONGOING") : FlowExecutionStatus.COMPLETED;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -49,7 +49,7 @@ import org.springframework.batch.core.step.StepSupport;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class FlowJobTests {
|
||||
|
||||
@@ -361,7 +361,7 @@ public class FlowJobTests {
|
||||
List<StateTransition> transitions = new ArrayList<StateTransition>();
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step1")), "end"));
|
||||
transitions
|
||||
.add(StateTransition.createStateTransition(new EndState(FlowExecutionStatus.FAILED, "end"), "step2"));
|
||||
.add(StateTransition.createStateTransition(new EndState(FlowExecutionStatus.FAILED, "end"), "step2"));
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step2")), ExitStatus.FAILED
|
||||
.getExitCode(), "end0"));
|
||||
transitions.add(StateTransition.createStateTransition(new StepState(new StubStep("step2")),
|
||||
@@ -450,7 +450,7 @@ public class FlowJobTests {
|
||||
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
JobExecutionDecider decider = new JobExecutionDecider() {
|
||||
@Override
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
assertNotNull(stepExecution);
|
||||
return new FlowExecutionStatus("SWITCH");
|
||||
@@ -491,7 +491,7 @@ public class FlowJobTests {
|
||||
|
||||
SimpleFlow flow = new SimpleFlow("job");
|
||||
JobExecutionDecider decider = new JobExecutionDecider() {
|
||||
@Override
|
||||
@Override
|
||||
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) {
|
||||
assertNotNull(stepExecution);
|
||||
throw new RuntimeException("Foo");
|
||||
@@ -669,7 +669,7 @@ public class FlowJobTests {
|
||||
/**
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
private class StubStep extends StepSupport {
|
||||
|
||||
@@ -677,7 +677,7 @@ public class FlowJobTests {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
stepExecution.setStatus(BatchStatus.COMPLETED);
|
||||
stepExecution.setExitStatus(ExitStatus.COMPLETED);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2009 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -43,7 +43,7 @@ import org.springframework.batch.core.step.StepSupport;
|
||||
*
|
||||
*/
|
||||
public class FlowStepTests {
|
||||
|
||||
|
||||
private JobRepository jobRepository;
|
||||
private JobExecution jobExecution;
|
||||
|
||||
@@ -164,7 +164,7 @@ public class FlowStepTests {
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
private class StubStep extends StepSupport {
|
||||
|
||||
@@ -179,7 +179,7 @@ public class FlowStepTests {
|
||||
this.fail = fail;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
BatchStatus status = BatchStatus.COMPLETED;
|
||||
ExitStatus exitStatus = ExitStatus.COMPLETED;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -20,14 +20,14 @@ import org.springframework.batch.core.job.flow.support.state.AbstractState;
|
||||
|
||||
/**
|
||||
* Base class for {@link State} implementations in test cases.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
*/
|
||||
public class StateSupport extends AbstractState {
|
||||
|
||||
private FlowExecutionStatus status;
|
||||
|
||||
|
||||
public StateSupport(String name) {
|
||||
this(name, FlowExecutionStatus.COMPLETED);
|
||||
}
|
||||
@@ -45,8 +45,8 @@ public class StateSupport extends AbstractState {
|
||||
}
|
||||
return this.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public boolean isEndState() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -28,44 +28,44 @@ import org.springframework.batch.core.repository.JobRestartException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class JobFlowExecutorSupport implements FlowExecutor {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String executeStep(Step step) throws JobInterruptedException, JobRestartException,
|
||||
StartLimitExceededException {
|
||||
StartLimitExceededException {
|
||||
return ExitStatus.COMPLETED.getExitCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public JobExecution getJobExecution() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public StepExecution getStepExecution() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void close(FlowExecution result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void abandonStepExecution() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public void updateJobExecutionStatus(FlowExecutionStatus status) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public boolean isRestart() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public void addExitStatus(String code) {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -39,7 +39,7 @@ public class EmptyItemWriter<T> implements ItemWriter<T>, InitializingBean {
|
||||
|
||||
List<Object> list;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
list = TransactionAwareProxyFactory.createTransactionalList();
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class EmptyItemWriter<T> implements ItemWriter<T>, InitializingBean {
|
||||
this.failurePoint = failurePoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void write(List<? extends T> items) {
|
||||
for (T data : items) {
|
||||
if (!failed && list.size() == failurePoint) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -26,7 +26,7 @@ public class JobExecutionNotFailedExceptionTests extends AbstractExceptionTests
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobExecutionNotFailedException(msg);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class JobExecutionNotFailedExceptionTests extends AbstractExceptionTests
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobExecutionNotFailedException(msg, t);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.batch.core.launch;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
import org.springframework.batch.core.launch.JobInstanceAlreadyExistsException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -27,7 +26,7 @@ public class JobInstanceAlreadyExistsExceptionTests extends AbstractExceptionTes
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobInstanceAlreadyExistsException(msg);
|
||||
}
|
||||
@@ -35,7 +34,7 @@ public class JobInstanceAlreadyExistsExceptionTests extends AbstractExceptionTes
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobInstanceAlreadyExistsException(msg, t);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -26,7 +26,7 @@ public class JobParametersNotFoundExceptionTests extends AbstractExceptionTests
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobParametersNotFoundException(msg);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class JobParametersNotFoundExceptionTests extends AbstractExceptionTests
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobParametersNotFoundException(msg, t);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.batch.core.launch;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
import org.springframework.batch.core.launch.NoSuchJobExecutionException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -27,7 +26,7 @@ public class NoSuchJobExecutionExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new NoSuchJobExecutionException(msg);
|
||||
}
|
||||
@@ -35,7 +34,7 @@ public class NoSuchJobExecutionExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new NoSuchJobExecutionException(msg, t);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.batch.core.launch;
|
||||
|
||||
import org.springframework.batch.core.AbstractExceptionTests;
|
||||
import org.springframework.batch.core.launch.NoSuchJobInstanceException;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -27,7 +26,7 @@ public class NoSuchJobInstanceExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new NoSuchJobInstanceException(msg);
|
||||
}
|
||||
@@ -35,7 +34,7 @@ public class NoSuchJobInstanceExceptionTests extends AbstractExceptionTests {
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new NoSuchJobInstanceException(msg, t);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -47,7 +47,7 @@ import org.springframework.core.task.TaskRejectedException;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SimpleJobLauncherTests {
|
||||
|
||||
@@ -162,7 +162,7 @@ public class SimpleJobLauncherTests {
|
||||
public void testTaskExecutor() throws Exception {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
jobLauncher.setTaskExecutor(new TaskExecutor() {
|
||||
@Override
|
||||
@Override
|
||||
public void execute(Runnable task) {
|
||||
list.add("execute");
|
||||
task.run();
|
||||
@@ -177,7 +177,7 @@ public class SimpleJobLauncherTests {
|
||||
|
||||
final List<String> list = new ArrayList<String>();
|
||||
jobLauncher.setTaskExecutor(new TaskExecutor() {
|
||||
@Override
|
||||
@Override
|
||||
public void execute(Runnable task) {
|
||||
list.add("execute");
|
||||
throw new TaskRejectedException("Planned failure");
|
||||
@@ -209,7 +209,7 @@ public class SimpleJobLauncherTests {
|
||||
@Test
|
||||
public void testRunWithException() throws Exception {
|
||||
job = new JobSupport() {
|
||||
@Override
|
||||
@Override
|
||||
public void execute(JobExecution execution) {
|
||||
execution.setExitStatus(ExitStatus.FAILED);
|
||||
throw new RuntimeException("foo");
|
||||
@@ -227,7 +227,7 @@ public class SimpleJobLauncherTests {
|
||||
@Test
|
||||
public void testRunWithError() throws Exception {
|
||||
job = new JobSupport() {
|
||||
@Override
|
||||
@Override
|
||||
public void execute(JobExecution execution) {
|
||||
execution.setExitStatus(ExitStatus.FAILED);
|
||||
throw new Error("foo");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -48,7 +48,7 @@ import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class CommandLineJobRunnerTests {
|
||||
|
||||
@@ -75,7 +75,7 @@ public class CommandLineJobRunnerTests {
|
||||
StubJobLauncher.jobExecution = jobExecution;
|
||||
stdin = System.in;
|
||||
System.setIn(new InputStream() {
|
||||
@Override
|
||||
@Override
|
||||
public int read() {
|
||||
return -1;
|
||||
}
|
||||
@@ -141,12 +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 available() throws IOException {
|
||||
throw new IOException("Planned");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int read() {
|
||||
return -1;
|
||||
}
|
||||
@@ -163,12 +163,12 @@ public class CommandLineJobRunnerTests {
|
||||
|
||||
int index = 0;
|
||||
|
||||
@Override
|
||||
public int available() {
|
||||
return input.length - index;
|
||||
}
|
||||
@Override
|
||||
public int available() {
|
||||
return input.length - index;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int read() {
|
||||
return index<input.length-1 ? (int) input[index++] : -1;
|
||||
}
|
||||
@@ -186,12 +186,12 @@ public class CommandLineJobRunnerTests {
|
||||
|
||||
int index = 0;
|
||||
|
||||
@Override
|
||||
public int available() {
|
||||
return input.length - index;
|
||||
}
|
||||
@Override
|
||||
public int available() {
|
||||
return input.length - index;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int read() {
|
||||
return index<input.length-1 ? (int) input[index++] : -1;
|
||||
}
|
||||
@@ -363,7 +363,7 @@ public class CommandLineJobRunnerTests {
|
||||
|
||||
private static int status;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void exit(int status) {
|
||||
StubSystemExiter.status = status;
|
||||
}
|
||||
@@ -383,7 +383,7 @@ public class CommandLineJobRunnerTests {
|
||||
|
||||
private static boolean destroyed = false;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException {
|
||||
|
||||
StubJobLauncher.jobParameters = jobParameters;
|
||||
@@ -416,12 +416,12 @@ public class CommandLineJobRunnerTests {
|
||||
|
||||
static JobExecution jobExecution;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Set<JobExecution> findRunningJobExecutions(String jobName) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public JobExecution getJobExecution(Long executionId) {
|
||||
if (jobExecution != null) {
|
||||
return jobExecution;
|
||||
@@ -429,7 +429,7 @@ public class CommandLineJobRunnerTests {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public List<JobExecution> getJobExecutions(JobInstance jobInstance) {
|
||||
if (jobInstance.getId() == 0) {
|
||||
return Arrays.asList(createJobExecution(jobInstance, BatchStatus.FAILED));
|
||||
@@ -463,12 +463,12 @@ public class CommandLineJobRunnerTests {
|
||||
return jobExecution;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public JobInstance getJobInstance(Long instanceId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public List<JobInstance> getJobInstances(String jobName, int start, int count) {
|
||||
if (jobInstances == null) {
|
||||
return new ArrayList<JobInstance>();
|
||||
@@ -478,12 +478,12 @@ public class CommandLineJobRunnerTests {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public StepExecution getStepExecution(Long jobExecutionId, Long stepExecutionId) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public List<String> getJobNames() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@@ -496,13 +496,13 @@ public class CommandLineJobRunnerTests {
|
||||
|
||||
static boolean called = false;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public JobParameters getJobParameters(Properties properties) {
|
||||
called = true;
|
||||
return delegate.getJobParameters(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Properties getProperties(JobParameters params) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -24,12 +24,11 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.launch.support.ScheduledJobParametersFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ScheduledJobParametersFactoryTests extends TestCase {
|
||||
|
||||
@@ -37,7 +36,7 @@ public class ScheduledJobParametersFactoryTests extends TestCase {
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
@@ -63,7 +62,7 @@ public class ScheduledJobParametersFactoryTests extends TestCase {
|
||||
public void testGetProperties() throws Exception {
|
||||
|
||||
JobParameters parameters = new JobParametersBuilder().addDate("schedule.date", dateFormat.parse("01/23/2008"))
|
||||
.addString("job.key", "myKey").addString("vendor.id", "33243243").toJobParameters();
|
||||
.addString("job.key", "myKey").addString("vendor.id", "33243243").toJobParameters();
|
||||
|
||||
Properties props = factory.getProperties(parameters);
|
||||
assertNotNull(props);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -58,7 +58,7 @@ import org.springframework.batch.support.PropertiesConverter;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SimpleJobOperatorTests {
|
||||
|
||||
@@ -67,14 +67,14 @@ public class SimpleJobOperatorTests {
|
||||
protected Job job;
|
||||
|
||||
private JobExplorer jobExplorer;
|
||||
|
||||
|
||||
private JobRepository jobRepository;
|
||||
|
||||
private JobParameters jobParameters;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -83,7 +83,7 @@ public class SimpleJobOperatorTests {
|
||||
@Override
|
||||
public JobParametersIncrementer getJobParametersIncrementer() {
|
||||
return new JobParametersIncrementer() {
|
||||
@Override
|
||||
@Override
|
||||
public JobParameters getNext(JobParameters parameters) {
|
||||
return jobParameters;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class SimpleJobOperatorTests {
|
||||
jobOperator = new SimpleJobOperator();
|
||||
|
||||
jobOperator.setJobRegistry(new MapJobRegistry() {
|
||||
@Override
|
||||
@Override
|
||||
public Job getJob(String name) throws NoSuchJobException {
|
||||
if (name.equals("foo")) {
|
||||
return job;
|
||||
@@ -102,6 +102,7 @@ public class SimpleJobOperatorTests {
|
||||
throw new NoSuchJobException("foo");
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public Set<String> getJobNames() {
|
||||
return new HashSet(Arrays.asList(new String[] { "foo", "bar" }));
|
||||
@@ -109,9 +110,9 @@ public class SimpleJobOperatorTests {
|
||||
});
|
||||
|
||||
jobOperator.setJobLauncher(new JobLauncher() {
|
||||
@Override
|
||||
@Override
|
||||
public JobExecution run(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException,
|
||||
JobRestartException, JobInstanceAlreadyCompleteException {
|
||||
JobRestartException, JobInstanceAlreadyCompleteException {
|
||||
return new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 999L);
|
||||
}
|
||||
});
|
||||
@@ -119,7 +120,7 @@ public class SimpleJobOperatorTests {
|
||||
jobExplorer = EasyMock.createNiceMock(JobExplorer.class);
|
||||
|
||||
jobOperator.setJobExplorer(jobExplorer);
|
||||
|
||||
|
||||
jobRepository = createMock(JobRepository.class);
|
||||
jobOperator.setJobRepository(jobRepository);
|
||||
|
||||
@@ -201,7 +202,7 @@ public class SimpleJobOperatorTests {
|
||||
jobParameters = new JobParameters();
|
||||
jobExplorer.getJobExecution(111L);
|
||||
EasyMock.expectLastCall()
|
||||
.andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L));
|
||||
.andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L));
|
||||
EasyMock.replay(jobExplorer);
|
||||
Long value = jobOperator.restart(111L);
|
||||
assertEquals(999, value.longValue());
|
||||
@@ -297,7 +298,7 @@ public class SimpleJobOperatorTests {
|
||||
final JobParameters jobParameters = new JobParameters();
|
||||
jobExplorer.getJobExecution(111L);
|
||||
EasyMock.expectLastCall()
|
||||
.andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L));
|
||||
.andReturn(new JobExecution(new JobInstance(123L, jobParameters, job.getName()), 111L));
|
||||
EasyMock.replay(jobExplorer);
|
||||
String value = jobOperator.getParameters(111L);
|
||||
assertEquals("a=b", value);
|
||||
@@ -381,7 +382,7 @@ public class SimpleJobOperatorTests {
|
||||
}
|
||||
EasyMock.verify(jobExplorer);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStop() throws Exception{
|
||||
JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
|
||||
@@ -397,29 +398,29 @@ public class SimpleJobOperatorTests {
|
||||
assertEquals(BatchStatus.STOPPING, jobExecution.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbort() throws Exception {
|
||||
JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
|
||||
JobExecution jobExecution = new JobExecution(jobInstance, 111L);
|
||||
jobExecution.setStatus(BatchStatus.STOPPING);
|
||||
jobExplorer.getJobExecution(123L);
|
||||
expectLastCall().andReturn(jobExecution);
|
||||
jobRepository.update(jobExecution);
|
||||
replay(jobExplorer);
|
||||
jobOperator.abandon(123L);
|
||||
assertEquals(BatchStatus.ABANDONED, jobExecution.getStatus());
|
||||
assertNotNull(jobExecution.getEndTime());
|
||||
}
|
||||
@Test
|
||||
public void testAbort() throws Exception {
|
||||
JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
|
||||
JobExecution jobExecution = new JobExecution(jobInstance, 111L);
|
||||
jobExecution.setStatus(BatchStatus.STOPPING);
|
||||
jobExplorer.getJobExecution(123L);
|
||||
expectLastCall().andReturn(jobExecution);
|
||||
jobRepository.update(jobExecution);
|
||||
replay(jobExplorer);
|
||||
jobOperator.abandon(123L);
|
||||
assertEquals(BatchStatus.ABANDONED, jobExecution.getStatus());
|
||||
assertNotNull(jobExecution.getEndTime());
|
||||
}
|
||||
|
||||
@Test(expected = JobExecutionAlreadyRunningException.class)
|
||||
public void testAbortNonStopping() throws Exception {
|
||||
JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
|
||||
JobExecution jobExecution = new JobExecution(jobInstance, 111L);
|
||||
jobExecution.setStatus(BatchStatus.STARTED);
|
||||
jobExplorer.getJobExecution(123L);
|
||||
expectLastCall().andReturn(jobExecution);
|
||||
jobRepository.update(jobExecution);
|
||||
replay(jobExplorer);
|
||||
jobOperator.abandon(123L);
|
||||
}
|
||||
@Test(expected = JobExecutionAlreadyRunningException.class)
|
||||
public void testAbortNonStopping() throws Exception {
|
||||
JobInstance jobInstance = new JobInstance(123L, jobParameters, job.getName());
|
||||
JobExecution jobExecution = new JobExecution(jobInstance, 111L);
|
||||
jobExecution.setStatus(BatchStatus.STARTED);
|
||||
jobExplorer.getJobExecution(123L);
|
||||
expectLastCall().andReturn(jobExecution);
|
||||
jobRepository.update(jobExecution);
|
||||
replay(jobExplorer);
|
||||
jobOperator.abandon(123L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -22,21 +22,19 @@ 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;
|
||||
|
||||
public class SimpleJvmExitCodeMapperTests extends TestCase {
|
||||
|
||||
private SimpleJvmExitCodeMapper ecm;
|
||||
private SimpleJvmExitCodeMapper ecm2;
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
ecm = new SimpleJvmExitCodeMapper();
|
||||
Map<String, Integer> ecmMap = new HashMap<String, Integer>();
|
||||
ecmMap.put("MY_CUSTOM_CODE", new Integer(3));
|
||||
ecm.setMapping(ecmMap);
|
||||
|
||||
|
||||
ecm2 = new SimpleJvmExitCodeMapper();
|
||||
Map<String, Integer> ecm2Map = new HashMap<String, Integer>();
|
||||
ecm2Map.put(ExitStatus.COMPLETED.getExitCode(), new Integer(-1));
|
||||
@@ -46,7 +44,7 @@ public class SimpleJvmExitCodeMapperTests extends TestCase {
|
||||
ecm2.setMapping(ecm2Map);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
@@ -60,12 +58,12 @@ public class SimpleJvmExitCodeMapperTests extends TestCase {
|
||||
ExitCodeMapper.JVM_EXITCODE_GENERIC_ERROR);
|
||||
assertEquals(
|
||||
ecm.intValue(ExitCodeMapper.JOB_NOT_PROVIDED),
|
||||
ExitCodeMapper.JVM_EXITCODE_JOB_ERROR);
|
||||
ExitCodeMapper.JVM_EXITCODE_JOB_ERROR);
|
||||
assertEquals(
|
||||
ecm.intValue(ExitCodeMapper.NO_SUCH_JOB),
|
||||
ExitCodeMapper.JVM_EXITCODE_JOB_ERROR);
|
||||
ExitCodeMapper.JVM_EXITCODE_JOB_ERROR);
|
||||
}
|
||||
|
||||
|
||||
public void testGetExitCodeWithPredefinedCodesOverridden() {
|
||||
System.out.println(ecm2.intValue(ExitStatus.COMPLETED.getExitCode()));
|
||||
assertEquals(
|
||||
@@ -73,20 +71,20 @@ public class SimpleJvmExitCodeMapperTests extends TestCase {
|
||||
assertEquals(
|
||||
ecm2.intValue(ExitStatus.FAILED.getExitCode()), -2);
|
||||
assertEquals(
|
||||
ecm2.intValue(ExitCodeMapper.JOB_NOT_PROVIDED), -3);
|
||||
ecm2.intValue(ExitCodeMapper.JOB_NOT_PROVIDED), -3);
|
||||
assertEquals(
|
||||
ecm2.intValue(ExitCodeMapper.NO_SUCH_JOB), -3);
|
||||
ecm2.intValue(ExitCodeMapper.NO_SUCH_JOB), -3);
|
||||
}
|
||||
|
||||
public void testGetExitCodeWithCustomCode() {
|
||||
assertEquals(ecm.intValue("MY_CUSTOM_CODE"),3);
|
||||
assertEquals(ecm.intValue("MY_CUSTOM_CODE"),3);
|
||||
}
|
||||
|
||||
public void testGetExitCodeWithDefaultCode() {
|
||||
assertEquals(
|
||||
ecm.intValue("UNDEFINED_CUSTOM_CODE"),
|
||||
ExitCodeMapper.JVM_EXITCODE_GENERIC_ERROR);
|
||||
ExitCodeMapper.JVM_EXITCODE_GENERIC_ERROR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class StubJobLauncher implements JobLauncher {
|
||||
return isRunning;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public JobExecution run(Job job, JobParameters jobParameters)
|
||||
throws JobExecutionAlreadyRunningException {
|
||||
lastRunCalled = RUN_JOB_IDENTIFIER;
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.springframework.batch.core.JobParametersIncrementer;
|
||||
|
||||
public class TestJobParametersIncrementer implements JobParametersIncrementer {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public JobParameters getNext(JobParameters parameters) {
|
||||
return new JobParametersBuilder().addString("foo", "spam").toJobParameters();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -26,7 +26,7 @@ import org.springframework.batch.core.JobInstance;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class CompositeJobExecutionListenerTests extends TestCase {
|
||||
|
||||
@@ -40,12 +40,12 @@ public class CompositeJobExecutionListenerTests extends TestCase {
|
||||
*/
|
||||
public void testSetListeners() {
|
||||
listener.setListeners(Arrays.asList(new JobExecutionListenerSupport() {
|
||||
@Override
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("fail");
|
||||
}
|
||||
}, new JobExecutionListenerSupport() {
|
||||
@Override
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("continue");
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class CompositeJobExecutionListenerTests extends TestCase {
|
||||
*/
|
||||
public void testSetListener() {
|
||||
listener.register(new JobExecutionListenerSupport() {
|
||||
@Override
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
list.add("fail");
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class CompositeJobExecutionListenerTests extends TestCase {
|
||||
*/
|
||||
public void testOpen() {
|
||||
listener.register(new JobExecutionListenerSupport() {
|
||||
@Override
|
||||
@Override
|
||||
public void beforeJob(JobExecution stepExecution) {
|
||||
list.add("foo");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -26,7 +26,7 @@ import org.springframework.batch.core.StepExecutionListener;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class CompositeStepExecutionListenerTests extends TestCase {
|
||||
|
||||
@@ -41,13 +41,13 @@ public class CompositeStepExecutionListenerTests extends TestCase {
|
||||
*/
|
||||
public void testSetListeners() {
|
||||
listener.setListeners(new StepExecutionListener[] { new StepExecutionListenerSupport() {
|
||||
@Override
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
list.add("fail");
|
||||
return ExitStatus.FAILED;
|
||||
}
|
||||
}, new StepExecutionListenerSupport() {
|
||||
@Override
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
list.add("continue");
|
||||
return ExitStatus.EXECUTING;
|
||||
@@ -64,7 +64,7 @@ public class CompositeStepExecutionListenerTests extends TestCase {
|
||||
*/
|
||||
public void testSetListener() {
|
||||
listener.register(new StepExecutionListenerSupport() {
|
||||
@Override
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
list.add("fail");
|
||||
return ExitStatus.FAILED;
|
||||
@@ -81,7 +81,7 @@ public class CompositeStepExecutionListenerTests extends TestCase {
|
||||
*/
|
||||
public void testOpen() {
|
||||
listener.register(new StepExecutionListenerSupport() {
|
||||
@Override
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
list.add("foo");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -36,7 +36,7 @@ import org.springframework.core.Ordered;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class JobListenerFactoryBeanTests {
|
||||
|
||||
@@ -105,7 +105,6 @@ public class JobListenerFactoryBeanTests {
|
||||
@Test
|
||||
public void testAnnotationsIsListener() throws Exception {
|
||||
assertTrue(JobListenerFactoryBean.isListener(new Object() {
|
||||
@SuppressWarnings("unused")
|
||||
@BeforeJob
|
||||
public void foo(JobExecution execution) {
|
||||
}
|
||||
@@ -120,12 +119,11 @@ public class JobListenerFactoryBeanTests {
|
||||
@Test
|
||||
public void testAnnotationsWithOrdered() throws Exception {
|
||||
Object delegate = new Ordered() {
|
||||
@SuppressWarnings("unused")
|
||||
@BeforeJob
|
||||
public void foo(JobExecution execution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 3;
|
||||
}
|
||||
@@ -146,7 +144,6 @@ public class JobListenerFactoryBeanTests {
|
||||
@Test
|
||||
public void testEmptySignatureAnnotation() {
|
||||
AbstractTestComponent delegate = new AbstractTestComponent() {
|
||||
@SuppressWarnings("unused")
|
||||
@AfterJob
|
||||
public void aMethod() {
|
||||
executed = true;
|
||||
@@ -161,7 +158,6 @@ public class JobListenerFactoryBeanTests {
|
||||
@Test
|
||||
public void testRightSignatureAnnotation() {
|
||||
AbstractTestComponent delegate = new AbstractTestComponent() {
|
||||
@SuppressWarnings("unused")
|
||||
@AfterJob
|
||||
public void aMethod(JobExecution jobExecution) {
|
||||
executed = true;
|
||||
@@ -177,7 +173,6 @@ public class JobListenerFactoryBeanTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testWrongSignatureAnnotation() {
|
||||
AbstractTestComponent delegate = new AbstractTestComponent() {
|
||||
@SuppressWarnings("unused")
|
||||
@AfterJob
|
||||
public void aMethod(Integer item) {
|
||||
executed = true;
|
||||
@@ -243,19 +238,18 @@ public class JobListenerFactoryBeanTests {
|
||||
|
||||
boolean afterJobCalled = false;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void afterJob(JobExecution jobExecution) {
|
||||
afterJobCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void beforeJob(JobExecution jobExecution) {
|
||||
beforeJobCalled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private class AnnotatedTestClass {
|
||||
|
||||
boolean beforeJobCalled = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -27,7 +27,7 @@ import org.springframework.core.annotation.Order;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class OrderedCompositeTests {
|
||||
|
||||
@@ -62,7 +62,7 @@ public class OrderedCompositeTests {
|
||||
public void testAddOrdered() {
|
||||
list.setItems(Arrays.asList((Object) "1"));
|
||||
list.add(new Ordered() {
|
||||
@Override
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
@@ -76,13 +76,13 @@ public class OrderedCompositeTests {
|
||||
public void testAddMultipleOrdered() {
|
||||
list.setItems(Arrays.asList((Object) "1"));
|
||||
list.add(new Ordered() {
|
||||
@Override
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
list.add(new Ordered() {
|
||||
@Override
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
@@ -97,13 +97,13 @@ public class OrderedCompositeTests {
|
||||
public void testAddDuplicateOrdered() {
|
||||
list.setItems(Arrays.asList((Object) "1"));
|
||||
list.add(new Ordered() {
|
||||
@Override
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
list.add(new Ordered() {
|
||||
@Override
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class OrderedCompositeTests {
|
||||
@Test
|
||||
public void testAddAnnotationOrdered() {
|
||||
list.add(new Ordered() {
|
||||
@Override
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -63,7 +63,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class StepListenerFactoryBeanTests {
|
||||
|
||||
@@ -186,12 +186,11 @@ public class StepListenerFactoryBeanTests {
|
||||
@Test
|
||||
public void testAnnotationsWithOrdered() throws Exception {
|
||||
Object delegate = new Ordered() {
|
||||
@SuppressWarnings("unused")
|
||||
@BeforeStep
|
||||
public void foo(StepExecution execution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 3;
|
||||
}
|
||||
@@ -204,12 +203,11 @@ public class StepListenerFactoryBeanTests {
|
||||
@Test
|
||||
public void testProxiedAnnotationsFactoryMethod() throws Exception {
|
||||
Object delegate = new InitializingBean() {
|
||||
@SuppressWarnings("unused")
|
||||
@BeforeStep
|
||||
public void foo(StepExecution execution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
}
|
||||
};
|
||||
@@ -226,7 +224,6 @@ public class StepListenerFactoryBeanTests {
|
||||
@Test
|
||||
public void testAnnotationsIsListener() throws Exception {
|
||||
assertTrue(StepListenerFactoryBean.isListener(new Object() {
|
||||
@SuppressWarnings("unused")
|
||||
@BeforeStep
|
||||
public void foo(StepExecution execution) {
|
||||
}
|
||||
@@ -238,7 +235,7 @@ public class StepListenerFactoryBeanTests {
|
||||
ProxyFactory factory = new ProxyFactory();
|
||||
factory.addInterface(DataSource.class);
|
||||
factory.addAdvice(new MethodInterceptor() {
|
||||
@Override
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
return null;
|
||||
}
|
||||
@@ -250,12 +247,11 @@ public class StepListenerFactoryBeanTests {
|
||||
@Test
|
||||
public void testProxiedAnnotationsIsListener() throws Exception {
|
||||
Object delegate = new InitializingBean() {
|
||||
@SuppressWarnings("unused")
|
||||
@BeforeStep
|
||||
public void foo(StepExecution execution) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
}
|
||||
};
|
||||
@@ -280,7 +276,6 @@ public class StepListenerFactoryBeanTests {
|
||||
@Test
|
||||
public void testEmptySignatureAnnotation() {
|
||||
AbstractTestComponent delegate = new AbstractTestComponent() {
|
||||
@SuppressWarnings("unused")
|
||||
@AfterWrite
|
||||
public void aMethod() {
|
||||
executed = true;
|
||||
@@ -296,7 +291,6 @@ public class StepListenerFactoryBeanTests {
|
||||
@Test
|
||||
public void testRightSignatureAnnotation() {
|
||||
AbstractTestComponent delegate = new AbstractTestComponent() {
|
||||
@SuppressWarnings("unused")
|
||||
@AfterWrite
|
||||
public void aMethod(List<String> items) {
|
||||
executed = true;
|
||||
@@ -314,7 +308,6 @@ public class StepListenerFactoryBeanTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testWrongSignatureAnnotation() {
|
||||
AbstractTestComponent delegate = new AbstractTestComponent() {
|
||||
@SuppressWarnings("unused")
|
||||
@AfterWrite
|
||||
public void aMethod(Integer item) {
|
||||
executed = true;
|
||||
@@ -381,7 +374,7 @@ public class StepListenerFactoryBeanTests {
|
||||
|
||||
int callcount = 0;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
@AfterStep
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
Assert.notNull(stepExecution);
|
||||
@@ -389,7 +382,7 @@ public class StepListenerFactoryBeanTests {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
callcount++;
|
||||
}
|
||||
@@ -401,14 +394,14 @@ public class StepListenerFactoryBeanTests {
|
||||
|
||||
int callcount = 0;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
Assert.notNull(stepExecution);
|
||||
callcount++;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void beforeStep(StepExecution stepExecution) {
|
||||
callcount++;
|
||||
}
|
||||
@@ -523,17 +516,17 @@ public class StepListenerFactoryBeanTests {
|
||||
onWriteErrorCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onSkipInProcess(String item, Throwable t) {
|
||||
onSkipInProcessCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onSkipInRead(Throwable t) {
|
||||
onSkipInReadCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onSkipInWrite(Integer item, Throwable t) {
|
||||
onSkipInWriteCalled = true;
|
||||
}
|
||||
|
||||
@@ -21,15 +21,15 @@ public class StepListenerMethodInterceptorTests {
|
||||
|
||||
MethodInvokerMethodInterceptor interceptor;
|
||||
TestClass testClass;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp(){
|
||||
testClass = new TestClass();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNormalCase() throws Throwable{
|
||||
|
||||
|
||||
Map<String, Set<MethodInvoker>> invokerMap = new HashMap<String, Set<MethodInvoker>>();
|
||||
for(Method method : TestClass.class.getMethods()){
|
||||
invokerMap.put(method.getName(), asSet( new SimpleMethodInvoker(testClass, method)));
|
||||
@@ -40,10 +40,10 @@ public class StepListenerMethodInterceptorTests {
|
||||
interceptor.invoke(new StubMethodInvocation(TestClass.class.getMethod("method2")));
|
||||
assertEquals(1, testClass.method2Count);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMultipleInvokersPerName() throws Throwable{
|
||||
|
||||
|
||||
Map<String, Set<MethodInvoker>> invokerMap = new HashMap<String, Set<MethodInvoker>>();
|
||||
Set<MethodInvoker> invokers = asSet(MethodInvokerUtils.getMethodInvokerByName(testClass, "method1", false));
|
||||
invokers.add(MethodInvokerUtils.getMethodInvokerByName(testClass, "method2", false));
|
||||
@@ -54,7 +54,7 @@ public class StepListenerMethodInterceptorTests {
|
||||
interceptor.invoke(new StubMethodInvocation(TestClass.class.getMethod("method2")));
|
||||
assertEquals(1, testClass.method2Count);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testExitStatusReturn() throws Throwable{
|
||||
Map<String, Set<MethodInvoker>> invokerMap = new HashMap<String, Set<MethodInvoker>>();
|
||||
@@ -64,69 +64,69 @@ public class StepListenerMethodInterceptorTests {
|
||||
interceptor = new MethodInvokerMethodInterceptor(invokerMap);
|
||||
assertEquals(ExitStatus.COMPLETED, interceptor.invoke(new StubMethodInvocation(TestClass.class.getMethod("method3"))));
|
||||
}
|
||||
|
||||
|
||||
public Set<MethodInvoker> asSet(MethodInvoker methodInvoker){
|
||||
Set<MethodInvoker> invokerSet = new HashSet<MethodInvoker>();
|
||||
invokerSet.add(methodInvoker);
|
||||
return invokerSet;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private class TestClass{
|
||||
|
||||
|
||||
int method1Count = 0;
|
||||
int method2Count = 0;
|
||||
int method3Count = 0;
|
||||
|
||||
|
||||
public void method1(){
|
||||
method1Count++;
|
||||
}
|
||||
|
||||
|
||||
public void method2(){
|
||||
method2Count++;
|
||||
}
|
||||
|
||||
|
||||
public ExitStatus method3(){
|
||||
method3Count++;
|
||||
return ExitStatus.COMPLETED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private class StubMethodInvocation implements MethodInvocation{
|
||||
|
||||
Method method;
|
||||
Object[] args;
|
||||
|
||||
|
||||
public StubMethodInvocation(Method method, Object... args) {
|
||||
this.method = method;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public Method getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object[] getArguments() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public AccessibleObject getStaticPart() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object getThis() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object proceed() throws Throwable {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ExampleItemReader implements ItemReader<String>, ItemStream {
|
||||
/**
|
||||
* Reads next record from input
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public String read() throws Exception {
|
||||
if (index >= input.length || index >= max) {
|
||||
return null;
|
||||
@@ -62,16 +62,16 @@ public class ExampleItemReader implements ItemReader<String>, ItemStream {
|
||||
return input[index++];
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void close() throws ItemStreamException {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void open(ExecutionContext executionContext) throws ItemStreamException {
|
||||
index = (int) executionContext.getLong("POSITION", min);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void update(ExecutionContext executionContext) throws ItemStreamException {
|
||||
executionContext.putLong("POSITION", index);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ import org.springframework.batch.item.ItemWriter;
|
||||
public class ExampleItemWriter implements ItemWriter<String> {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ExampleItemWriter.class);
|
||||
|
||||
|
||||
private static List<String> items = new ArrayList<String>();
|
||||
|
||||
|
||||
public static void clear() {
|
||||
items.clear();
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class ExampleItemWriter implements ItemWriter<String> {
|
||||
/**
|
||||
* @see ItemWriter#write(List)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public void write(List<? extends String> data) throws Exception {
|
||||
log.info(data);
|
||||
items.addAll(data);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2009 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -27,17 +27,17 @@ import org.springframework.batch.item.ExecutionContext;
|
||||
*/
|
||||
public class MinMaxPartitioner extends SimplePartitioner {
|
||||
|
||||
@Override
|
||||
@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
|
||||
int range = total/gridSize;
|
||||
int i = 0;
|
||||
for (ExecutionContext context : partition.values()) {
|
||||
int min = (i++)*range;
|
||||
int max = Math.min(total, (min+1)*range);
|
||||
context.putInt("min", min);
|
||||
context.putInt("max", max);
|
||||
int min = (i++)*range;
|
||||
int max = Math.min(total, (min+1)*range);
|
||||
context.putInt("min", min);
|
||||
context.putInt("max", max);
|
||||
}
|
||||
return partition;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -37,7 +37,7 @@ import org.springframework.batch.core.repository.support.MapJobRepositoryFactory
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class PartitionStepTests {
|
||||
|
||||
@@ -57,7 +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
|
||||
@Override
|
||||
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
|
||||
throws Exception {
|
||||
Set<StepExecution> executions = stepSplitter.split(stepExecution, 2);
|
||||
@@ -82,7 +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
|
||||
@Override
|
||||
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
|
||||
throws Exception {
|
||||
Set<StepExecution> executions = stepSplitter.split(stepExecution, 2);
|
||||
@@ -108,7 +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
|
||||
@Override
|
||||
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
|
||||
throws Exception {
|
||||
Set<StepExecution> executions = stepSplitter.split(stepExecution, 2);
|
||||
@@ -155,7 +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
|
||||
@Override
|
||||
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
|
||||
throws Exception {
|
||||
Set<StepExecution> executions = stepSplitter.split(stepExecution, 2);
|
||||
@@ -187,7 +187,7 @@ public class PartitionStepTests {
|
||||
});
|
||||
step.setStepExecutionSplitter(new SimpleStepExecutionSplitter(jobRepository, true, step.getName(), new SimplePartitioner()));
|
||||
step.setPartitionHandler(new PartitionHandler() {
|
||||
@Override
|
||||
@Override
|
||||
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
|
||||
throws Exception {
|
||||
return Arrays.asList(stepExecution);
|
||||
|
||||
@@ -59,11 +59,11 @@ 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;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public Map<String, ExecutionContext> partition(int gridSize) {
|
||||
return map;
|
||||
}
|
||||
});
|
||||
assertEquals(1, splitter.split(stepExecution, 2).size());
|
||||
}
|
||||
|
||||
@@ -80,12 +80,12 @@ public class SimpleStepExecutionSplitterTests {
|
||||
@Test
|
||||
public void testRememberPartitionNames() throws Exception {
|
||||
class CustomPartitioner implements Partitioner, PartitionNameProvider {
|
||||
@Override
|
||||
@Override
|
||||
public Map<String, ExecutionContext> partition(int gridSize) {
|
||||
return Collections.singletonMap("foo", new ExecutionContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Collection<String> getPartitionNames(int gridSize) {
|
||||
return Arrays.asList("foo");
|
||||
}
|
||||
|
||||
@@ -27,19 +27,19 @@ public class TaskExecutorPartitionHandlerTests {
|
||||
private TaskExecutorPartitionHandler handler = new TaskExecutorPartitionHandler();
|
||||
|
||||
private int count = 0;
|
||||
|
||||
|
||||
private Collection<String> stepExecutions = new TreeSet<String>();
|
||||
|
||||
private StepExecution stepExecution = new StepExecution("step", new JobExecution(1L));
|
||||
|
||||
private StepExecutionSplitter stepExecutionSplitter = new StepExecutionSplitter() {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getStepName() {
|
||||
return stepExecution.getStepName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Set<StepExecution> split(StepExecution stepExecution, int gridSize) throws JobExecutionException {
|
||||
HashSet<StepExecution> result = new HashSet<StepExecution>();
|
||||
for (int i = gridSize; i-- > 0;) {
|
||||
@@ -94,7 +94,7 @@ public class TaskExecutorPartitionHandlerTests {
|
||||
public void testTaskExecutorFailure() throws Exception {
|
||||
handler.setGridSize(2);
|
||||
handler.setTaskExecutor(new TaskExecutor() {
|
||||
@Override
|
||||
@Override
|
||||
public void execute(Runnable task) {
|
||||
if (count > 0) {
|
||||
throw new TaskRejectedException("foo");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -26,7 +26,7 @@ public class JobExecutionAlreadyRunningExceptionTests extends AbstractExceptionT
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobExecutionAlreadyRunningException(msg);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class JobExecutionAlreadyRunningExceptionTests extends AbstractExceptionT
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobExecutionAlreadyRunningException(msg, t);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -26,7 +26,7 @@ public class JobInstanceAlreadyCompleteExceptionTests extends AbstractExceptionT
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobInstanceAlreadyCompleteException(msg);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class JobInstanceAlreadyCompleteExceptionTests extends AbstractExceptionT
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobInstanceAlreadyCompleteException(msg, t);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -19,7 +19,7 @@ import org.springframework.batch.core.AbstractExceptionTests;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class JobRestartExceptionTests extends AbstractExceptionTests {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class JobRestartExceptionTests extends AbstractExceptionTests {
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg) throws Exception {
|
||||
return new JobRestartException(msg);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class JobRestartExceptionTests extends AbstractExceptionTests {
|
||||
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
|
||||
* java.lang.Throwable)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Exception getException(String msg, Throwable t) throws Exception {
|
||||
return new JobRestartException(msg, t);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -29,7 +29,7 @@ import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class JdbcJobDaoQueryTests extends TestCase {
|
||||
|
||||
@@ -41,23 +41,23 @@ public class JdbcJobDaoQueryTests extends TestCase {
|
||||
* (non-Javadoc)
|
||||
* @see junit.framework.TestCase#setUp()
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
jobExecutionDao = new JdbcJobExecutionDao();
|
||||
jobExecutionDao.setJobExecutionIncrementer(new DataFieldMaxValueIncrementer() {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int nextIntValue() throws DataAccessException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public long nextLongValue() throws DataAccessException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String nextStringValue() throws DataAccessException {
|
||||
return "bar";
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class JdbcJobDaoQueryTests extends TestCase {
|
||||
public void testTablePrefix() throws Exception {
|
||||
jobExecutionDao.setTablePrefix("FOO_");
|
||||
jobExecutionDao.setJdbcTemplate(new JdbcTemplate() {
|
||||
@Override
|
||||
@Override
|
||||
public int update(String sql, Object[] args, int[] argTypes) throws DataAccessException {
|
||||
list.add(sql);
|
||||
return 1;
|
||||
|
||||
@@ -13,11 +13,11 @@ 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.support.JdbcTestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.batch.support.JdbcTestUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -25,23 +25,23 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
|
||||
@Autowired
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private JobInstanceDao jobInstanceDao;
|
||||
|
||||
@Autowired
|
||||
private JobExecutionDao jobExecutionDao;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected JobInstanceDao getJobInstanceDao() {
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "BATCH_JOB_EXECUTION_CONTEXT",
|
||||
"BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION",
|
||||
"BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE");
|
||||
"BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION",
|
||||
"BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE");
|
||||
return jobInstanceDao;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@ContextConfiguration(locations = "sql-dao-test.xml")
|
||||
public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected StepExecutionDao getStepExecutionDao() {
|
||||
return (StepExecutionDao) applicationContext.getBean("stepExecutionDao");
|
||||
}
|
||||
|
||||
@Override
|
||||
@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");
|
||||
@@ -32,15 +32,15 @@ public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
|
||||
*/
|
||||
@Transactional @Test
|
||||
public void testTruncateExitDescription() {
|
||||
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
sb.append("too long exit description");
|
||||
}
|
||||
String longDescription = sb.toString();
|
||||
|
||||
|
||||
ExitStatus exitStatus = ExitStatus.FAILED.addExitDescription(longDescription);
|
||||
|
||||
|
||||
stepExecution.setExitStatus(exitStatus);
|
||||
|
||||
((JdbcStepExecutionDao) dao).setExitMessageLength(250);
|
||||
@@ -58,5 +58,5 @@ public class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
|
||||
assertTrue("Exit description should be truncated", retrievedAfterUpdate.getExitStatus().getExitDescription()
|
||||
.length() < stepExecution.getExitStatus().getExitDescription().length());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package org.springframework.batch.core.repository.dao;
|
||||
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -16,8 +17,6 @@ import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
|
||||
|
||||
@@ -25,7 +24,7 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
|
||||
protected JobExecutionDao getJobExecutionDao() {
|
||||
return new MapJobExecutionDao();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected JobInstanceDao getJobInstanceDao() {
|
||||
return new MapJobInstanceDao();
|
||||
@@ -38,23 +37,23 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
|
||||
public void testPersistentCopy() {
|
||||
JobExecutionDao tested = new MapJobExecutionDao();
|
||||
JobExecution jobExecution = new JobExecution(new JobInstance((long) 1, new JobParameters(), "mapJob"));
|
||||
|
||||
|
||||
assertNull(jobExecution.getStartTime());
|
||||
tested.saveJobExecution(jobExecution);
|
||||
jobExecution.setStartTime(new Date());
|
||||
|
||||
|
||||
JobExecution retrieved = tested.getJobExecution(jobExecution.getId());
|
||||
assertNull(retrieved.getStartTime());
|
||||
|
||||
|
||||
tested.updateJobExecution(jobExecution);
|
||||
jobExecution.setEndTime(new Date());
|
||||
assertNull(retrieved.getEndTime());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the ids are properly generated even under heavy concurrent load
|
||||
*/
|
||||
* Verify that the ids are properly generated even under heavy concurrent load
|
||||
*/
|
||||
@Test
|
||||
public void testConcurrentSaveJobExecution() throws Exception {
|
||||
final int iterations = 100;
|
||||
@@ -69,7 +68,7 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
|
||||
|
||||
// Implementation of the high-concurrency code
|
||||
final Runnable codeUnderTest = new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
JobExecution jobExecution = new JobExecution(new JobInstance((long) -1, new JobParameters(), "mapJob"));
|
||||
@@ -98,11 +97,13 @@ public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
|
||||
for(Thread t : threads) { t.join(); }
|
||||
|
||||
// Ensure no general exceptions arose
|
||||
if(exception.get() != null) throw new RuntimeException("Excepion occurred under high concurrency usage", exception.get());
|
||||
if(exception.get() != null) {
|
||||
throw new RuntimeException("Excepion occurred under high concurrency usage", exception.get());
|
||||
}
|
||||
|
||||
// Validate the ids: we'd expect one of these three things to fail
|
||||
if(ids.size() < iterations) {
|
||||
fail("Duplicate id generated during high concurrency usage");
|
||||
fail("Duplicate id generated during high concurrency usage");
|
||||
}
|
||||
if(ids.first() < 0) {
|
||||
fail("Generated an id less than zero during high concurrency usage: " + ids.first());
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.junit.runners.JUnit4;
|
||||
@RunWith(JUnit4.class)
|
||||
public class MapJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected JobInstanceDao getJobInstanceDao() {
|
||||
return new MapJobInstanceDao();
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import static org.junit.Assert.assertNull;
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
@@ -18,17 +18,17 @@ import org.springframework.batch.core.repository.support.SimpleJobRepository;
|
||||
@RunWith(JUnit4.class)
|
||||
public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected StepExecutionDao getStepExecutionDao() {
|
||||
return new MapStepExecutionDao();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected JobRepository getJobRepository() {
|
||||
return new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(), new MapStepExecutionDao(),
|
||||
new MapExecutionContextDao());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Modifications to saved entity do not affect the persisted object.
|
||||
*/
|
||||
@@ -37,18 +37,18 @@ public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
|
||||
StepExecutionDao tested = new MapStepExecutionDao();
|
||||
JobExecution jobExecution = new JobExecution(77L);
|
||||
StepExecution stepExecution = new StepExecution("stepName", jobExecution);
|
||||
|
||||
|
||||
assertNull(stepExecution.getEndTime());
|
||||
tested.saveStepExecution(stepExecution);
|
||||
stepExecution.setEndTime(new Date());
|
||||
|
||||
|
||||
StepExecution retrieved = tested.getStepExecution(jobExecution, stepExecution.getId());
|
||||
assertNull(retrieved.getEndTime());
|
||||
|
||||
|
||||
stepExecution.setEndTime(null);
|
||||
tested.updateStepExecution(stepExecution);
|
||||
stepExecution.setEndTime(new Date());
|
||||
|
||||
|
||||
StepExecution stored = tested.getStepExecution(jobExecution, stepExecution.getId());
|
||||
assertNull(stored.getEndTime());
|
||||
}
|
||||
@@ -56,50 +56,50 @@ public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
|
||||
@Test
|
||||
public void testAddStepExecutions() {
|
||||
StepExecutionDao tested = new MapStepExecutionDao();
|
||||
|
||||
|
||||
JobExecution jobExecution = new JobExecution(88L);
|
||||
|
||||
|
||||
// Create step execution with status STARTED
|
||||
StepExecution stepExecution = new StepExecution("Step one", jobExecution);
|
||||
StepExecution stepExecution = new StepExecution("Step one", jobExecution);
|
||||
stepExecution.setStatus(BatchStatus.STARTED);
|
||||
|
||||
|
||||
// Save and check id
|
||||
tested.saveStepExecution(stepExecution);
|
||||
assertNotNull(stepExecution.getId());
|
||||
|
||||
// Job execution instance doesn't contain step execution instances
|
||||
|
||||
// Job execution instance doesn't contain step execution instances
|
||||
assertEquals(0, jobExecution.getStepExecutions().size());
|
||||
|
||||
|
||||
// Load all execution steps and check
|
||||
tested.addStepExecutions(jobExecution);
|
||||
assertEquals(1, jobExecution.getStepExecutions().size());
|
||||
|
||||
// Check the first (and only) step execution instance of the job instance
|
||||
|
||||
// Check the first (and only) step execution instance of the job instance
|
||||
StepExecution jobStepExecution = jobExecution.getStepExecutions().iterator().next();
|
||||
assertEquals(BatchStatus.STARTED, jobStepExecution.getStatus());
|
||||
assertEquals(stepExecution.getId(), jobStepExecution.getId());
|
||||
|
||||
// Load the step execution instance from the repository and check is it the same
|
||||
|
||||
// Load the step execution instance from the repository and check is it the same
|
||||
StepExecution repoStepExecution = tested.getStepExecution(jobExecution, stepExecution.getId());
|
||||
assertEquals(stepExecution.getId(), repoStepExecution.getId());
|
||||
assertEquals(BatchStatus.STARTED, repoStepExecution.getStatus());
|
||||
|
||||
|
||||
// Update the step execution instance
|
||||
repoStepExecution.setStatus(BatchStatus.COMPLETED);
|
||||
|
||||
|
||||
// Update the step execution in the repository and check
|
||||
tested.updateStepExecution(repoStepExecution);
|
||||
StepExecution updatedStepExecution = tested.getStepExecution(jobExecution, stepExecution.getId());
|
||||
assertEquals(stepExecution.getId(), updatedStepExecution.getId());
|
||||
assertEquals(BatchStatus.COMPLETED, updatedStepExecution.getStatus());
|
||||
|
||||
|
||||
// Now, add step executions from the repository and check
|
||||
tested.addStepExecutions(jobExecution);
|
||||
|
||||
|
||||
jobStepExecution = jobExecution.getStepExecutions().iterator().next();
|
||||
assertEquals(1, jobExecution.getStepExecutions().size());
|
||||
assertEquals(stepExecution.getId(), jobStepExecution.getId());
|
||||
assertEquals(BatchStatus.COMPLETED, jobStepExecution.getStatus());
|
||||
assertEquals(BatchStatus.COMPLETED, jobStepExecution.getStatus());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -30,11 +30,11 @@ import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.core.scope.context.ChunkContext;
|
||||
import org.springframework.batch.core.step.tasklet.Tasklet;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
import org.springframework.batch.support.JdbcTestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.batch.support.JdbcTestUtils;
|
||||
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -62,7 +62,7 @@ public class TablePrefixTests {
|
||||
|
||||
public static class TestTasklet implements Tasklet {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
return RepeatStatus.FINISHED;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -332,17 +332,17 @@ public class JobRepositoryFactoryBeanTests {
|
||||
|
||||
private static class StubIncrementer implements DataFieldMaxValueIncrementer {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int nextIntValue() throws DataAccessException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public long nextLongValue() throws DataAccessException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String nextStringValue() throws DataAccessException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Repository tests using JDBC DAOs (rather than mocks).
|
||||
*
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -58,7 +58,7 @@ public class SimpleJobRepositoryProxyTests {
|
||||
|
||||
private boolean invoked;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
invoked = true;
|
||||
return invocation.proceed();
|
||||
|
||||
@@ -5,19 +5,19 @@ package org.springframework.batch.core.resource;
|
||||
* Simple domain object for testing purposes.
|
||||
*/
|
||||
public class Foo {
|
||||
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private int value;
|
||||
|
||||
|
||||
public Foo(){}
|
||||
|
||||
|
||||
public Foo(int id, String name, int value) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -36,8 +36,8 @@ public class Foo {
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Foo[id=" +id +",name=" + name + ",value=" + value + "]";
|
||||
}
|
||||
@@ -54,24 +54,31 @@ public class Foo {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Foo other = (Foo) obj;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
}
|
||||
else if (!name.equals(other.name))
|
||||
if (obj == null) {
|
||||
return false;
|
||||
if (value != other.value)
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Foo other = (Foo) obj;
|
||||
if (id != other.id) {
|
||||
return false;
|
||||
}
|
||||
if (name == null) {
|
||||
if (other.name != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (!name.equals(other.name)) {
|
||||
return false;
|
||||
}
|
||||
if (value != other.value) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,16 +6,17 @@ import java.sql.SQLException;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class FooRowMapper implements RowMapper {
|
||||
|
||||
@Override
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
@Override
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
|
||||
Foo foo = new Foo();
|
||||
foo.setId(rs.getInt(1));
|
||||
foo.setName(rs.getString(2));
|
||||
foo.setValue(rs.getInt(3));
|
||||
|
||||
return foo;
|
||||
}
|
||||
Foo foo = new Foo();
|
||||
foo.setId(rs.getInt(1));
|
||||
foo.setName(rs.getString(2));
|
||||
foo.setValue(rs.getInt(3));
|
||||
|
||||
return foo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -35,20 +35,20 @@ import org.springframework.batch.core.job.AbstractJob;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.RowCallbackHandler;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowCallbackHandler;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {
|
||||
"/org/springframework/batch/core/resource/ListPreparedStatementSetterTests-context.xml",
|
||||
"/org/springframework/batch/core/repository/dao/data-source-context.xml" })
|
||||
"/org/springframework/batch/core/repository/dao/data-source-context.xml" })
|
||||
public class ListPreparedStatementSetterTests {
|
||||
|
||||
ListPreparedStatementSetter pss;
|
||||
@@ -88,11 +88,11 @@ 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));
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void processRow(ResultSet rs) throws SQLException {
|
||||
results.add(rs.getString(1));
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(2, results.size());
|
||||
assertEquals("bar2", results.get(0));
|
||||
@@ -134,7 +134,7 @@ public class ListPreparedStatementSetterTests {
|
||||
public static class FooStoringItemWriter implements ItemWriter<Foo> {
|
||||
private List<Foo> foos = new ArrayList<Foo>();
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void write(List<? extends Foo> items) throws Exception {
|
||||
foos.addAll(items);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -31,7 +31,7 @@ import org.springframework.batch.repeat.RepeatContext;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link StepExecutionSimpleCompletionPolicy}
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class StepExecutionSimpleCompletionPolicyTests extends TestCase {
|
||||
@@ -49,7 +49,7 @@ public class StepExecutionSimpleCompletionPolicyTests extends TestCase {
|
||||
* mock step context
|
||||
*/
|
||||
|
||||
@Override
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
|
||||
JobParameters jobParameters = new JobParametersBuilder().addLong("commit.interval", 2L).toJobParameters();
|
||||
@@ -60,7 +60,7 @@ public class StepExecutionSimpleCompletionPolicyTests extends TestCase {
|
||||
policy.beforeStep(stepExecution);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testToString() throws Exception {
|
||||
String msg = policy.toString();
|
||||
assertTrue("String does not contain chunk size", msg.indexOf("chunkSize=2")>=0);
|
||||
|
||||
@@ -45,7 +45,7 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware {
|
||||
|
||||
private int beanCount;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||
}
|
||||
@@ -81,7 +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
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
StepExecution stepExecution = new StepExecution(value, new JobExecution(0L), id);
|
||||
ExecutionContext executionContext = stepExecution.getExecutionContext();
|
||||
@@ -121,7 +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
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
ExecutionContext executionContext = stepExecution.getExecutionContext();
|
||||
executionContext.put("foo", value);
|
||||
|
||||
@@ -8,12 +8,12 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
public class JobStartupRunner implements InitializingBean {
|
||||
|
||||
private Step step;
|
||||
|
||||
|
||||
public void setStep(Step step) {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
StepExecution stepExecution = new StepExecution("step", new JobExecution(1L), 0L);
|
||||
step.execute(stepExecution);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class StepScopeClassIntegrationTests implements BeanFactoryAware {
|
||||
|
||||
private int beanCount;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ import org.springframework.util.StopWatch;
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
public class StepScopePerformanceTests implements ApplicationContextAware {
|
||||
|
||||
|
||||
private Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext)
|
||||
throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
|
||||
@@ -61,7 +61,7 @@ public class StepScopePlaceholderIntegrationTests implements BeanFactoryAware {
|
||||
|
||||
private int beanCount;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class StepScopeProxyTargetClassIntegrationTests implements BeanFactoryAwa
|
||||
|
||||
private int beanCount;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -38,8 +38,9 @@ import org.springframework.context.support.StaticApplicationContext;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class StepScopeTests {
|
||||
|
||||
private StepScope scope = new StepScope();
|
||||
@@ -64,7 +65,7 @@ public class StepScopeTests {
|
||||
StepSynchronizationManager.close();
|
||||
try {
|
||||
scope.get("foo", new ObjectFactory() {
|
||||
@Override
|
||||
@Override
|
||||
public Object getObject() throws BeansException {
|
||||
return foo;
|
||||
}
|
||||
@@ -81,7 +82,7 @@ public class StepScopeTests {
|
||||
public void testGetWithNothingAlreadyThere() {
|
||||
final String foo = "bar";
|
||||
Object value = scope.get("foo", new ObjectFactory() {
|
||||
@Override
|
||||
@Override
|
||||
public Object getObject() throws BeansException {
|
||||
return foo;
|
||||
}
|
||||
@@ -94,7 +95,7 @@ public class StepScopeTests {
|
||||
public void testGetWithSomethingAlreadyThere() {
|
||||
context.setAttribute("foo", "bar");
|
||||
Object value = scope.get("foo", new ObjectFactory() {
|
||||
@Override
|
||||
@Override
|
||||
public Object getObject() throws BeansException {
|
||||
return null;
|
||||
}
|
||||
@@ -108,7 +109,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
|
||||
@Override
|
||||
public Object getObject() throws BeansException {
|
||||
return "spam";
|
||||
}
|
||||
@@ -137,7 +138,7 @@ public class StepScopeTests {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
context.setAttribute("foo", "bar");
|
||||
scope.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("foo");
|
||||
}
|
||||
@@ -154,13 +155,13 @@ public class StepScopeTests {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
context.setAttribute("foo", "bar");
|
||||
scope.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("foo");
|
||||
}
|
||||
});
|
||||
scope.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("bar");
|
||||
}
|
||||
@@ -186,6 +187,7 @@ public class StepScopeTests {
|
||||
assertEquals(11, scope.getOrder());
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
@Test
|
||||
public void testName() throws Exception {
|
||||
scope.setName("foo");
|
||||
|
||||
@@ -4,15 +4,16 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class TestCollaborator implements Collaborator, Serializable {
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
private Collaborator parent;
|
||||
|
||||
|
||||
private List<String> list;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public List<String> getList() {
|
||||
return list;
|
||||
}
|
||||
@@ -21,7 +22,7 @@ public class TestCollaborator implements Collaborator, Serializable {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Collaborator getParent() {
|
||||
return parent;
|
||||
}
|
||||
@@ -30,7 +31,7 @@ public class TestCollaborator implements Collaborator, Serializable {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ package org.springframework.batch.core.scope;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class TestDisposableCollaborator extends TestCollaborator implements DisposableBean {
|
||||
|
||||
public static volatile String message = "none";
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
message = (message.equals("none") ? "" : message + ",") + getName() + ":destroyed";
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class TestStep implements Step {
|
||||
context = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void execute(StepExecution stepExecution) throws JobInterruptedException {
|
||||
context = StepSynchronizationManager.getContext();
|
||||
setContextFromCollaborator();
|
||||
@@ -43,17 +43,17 @@ public class TestStep implements Step {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getName() {
|
||||
return "foo";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int getStartLimit() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isAllowStartIfComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -30,12 +30,11 @@ import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.scope.context.StepContext;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class StepContextTests {
|
||||
|
||||
@@ -81,7 +80,7 @@ public class StepContextTests {
|
||||
public void testDestructionCallbackSunnyDay() throws Exception {
|
||||
context.setAttribute("foo", "FOO");
|
||||
context.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("bar");
|
||||
}
|
||||
@@ -94,7 +93,7 @@ public class StepContextTests {
|
||||
@Test
|
||||
public void testDestructionCallbackMissingAttribute() throws Exception {
|
||||
context.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("bar");
|
||||
}
|
||||
@@ -110,14 +109,14 @@ public class StepContextTests {
|
||||
context.setAttribute("foo", "FOO");
|
||||
context.setAttribute("bar", "BAR");
|
||||
context.registerDestructionCallback("bar", new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("spam");
|
||||
throw new RuntimeException("fail!");
|
||||
}
|
||||
});
|
||||
context.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("bar");
|
||||
throw new RuntimeException("fail!");
|
||||
|
||||
@@ -45,7 +45,7 @@ public class StepSynchronizationManagerTests {
|
||||
final List<String> list = new ArrayList<String>();
|
||||
StepContext context = StepSynchronizationManager.register(stepExecution);
|
||||
context.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("foo");
|
||||
}
|
||||
@@ -70,7 +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
|
||||
@Override
|
||||
public StepContext call() throws Exception {
|
||||
try {
|
||||
StepSynchronizationManager.register(stepExecution);
|
||||
@@ -95,7 +95,7 @@ public class StepSynchronizationManagerTests {
|
||||
StepContext context = StepSynchronizationManager.register(stepExecution);
|
||||
final List<String> list = new ArrayList<String>();
|
||||
context.registerDestructionCallback("foo", new Runnable() {
|
||||
@Override
|
||||
@Override
|
||||
public void run() {
|
||||
list.add("foo");
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware {
|
||||
|
||||
private int beanCount;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = (ListableBeanFactory) beanFactory;
|
||||
}
|
||||
@@ -80,7 +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
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
attributes.set(Collections.singletonMap("foo", value));
|
||||
try {
|
||||
@@ -107,7 +107,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware {
|
||||
|
||||
private Object root;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object getContext() {
|
||||
return root;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class AsyncPlaceholderTargetSourceTests implements BeanFactoryAware {
|
||||
|
||||
private Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -6,20 +6,20 @@ public class ContextFactorySupport implements ContextFactory {
|
||||
|
||||
/**
|
||||
* Returns this. Override for more sensible behaviour.
|
||||
*
|
||||
*
|
||||
* @see org.springframework.batch.core.scope.util.ContextFactory#getContext()
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public Object getContext() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the context plus a counter, so each call is unique.
|
||||
*
|
||||
*
|
||||
* @see org.springframework.batch.core.scope.util.ContextFactory#getContextId()
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public String getContextId() {
|
||||
return getContext()+"#"+(count ++);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
* Copyright 2006-2013 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.
|
||||
@@ -34,7 +34,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@@ -165,13 +165,13 @@ public class MultipleContextPlaceholderTargetSourceTests {
|
||||
|
||||
public static class TestBean {
|
||||
private String name;
|
||||
|
||||
|
||||
private TestBean parent;
|
||||
|
||||
private List<String> names = new ArrayList<String>();
|
||||
|
||||
private Map<String, String> map = new HashMap<String, String>();
|
||||
|
||||
|
||||
public TestBean getParent() {
|
||||
return parent;
|
||||
}
|
||||
@@ -203,14 +203,14 @@ public class MultipleContextPlaceholderTargetSourceTests {
|
||||
public void setMap(Map<String, String> map) {
|
||||
this.map.putAll(map);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static class SimpleContextFactory extends ContextFactorySupport {
|
||||
|
||||
private Object root;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object getContext() {
|
||||
return root;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PlaceholderTargetSourceCustomEditorTests extends ContextFactorySupp
|
||||
|
||||
private Date date = new Date(1L);
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object getContext() {
|
||||
return this;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class PlaceholderTargetSourceCustomEditorTests extends ContextFactorySupp
|
||||
public Foo() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport {
|
||||
|
||||
private Date date = new Date(1L);
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object getContext() {
|
||||
return this;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport {
|
||||
|
||||
private PlaceholderTargetSource createValue(String name, String value) throws Exception {
|
||||
String input = IOUtils.toString(new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass())
|
||||
.getInputStream());
|
||||
.getInputStream());
|
||||
input = input.replace("<!-- INSERT -->", String.format("<property name=\"%s\" value=\"%s\" />", name, value));
|
||||
Resource resource = new ByteArrayResource(input.getBytes());
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
@@ -108,8 +108,8 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport {
|
||||
|
||||
@Test
|
||||
public void testPartialReplaceIntegerToString() throws Exception {
|
||||
Node target = (Node) createValue("name", "foo-%{integer}").getTarget();
|
||||
assertEquals("foo-4321", target.getName());
|
||||
Node target = (Node) createValue("name", "foo-%{integer}").getTarget();
|
||||
assertEquals("foo-4321", target.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -160,7 +160,7 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport {
|
||||
public Foo() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public long getValue() {
|
||||
return value;
|
||||
}
|
||||
@@ -173,12 +173,12 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class PlaceholderTargetSourceErrorTests extends ContextFactorySupport {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Node getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user