Updated for various code warnings
This commit addresses a number of deprications and other code warnings. There are still many more to address, but this is a start.
This commit is contained in:
@@ -45,7 +45,7 @@ public class JobInstance extends Entity implements javax.batch.runtime.JobInstan
|
||||
|
||||
public JobInstance(Long id, String jobName) {
|
||||
super(id);
|
||||
Assert.hasLength(jobName);
|
||||
Assert.hasLength(jobName, "A jobName is required");
|
||||
this.jobName = jobName;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ public class StepExecution extends Entity {
|
||||
*/
|
||||
public StepExecution(String stepName, JobExecution jobExecution) {
|
||||
super();
|
||||
Assert.hasLength(stepName);
|
||||
Assert.hasLength(stepName, "A stepName is required");
|
||||
this.stepName = stepName;
|
||||
this.jobExecution = jobExecution;
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class StepExecution extends Entity {
|
||||
@SuppressWarnings("unused")
|
||||
private StepExecution(String stepName) {
|
||||
super();
|
||||
Assert.hasLength(stepName);
|
||||
Assert.hasLength(stepName, "A stepName is required");
|
||||
this.stepName = stepName;
|
||||
this.jobExecution = null;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ package org.springframework.batch.core.configuration;
|
||||
*/
|
||||
public class BatchConfigurationException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @param t an exception to be wrapped
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
@@ -57,7 +56,7 @@ public class ClasspathXmlApplicationContextsFactoryBean implements FactoryBean<A
|
||||
* resources can be given as a pattern (e.g.
|
||||
* <code>classpath*:/config/*-context.xml</code>).
|
||||
*
|
||||
* @param resources
|
||||
* @param resources array of resources to use
|
||||
*/
|
||||
public void setResources(Resource[] resources) {
|
||||
this.resources = Arrays.asList(resources);
|
||||
@@ -105,7 +104,6 @@ public class ClasspathXmlApplicationContextsFactoryBean implements FactoryBean<A
|
||||
* in {@link #setResources(Resource[])}.
|
||||
*
|
||||
* @return an array of {@link ApplicationContextFactory}
|
||||
* @throws Exception
|
||||
* @see org.springframework.beans.factory.FactoryBean#getObject()
|
||||
*/
|
||||
@Override
|
||||
@@ -115,7 +113,7 @@ public class ClasspathXmlApplicationContextsFactoryBean implements FactoryBean<A
|
||||
return new ApplicationContextFactory[0];
|
||||
}
|
||||
|
||||
List<ApplicationContextFactory> applicationContextFactories = new ArrayList<ApplicationContextFactory>();
|
||||
List<ApplicationContextFactory> applicationContextFactories = new ArrayList<>();
|
||||
for (Resource resource : resources) {
|
||||
GenericApplicationContextFactory factory = new GenericApplicationContextFactory(resource);
|
||||
factory.setCopyConfiguration(copyConfiguration);
|
||||
@@ -158,7 +156,6 @@ public class ClasspathXmlApplicationContextsFactoryBean implements FactoryBean<A
|
||||
* factories.
|
||||
*
|
||||
* @param applicationContext the {@link ApplicationContext} to set
|
||||
* @throws BeansException
|
||||
* @see ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,7 @@ public class MapJobRegistry implements JobRegistry {
|
||||
|
||||
@Override
|
||||
public void register(JobFactory jobFactory) throws DuplicateJobException {
|
||||
Assert.notNull(jobFactory);
|
||||
Assert.notNull(jobFactory, "jobFactory is null");
|
||||
String name = jobFactory.getJobName();
|
||||
Assert.notNull(name, "Job configuration must have a name.");
|
||||
JobFactory previousValue = map.putIfAbsent(name, jobFactory);
|
||||
|
||||
@@ -24,6 +24,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import org.springframework.batch.core.job.flow.FlowExecutionStatus;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
|
||||
@@ -33,9 +37,6 @@ import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -89,7 +90,7 @@ public abstract class AbstractFlowParser extends AbstractSingleBeanDefinitionPar
|
||||
* is available (null is fine, but the quality of error reports is better if
|
||||
* it is available).
|
||||
*
|
||||
* @param jobFactoryRef
|
||||
* @param jobFactoryRef name of the ref
|
||||
*/
|
||||
protected void setJobFactoryRef(String jobFactoryRef) {
|
||||
this.jobFactoryRef = jobFactoryRef;
|
||||
@@ -179,7 +180,7 @@ public abstract class AbstractFlowParser extends AbstractSingleBeanDefinitionPar
|
||||
/**
|
||||
* Find all of the elements that are pointed to by this element.
|
||||
*
|
||||
* @param element
|
||||
* @param element The parent element
|
||||
* @return a collection of reachable element names
|
||||
*/
|
||||
private Set<String> findReachableElements(Element element) {
|
||||
@@ -208,8 +209,8 @@ public abstract class AbstractFlowParser extends AbstractSingleBeanDefinitionPar
|
||||
/**
|
||||
* Find all of the elements reachable from the startElement.
|
||||
*
|
||||
* @param startElement
|
||||
* @param reachableElementMap
|
||||
* @param startElement name of the element to start from
|
||||
* @param reachableElementMap Map of elements that can be reached from the startElement
|
||||
* @param accumulator a collection of reachable element names
|
||||
*/
|
||||
protected void findAllReachableElements(String startElement, Map<String, Set<String>> reachableElementMap,
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import org.springframework.batch.core.listener.StepListenerMetaData;
|
||||
import org.springframework.beans.MutablePropertyValues;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -28,9 +32,6 @@ import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
* Internal parser for the <step/> elements inside a job. A step element
|
||||
@@ -89,7 +90,7 @@ public abstract class AbstractStepParser {
|
||||
|
||||
/**
|
||||
* @param stepElement The <step/> element
|
||||
* @param parserContext
|
||||
* @param parserContext context
|
||||
* @param jobFactoryRef the reference to the {@link JobParserJobFactoryBean}
|
||||
* from the enclosing tag. Use 'null' if unknown.
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,8 @@ package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.batch.core.listener.StepListenerMetaData;
|
||||
import org.springframework.batch.repeat.policy.SimpleCompletionPolicy;
|
||||
import org.springframework.beans.BeanMetadataElement;
|
||||
@@ -35,7 +37,6 @@ import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Internal parser for the <chunk/> element inside a step.
|
||||
@@ -67,8 +68,8 @@ public class ChunkElementParser {
|
||||
StepListenerMetaData.itemListenerMetaData());
|
||||
|
||||
/**
|
||||
* @param element
|
||||
* @param parserContext
|
||||
* @param element the element to parse
|
||||
* @param parserContext the context to use
|
||||
*/
|
||||
protected void parse(Element element, AbstractBeanDefinition bd, ParserContext parserContext, boolean underspecified) {
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ InitializingBean {
|
||||
* Convenience constructor to immediately add name (which is mandatory but
|
||||
* not final).
|
||||
*
|
||||
* @param name
|
||||
* @param name name of the job
|
||||
*/
|
||||
public AbstractJob(String name) {
|
||||
super();
|
||||
@@ -154,7 +154,7 @@ InitializingBean {
|
||||
* Retrieve the step with the given name. If there is no Step with the given
|
||||
* name, then return null.
|
||||
*
|
||||
* @param stepName
|
||||
* @param stepName name of the step
|
||||
* @return the Step
|
||||
*/
|
||||
@Override
|
||||
@@ -242,7 +242,7 @@ InitializingBean {
|
||||
* state of the batch meta domain (jobs, steps, executions) during the life
|
||||
* of a job.
|
||||
*
|
||||
* @param jobRepository
|
||||
* @param jobRepository repository to use during the job execution
|
||||
*/
|
||||
public void setJobRepository(JobRepository jobRepository) {
|
||||
this.jobRepository = jobRepository;
|
||||
|
||||
@@ -67,11 +67,7 @@ public class StepState extends AbstractState implements StepLocator, StepHolder
|
||||
return new FlowExecutionStatus(executor.executeStep(step));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated in favor of using {@link StepLocator#getStep(String)}.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Step getStep() {
|
||||
return step;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class JobListenerAdapter implements JobExecutionListener {
|
||||
* @param delegate to be delegated to
|
||||
*/
|
||||
public JobListenerAdapter(JobListener delegate) {
|
||||
Assert.notNull(delegate);
|
||||
Assert.notNull(delegate, "Delegate is required");
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class BatchletStep extends TaskletStep {
|
||||
*/
|
||||
public BatchletStep(String name, BatchPropertyContext propertyContext) {
|
||||
super(name);
|
||||
Assert.notNull(propertyContext);
|
||||
Assert.notNull(propertyContext, "A propertyContext is required");
|
||||
this.propertyContext = propertyContext;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,22 @@
|
||||
*/
|
||||
package org.springframework.batch.core.launch.support;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.Job;
|
||||
@@ -44,19 +58,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Basic launcher for starting jobs from the command line. In general, it is
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core.listener;
|
||||
|
||||
import static org.springframework.batch.support.MethodInvokerUtils.getMethodInvokerByAnnotation;
|
||||
import static org.springframework.batch.support.MethodInvokerUtils.getMethodInvokerForInterface;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -26,6 +23,7 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.aop.TargetSource;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
@@ -37,6 +35,9 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import static org.springframework.batch.support.MethodInvokerUtils.getMethodInvokerByAnnotation;
|
||||
import static org.springframework.batch.support.MethodInvokerUtils.getMethodInvokerForInterface;
|
||||
|
||||
/**
|
||||
* {@link FactoryBean} implementation that builds a listener based on the
|
||||
* various lifecycle methods or annotations that are provided. There are three
|
||||
@@ -157,7 +158,10 @@ public abstract class AbstractListenerFactoryBean<T> implements FactoryBean<Obje
|
||||
else {
|
||||
proxyFactory.setTarget(delegate);
|
||||
}
|
||||
proxyFactory.setInterfaces(listenerInterfaces.toArray(new Class[0]));
|
||||
@SuppressWarnings("rawtypes")
|
||||
Class[] a = new Class[0];
|
||||
|
||||
proxyFactory.setInterfaces(listenerInterfaces.toArray(a));
|
||||
proxyFactory.addAdvisor(new DefaultPointcutAdvisor(new MethodInvokerMethodInterceptor(invokerMap, ordered)));
|
||||
return proxyFactory.getProxy();
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(jdbcTemplate);
|
||||
Assert.notNull(jdbcTemplate, "JdbcOperations is required");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ public class DefaultExecutionContextSerializer implements ExecutionContextSerial
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void serialize(Map<String, Object> context, OutputStream out) throws IOException {
|
||||
Assert.notNull(context);
|
||||
Assert.notNull(out);
|
||||
Assert.notNull(context, "context is required");
|
||||
Assert.notNull(out, "OutputStream is required");
|
||||
|
||||
for(Object value : context.values()) {
|
||||
Assert.notNull(value);
|
||||
Assert.notNull(value, "A null value was found");
|
||||
if (!(value instanceof Serializable)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Value: [ " + value + "must be serializable."
|
||||
|
||||
@@ -15,19 +15,20 @@
|
||||
*/
|
||||
package org.springframework.batch.core.repository.dao;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.batch.core.repository.ExecutionContextSerializer;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.springframework.batch.core.repository.ExecutionContextSerializer;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Implementation that uses Jackson2 to provide (de)serialization.
|
||||
*
|
||||
@@ -60,8 +61,8 @@ public class Jackson2ExecutionContextStringSerializer implements ExecutionContex
|
||||
|
||||
public void serialize(Map<String, Object> context, OutputStream out) throws IOException {
|
||||
|
||||
Assert.notNull(context);
|
||||
Assert.notNull(out);
|
||||
Assert.notNull(context, "A context is required");
|
||||
Assert.notNull(out, "An OutputStream is required");
|
||||
|
||||
objectMapper.writeValue(out, context);
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
|
||||
*/
|
||||
private void validateJobExecution(JobExecution jobExecution) {
|
||||
|
||||
Assert.notNull(jobExecution);
|
||||
Assert.notNull(jobExecution, "jobExecution cannot be null");
|
||||
Assert.notNull(jobExecution.getJobId(), "JobExecution Job-Id cannot be null.");
|
||||
Assert.notNull(jobExecution.getStatus(), "JobExecution status cannot be null.");
|
||||
Assert.notNull(jobExecution.getCreateTime(), "JobExecution create time cannot be null");
|
||||
|
||||
@@ -153,7 +153,7 @@ JobInstanceDao, InitializingBean {
|
||||
if (instances.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
Assert.state(instances.size() == 1);
|
||||
Assert.state(instances.size() == 1, "instance counte must be 1 but was " + instances.size());
|
||||
return instances.get(0);
|
||||
}
|
||||
}
|
||||
@@ -282,7 +282,7 @@ JobInstanceDao, InitializingBean {
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
super.afterPropertiesSet();
|
||||
Assert.notNull(jobIncrementer);
|
||||
Assert.notNull(jobIncrementer, "JobIncrementer is required");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -211,7 +211,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
private void validateStepExecution(StepExecution stepExecution) {
|
||||
Assert.notNull(stepExecution);
|
||||
Assert.notNull(stepExecution, "stepExecution is required");
|
||||
Assert.notNull(stepExecution.getStepName(), "StepExecution step name cannot be null.");
|
||||
Assert.notNull(stepExecution.getStartTime(), "StepExecution start time cannot be null.");
|
||||
Assert.notNull(stepExecution.getStatus(), "StepExecution status cannot be null.");
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MapJobExecutionDao implements JobExecutionDao {
|
||||
|
||||
@Override
|
||||
public void saveJobExecution(JobExecution jobExecution) {
|
||||
Assert.isTrue(jobExecution.getId() == null);
|
||||
Assert.isTrue(jobExecution.getId() == null, "jobExecution id is not null");
|
||||
Long newId = currentId.getAndIncrement();
|
||||
jobExecution.setId(newId);
|
||||
jobExecution.incrementVersion();
|
||||
|
||||
@@ -68,8 +68,8 @@ public class MapStepExecutionDao implements StepExecutionDao {
|
||||
@Override
|
||||
public void saveStepExecution(StepExecution stepExecution) {
|
||||
|
||||
Assert.isTrue(stepExecution.getId() == null);
|
||||
Assert.isTrue(stepExecution.getVersion() == null);
|
||||
Assert.isTrue(stepExecution.getId() == null, "stepExecution id was not null");
|
||||
Assert.isTrue(stepExecution.getVersion() == null, "stepExecution version was not null");
|
||||
Assert.notNull(stepExecution.getJobExecutionId(), "JobExecution must be saved already.");
|
||||
|
||||
Map<Long, StepExecution> executions = executionsByJobExecutionId.get(stepExecution.getJobExecutionId());
|
||||
@@ -89,7 +89,7 @@ public class MapStepExecutionDao implements StepExecutionDao {
|
||||
@Override
|
||||
public void updateStepExecution(StepExecution stepExecution) {
|
||||
|
||||
Assert.notNull(stepExecution.getJobExecutionId());
|
||||
Assert.notNull(stepExecution.getJobExecutionId(), "jobExecution id is null");
|
||||
|
||||
Map<Long, StepExecution> executions = executionsByJobExecutionId.get(stepExecution.getJobExecutionId());
|
||||
Assert.notNull(executions, "step executions for given job execution are expected to be already saved");
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.springframework.util.Assert;
|
||||
* versions, this serializer is depricated in favor of
|
||||
* {@link Jackson2ExecutionContextStringSerializer}
|
||||
*/
|
||||
@Deprecated
|
||||
public class XStreamExecutionContextStringSerializer implements ExecutionContextSerializer, InitializingBean {
|
||||
|
||||
private ReflectionProvider reflectionProvider = null;
|
||||
@@ -87,8 +88,8 @@ public class XStreamExecutionContextStringSerializer implements ExecutionContext
|
||||
*/
|
||||
@Override
|
||||
public void serialize(Map<String, Object> context, OutputStream out) throws IOException {
|
||||
Assert.notNull(context);
|
||||
Assert.notNull(out);
|
||||
Assert.notNull(context, "context is required");
|
||||
Assert.notNull(out, "An OutputStream is required");
|
||||
|
||||
out.write(xstream.toXML(context).getBytes());
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
/**
|
||||
* Convenient constructor for setting only the name property.
|
||||
*
|
||||
* @param name
|
||||
* @param name Name of the step
|
||||
*/
|
||||
public AbstractStep(String name) {
|
||||
this.name = name;
|
||||
@@ -147,7 +147,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
* {@link StepExecution} before returning.
|
||||
*
|
||||
* @param stepExecution the current step context
|
||||
* @throws Exception
|
||||
* @throws Exception checked exception thrown by implementation
|
||||
*/
|
||||
protected abstract void doExecute(StepExecution stepExecution) throws Exception;
|
||||
|
||||
@@ -156,7 +156,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
* acquire resources. Does nothing by default.
|
||||
*
|
||||
* @param ctx the {@link ExecutionContext} to use
|
||||
* @throws Exception
|
||||
* @throws Exception checked exception thrown by implementation
|
||||
*/
|
||||
protected void open(ExecutionContext ctx) throws Exception {
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
* of the finally block), to close or release resources. Does nothing by default.
|
||||
*
|
||||
* @param ctx the {@link ExecutionContext} to use
|
||||
* @throws Exception
|
||||
* @throws Exception checked exception thrown by implementation
|
||||
*/
|
||||
protected void close(ExecutionContext ctx) throws Exception {
|
||||
}
|
||||
@@ -293,7 +293,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
|
||||
/**
|
||||
* Registers the {@link StepExecution} for property resolution via {@link StepScope}
|
||||
*
|
||||
* @param stepExecution
|
||||
* @param stepExecution StepExecution to use when hydrating the StepScoped beans
|
||||
*/
|
||||
protected void doExecutionRegistration(StepExecution stepExecution) {
|
||||
StepSynchronizationManager.register(stepExecution);
|
||||
|
||||
@@ -198,7 +198,7 @@ public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public SimpleStepBuilder listener(Object listener) {
|
||||
public SimpleStepBuilder<I, O> listener(Object listener) {
|
||||
super.listener(listener);
|
||||
|
||||
Set<Method> skipListenerMethods = new HashSet<Method>();
|
||||
@@ -224,7 +224,7 @@ public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
SimpleStepBuilder result = this;
|
||||
SimpleStepBuilder<I, O> result = this;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -548,12 +548,9 @@ public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
|
||||
types.add(ExhaustedRetryException.class);
|
||||
final Classifier<Throwable, Boolean> panic = new BinaryExceptionClassifier(types, true);
|
||||
|
||||
classifier = new Classifier<Throwable, Boolean>() {
|
||||
@Override
|
||||
public Boolean classify(Throwable classifiable) {
|
||||
// Rollback if either the user's list or our own applies
|
||||
return panic.classify(classifiable) || binary.classify(classifiable);
|
||||
}
|
||||
classifier = (Classifier<Throwable, Boolean>) classifiable -> {
|
||||
// Rollback if either the user's list or our own applies
|
||||
return panic.classify(classifiable) || binary.classify(classifiable);
|
||||
};
|
||||
|
||||
}
|
||||
@@ -700,8 +697,9 @@ public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
|
||||
return skipPolicyWrapper;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void addNonSkippableExceptionIfMissing(Class<? extends Throwable>... cls) {
|
||||
List<Class<? extends Throwable>> exceptions = new ArrayList<Class<? extends Throwable>>();
|
||||
List<Class<? extends Throwable>> exceptions = new ArrayList<>();
|
||||
for (Class<? extends Throwable> exceptionClass : nonSkippableExceptionClasses) {
|
||||
exceptions.add(exceptionClass);
|
||||
}
|
||||
@@ -713,8 +711,9 @@ public class FaultTolerantStepBuilder<I, O> extends SimpleStepBuilder<I, O> {
|
||||
nonSkippableExceptionClasses = exceptions;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void addNonRetryableExceptionIfMissing(Class<? extends Throwable>... cls) {
|
||||
List<Class<? extends Throwable>> exceptions = new ArrayList<Class<? extends Throwable>>();
|
||||
List<Class<? extends Throwable>> exceptions = new ArrayList<>();
|
||||
for (Class<? extends Throwable> exceptionClass : nonRetryableExceptionClasses) {
|
||||
exceptions.add(exceptionClass);
|
||||
}
|
||||
|
||||
@@ -249,10 +249,10 @@ public class SimpleStepBuilder<I, O> extends AbstractTaskletStepBuilder<SimpleSt
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public SimpleStepBuilder listener(Object listener) {
|
||||
public SimpleStepBuilder<I, O> listener(Object listener) {
|
||||
super.listener(listener);
|
||||
|
||||
Set<Method> itemListenerMethods = new HashSet<Method>();
|
||||
Set<Method> itemListenerMethods = new HashSet<>();
|
||||
itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeRead.class));
|
||||
itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), AfterRead.class));
|
||||
itemListenerMethods.addAll(ReflectionUtils.findMethod(listener.getClass(), BeforeProcess.class));
|
||||
@@ -270,7 +270,7 @@ public class SimpleStepBuilder<I, O> extends AbstractTaskletStepBuilder<SimpleSt
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
SimpleStepBuilder result = this;
|
||||
SimpleStepBuilder<I, O> result = this;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class Chunk<W> implements Iterable<W> {
|
||||
|
||||
/**
|
||||
* Add the item to the chunk.
|
||||
* @param item
|
||||
* @param item the item to add
|
||||
*/
|
||||
public void add(W item) {
|
||||
items.add(item);
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ChunkOrientedTasklet<I> implements Tasklet {
|
||||
* readers. Main (or only) use case for setting this flag to false is a
|
||||
* transactional JMS item reader.
|
||||
*
|
||||
* @param buffering
|
||||
* @param buffering indicator
|
||||
*/
|
||||
public void setBuffering(boolean buffering) {
|
||||
this.buffering = buffering;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class CallableTaskletAdapter implements Tasklet, InitializingBean {
|
||||
*/
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(callable);
|
||||
Assert.notNull(callable, "A Callable is required");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,7 +50,7 @@ public class ConfigurableSystemProcessExitCodeMapper implements SystemProcessExi
|
||||
* {@link org.springframework.batch.core.ExitStatus} values.
|
||||
*/
|
||||
public void setMappings(Map<Object, ExitStatus> mappings) {
|
||||
Assert.notNull(mappings.get(ELSE_KEY));
|
||||
Assert.notNull(mappings.get(ELSE_KEY), "Missing value for " + ELSE_KEY);
|
||||
this.mappings = mappings;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
@@ -31,6 +30,8 @@ import org.springframework.batch.core.repository.JobRestartException;
|
||||
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @since 2.0
|
||||
@@ -63,11 +64,6 @@ public abstract class AbstractJobParserTests {
|
||||
return jobRepository.createJobExecution(job.getName(), new JobParametersBuilder().addLong("key1", 1L).toJobParameters());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jobExecution
|
||||
* @param stepName
|
||||
* @return the StepExecution corresponding to the specified step
|
||||
*/
|
||||
protected StepExecution getStepExecution(JobExecution jobExecution, String stepName) {
|
||||
for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
|
||||
if (stepExecution.getStepName().equals(stepName)) {
|
||||
|
||||
@@ -15,18 +15,13 @@
|
||||
*/
|
||||
package org.springframework.batch.core.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.Step;
|
||||
import org.springframework.batch.core.step.item.SimpleChunkProcessor;
|
||||
import org.springframework.batch.core.step.skip.SkipPolicy;
|
||||
@@ -50,6 +45,12 @@ import org.springframework.retry.policy.SimpleRetryPolicy;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* @author Dan Garrette
|
||||
* @author Dave Syer
|
||||
@@ -338,7 +339,7 @@ public class ChunkElementParserTests {
|
||||
/**
|
||||
* @param object the target object
|
||||
* @param path the path to the required field
|
||||
* @return
|
||||
* @return The field
|
||||
*/
|
||||
private Object getNestedPath(Object object, String path) {
|
||||
while (StringUtils.hasText(path)) {
|
||||
|
||||
@@ -43,9 +43,9 @@ public abstract class AbstractJsrTestCase {
|
||||
* reach one of those statuses within the given timeout, a {@link java.util.concurrent.TimeoutException} is
|
||||
* thrown.
|
||||
*
|
||||
* @param jobName
|
||||
* @param properties
|
||||
* @param timeout
|
||||
* @param jobName Name of the job to run
|
||||
* @param properties Properties to pass the job
|
||||
* @param timeout length of time to wait for a job to finish
|
||||
* @return the {@link javax.batch.runtime.JobExecution} for the final state of the job
|
||||
* @throws java.util.concurrent.TimeoutException if the timeout occurs
|
||||
*/
|
||||
@@ -78,9 +78,9 @@ public abstract class AbstractJsrTestCase {
|
||||
* reach one of those statuses within the given timeout, a {@link java.util.concurrent.TimeoutException} is
|
||||
* thrown.
|
||||
*
|
||||
* @param executionId
|
||||
* @param properties
|
||||
* @param timeout
|
||||
* @param executionId The execution id to restart
|
||||
* @param properties The Properties to pass to the new run
|
||||
* @param timeout The length of time to wait for the job to run
|
||||
* @return the {@link JobExecution} for the final state of the job
|
||||
* @throws java.util.concurrent.TimeoutException if the timeout occurs
|
||||
*/
|
||||
|
||||
@@ -15,12 +15,9 @@
|
||||
*/
|
||||
package org.springframework.batch.core.jsr.configuration.xml;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.batch.api.BatchProperty;
|
||||
import javax.batch.api.Batchlet;
|
||||
import javax.batch.api.Decider;
|
||||
@@ -35,12 +32,15 @@ import javax.batch.runtime.context.JobContext;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.StepContribution;
|
||||
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
|
||||
import org.springframework.batch.core.scope.context.ChunkContext;
|
||||
import org.springframework.batch.core.step.tasklet.Tasklet;
|
||||
import org.springframework.batch.repeat.RepeatStatus;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Configuration test for parsing various <properties /> elements defined by JSR-352.
|
||||
@@ -78,30 +78,30 @@ public class JobPropertyTests extends AbstractJsrTestCase {
|
||||
|
||||
@Override
|
||||
public void open(Serializable serializable) throws Exception {
|
||||
org.springframework.util.Assert.notNull(stepContext);
|
||||
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step2PropertyName1"));
|
||||
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step2PropertyName2"));
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step1PropertyName1").equals("step1PropertyValue1"));
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step1PropertyName2").equals("step1PropertyValue2"));
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName1") == null);
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName2") == null);
|
||||
org.springframework.util.Assert.isTrue("readerPropertyValue1".equals(readerPropertyName1));
|
||||
org.springframework.util.Assert.isTrue("readerPropertyValue2".equals(readerPropertyName2));
|
||||
org.springframework.util.Assert.isTrue("annotationNamedReaderPropertyValue".equals(annotationNamedProperty));
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty);
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
|
||||
org.springframework.util.Assert.isNull(batchAnnotatedOnlyField);
|
||||
org.springframework.util.Assert.notNull(injectAnnotatedOnlyField);
|
||||
org.springframework.util.Assert.isTrue("job1".equals(injectAnnotatedOnlyField.getJobName()));
|
||||
org.springframework.util.Assert.isNull(readerPropertyName3);
|
||||
org.springframework.util.Assert.notNull(stepContext, "stepContext is not null");
|
||||
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step2PropertyName1"), "step2PropertyName1 is not null");
|
||||
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step2PropertyName2"), "step2PropertyName2 is not null");
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step1PropertyName1").equals("step1PropertyValue1"), "The value of step2PropertyName1 does not equal step2PropertyName1");
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step1PropertyName2").equals("step1PropertyValue2"), "The value of step2PropertyName2 does not equal step2PropertyName2");
|
||||
org.springframework.util.Assert.isNull(stepContext.getProperties().get("jobPropertyName1"), "jobPropertyName1 is not null");
|
||||
org.springframework.util.Assert.isNull(stepContext.getProperties().get("jobPropertyName2") == null, "jobPropertyName2 is not null");
|
||||
org.springframework.util.Assert.isTrue("readerPropertyValue1".equals(readerPropertyName1), "The value of readerPropertyValue1 does not equal readerPropertyValue1");
|
||||
org.springframework.util.Assert.isTrue("readerPropertyValue2".equals(readerPropertyName2), "The value of readerPropertyValue2 does not equal readerPropertyValue2");
|
||||
org.springframework.util.Assert.isTrue("annotationNamedReaderPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedReaderPropertyValue does not equal annotationNamedReaderPropertyValue");
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
|
||||
org.springframework.util.Assert.isNull(batchAnnotatedOnlyField, "batchAnnotatedOnlyField is not null");
|
||||
org.springframework.util.Assert.notNull(injectAnnotatedOnlyField, "injectAnnotatedOnlyField is not null");
|
||||
org.springframework.util.Assert.isTrue("job1".equals(injectAnnotatedOnlyField.getJobName()), "injectAnnotatedOnlyField does not equal job1");
|
||||
org.springframework.util.Assert.isNull(readerPropertyName3, "readerPropertyName3 is not null");
|
||||
|
||||
Properties jobProperties = injectAnnotatedOnlyField.getProperties();
|
||||
org.springframework.util.Assert.isTrue(jobProperties.size() == 5);
|
||||
org.springframework.util.Assert.isTrue(jobProperties.get("jobPropertyName1").equals("jobPropertyValue1"));
|
||||
org.springframework.util.Assert.isTrue(jobProperties.get("jobPropertyName2").equals("jobPropertyValue2"));
|
||||
org.springframework.util.Assert.isTrue(jobProperties.get("step2name").equals("step2"));
|
||||
org.springframework.util.Assert.isTrue(jobProperties.get("filestem").equals("postings"));
|
||||
org.springframework.util.Assert.isTrue(jobProperties.get("x").equals("xVal"));
|
||||
org.springframework.util.Assert.isTrue(jobProperties.size() == 5, "jobProperties has the wrong number of values. Expected 5, got " + jobProperties.size());
|
||||
org.springframework.util.Assert.isTrue(jobProperties.get("jobPropertyName1").equals("jobPropertyValue1"), "The value of jobPropertyName1 does not equal jobPropertyName1");
|
||||
org.springframework.util.Assert.isTrue(jobProperties.get("jobPropertyName2").equals("jobPropertyValue2"), "The value of jobPropertyName2 does not equal jobPropertyName2");
|
||||
org.springframework.util.Assert.isTrue(jobProperties.get("step2name").equals("step2"), "The value of step2name does note equal step2");
|
||||
org.springframework.util.Assert.isTrue(jobProperties.get("filestem").equals("postings"), "The value of filestem does not equal postings");
|
||||
org.springframework.util.Assert.isTrue(jobProperties.get("x").equals("xVal"), "The value of x does not equal xVal");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,11 +133,11 @@ public class JobPropertyTests extends AbstractJsrTestCase {
|
||||
|
||||
@Override
|
||||
public Object processItem(Object o) throws Exception {
|
||||
org.springframework.util.Assert.isTrue("processorPropertyValue1".equals(processorPropertyName1));
|
||||
org.springframework.util.Assert.isTrue("processorPropertyValue2".equals(processorPropertyName2));
|
||||
org.springframework.util.Assert.isTrue("annotationNamedProcessorPropertyValue".equals(annotationNamedProperty));
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty);
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
|
||||
org.springframework.util.Assert.isTrue("processorPropertyValue1".equals(processorPropertyName1), "The value of processorPropertyValue1 does not equal processorPropertyValue1");
|
||||
org.springframework.util.Assert.isTrue("processorPropertyValue2".equals(processorPropertyName2), "The value of processorPropertyValue2 does not equal processorPropertyValue2");
|
||||
org.springframework.util.Assert.isTrue("annotationNamedProcessorPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedProcessorPropertyValue does not equal annotationNamedProcessorPropertyValue");
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty, "The notDefinedProperty is not null");
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "The notDefinedNamedProperty is not null");
|
||||
|
||||
return o;
|
||||
}
|
||||
@@ -152,11 +152,11 @@ public class JobPropertyTests extends AbstractJsrTestCase {
|
||||
|
||||
@Override
|
||||
public void open(Serializable serializable) throws Exception {
|
||||
org.springframework.util.Assert.isTrue("writerPropertyValue1".equals(writerPropertyName1));
|
||||
org.springframework.util.Assert.isTrue("writerPropertyValue2".equals(writerPropertyName2));
|
||||
org.springframework.util.Assert.isTrue("annotationNamedWriterPropertyValue".equals(annotationNamedProperty));
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty);
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
|
||||
org.springframework.util.Assert.isTrue("writerPropertyValue1".equals(writerPropertyName1), "The value of writerPropertyValue1 does not equal writerPropertyValue1");
|
||||
org.springframework.util.Assert.isTrue("writerPropertyValue2".equals(writerPropertyName2), "The value of writerPropertyValue2 does not equal writerPropertyValue2");
|
||||
org.springframework.util.Assert.isTrue("annotationNamedWriterPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedWriterPropertyValue does not equal annotationNamedWriterPropertyValue");
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,11 +188,11 @@ public class JobPropertyTests extends AbstractJsrTestCase {
|
||||
|
||||
@Override
|
||||
public void beginCheckpoint() throws Exception {
|
||||
org.springframework.util.Assert.isTrue("algorithmPropertyValue1".equals(algorithmPropertyName1));
|
||||
org.springframework.util.Assert.isTrue("algorithmPropertyValue2".equals(algorithmPropertyName2));
|
||||
org.springframework.util.Assert.isTrue("annotationNamedAlgorithmPropertyValue".equals(annotationNamedProperty));
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty);
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
|
||||
org.springframework.util.Assert.isTrue("algorithmPropertyValue1".equals(algorithmPropertyName1), "The value of algorithmPropertyValue1 does not equal algorithmPropertyValue1");
|
||||
org.springframework.util.Assert.isTrue("algorithmPropertyValue2".equals(algorithmPropertyName2), "The value of algorithmPropertyValue2 does not equal algorithmPropertyValue2");
|
||||
org.springframework.util.Assert.isTrue("annotationNamedAlgorithmPropertyValue".equals(annotationNamedProperty), "The annotationNamedAlgorithmPropertyValue does not equal annotationNamedAlgorithmPropertyValue");
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -214,11 +214,11 @@ public class JobPropertyTests extends AbstractJsrTestCase {
|
||||
|
||||
@Override
|
||||
public String decide(javax.batch.runtime.StepExecution[] executions) throws Exception {
|
||||
org.springframework.util.Assert.isTrue("deciderPropertyValue1".equals(deciderPropertyName1));
|
||||
org.springframework.util.Assert.isTrue("deciderPropertyValue2".equals(deciderPropertyName2));
|
||||
org.springframework.util.Assert.isTrue("annotationNamedDeciderPropertyValue".equals(annotationNamedProperty));
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty);
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
|
||||
org.springframework.util.Assert.isTrue("deciderPropertyValue1".equals(deciderPropertyName1), "The value of deciderPropertyValue1 does not equal deciderPropertyValue1");
|
||||
org.springframework.util.Assert.isTrue("deciderPropertyValue2".equals(deciderPropertyName2), "The value of deciderPropertyValue2 does not equal deciderPropertyValue2");
|
||||
org.springframework.util.Assert.isTrue("annotationNamedDeciderPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedDeciderPropertyValue does not equal annotationNamedDeciderPropertyValue");
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
|
||||
|
||||
return "step2";
|
||||
}
|
||||
@@ -233,11 +233,11 @@ public class JobPropertyTests extends AbstractJsrTestCase {
|
||||
|
||||
@Override
|
||||
public void beforeStep() throws Exception {
|
||||
org.springframework.util.Assert.isTrue("stepListenerPropertyValue1".equals(stepListenerPropertyName1));
|
||||
org.springframework.util.Assert.isTrue("stepListenerPropertyValue2".equals(stepListenerPropertyName2));
|
||||
org.springframework.util.Assert.isTrue("annotationNamedStepListenerPropertyValue".equals(annotationNamedProperty));
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty);
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
|
||||
org.springframework.util.Assert.isTrue("stepListenerPropertyValue1".equals(stepListenerPropertyName1), "The value of stepListenerPropertyValue1 does not equal stepListenerPropertyValue1");
|
||||
org.springframework.util.Assert.isTrue("stepListenerPropertyValue2".equals(stepListenerPropertyName2), "The value of stepListenerPropertyValue2 does not equal stepListenerPropertyValue2");
|
||||
org.springframework.util.Assert.isTrue("annotationNamedStepListenerPropertyValue".equals(annotationNamedProperty), "The value of annotationNamedStepListenerPropertyValue does note equal annotationNamedStepListenerPropertyValue");
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -258,22 +258,22 @@ public class JobPropertyTests extends AbstractJsrTestCase {
|
||||
|
||||
@Override
|
||||
public String process() throws Exception {
|
||||
org.springframework.util.Assert.notNull(stepContext);
|
||||
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step1PropertyName1"));
|
||||
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step1PropertyName2"));
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step2PropertyName1").equals("step2PropertyValue1"));
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step2PropertyName2").equals("step2PropertyValue2"));
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName1") == null);
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName2") == null);
|
||||
org.springframework.util.Assert.notNull(stepContext, "StepContext is not null");
|
||||
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step1PropertyName1"), "The value of step1PropertyName1 is not null");
|
||||
org.springframework.util.Assert.isNull(stepContext.getProperties().get("step1PropertyName2"), "The value of step1PropertyName2 is not null");
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step2PropertyName1").equals("step2PropertyValue1"), "The value of step2PropertyName1 does not equal step2PropertyName1");
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("step2PropertyName2").equals("step2PropertyValue2"), "The value of step2PropertyName2 does not equal step2PropertyName2");
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName1") == null, "jobPropertyName1 is not null");
|
||||
org.springframework.util.Assert.isTrue(stepContext.getProperties().get("jobPropertyName2") == null, "jobPropertyName2 is not null");
|
||||
|
||||
org.springframework.util.Assert.isTrue("batchletPropertyValue1".equals(batchletPropertyName1));
|
||||
org.springframework.util.Assert.isTrue("batchletPropertyValue2".equals(batchletPropertyName2));
|
||||
org.springframework.util.Assert.isTrue("annotationNamedBatchletPropertyValue".equals(annotationNamedProperty));
|
||||
org.springframework.util.Assert.isTrue("postings.txt".equals(infile));
|
||||
org.springframework.util.Assert.isTrue("xVal".equals(y));
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty);
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty);
|
||||
org.springframework.util.Assert.isNull(x);
|
||||
org.springframework.util.Assert.isTrue("batchletPropertyValue1".equals(batchletPropertyName1), "batchletPropertyValue1 does not equal batchletPropertyValue1");
|
||||
org.springframework.util.Assert.isTrue("batchletPropertyValue2".equals(batchletPropertyName2), "batchletPropertyValue2 does not equal batchletPropertyValue2");
|
||||
org.springframework.util.Assert.isTrue("annotationNamedBatchletPropertyValue".equals(annotationNamedProperty), "annotationNamedBatchletPropertyValue does not equal annotationNamedBatchletPropertyValue");
|
||||
org.springframework.util.Assert.isTrue("postings.txt".equals(infile), "infile does not equal postings.txt");
|
||||
org.springframework.util.Assert.isTrue("xVal".equals(y), "y does not equal xVal");
|
||||
org.springframework.util.Assert.isNull(notDefinedProperty, "notDefinedProperty is not null");
|
||||
org.springframework.util.Assert.isNull(notDefinedAnnotationNamedProperty, "notDefinedAnnotationNamedProperty is not null");
|
||||
org.springframework.util.Assert.isNull(x, "x is not null");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -290,7 +290,7 @@ public class JobPropertyTests extends AbstractJsrTestCase {
|
||||
|
||||
@Override
|
||||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
|
||||
org.springframework.util.Assert.isTrue("p1val".equals(p1));
|
||||
org.springframework.util.Assert.isTrue("p1val".equals(p1), "Expected p1val, got " + p1);
|
||||
|
||||
return RepeatStatus.FINISHED;
|
||||
}
|
||||
|
||||
@@ -15,11 +15,16 @@
|
||||
*/
|
||||
package org.springframework.batch.core.jsr.configuration.xml;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.batch.api.BatchProperty;
|
||||
import javax.batch.api.Batchlet;
|
||||
import javax.batch.api.chunk.AbstractItemReader;
|
||||
@@ -31,16 +36,12 @@ import javax.batch.runtime.JobExecution;
|
||||
import javax.batch.runtime.context.JobContext;
|
||||
import javax.batch.runtime.context.StepContext;
|
||||
import javax.inject.Inject;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.jsr.AbstractJsrTestCase;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -221,14 +222,14 @@ public class PartitionParserTests extends AbstractJsrTestCase {
|
||||
public void analyzeCollectorData(Serializable data) throws Exception {
|
||||
name = artifactName;
|
||||
|
||||
Assert.isTrue(data.equals("c"));
|
||||
Assert.isTrue(data.equals("c"), "Expected c but was " + data);
|
||||
jobContext.setExitStatus(jobContext.getExitStatus() + data + "a");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analyzeStatus(BatchStatus batchStatus, String exitStatus)
|
||||
throws Exception {
|
||||
Assert.isTrue(batchStatus.equals(BatchStatus.COMPLETED));
|
||||
Assert.isTrue(batchStatus.equals(BatchStatus.COMPLETED), String.format("expected %s but received %s", BatchStatus.COMPLETED, batchStatus));
|
||||
jobContext.setExitStatus(jobContext.getExitStatus() + "AS");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class RetryListenerTests {
|
||||
|
||||
String currentItem = (String) item;
|
||||
|
||||
Assert.isTrue("three".equals(currentItem));
|
||||
Assert.isTrue("three".equals(currentItem), "currentItem was expected to be three but was not " + currentItem);
|
||||
Assert.isInstanceOf(IllegalArgumentException.class, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,9 @@ public class ThreadLocalClassloaderBeanPostProcessorTestsBatchlet implements Bat
|
||||
@Override
|
||||
public String process() throws Exception {
|
||||
Assert.isTrue("someParameter".equals(jobParam1), jobParam1 + " does not equal someParamter");
|
||||
Assert.isTrue("threadLocalClassloaderBeanPostProcessorTestsJob".equals(jobContext.getJobName()));
|
||||
Assert.isTrue("step1".equals(stepContext.getStepName()));
|
||||
Assert.isTrue("threadLocalClassloaderBeanPostProcessorTestsJob".equals(jobContext.getJobName()),
|
||||
"jobName does not equal threadLocalClassloaderBeanPostProcessorTestsJob");
|
||||
Assert.isTrue("step1".equals(stepContext.getStepName()), "stepName does not equal step1");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -140,8 +140,8 @@ public class DecisionStepTests extends AbstractJsrTestCase {
|
||||
|
||||
@Override
|
||||
public String decide(StepExecution[] executions) throws Exception {
|
||||
Assert.isTrue(executions.length == 1);
|
||||
Assert.isTrue(executions[0].getStepName().equals("step1"));
|
||||
Assert.isTrue(executions.length == 1, "Invalid array length");
|
||||
Assert.isTrue(executions[0].getStepName().equals("step1"), "Incorrect step name");
|
||||
|
||||
if(runs == 0) {
|
||||
runs++;
|
||||
|
||||
@@ -15,15 +15,16 @@
|
||||
*/
|
||||
package org.springframework.batch.core.listener;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
/**
|
||||
* Tests for {@link ExecutionContextPromotionListener}.
|
||||
*/
|
||||
@@ -57,8 +58,8 @@ public class ExecutionContextPromotionListenerTests {
|
||||
StepExecution stepExecution = jobExecution.createStepExecution("step1");
|
||||
stepExecution.setExitStatus(ExitStatus.COMPLETED);
|
||||
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
|
||||
|
||||
stepExecution.getExecutionContext().putString(key, value);
|
||||
stepExecution.getExecutionContext().putString(key2, value2);
|
||||
@@ -87,8 +88,8 @@ public class ExecutionContextPromotionListenerTests {
|
||||
StepExecution stepExecution = jobExecution.createStepExecution("step1");
|
||||
stepExecution.setExitStatus(new ExitStatus(status));
|
||||
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
|
||||
|
||||
stepExecution.getExecutionContext().putString(key, value);
|
||||
stepExecution.getExecutionContext().putString(key2, value2);
|
||||
@@ -117,8 +118,8 @@ public class ExecutionContextPromotionListenerTests {
|
||||
StepExecution stepExecution = jobExecution.createStepExecution("step1");
|
||||
stepExecution.setExitStatus(new ExitStatus(status2));
|
||||
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
|
||||
|
||||
stepExecution.getExecutionContext().putString(key, value);
|
||||
stepExecution.getExecutionContext().putString(key2, value2);
|
||||
@@ -147,8 +148,8 @@ public class ExecutionContextPromotionListenerTests {
|
||||
StepExecution stepExecution = jobExecution.createStepExecution("step1");
|
||||
stepExecution.setExitStatus(new ExitStatus(status));
|
||||
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
|
||||
|
||||
stepExecution.getExecutionContext().putString(key, value);
|
||||
stepExecution.getExecutionContext().putString(key2, value2);
|
||||
@@ -176,8 +177,8 @@ public class ExecutionContextPromotionListenerTests {
|
||||
StepExecution stepExecution = jobExecution.createStepExecution("step1");
|
||||
stepExecution.setExitStatus(ExitStatus.COMPLETED);
|
||||
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
|
||||
|
||||
stepExecution.getExecutionContext().putString(key, value);
|
||||
|
||||
@@ -203,8 +204,8 @@ public class ExecutionContextPromotionListenerTests {
|
||||
StepExecution stepExecution = jobExecution.createStepExecution("step1");
|
||||
stepExecution.setExitStatus(ExitStatus.COMPLETED);
|
||||
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
|
||||
|
||||
jobExecution.getExecutionContext().putString(key, value);
|
||||
|
||||
@@ -231,8 +232,8 @@ public class ExecutionContextPromotionListenerTests {
|
||||
StepExecution stepExecution = jobExecution.createStepExecution("step1");
|
||||
stepExecution.setExitStatus(ExitStatus.COMPLETED);
|
||||
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty());
|
||||
Assert.state(jobExecution.getExecutionContext().isEmpty(), "Job ExecutionContext is not empty");
|
||||
Assert.state(stepExecution.getExecutionContext().isEmpty(), "Step ExecutionContext is not empty");
|
||||
|
||||
stepExecution.getExecutionContext().putString(key, value);
|
||||
|
||||
|
||||
@@ -15,23 +15,17 @@
|
||||
*/
|
||||
package org.springframework.batch.core.listener;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.batch.core.listener.StepListenerMetaData.AFTER_STEP;
|
||||
import static org.springframework.batch.core.listener.StepListenerMetaData.AFTER_WRITE;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.batch.core.ChunkListener;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
@@ -63,6 +57,12 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.springframework.batch.core.listener.StepListenerMetaData.AFTER_STEP;
|
||||
import static org.springframework.batch.core.listener.StepListenerMetaData.AFTER_WRITE;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
@@ -380,7 +380,7 @@ public class StepListenerFactoryBeanTests {
|
||||
@Override
|
||||
@AfterStep
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
Assert.notNull(stepExecution);
|
||||
Assert.notNull(stepExecution, "A stepExecution is required");
|
||||
callcount++;
|
||||
return null;
|
||||
}
|
||||
@@ -399,7 +399,7 @@ public class StepListenerFactoryBeanTests {
|
||||
|
||||
@Override
|
||||
public ExitStatus afterStep(StepExecution stepExecution) {
|
||||
Assert.notNull(stepExecution);
|
||||
Assert.notNull(stepExecution, "A stepExecution is required");
|
||||
callcount++;
|
||||
return null;
|
||||
}
|
||||
@@ -489,7 +489,7 @@ public class StepListenerFactoryBeanTests {
|
||||
|
||||
@AfterRead
|
||||
public void afterReadMethod(Object item) {
|
||||
Assert.notNull(item);
|
||||
Assert.notNull(item, "An item is required");
|
||||
afterReadCalled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core.repository.dao;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
@@ -28,6 +23,7 @@ import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.batch.core.BatchStatus;
|
||||
import org.springframework.batch.core.ExitStatus;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
@@ -36,7 +32,12 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.dao.OptimisticLockingFailureException;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public abstract class AbstractJobExecutionDaoTests {
|
||||
|
||||
@@ -307,13 +308,13 @@ public abstract class AbstractJobExecutionDaoTests {
|
||||
dao.saveJobExecution(exec1);
|
||||
|
||||
JobExecution exec2 = new JobExecution(jobInstance, jobParameters);
|
||||
Assert.state(exec1.getId() != null);
|
||||
assertTrue(exec1.getId() != null);
|
||||
exec2.setId(exec1.getId());
|
||||
|
||||
exec2.setStatus(BatchStatus.STARTED);
|
||||
exec2.setVersion(7);
|
||||
Assert.state(exec1.getVersion() != exec2.getVersion());
|
||||
Assert.state(exec1.getStatus() != exec2.getStatus());
|
||||
assertTrue(exec1.getVersion() != exec2.getVersion());
|
||||
assertTrue(exec1.getStatus() != exec2.getStatus());
|
||||
|
||||
dao.synchronizeStatus(exec2);
|
||||
|
||||
@@ -334,13 +335,13 @@ public abstract class AbstractJobExecutionDaoTests {
|
||||
dao.saveJobExecution(exec1);
|
||||
|
||||
JobExecution exec2 = new JobExecution(jobInstance, jobParameters);
|
||||
Assert.state(exec1.getId() != null);
|
||||
assertTrue(exec1.getId() != null);
|
||||
exec2.setId(exec1.getId());
|
||||
|
||||
exec2.setStatus(BatchStatus.UNKNOWN);
|
||||
exec2.setVersion(7);
|
||||
Assert.state(exec1.getVersion() != exec2.getVersion());
|
||||
Assert.state(exec1.getStatus().isLessThan(exec2.getStatus()));
|
||||
assertTrue(exec1.getVersion() != exec2.getVersion());
|
||||
assertTrue(exec1.getStatus().isLessThan(exec2.getStatus()));
|
||||
|
||||
dao.synchronizeStatus(exec2);
|
||||
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
*/
|
||||
package org.springframework.batch.core.step.item;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -30,6 +26,10 @@ import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
@@ -81,8 +81,7 @@ public class AlmostStatefulRetryChunkTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chunk
|
||||
* @throws Exception
|
||||
* @param chunk Chunk to retry
|
||||
*/
|
||||
private void statefulRetry(Chunk<String> chunk) throws Exception {
|
||||
if (retryAttempts <= retryLimit) {
|
||||
@@ -113,8 +112,7 @@ public class AlmostStatefulRetryChunkTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chunk
|
||||
* @throws Exception
|
||||
* @param chunk Chunk to recover
|
||||
*/
|
||||
private void recover(Chunk<String> chunk) throws Exception {
|
||||
for (Chunk<String>.ChunkIterator iterator = chunk.iterator(); iterator.hasNext();) {
|
||||
@@ -129,8 +127,7 @@ public class AlmostStatefulRetryChunkTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param items
|
||||
* @throws Exception
|
||||
* @param items items to write
|
||||
*/
|
||||
private void doWrite(List<String> items) throws Exception {
|
||||
if (items.contains("fail")) {
|
||||
|
||||
@@ -224,7 +224,7 @@ public class SystemCommandTaskletIntegrationTests {
|
||||
@Test
|
||||
public void testWorkingDirectory() throws Exception {
|
||||
File notExistingFile = new File("not-existing-path");
|
||||
Assert.state(!notExistingFile.exists());
|
||||
Assert.state(!notExistingFile.exists(), "not-existing-path does actually exist");
|
||||
|
||||
try {
|
||||
tasklet.setWorkingDirectory(notExistingFile.getCanonicalPath());
|
||||
@@ -235,8 +235,8 @@ public class SystemCommandTaskletIntegrationTests {
|
||||
}
|
||||
|
||||
File notDirectory = File.createTempFile(this.getClass().getName(), null);
|
||||
Assert.state(notDirectory.exists());
|
||||
Assert.state(!notDirectory.isDirectory());
|
||||
Assert.state(notDirectory.exists(), "The file does not exist");
|
||||
Assert.state(!notDirectory.isDirectory(), "The file is actually a directory");
|
||||
|
||||
try {
|
||||
tasklet.setWorkingDirectory(notDirectory.getCanonicalPath());
|
||||
@@ -247,8 +247,8 @@ public class SystemCommandTaskletIntegrationTests {
|
||||
}
|
||||
|
||||
File directory = notDirectory.getParentFile();
|
||||
Assert.state(directory.exists());
|
||||
Assert.state(directory.isDirectory());
|
||||
Assert.state(directory.exists(), "The directory does not exist");
|
||||
Assert.state(directory.isDirectory(), "The directory is not a directory");
|
||||
|
||||
// no error expected now
|
||||
tasklet.setWorkingDirectory(directory.getCanonicalPath());
|
||||
|
||||
@@ -16,9 +16,14 @@
|
||||
|
||||
package test.jdbc.datasource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
@@ -33,10 +38,6 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Wrapper for a {@link DataSource} that can run scripts on start up and shut
|
||||
* down. Us as a bean definition <br><br>
|
||||
@@ -75,7 +76,7 @@ public class DataSourceInitializer implements InitializingBean {
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(dataSource);
|
||||
Assert.notNull(dataSource, "A DataSource is required");
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user