BATCH-1891: Migrate usage of deprecated classes

This commit is contained in:
Chris Schaefer
2012-09-16 23:30:12 -04:00
committed by Dave Syer
parent b1246f99b1
commit d0e0334674
58 changed files with 282 additions and 253 deletions

View File

@@ -15,11 +15,7 @@
*/
package org.springframework.batch.core.configuration.support;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;

View File

@@ -30,8 +30,8 @@ import org.springframework.batch.core.repository.dao.StepExecutionDao;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.jdbc.core.simple.SimpleJdbcOperations;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
import org.springframework.jdbc.support.lob.LobHandler;
@@ -50,7 +50,7 @@ public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean
private DataSource dataSource;
private SimpleJdbcOperations jdbcTemplate;
private JdbcOperations jdbcTemplate;
private String tablePrefix = AbstractJdbcBatchMetadataDao.DEFAULT_TABLE_PREFIX;
@@ -96,7 +96,7 @@ public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean
Assert.notNull(dataSource, "DataSource must not be null.");
jdbcTemplate = new SimpleJdbcTemplate(dataSource);
jdbcTemplate = new JdbcTemplate(dataSource);
}

View File

@@ -19,7 +19,7 @@ package org.springframework.batch.core.repository.dao;
import java.sql.Types;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.jdbc.core.simple.SimpleJdbcOperations;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -42,7 +42,7 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {
private int clobTypeToUse = Types.CLOB;
private SimpleJdbcOperations jdbcTemplate;
private JdbcOperations jdbcTemplate;
protected String getQuery(String base) {
return StringUtils.replace(base, "%PREFIX%", tablePrefix);
@@ -63,11 +63,11 @@ public abstract class AbstractJdbcBatchMetadataDao implements InitializingBean {
this.tablePrefix = tablePrefix;
}
public void setJdbcTemplate(SimpleJdbcOperations jdbcTemplate) {
public void setJdbcTemplate(JdbcOperations jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
protected SimpleJdbcOperations getJdbcTemplate() {
protected JdbcOperations getJdbcTemplate() {
return jdbcTemplate;
}

View File

@@ -190,7 +190,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem
longContext = null;
}
getJdbcTemplate().getJdbcOperations().update(getQuery(sql), new PreparedStatementSetter() {
getJdbcTemplate().update(getQuery(sql), new PreparedStatementSetter() {
public void setValues(PreparedStatement ps) throws SQLException {
ps.setString(1, shortContext);
if (longContext != null) {

View File

@@ -135,7 +135,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
jobExecution.getStartTime(), jobExecution.getEndTime(), jobExecution.getStatus().toString(),
jobExecution.getExitStatus().getExitCode(), jobExecution.getExitStatus().getExitDescription(),
jobExecution.getVersion(), jobExecution.getCreateTime(), jobExecution.getLastUpdated() };
getJdbcTemplate().getJdbcOperations().update(
getJdbcTemplate().update(
getQuery(SAVE_JOB_EXECUTION),
parameters,
new int[] { Types.BIGINT, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR,
@@ -197,7 +197,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
throw new NoSuchObjectException("Invalid JobExecution, ID " + jobExecution.getId() + " not found.");
}
int count = getJdbcTemplate().getJdbcOperations().update(
int count = getJdbcTemplate().update(
getQuery(UPDATE_JOB_EXECUTION),
parameters,
new int[] { Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
@@ -265,8 +265,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
result.add(mapper.mapRow(rs, 0));
}
};
getJdbcTemplate().getJdbcOperations()
.query(getQuery(GET_RUNNING_EXECUTIONS), new Object[] { jobName }, handler);
getJdbcTemplate().query(getQuery(GET_RUNNING_EXECUTIONS), new Object[] { jobName }, handler);
return result;
}

View File

@@ -114,7 +114,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
Object[] parameters = new Object[] { jobId, jobName,
createJobKey(jobParameters), jobInstance.getVersion() };
getJdbcTemplate().getJdbcOperations().update(
getJdbcTemplate().update(
getQuery(CREATE_JOB_INSTANCE),
parameters,
new int[] { Types.BIGINT, Types.VARCHAR, Types.VARCHAR,
@@ -195,8 +195,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
args = new Object[] { jobId, key, type, "", value, 0L, 0D };
}
getJdbcTemplate().getJdbcOperations().update(
getQuery(CREATE_JOB_PARAMETERS), args, argTypes);
getJdbcTemplate().update(getQuery(CREATE_JOB_PARAMETERS), args, argTypes);
}
/**
@@ -277,9 +276,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
map.put(rs.getString(2), value);
}
};
getJdbcTemplate().getJdbcOperations().query(
getQuery(FIND_PARAMS_FROM_ID), new Object[] { instanceId },
handler);
getJdbcTemplate().query(getQuery(FIND_PARAMS_FROM_ID), new Object[] { instanceId }, handler);
return new JobParameters(map);
}
@@ -330,8 +327,7 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
};
@SuppressWarnings("unchecked")
List<JobInstance> result = (List<JobInstance>) getJdbcTemplate()
.getJdbcOperations().query(getQuery(FIND_LAST_JOBS_BY_NAME),
List<JobInstance> result = (List<JobInstance>) getJdbcTemplate().query(getQuery(FIND_LAST_JOBS_BY_NAME),
new Object[] { jobName }, extractor);
return result;

View File

@@ -123,7 +123,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(),
stepExecution.getWriteSkipCount(), stepExecution.getProcessSkipCount(),
stepExecution.getRollbackCount(), stepExecution.getLastUpdated() };
getJdbcTemplate().getJdbcOperations().update(
getJdbcTemplate().update(
getQuery(SAVE_STEP_EXECUTION),
parameters,
new int[] { Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP,
@@ -136,7 +136,6 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
* Validate StepExecution. At a minimum, JobId, StartTime, and Status cannot
* be null. EndTime can be null for an unfinished job.
*
* @param value
* @throws IllegalArgumentException
*/
private void validateStepExecution(StepExecution stepExecution) {
@@ -169,8 +168,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
stepExecution.getReadSkipCount(), stepExecution.getProcessSkipCount(),
stepExecution.getWriteSkipCount(), stepExecution.getRollbackCount(),
stepExecution.getLastUpdated(), stepExecution.getId(), stepExecution.getVersion() };
int count = getJdbcTemplate().getJdbcOperations()
.update(
int count = getJdbcTemplate().update(
getQuery(UPDATE_STEP_EXECUTION),
parameters,
new int[] { Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
@@ -194,7 +192,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
/**
* Truncate the exit description if the length exceeds
* {@link #EXIT_MESSAGE_LENGTH}.
* {@link #DEFAULT_EXIT_MESSAGE_LENGTH}.
* @param description the string to truncate
* @return truncated description
*/

View File

@@ -21,7 +21,6 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

View File

@@ -17,7 +17,6 @@
package org.springframework.batch.core.repository.dao;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

View File

@@ -38,8 +38,8 @@ import org.springframework.batch.item.database.support.DefaultDataFieldMaxValueI
import org.springframework.batch.support.DatabaseType;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.jdbc.core.simple.SimpleJdbcOperations;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.lob.LobHandler;
import org.springframework.jdbc.support.lob.OracleLobHandler;
import org.springframework.util.Assert;
@@ -61,7 +61,7 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
private DataSource dataSource;
private SimpleJdbcOperations jdbcTemplate;
private JdbcOperations jdbcTemplate;
private String databaseType;
@@ -135,7 +135,7 @@ public class JobRepositoryFactoryBean extends AbstractJobRepositoryFactoryBean i
Assert.notNull(dataSource, "DataSource must not be null.");
jdbcTemplate = new SimpleJdbcTemplate(dataSource);
jdbcTemplate = new JdbcTemplate(dataSource);
if (incrementerFactory == null) {
incrementerFactory = new DefaultDataFieldMaxValueIncrementerFactory(dataSource);

View File

@@ -53,11 +53,9 @@ import org.springframework.batch.retry.RetryListener;
import org.springframework.batch.retry.listener.RetryListenerSupport;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.dao.DeadlockLoserDataAccessException;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.transaction.PlatformTransactionManager;
@@ -150,14 +148,14 @@ public class StepParserTests {
@Test(expected = BeanDefinitionParsingException.class)
public void testTaskletStepWithBadStepListener() throws Exception {
String contextLocation = "org/springframework/batch/core/configuration/xml/StepParserBadStepListenerTests-context.xml";
new XmlBeanFactory(new ClassPathResource(contextLocation));
new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserBadStepListenerTests-context.xml");
}
@Test(expected = BeanDefinitionParsingException.class)
public void testTaskletStepWithBadRetryListener() throws Exception {
String contextLocation = "org/springframework/batch/core/configuration/xml/StepParserBadRetryListenerTests-context.xml";
new XmlBeanFactory(new ClassPathResource(contextLocation));
new ClassPathXmlApplicationContext(
"org/springframework/batch/core/configuration/xml/StepParserBadRetryListenerTests-context.xml");
}
@Test

View File

@@ -14,7 +14,7 @@ import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.repository.dao.JdbcJobInstanceDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -22,7 +22,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
public class JobLauncherIntegrationTests {
private SimpleJdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
private JobLauncher jobLauncher;
@@ -32,7 +32,7 @@ public class JobLauncherIntegrationTests {
@Autowired
public void setDataSource(DataSource dataSource) {
jdbcTemplate = new SimpleJdbcTemplate(dataSource);
jdbcTemplate = new JdbcTemplate(dataSource);
}
@Test

View File

@@ -24,7 +24,6 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;

View File

@@ -31,7 +31,7 @@ import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -49,11 +49,11 @@ public class RestartIntegrationTests {
@Autowired
private Job job;
private SimpleJdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
@Test

View File

@@ -26,7 +26,7 @@ import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -44,11 +44,11 @@ public class VanillaIntegrationTests {
@Autowired
private Job job;
private SimpleJdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
@Test

View File

@@ -37,7 +37,7 @@ import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -61,11 +61,11 @@ public abstract class AbstractJobDaoTests {
protected Date jobExecutionStartTime = new Date(System.currentTimeMillis());
protected SimpleJdbcTemplate simpleJdbcTemplate;
protected JdbcTemplate jdbcTemplate;
@Autowired
public void setDataSource(DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
/*
@@ -98,14 +98,14 @@ public abstract class AbstractJobDaoTests {
@Transactional @Test
public void testVersionIsNotNullForJob() throws Exception {
int version = simpleJdbcTemplate.queryForInt("select version from BATCH_JOB_INSTANCE where JOB_INSTANCE_ID="
int version = jdbcTemplate.queryForInt("select version from BATCH_JOB_INSTANCE where JOB_INSTANCE_ID="
+ jobInstance.getId());
assertEquals(0, version);
}
@Transactional @Test
public void testVersionIsNotNullForJobExecution() throws Exception {
int version = simpleJdbcTemplate.queryForInt("select version from BATCH_JOB_EXECUTION where JOB_EXECUTION_ID="
int version = jdbcTemplate.queryForInt("select version from BATCH_JOB_EXECUTION where JOB_EXECUTION_ID="
+ jobExecution.getId());
assertEquals(0, version);
}
@@ -221,7 +221,7 @@ public abstract class AbstractJobDaoTests {
// Create job.
jobInstance = jobInstanceDao.createJobInstance(testJob, jobParameters);
List<Map<String, Object>> jobs = simpleJdbcTemplate.queryForList(
List<Map<String, Object>> jobs = jdbcTemplate.queryForList(
"SELECT * FROM BATCH_JOB_INSTANCE where JOB_INSTANCE_ID=?",
jobInstance.getId());
assertEquals(1, jobs.size());

View File

@@ -25,7 +25,6 @@ import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
/**
@@ -64,12 +63,12 @@ public class JdbcJobDaoQueryTests extends TestCase {
public void testTablePrefix() throws Exception {
jobExecutionDao.setTablePrefix("FOO_");
jobExecutionDao.setJdbcTemplate(new SimpleJdbcTemplate(new JdbcTemplate() {
jobExecutionDao.setJdbcTemplate(new JdbcTemplate() {
public int update(String sql, Object[] args, int[] argTypes) throws DataAccessException {
list.add(sql);
return 1;
}
}));
});
JobExecution jobExecution = new JobExecution(new JobInstance(new Long(11), new JobParameters(), "testJob"));
jobExecutionDao.saveJobExecution(jobExecution);

View File

@@ -34,7 +34,7 @@ public class JdbcJobDaoTests extends AbstractJobDaoTests {
.addExitDescription(LONG_STRING));
jobExecutionDao.updateJobExecution(jobExecution);
List<Map<String, Object>> executions = simpleJdbcTemplate.queryForList(
List<Map<String, Object>> executions = jdbcTemplate.queryForList(
"SELECT * FROM BATCH_JOB_EXECUTION where JOB_INSTANCE_ID=?",
jobInstance.getId());
assertEquals(1, executions.size());

View File

@@ -4,10 +4,10 @@ import javax.sql.DataSource;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.jdbc.SimpleJdbcTestUtils;
import org.springframework.batch.support.JdbcTestUtils;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "sql-dao-test.xml" })
@@ -22,11 +22,11 @@ public class JdbcJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
@Autowired
private JobInstanceDao jobInstanceDao;
private SimpleJdbcTemplate simpleJdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
public void setDataSource(DataSource dataSource) {
simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
jdbcTemplate = new JdbcTemplate(dataSource);
}
@Override
@@ -36,9 +36,9 @@ public class JdbcJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
@Override
protected JobExecutionDao getJobExecutionDao() {
SimpleJdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "BATCH_JOB_EXECUTION_CONTEXT",
"BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION", "BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS",
"BATCH_JOB_INSTANCE");
JdbcTestUtils.deleteFromTables(jdbcTemplate, "BATCH_JOB_EXECUTION_CONTEXT",
"BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION", "BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS",
"BATCH_JOB_INSTANCE");
return jobExecutionDao;
}

View File

@@ -14,21 +14,21 @@ import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.jdbc.SimpleJdbcTestUtils;
import org.springframework.batch.support.JdbcTestUtils;
import org.springframework.transaction.annotation.Transactional;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "sql-dao-test.xml")
public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
private SimpleJdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
public void setDataSource(DataSource dataSource) {
this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
@Autowired
@@ -38,9 +38,9 @@ public class JdbcJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
private JobExecutionDao jobExecutionDao;
protected JobInstanceDao getJobInstanceDao() {
SimpleJdbcTestUtils.deleteFromTables(jdbcTemplate, "BATCH_JOB_EXECUTION_CONTEXT",
"BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION",
"BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE");
JdbcTestUtils.deleteFromTables(jdbcTemplate, "BATCH_JOB_EXECUTION_CONTEXT",
"BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION",
"BATCH_JOB_EXECUTION", "BATCH_JOB_PARAMS", "BATCH_JOB_INSTANCE");
return jobInstanceDao;
}

View File

@@ -3,8 +3,7 @@ package org.springframework.batch.core.repository.dao;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.Ignore;
import org.junit.internal.runners.JUnit4ClassRunner;
import org.junit.runners.JUnit4;
import org.junit.runner.RunWith;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
@@ -13,7 +12,7 @@ import org.springframework.batch.item.ExecutionContext;
/**
* Tests for {@link MapExecutionContextDao}.
*/
@RunWith(JUnit4ClassRunner.class)
@RunWith(JUnit4.class)
public class MapExecutionContextDaoTests extends AbstractExecutionContextDaoTests {
@Override

View File

@@ -1,29 +1,24 @@
package org.springframework.batch.core.repository.dao;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.internal.runners.JUnit4ClassRunner;
import org.junit.runners.JUnit4;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
import static org.junit.Assert.*;
@RunWith(JUnit4ClassRunner.class)
@RunWith(JUnit4.class)
public class MapJobExecutionDaoTests extends AbstractJobExecutionDaoTests {
@Override

View File

@@ -1,9 +1,9 @@
package org.springframework.batch.core.repository.dao;
import org.junit.runner.RunWith;
import org.junit.internal.runners.JUnit4ClassRunner;
import org.junit.runners.JUnit4;
@RunWith(JUnit4ClassRunner.class)
@RunWith(JUnit4.class)
public class MapJobInstanceDaoTests extends AbstractJobInstanceDaoTests {
protected JobInstanceDao getJobInstanceDao() {

View File

@@ -7,7 +7,7 @@ import static org.junit.Assert.assertNull;
import java.util.Date;
import org.junit.Test;
import org.junit.internal.runners.JUnit4ClassRunner;
import org.junit.runners.JUnit4;
import org.junit.runner.RunWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution;
@@ -15,7 +15,7 @@ import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.support.SimpleJobRepository;
@RunWith(JUnit4ClassRunner.class)
@RunWith(JUnit4.class)
public class MapStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
protected StepExecutionDao getStepExecutionDao() {

View File

@@ -31,10 +31,10 @@ import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.jdbc.SimpleJdbcTestUtils;
import org.springframework.batch.support.JdbcTestUtils;
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
@@ -46,18 +46,18 @@ public class TablePrefixTests {
@Autowired
private Job job;
private SimpleJdbcTemplate simpleJdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
public void setDataSource(DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
@Test
public void testJobLaunch() throws Exception {
JobExecution jobExecution = jobLauncher.run(job, new JobParameters());
assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus());
assertEquals(1, SimpleJdbcTestUtils.countRowsInTable(simpleJdbcTemplate, "PREFIX_JOB_INSTANCE"));
assertEquals(1, JdbcTestUtils.countRowsInTable(jdbcTemplate, "PREFIX_JOB_INSTANCE"));
}
public static class TestTasklet implements Tasklet {

View File

@@ -36,7 +36,7 @@ import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
@@ -55,11 +55,11 @@ public class ListPreparedStatementSetterTests {
StepExecution stepExecution;
private SimpleJdbcTemplate simpleJdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
public void setDataSource(DataSource dataSource) {
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
@Autowired
@@ -86,7 +86,7 @@ public class ListPreparedStatementSetterTests {
public void testSetValues() {
final List<String> results = new ArrayList<String>();
simpleJdbcTemplate.getJdbcOperations().query("SELECT NAME from T_FOOS where ID > ? and ID < ?", pss,
jdbcTemplate.query("SELECT NAME from T_FOOS where ID > ? and ID < ?", pss,
new RowCallbackHandler() {
public void processRow(ResultSet rs) throws SQLException {
results.add(rs.getString(1));
@@ -107,12 +107,12 @@ public class ListPreparedStatementSetterTests {
@Test
public void testXmlConfiguration() throws Exception {
this.simpleJdbcTemplate.update("create table FOO (ID integer, NAME varchar(40), VALUE integer)");
this.jdbcTemplate.update("create table FOO (ID integer, NAME varchar(40), VALUE integer)");
try {
this.simpleJdbcTemplate.update("insert into FOO values (?,?,?)", 0, "zero", 0);
this.simpleJdbcTemplate.update("insert into FOO values (?,?,?)", 1, "one", 1);
this.simpleJdbcTemplate.update("insert into FOO values (?,?,?)", 2, "two", 2);
this.simpleJdbcTemplate.update("insert into FOO values (?,?,?)", 3, "three", 3);
this.jdbcTemplate.update("insert into FOO values (?,?,?)", 0, "zero", 0);
this.jdbcTemplate.update("insert into FOO values (?,?,?)", 1, "one", 1);
this.jdbcTemplate.update("insert into FOO values (?,?,?)", 2, "two", 2);
this.jdbcTemplate.update("insert into FOO values (?,?,?)", 3, "three", 3);
JobParametersBuilder builder = new JobParametersBuilder().addLong("min.id", 1L).addLong("max.id", 2L);
JobExecution jobExecution = this.jobLauncher.run(this.job, builder.toJobParameters());
@@ -126,7 +126,7 @@ public class ListPreparedStatementSetterTests {
assertEquals(new Foo(2, "two", 2), foos.get(1));
}
finally {
this.simpleJdbcTemplate.update("drop table FOO");
this.jdbcTemplate.update("drop table FOO");
}
}

View File

@@ -136,10 +136,8 @@ public class AsyncStepScopeIntegrationTests implements BeanFactoryAware {
taskExecutor.execute(task);
}
int i = 0;
for (FutureTask<String> task : tasks) {
assertEquals("foo", task.get());
i++;
}
// Don't close the outer scope until all tasks are finished. This should

View File

@@ -30,7 +30,7 @@
<property name="stepExecutionIncrementer" ref="stepExecutionIncrementer" />
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg ref="dataSource" />
</bean>
</beans>