IN PROGRESS - BATCH-709: Change all collections to use generics

This commit is contained in:
robokaso
2008-07-17 16:09:42 +00:00
parent 209d24abda
commit cb5584bc1d
37 changed files with 147 additions and 133 deletions

View File

@@ -32,7 +32,7 @@ public class JobParametersBuilderTests extends TestCase {
parametersBuilder.addDate("SCHEDULE_DATE", date);
parametersBuilder.addLong("LONG", new Long(1));
parametersBuilder.addString("STRING", "string value");
Iterator parameters = parametersBuilder.toJobParameters().getParameters().keySet().iterator();
Iterator<String> parameters = parametersBuilder.toJobParameters().getParameters().keySet().iterator();
assertEquals("STRING", parameters.next());
assertEquals("LONG", parameters.next());
assertEquals("SCHEDULE_DATE", parameters.next());
@@ -42,7 +42,7 @@ public class JobParametersBuilderTests extends TestCase {
parametersBuilder.addString("foo", "value foo");
parametersBuilder.addString("bar", "value bar");
parametersBuilder.addString("spam", "value spam");
Iterator parameters = parametersBuilder.toJobParameters().getParameters().keySet().iterator();
Iterator<String> parameters = parametersBuilder.toJobParameters().getParameters().keySet().iterator();
assertEquals("foo", parameters.next());
assertEquals("bar", parameters.next());
assertEquals("spam", parameters.next());

View File

@@ -5,14 +5,13 @@ package org.springframework.batch.core;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang.SerializationUtils;
import junit.framework.TestCase;
import org.apache.commons.lang.SerializationUtils;
/**
* @author Lucas Ward
*
@@ -21,13 +20,13 @@ public class JobParametersTests extends TestCase {
JobParameters parameters;
Map stringMap;
Map<String, String> stringMap;
Map longMap;
Map<String, Long> longMap;
Map dateMap;
Map doubleMap;
Map<String, Date> dateMap;
Map<String, Double> doubleMap;
Date date1 = new Date(4321431242L);
@@ -40,25 +39,26 @@ public class JobParametersTests extends TestCase {
private JobParameters getNewParameters() {
stringMap = new HashMap();
stringMap = new HashMap<String, String>();
stringMap.put("string.key1", "value1");
stringMap.put("string.key2", "value2");
longMap = new HashMap();
longMap = new HashMap<String, Long>();
longMap.put("long.key1", new Long(1));
longMap.put("long.key2", new Long(2));
doubleMap = new HashMap();
doubleMap = new HashMap<String, Double>();
doubleMap.put("double.key1", new Double(1.1));
doubleMap.put("double.key2", new Double(2.2));
dateMap = new HashMap();
dateMap = new HashMap<String, Date>();
dateMap.put("date.key1", date1);
dateMap.put("date.key2", date2);
return new JobParameters(stringMap, longMap, doubleMap, dateMap);
}
@SuppressWarnings("unchecked")
public void testBadLongKeyException() throws Exception {
Map badLongMap = new HashMap();
@@ -73,6 +73,7 @@ public class JobParametersTests extends TestCase {
}
}
@SuppressWarnings("unchecked")
public void testBadLongConstructorException() throws Exception {
Map badLongMap = new HashMap();
@@ -86,7 +87,8 @@ public class JobParametersTests extends TestCase {
// expected
}
}
@SuppressWarnings("unchecked")
public void testBadDoubleConstructorException() throws Exception {
Map badDoubleMap = new HashMap();
@@ -101,6 +103,7 @@ public class JobParametersTests extends TestCase {
}
}
@SuppressWarnings("unchecked")
public void testBadStringConstructorException() throws Exception {
Map badMap = new HashMap();
@@ -115,6 +118,7 @@ public class JobParametersTests extends TestCase {
}
}
@SuppressWarnings("unchecked")
public void testBadDateConstructorException() throws Exception {
Map badMap = new HashMap();
@@ -148,12 +152,12 @@ public class JobParametersTests extends TestCase {
assertEquals(new Long(1), parameters.getLongParameters().get("long.key1"));
assertEquals(new Long(2), parameters.getLongParameters().get("long.key2"));
}
public void testGetDouble() {
assertEquals(new Double(1.1), parameters.getDouble("double.key1"));
assertEquals(new Double(2.2), parameters.getDouble("double.key2"));
}
public void testGetDoubleParameters() {
assertEquals(new Double(1.1), parameters.getDoubleParameters().get("double.key1"));
assertEquals(new Double(2.2), parameters.getDoubleParameters().get("double.key2"));
@@ -200,28 +204,27 @@ public class JobParametersTests extends TestCase {
public void testToStringOrder() {
Map props = parameters.getParameters();
Map<String, Object> props = parameters.getParameters();
StringBuffer stringBuilder = new StringBuffer();
for (Iterator it = props.entrySet().iterator(); it.hasNext();) {
Entry entry = (Entry) it.next();
for (Entry<?, ?> entry : props.entrySet()) {
stringBuilder.append(entry.toString() + ";");
}
String string1 = stringBuilder.toString();
stringMap = new HashMap();
stringMap = new HashMap<String, String>();
stringMap.put("string.key2", "value2");
stringMap.put("string.key1", "value1");
longMap = new HashMap();
longMap = new HashMap<String, Long>();
longMap.put("long.key2", new Long(2));
longMap.put("long.key1", new Long(1));
doubleMap = new HashMap();
doubleMap = new HashMap<String, Double>();
doubleMap.put("double.key2", new Double(2.2));
doubleMap.put("double.key1", new Double(1.1));
dateMap = new HashMap();
dateMap = new HashMap<String, Date>();
dateMap.put("date.key2", date2);
dateMap.put("date.key1", date1);
@@ -229,8 +232,7 @@ public class JobParametersTests extends TestCase {
props = testProps.getParameters();
stringBuilder = new StringBuffer();
for (Iterator it = props.entrySet().iterator(); it.hasNext();) {
Entry entry = (Entry) it.next();
for (Entry<?, ?> entry : props.entrySet()) {
stringBuilder.append(entry.toString() + ";");
}
String string2 = stringBuilder.toString();
@@ -247,12 +249,12 @@ public class JobParametersTests extends TestCase {
int code = getNewParameters().hashCode();
assertEquals(code, parameters.hashCode());
}
public void testSerialization() {
JobParameters params = getNewParameters();
byte[] serialized = SerializationUtils.serialize(params);
assertEquals(params, SerializationUtils.deserialize(serialized));
}
}

View File

@@ -211,7 +211,7 @@ public class StepExecutionTests extends TestCase {
}
public void testHashCodeViaHashSet() throws Exception {
Set set = new HashSet();
Set<StepExecution> set = new HashSet<StepExecution>();
set.add(execution);
assertTrue(set.contains(execution));
execution.setExecutionContext(foobarEc);

View File

@@ -103,7 +103,7 @@ public class JobRegistryBeanPostProcessorTests extends TestCase {
"test-context.xml", getClass());
MapJobRegistry registry = (MapJobRegistry) context
.getBean("registry");
Collection configurations = registry.getJobNames();
Collection<String> configurations = registry.getJobNames();
// System.err.println(configurations);
String[] names = context.getBeanNamesForType(JobSupport.class);
int count = names.length;

View File

@@ -89,7 +89,7 @@ public class MapJobRegistryTests extends TestCase {
JobFactory jobFactory = new ReferenceJobFactory(new JobSupport("foo"));
registry.register(jobFactory);
registry.register(new ReferenceJobFactory(new JobSupport("bar")));
Collection configurations = registry.getJobNames();
Collection<String> configurations = registry.getJobNames();
assertEquals(2, configurations.size());
assertTrue(configurations.contains(jobFactory.getJobName()));
}

View File

@@ -37,7 +37,7 @@ import org.springframework.util.ClassUtils;
*/
public class JobSupport implements BeanNameAware, Job {
private List steps = new ArrayList();
private List<Step> steps = new ArrayList<Step>();
private String name;
@@ -98,11 +98,11 @@ public class JobSupport implements BeanNameAware, Job {
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.IJob#getSteps()
*/
public List getSteps() {
public List<Step> getSteps() {
return steps;
}
public void setSteps(List steps) {
public void setSteps(List<Step> steps) {
this.steps.clear();
this.steps.addAll(steps);
}

View File

@@ -16,6 +16,7 @@
package org.springframework.batch.core.job;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -63,7 +64,7 @@ public class SimpleJobTests extends TestCase {
private StepExecutionDao stepExecutionDao;
private List list = new ArrayList();
private List<Serializable> list = new ArrayList<Serializable>();
private JobInstance jobInstance;
@@ -109,7 +110,7 @@ public class SimpleJobTests extends TestCase {
step1.setJobRepository(jobRepository);
step2.setJobRepository(jobRepository);
List steps = new ArrayList();
List<Step> steps = new ArrayList<Step>();
steps.add(step1);
steps.add(step2);
job.setName("testJob");
@@ -146,7 +147,7 @@ public class SimpleJobTests extends TestCase {
return false;
}
};
List steps = new ArrayList();
List<Step> steps = new ArrayList<Step>();
steps.add(testStep);
job.setSteps(steps);
job.execute(jobExecution);
@@ -289,7 +290,7 @@ public class SimpleJobTests extends TestCase {
}
public void testNoSteps() throws Exception {
job.setSteps(new ArrayList());
job.setSteps(new ArrayList<Step>());
job.execute(jobExecution);
ExitStatus exitStatus = jobExecution.getExitStatus();

View File

@@ -40,11 +40,12 @@ public class EmptyItemWriter implements ItemWriter, InitializingBean {
protected Log logger = LogFactory.getLog(EmptyItemWriter.class);
List list;
List<Object> list;
@SuppressWarnings("unchecked")
public void afterPropertiesSet() throws Exception {
TransactionAwareProxyFactory factory = new TransactionAwareProxyFactory(new ArrayList());
list = (List) factory.createInstance();
list = (List<Object>) factory.createInstance();
}
public void setFailurePoint(int failurePoint) {
@@ -60,7 +61,7 @@ public class EmptyItemWriter implements ItemWriter, InitializingBean {
list.add(data);
}
public List getList() {
public List<Object> getList() {
return list;
}

View File

@@ -78,7 +78,7 @@ public class SimpleJobLauncherTests extends TestCase {
}
public void testTaskExecutor() throws Exception {
final List list = new ArrayList();
final List<String> list = new ArrayList<String>();
jobLauncher.setTaskExecutor(new TaskExecutor() {
public void execute(Runnable task) {
list.add("execute");

View File

@@ -31,11 +31,9 @@ import org.springframework.batch.core.configuration.support.ReferenceJobFactory;
import org.springframework.batch.core.converter.JobParametersConverter;
import org.springframework.batch.core.job.JobSupport;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.support.SimpleExportedJobLauncher;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.step.StepSupport;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.support.PropertiesConverter;
/**
* @author Dave Syer
@@ -47,7 +45,7 @@ public class SimpleExportedJobLauncherTests extends TestCase {
private MapJobRegistry jobLocator;
private List list = new ArrayList();
private List<JobParameters> list = new ArrayList<JobParameters>();
protected void setUp() throws Exception {
super.setUp();
@@ -214,7 +212,7 @@ public class SimpleExportedJobLauncherTests extends TestCase {
});
launcher.run("foo", "bar=spam,bucket=crap");
assertEquals(1, list.size());
assertEquals("spam", ((JobParameters) list.get(0)).getString("foo"));
assertEquals("spam", list.get(0).getString("foo"));
}
/**

View File

@@ -32,12 +32,12 @@ public class SimpleJvmExitCodeMapperTests extends TestCase {
protected void setUp() throws Exception {
ecm = new SimpleJvmExitCodeMapper();
Map ecmMap = new HashMap();
Map<String, Integer> ecmMap = new HashMap<String, Integer>();
ecmMap.put("MY_CUSTOM_CODE", new Integer(3));
ecm.setMapping(ecmMap);
ecm2 = new SimpleJvmExitCodeMapper();
Map ecm2Map = new HashMap();
Map<String, Integer> ecm2Map = new HashMap<String, Integer>();
ecm2Map.put(ExitStatus.FINISHED.getExitCode(), new Integer(-1));
ecm2Map.put(ExitStatus.FAILED.getExitCode(), new Integer(-2));
ecm2Map.put(ExitCodeMapper.JOB_NOT_PROVIDED, new Integer(-3));

View File

@@ -32,7 +32,7 @@ public class CompositeJobExecutionListenerTests extends TestCase {
private CompositeExecutionJobListener listener = new CompositeExecutionJobListener();
private List list = new ArrayList();
private List<String> list = new ArrayList<String>();
/**
* Test method for

View File

@@ -32,7 +32,7 @@ public class CompositeStepExecutionListenerTests extends TestCase {
private CompositeStepExecutionListener listener = new CompositeStepExecutionListener();
private List list = new ArrayList();
private List<String> list = new ArrayList<String>();
/**
* Test method for

View File

@@ -34,7 +34,7 @@ public class OrderedCompositeTests extends TestCase {
*/
public void testSetItems() {
list.setItems(new String[] {"1", "2"});
Iterator iterator = list.iterator();
Iterator<Object> iterator = list.iterator();
assertEquals("1", iterator.next());
assertEquals("2", iterator.next());
}
@@ -45,7 +45,7 @@ public class OrderedCompositeTests extends TestCase {
public void testAdd() {
list.setItems(new String[] {"1"});
list.add("3");
Iterator iterator = list.iterator();
Iterator<Object> iterator = list.iterator();
assertEquals("1", iterator.next());
assertEquals("3", iterator.next());
}
@@ -60,7 +60,7 @@ public class OrderedCompositeTests extends TestCase {
return 0;
}
});
Iterator iterator = list.iterator();
Iterator<Object> iterator = list.iterator();
iterator.next();
assertEquals("1", iterator.next());
}
@@ -80,7 +80,7 @@ public class OrderedCompositeTests extends TestCase {
return 0;
}
});
Iterator iterator = list.iterator();
Iterator<Object> iterator = list.iterator();
assertEquals(0, ((Ordered) iterator.next()).getOrder());
assertEquals(1, ((Ordered) iterator.next()).getOrder());
assertEquals("1", iterator.next());

View File

@@ -151,7 +151,7 @@ public abstract class AbstractJobDaoTests extends AbstractTransactionalDataSourc
jobExecution.setEndTime(new Date(System.currentTimeMillis()));
jobExecutionDao.updateJobExecution(jobExecution);
List executions = jobExecutionDao.findJobExecutions(jobInstance);
List<JobExecution> executions = jobExecutionDao.findJobExecutions(jobInstance);
assertEquals(executions.size(), 1);
validateJobExecution(jobExecution, (JobExecution) executions.get(0));
@@ -159,7 +159,7 @@ public abstract class AbstractJobDaoTests extends AbstractTransactionalDataSourc
public void testSaveJobExecution() {
List executions = jobExecutionDao.findJobExecutions(jobInstance);
List<JobExecution> executions = jobExecutionDao.findJobExecutions(jobInstance);
assertEquals(executions.size(), 1);
validateJobExecution(jobExecution, (JobExecution) executions.get(0));
}
@@ -208,13 +208,14 @@ public abstract class AbstractJobDaoTests extends AbstractTransactionalDataSourc
assertEquals(jobExecutionDao.getJobExecutionCount(testJob), 0);
}
@SuppressWarnings("unchecked")
public void testJobWithSimpleJobIdentifier() throws Exception {
Job testJob = new JobSupport("test");
// Create job.
jobInstance = jobInstanceDao.createJobInstance(testJob, jobParameters);
List jobs = jdbcTemplate.queryForList("SELECT * FROM BATCH_JOB_INSTANCE where JOB_INSTANCE_ID=?",
List<JobInstance> jobs = jdbcTemplate.queryForList("SELECT * FROM BATCH_JOB_INSTANCE where JOB_INSTANCE_ID=?",
new Object[] { jobInstance.getId() });
assertEquals(1, jobs.size());
assertEquals("test", ((Map) jobs.get(0)).get("JOB_NAME"));
@@ -237,7 +238,7 @@ public abstract class AbstractJobDaoTests extends AbstractTransactionalDataSourc
public void testFindJobExecutions() {
List results = jobExecutionDao.findJobExecutions(jobInstance);
List<JobExecution> results = jobExecutionDao.findJobExecutions(jobInstance);
assertEquals(results.size(), 1);
validateJobExecution(jobExecution, (JobExecution) results.get(0));
}

View File

@@ -35,7 +35,7 @@ public abstract class AbstractJobExecutionDaoTests extends AbstractTransactional
dao.saveJobExecution(execution);
List executions = dao.findJobExecutions(jobInstance);
List<JobExecution> executions = dao.findJobExecutions(jobInstance);
assertTrue(executions.size() == 1);
assertEquals(execution, executions.get(0));
}
@@ -111,7 +111,7 @@ public abstract class AbstractJobExecutionDaoTests extends AbstractTransactional
public void testSaveAndFindContext() {
dao.saveJobExecution(execution);
ExecutionContext ctx = new ExecutionContext(new HashMap() {
ExecutionContext ctx = new ExecutionContext(new HashMap<String, Object>() {
{
put("key", "value");
}
@@ -135,7 +135,7 @@ public abstract class AbstractJobExecutionDaoTests extends AbstractTransactional
public void testUpdateContext() {
dao.saveJobExecution(execution);
ExecutionContext ctx = new ExecutionContext(new HashMap() {
ExecutionContext ctx = new ExecutionContext(new HashMap<String, Object>() {
{
put("key", "value");
}

View File

@@ -150,7 +150,7 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona
public void testSaveAndFindContext() {
dao.saveStepExecution(stepExecution);
ExecutionContext ctx = new ExecutionContext(new HashMap() {
ExecutionContext ctx = new ExecutionContext(new HashMap<String, Object>() {
{
put("key", "value");
}
@@ -174,7 +174,7 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona
public void testUpdateContext() {
dao.saveStepExecution(stepExecution);
ExecutionContext ctx = new ExecutionContext(new HashMap() {
ExecutionContext ctx = new ExecutionContext(new HashMap<String, Object>() {
{
put("key", "value");
}

View File

@@ -35,7 +35,7 @@ public class JdbcJobDaoQueryTests extends TestCase {
JdbcJobExecutionDao jobExecutionDao;
List list = new ArrayList();
List<String> list = new ArrayList<String>();
/*
* (non-Javadoc)
@@ -73,7 +73,7 @@ public class JdbcJobDaoQueryTests extends TestCase {
jobExecutionDao.saveJobExecution(jobExecution);
assertEquals(1, list.size());
String query = (String) list.get(0);
String query = list.get(0);
assertTrue("Query did not contain FOO_:" + query, query.indexOf("FOO_") >= 0);
}

View File

@@ -3,6 +3,7 @@ package org.springframework.batch.core.repository.dao;
import java.util.List;
import java.util.Map;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDao;
import org.springframework.batch.core.repository.dao.JdbcJobExecutionDao;
import org.springframework.batch.core.repository.dao.JdbcJobInstanceDao;
@@ -17,6 +18,7 @@ public class JdbcJobDaoTests extends AbstractJobDaoTests {
((JdbcJobExecutionDao) jobExecutionDao).setTablePrefix(AbstractJdbcBatchMetadataDao.DEFAULT_TABLE_PREFIX);
}
@SuppressWarnings("unchecked")
public void testUpdateJobExecutionWithLongExitCode() {
assertTrue(LONG_STRING.length() > 250);
@@ -25,7 +27,7 @@ public class JdbcJobDaoTests extends AbstractJobDaoTests {
.addExitDescription(LONG_STRING));
jobExecutionDao.updateJobExecution(jobExecution);
List executions = jdbcTemplate.queryForList(
List<JobExecution> executions = jdbcTemplate.queryForList(
"SELECT * FROM BATCH_JOB_EXECUTION where JOB_INSTANCE_ID=?",
new Object[] { jobInstance.getId() });
assertEquals(1, executions.size());

View File

@@ -27,9 +27,9 @@ import org.springframework.batch.item.ExecutionContext;
public class MockStepDao implements StepExecutionDao {
private List newSteps;
private List<Step> newSteps;
public List findStepInstances(JobInstance job) {
public List<Step> findStepInstances(JobInstance job) {
return newSteps;
}
@@ -39,7 +39,7 @@ public class MockStepDao implements StepExecutionDao {
public void updateStepExecution(StepExecution stepExecution) {
}
public void setStepsToReturnOnCreate(List steps) {
public void setStepsToReturnOnCreate(List<Step> steps) {
this.newSteps = steps;
}

View File

@@ -47,22 +47,22 @@ public class SimpleJobRepositoryIntegrationTests extends AbstractTransactionalDa
job.setRestartable(true);
Map stringParams = new HashMap() {
Map<String, String> stringParams = new HashMap<String, String>() {
{
put("stringKey", "stringValue");
}
};
Map longParams = new HashMap() {
Map<String, Long> longParams = new HashMap<String, Long>() {
{
put("longKey", new Long(1));
}
};
Map doubleParams = new HashMap() {
Map<String, Double> doubleParams = new HashMap<String, Double>() {
{
put("doubleKey", new Double(1.1));
}
};
Map dateParams = new HashMap() {
Map<String, Date> dateParams = new HashMap<String, Date>() {
{
put("dateKey", new Date(1));
}

View File

@@ -72,7 +72,7 @@ public class SimpleJobRepositoryTests extends TestCase {
String databaseStep2;
List steps;
List<String> steps;
public void setUp() throws Exception {
@@ -93,7 +93,7 @@ public class SimpleJobRepositoryTests extends TestCase {
stepConfiguration2 = new StepSupport("TestStep2");
List stepConfigurations = new ArrayList();
List<Step> stepConfigurations = new ArrayList<Step>();
stepConfigurations.add(stepConfiguration1);
stepConfigurations.add(stepConfiguration2);
@@ -104,7 +104,7 @@ public class SimpleJobRepositoryTests extends TestCase {
databaseStep1 = "dbStep1";
databaseStep2 = "dbStep2";
steps = new ArrayList();
steps = new ArrayList<String>();
steps.add(databaseStep1);
steps.add(databaseStep2);

View File

@@ -40,7 +40,7 @@ public class JdbcCursorItemReaderPreparedStatementIntegrationTests extends
StepExecution stepExecution = new StepExecution("taskletStep", jobExecution, new Long(3) );
pss.beforeStep(stepExecution);
List parameterNames = new ArrayList();
List<String> parameterNames = new ArrayList<String>();
parameterNames.add("begin.id");
parameterNames.add("end.id");
pss.setParameterKeys(parameterNames);

View File

@@ -57,11 +57,11 @@ public class StepExecutionPreparedStatementSetterTests extends AbstractTransacti
public void testSetValues(){
List parameterNames = new ArrayList();
List<String> parameterNames = new ArrayList<String>();
parameterNames.add("begin.id");
parameterNames.add("end.id");
pss.setParameterKeys(parameterNames);
final List results = new ArrayList();
final List<String> results = new ArrayList<String>();
jdbcTemplate.query("SELECT NAME from T_FOOS where ID > ? and ID < ?", pss, new RowCallbackHandler(){
public void processRow(ResultSet rs) throws SQLException {
@@ -85,7 +85,7 @@ public class StepExecutionPreparedStatementSetterTests extends AbstractTransacti
public void testNonExistentProperties(){
List parameterNames = new ArrayList();
List<String> parameterNames = new ArrayList<String>();
parameterNames.add("badParameter");
parameterNames.add("end.id");
pss.setParameterKeys(parameterNames);

View File

@@ -30,7 +30,7 @@ public class AbstractStepTests extends TestCase {
/**
* Sequence of events encountered during step execution.
*/
final List events = new ArrayList();
final List<String> events = new ArrayList<String>();
final StepExecution execution = new StepExecution(tested.getName(), new JobExecution(new JobInstance(new Long(1),
new JobParameters(), "jobName")));

View File

@@ -39,7 +39,6 @@ import org.springframework.batch.item.support.AbstractItemWriter;
import org.springframework.batch.item.support.ListItemReader;
import org.springframework.batch.repeat.policy.SimpleCompletionPolicy;
import org.springframework.batch.repeat.support.RepeatTemplate;
import org.springframework.batch.support.PropertiesConverter;
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
@@ -52,7 +51,7 @@ import org.springframework.util.ClassUtils;
*/
public class ItemOrientedStepIntegrationTests extends AbstractDependencyInjectionSpringContextTests {
private List processed = new ArrayList();
private List<String> processed = new ArrayList<String>();
private ItemOrientedStep step;

View File

@@ -16,6 +16,7 @@
package org.springframework.batch.core.step.item;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -56,16 +57,15 @@ import org.springframework.batch.repeat.ExitStatus;
import org.springframework.batch.repeat.policy.DefaultResultCompletionPolicy;
import org.springframework.batch.repeat.policy.SimpleCompletionPolicy;
import org.springframework.batch.repeat.support.RepeatTemplate;
import org.springframework.batch.support.PropertiesConverter;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.transaction.TransactionException;
import org.springframework.transaction.support.DefaultTransactionStatus;
public class ItemOrientedStepTests extends TestCase {
List processed = new ArrayList();
List<String> processed = new ArrayList<String>();
private List list = new ArrayList();
private List<Serializable> list = new ArrayList<Serializable>();
ItemWriter itemWriter = new AbstractItemWriter() {
public void write(Object data) throws Exception {

View File

@@ -116,6 +116,7 @@ public class ItemSkipPolicyItemHandlerTests extends TestCase {
assertEquals(new Holder("5"), handler.read(contribution));
}
@SuppressWarnings("unchecked")
public void testWriteWithSkipAfterMark() throws Exception {
handler.setItemSkipPolicy(new AlwaysSkipItemSkipPolicy());
try {
@@ -137,7 +138,7 @@ public class ItemSkipPolicyItemHandlerTests extends TestCase {
assertEquals(2, contribution.getSkipCount());
assertEquals(1, TransactionSynchronizationManager.getResourceMap().size());
Set removed = (Set) TransactionSynchronizationManager.getResourceMap().values().iterator().next();
Set<Object> removed = (Set) TransactionSynchronizationManager.getResourceMap().values().iterator().next();
// one skipped item was detected on read
assertEquals(1, removed.size());
// mark() should remove the set of removed keys
@@ -274,7 +275,7 @@ public class ItemSkipPolicyItemHandlerTests extends TestCase {
final String[] values = { "1", "2", "3", "4", "5" };
Collection processed = new ArrayList();
Collection<Object> processed = new ArrayList<Object>();
int counter = -1;
@@ -310,7 +311,7 @@ public class ItemSkipPolicyItemHandlerTests extends TestCase {
boolean mutate = false;
List written = new ArrayList();
List<Object> written = new ArrayList<Object>();
int flushIndex = -1;

View File

@@ -41,13 +41,13 @@ public class RepeatOperationsStepFactoryBeanTests extends TestCase {
private RepeatOperationsStepFactoryBean factory = new RepeatOperationsStepFactoryBean();
private List list;
private List<String> list;
private JobExecution jobExecution = new JobExecution(new JobInstance(new Long(0L), new JobParameters(), "job"));
protected void setUp() throws Exception {
factory.setBeanName("RepeatOperationsStep");
factory.setItemReader(new ListItemReader(new ArrayList()));
factory.setItemReader(new ListItemReader(new ArrayList<String>()));
factory.setItemWriter(new EmptyItemWriter());
factory.setJobRepository(new JobRepositorySupport());
factory.setTransactionManager(new ResourcelessTransactionManager());
@@ -63,7 +63,7 @@ public class RepeatOperationsStepFactoryBeanTests extends TestCase {
public void testStepOperationsWithoutChunkListener() throws Exception {
factory.setItemReader(new ListItemReader(new ArrayList()));
factory.setItemReader(new ListItemReader(new ArrayList<String>()));
factory.setItemWriter(new EmptyItemWriter());
factory.setJobRepository(new JobRepositorySupport());
factory.setTransactionManager(new ResourcelessTransactionManager());
@@ -71,7 +71,7 @@ public class RepeatOperationsStepFactoryBeanTests extends TestCase {
factory.setStepOperations(new RepeatOperations() {
public ExitStatus iterate(RepeatCallback callback) {
list = new ArrayList();
list = new ArrayList<String>();
list.add("foo");
return ExitStatus.FINISHED;
}

View File

@@ -125,7 +125,7 @@ public class SimpleRetryExceptionHandlerTests extends TestCase {
* @param ex
* @return
*/
private SimpleRetryExceptionHandler getHandlerAfterRetry(RetryPolicy retryPolicy, RuntimeException ex, Class[] fatalExceptions) {
private SimpleRetryExceptionHandler getHandlerAfterRetry(RetryPolicy retryPolicy, RuntimeException ex, Class<?>[] fatalExceptions) {
// Always rethrow if the retry is exhausted
SimpleRetryExceptionHandler handler = new SimpleRetryExceptionHandler(retryPolicy,

View File

@@ -55,12 +55,12 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor;
*/
public class SimpleStepFactoryBeanTests extends TestCase {
private List recovered = new ArrayList();
private List<Exception> recovered = new ArrayList<Exception>();
private SimpleJobRepository repository = new SimpleJobRepository(new MapJobInstanceDao(), new MapJobExecutionDao(),
new MapStepExecutionDao());
private List written = new ArrayList();
private List<String> written = new ArrayList<String>();
private ItemWriter writer = new AbstractItemWriter() {
public void write(Object data) throws Exception {
@@ -92,10 +92,11 @@ public class SimpleStepFactoryBeanTests extends TestCase {
return getStepFactory(new String[] { arg0, arg1 });
}
@SuppressWarnings("unchecked")
private SimpleStepFactoryBean getStepFactory(String[] args) throws Exception {
SimpleStepFactoryBean factory = new SimpleStepFactoryBean();
List items = TransactionAwareProxyFactory.createTransactionalList();
List<String> items = TransactionAwareProxyFactory.createTransactionalList();
items.addAll(Arrays.asList(args));
reader = new ListItemReader(items);
@@ -109,7 +110,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
public void testSimpleJob() throws Exception {
job.setSteps(new ArrayList());
job.setSteps(new ArrayList<Step>());
AbstractStep step = (AbstractStep) getStepFactory("foo", "bar").getObject();
step.setName("step1");
job.addStep(step);
@@ -127,7 +128,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
public void testSimpleConcurrentJob() throws Exception {
job.setSteps(new ArrayList());
job.setSteps(new ArrayList<Step>());
SimpleStepFactoryBean factory = getStepFactory("foo", "bar");
factory.setTaskExecutor(new SimpleAsyncTaskExecutor());
factory.setThrottleLimit(1);
@@ -146,7 +147,7 @@ public class SimpleStepFactoryBeanTests extends TestCase {
public void testSimpleJobWithItemListeners() throws Exception {
final List throwables = new ArrayList();
final List<Throwable> throwables = new ArrayList<Throwable>();
RepeatTemplate chunkOperations = new RepeatTemplate();
// Always handle the exception a check it is the right one...

View File

@@ -17,7 +17,6 @@ package org.springframework.batch.core.step.item;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import junit.framework.TestCase;
@@ -37,9 +36,9 @@ public class SkipLimitReadFailurePolicyTests extends TestCase {
protected void setUp() throws Exception {
super.setUp();
List skippableExceptions = new ArrayList();
List<Class<?>> skippableExceptions = new ArrayList<Class<?>>();
skippableExceptions.add(FlatFileParseException.class);
List fatalExceptions = Collections.EMPTY_LIST;
List<Class<?>> fatalExceptions = new ArrayList<Class<?>>();
failurePolicy = new LimitCheckingItemSkipPolicy(1, skippableExceptions, fatalExceptions);
}

View File

@@ -41,7 +41,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
private SkipLimitStepFactoryBean factory = new SkipLimitStepFactoryBean();
private Class[] skippableExceptions = new Class[] { SkippableException.class, SkippableRuntimeException.class };
private Class<?>[] skippableExceptions = new Class[] { SkippableException.class, SkippableRuntimeException.class };
private final int SKIP_LIMIT = 2;
@@ -89,7 +89,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
assertTrue(reader.processed.contains("4"));
assertFalse(writer.written.contains("4"));
List expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("1,3,5"));
List<String> expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("1,3,5"));
assertEquals(expectedOutput, writer.written);
assertEquals(4, stepExecution.getItemCount().intValue());
@@ -171,7 +171,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
assertFalse(writer.written.contains("4"));
// failure on "4" tripped the skip limit so we never got to "5"
List expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("1,3"));
List<String> expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("1,3"));
assertEquals(expectedOutput, writer.written);
}
@@ -179,6 +179,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
/**
* Check items causing errors are skipped as expected.
*/
@SuppressWarnings("unchecked")
public void testSkipOverLimitOnRead() throws Exception {
reader = new SkipReaderStub(StringUtils.commaDelimitedListToStringArray("1,2,3,4,5,6"), StringUtils
@@ -210,7 +211,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
// failure on "5" tripped the skip limit but "4" failed on write and was skipped and
// RepeatSynchronizationManager.setCompleteOnly() was called in the retry policy to
// aggressively commit after a recovery ("1" was written at that point)
List expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("1"));
List<String> expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("1"));
assertEquals(expectedOutput, writer.written);
}
@@ -218,6 +219,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
/**
* Check items causing errors are skipped as expected.
*/
@SuppressWarnings("unchecked")
public void testSkipOnReadNotDoubleCounted() throws Exception {
reader = new SkipReaderStub(StringUtils.commaDelimitedListToStringArray("1,2,3,4,5,6"), StringUtils
@@ -236,7 +238,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
assertEquals(1, stepExecution.getWriteSkipCount().intValue());
// skipped 2,3,4,5
List expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("1,6"));
List<String> expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("1,6"));
assertEquals(expectedOutput, writer.written);
}
@@ -244,6 +246,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
/**
* Check items causing errors are skipped as expected.
*/
@SuppressWarnings("unchecked")
public void testSkipOnWriteNotDoubleCounted() throws Exception {
reader = new SkipReaderStub(StringUtils.commaDelimitedListToStringArray("1,2,3,4,5,6,7"), StringUtils
@@ -267,15 +270,16 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
assertEquals(2, stepExecution.getWriteSkipCount().intValue());
// skipped 2,3,4,5
List expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("1,6,7"));
List<String> expectedOutput = Arrays.asList(StringUtils.commaDelimitedListToStringArray("1,6,7"));
assertEquals(expectedOutput, writer.written);
}
@SuppressWarnings("unchecked")
public void testDefaultSkipPolicy() throws Exception {
factory.setSkippableExceptionClasses(new Class[] { Exception.class });
factory.setSkipLimit(1);
List items = TransactionAwareProxyFactory.createTransactionalList();
List<String> items = TransactionAwareProxyFactory.createTransactionalList();
items.addAll(Arrays.asList(new String[] { "a", "b", "c" }));
ItemReader provider = new ListItemReader(items) {
public Object read() {
@@ -307,19 +311,19 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
private final String[] items;
private Collection processed = new ArrayList();
private Collection<String> processed = new ArrayList<String>();
private int counter = -1;
private int marked = 0;
private final Collection failures;
private final Collection<String> failures;
public SkipReaderStub() {
this(new String[] { "1", "2", "3", "4", "5" }, Collections.singleton("2"));
}
public SkipReaderStub(String[] items, Collection failures) {
public SkipReaderStub(String[] items, Collection<String> failures) {
this.items = items;
this.failures = failures;
}
@@ -359,12 +363,13 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
protected final Log logger = LogFactory.getLog(getClass());
private List written = new ArrayList();
private List<Object> written = new ArrayList<Object>();
private int flushIndex = -1;
private final Collection failures;
private final Collection<String> failures;
@SuppressWarnings("unchecked")
public SkipWriterStub() {
this(StringUtils.commaDelimitedListToSet("4"));
}
@@ -372,7 +377,7 @@ public class SkipLimitStepFactoryBeanTests extends TestCase {
/**
* @param failures commaDelimitedListToSet
*/
public SkipWriterStub(Collection failures) {
public SkipWriterStub(Collection<String> failures) {
this.failures = failures;
}

View File

@@ -59,9 +59,9 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase {
private SkipLimitStepFactoryBean factory = new SkipLimitStepFactoryBean();
private List recovered = new ArrayList();
private List<Object> recovered = new ArrayList<Object>();
private List processed = new ArrayList();
private List<String> processed = new ArrayList<String>();
int count = 0;
@@ -88,7 +88,7 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase {
factory.setBeanName("step");
factory.setItemReader(new ListItemReader(new ArrayList()));
factory.setItemReader(new ListItemReader(new ArrayList<String>()));
factory.setItemWriter(processor);
factory.setJobRepository(repository);
factory.setTransactionManager(new ResourcelessTransactionManager());
@@ -119,8 +119,9 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase {
*
* @throws Exception
*/
@SuppressWarnings("unchecked")
public void testSuccessfulRetryWithReadFailure() throws Exception {
List items = TransactionAwareProxyFactory.createTransactionalList();
List<String> items = TransactionAwareProxyFactory.createTransactionalList();
items.addAll(Arrays.asList(new String[] { "a", "b", "c" }));
ItemReader provider = new ListItemReader(items) {
public Object read() {
@@ -147,10 +148,11 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase {
assertEquals(3, stepExecution.getItemCount().intValue());
}
@SuppressWarnings("unchecked")
public void testSkipAndRetry() throws Exception {
factory.setSkippableExceptionClasses(new Class[] { Exception.class });
factory.setSkipLimit(2);
List items = TransactionAwareProxyFactory.createTransactionalList();
List<String> items = TransactionAwareProxyFactory.createTransactionalList();
items.addAll(Arrays.asList(new String[] { "a", "b", "c", "d", "e", "f" }));
ItemReader provider = new ListItemReader(items) {
public Object read() {
@@ -175,6 +177,7 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase {
assertEquals(4, stepExecution.getItemCount().intValue());
}
@SuppressWarnings("unchecked")
public void testSkipAndRetryWithWriteFailure() throws Exception {
factory.setSkippableExceptionClasses(new Class[] { RetryException.class });
@@ -185,7 +188,7 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase {
}
} });
factory.setSkipLimit(2);
List items = TransactionAwareProxyFactory.createTransactionalList();
List<String> items = TransactionAwareProxyFactory.createTransactionalList();
items.addAll(Arrays.asList(new String[] { "a", "b", "c", "d", "e", "f" }));
ItemReader provider = new ListItemReader(items) {
public Object read() {
@@ -221,11 +224,12 @@ public class StatefulRetryStepFactoryBeanTests extends TestCase {
assertEquals(17, count);
}
@SuppressWarnings("unchecked")
public void testRetryWithNoSkip() throws Exception {
factory.setRetryableExceptionClasses(new Class[] { Exception.class });
factory.setRetryLimit(4);
factory.setSkipLimit(0);
List items = TransactionAwareProxyFactory.createTransactionalList();
List<String> items = TransactionAwareProxyFactory.createTransactionalList();
items.addAll(Arrays.asList(new String[] { "b" }));
ItemReader provider = new ListItemReader(items) {
public Object read() {

View File

@@ -1,5 +1,6 @@
package org.springframework.batch.core.step.tasklet;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -21,7 +22,7 @@ public class TaskletStepTests extends TestCase {
private StepExecution stepExecution;
private List list = new ArrayList();
private List<Serializable> list = new ArrayList<Serializable>();
protected void setUp() throws Exception {
stepExecution = new StepExecution("stepName", new JobExecution(new JobInstance(new Long(0L),

View File

@@ -17,7 +17,6 @@
package test.jdbc.datasource;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.sql.DataSource;
@@ -99,6 +98,7 @@ public class InitializingDataSourceFactoryBean extends AbstractFactoryBean {
TransactionTemplate transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource));
transactionTemplate.execute(new TransactionCallback() {
@SuppressWarnings("unchecked")
public Object doInTransaction(TransactionStatus status) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
String[] scripts;
@@ -122,10 +122,9 @@ public class InitializingDataSourceFactoryBean extends AbstractFactoryBean {
}
private String stripComments(List list) {
private String stripComments(List<String> list) {
StringBuffer buffer = new StringBuffer();
for (Iterator iter = list.iterator(); iter.hasNext();) {
String line = (String) iter.next();
for (String line : list) {
if (!line.startsWith("//") && !line.startsWith("--")) {
buffer.append(line + "\n");
}
@@ -133,7 +132,7 @@ public class InitializingDataSourceFactoryBean extends AbstractFactoryBean {
return buffer.toString();
}
public Class getObjectType() {
public Class<DataSource> getObjectType() {
return DataSource.class;
}