Merge pull request #85 from chrisjs/BATCH-1929
BATCH-1929: Convert deprecated classes from the org.springframework.jdbc.core.simple package in core-tests
This commit is contained in:
@@ -22,10 +22,10 @@ import org.springframework.batch.core.test.football.Game;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
|
||||
import org.springframework.jdbc.core.support.JdbcDaoSupport;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
|
||||
|
||||
public class JdbcGameDao extends SimpleJdbcDaoSupport implements ItemWriter<Game> {
|
||||
public class JdbcGameDao extends JdbcDaoSupport implements ItemWriter<Game> {
|
||||
|
||||
private SimpleJdbcInsert insertGame;
|
||||
|
||||
|
||||
@@ -18,23 +18,28 @@ package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import org.springframework.batch.core.test.football.Player;
|
||||
import org.springframework.batch.core.test.football.PlayerDao;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
|
||||
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class JdbcPlayerDao extends SimpleJdbcDaoSupport implements PlayerDao {
|
||||
public class JdbcPlayerDao implements PlayerDao {
|
||||
|
||||
public static final String INSERT_PLAYER =
|
||||
"INSERT into PLAYERS (player_id, last_name, first_name, pos, year_of_birth, year_drafted)" +
|
||||
" values (:id, :lastName, :firstName, :position, :birthYear, :debutYear)";
|
||||
|
||||
public void savePlayer(Player player) {
|
||||
|
||||
getSimpleJdbcTemplate().update(INSERT_PLAYER,
|
||||
new BeanPropertySqlParameterSource(player));
|
||||
|
||||
|
||||
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||
|
||||
public void savePlayer(Player player) {
|
||||
namedParameterJdbcTemplate.update(INSERT_PLAYER, new BeanPropertySqlParameterSource(player));
|
||||
}
|
||||
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,16 +21,20 @@ import java.util.List;
|
||||
import org.springframework.batch.core.test.football.PlayerSummary;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
|
||||
public class JdbcPlayerSummaryDao extends SimpleJdbcDaoSupport implements ItemWriter<PlayerSummary> {
|
||||
import javax.sql.DataSource;
|
||||
|
||||
public class JdbcPlayerSummaryDao implements ItemWriter<PlayerSummary> {
|
||||
|
||||
private static final String INSERT_SUMMARY = "INSERT into PLAYER_SUMMARY(ID, YEAR_NO, COMPLETES, ATTEMPTS, PASSING_YARDS, PASSING_TD, "
|
||||
+ "INTERCEPTIONS, RUSHES, RUSH_YARDS, RECEPTIONS, RECEPTIONS_YARDS, TOTAL_TD) "
|
||||
+ "values(:id, :year, :completes, :attempts, :passingYards, :passingTd, "
|
||||
+ ":interceptions, :rushes, :rushYards, :receptions, :receptionYards, :totalTd)";
|
||||
|
||||
public void write(List<? extends PlayerSummary> summaries) {
|
||||
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||
|
||||
public void write(List<? extends PlayerSummary> summaries) {
|
||||
|
||||
for (PlayerSummary summary : summaries) {
|
||||
|
||||
@@ -42,10 +46,11 @@ public class JdbcPlayerSummaryDao extends SimpleJdbcDaoSupport implements ItemWr
|
||||
summary.getReceptions()).addValue("receptionYards", summary.getReceptionYards()).addValue(
|
||||
"totalTd", summary.getTotalTd());
|
||||
|
||||
getSimpleJdbcTemplate().update(INSERT_SUMMARY, args);
|
||||
|
||||
namedParameterJdbcTemplate.update(INSERT_SUMMARY, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@
|
||||
</bean>
|
||||
|
||||
<bean id="retryPolicy" class="org.springframework.retry.policy.SimpleRetryPolicy" scope="step">
|
||||
<property name="maxAttempts" value="#{jobParameters['retry.limit']}" />
|
||||
<property name="retryableExceptions">
|
||||
<constructor-arg value="#{jobParameters['retry.limit']}"/>
|
||||
<constructor-arg>
|
||||
<map key-type="java.lang.Class">
|
||||
<entry key="org.springframework.dao.DataAccessException" value="true"/>
|
||||
</map>
|
||||
</property>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<step id="summarizationStep" xmlns="http://www.springframework.org/schema/batch">
|
||||
|
||||
@@ -32,10 +32,10 @@ import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
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;
|
||||
import org.springframework.test.jdbc.SimpleJdbcTestUtils;
|
||||
import org.springframework.batch.support.JdbcTestUtils;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -48,7 +48,7 @@ public class FootballJobIntegrationTests {
|
||||
/** Logger */
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private SimpleJdbcTemplate simpleJdbcTemplate;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
private JobLauncher jobLauncher;
|
||||
@@ -58,12 +58,12 @@ public class FootballJobIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void clear() {
|
||||
SimpleJdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "PLAYER_SUMMARY", "GAMES", "PLAYERS");
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "PLAYER_SUMMARY", "GAMES", "PLAYERS");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -33,10 +33,10 @@ import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.batch.support.DatabaseType;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -49,7 +49,7 @@ public class FootballJobSkipIntegrationTests {
|
||||
/** Logger */
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private SimpleJdbcTemplate simpleJdbcTemplate;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
private JobLauncher jobLauncher;
|
||||
@@ -61,13 +61,13 @@ public class FootballJobSkipIntegrationTests {
|
||||
|
||||
@Autowired
|
||||
public void setDataSource(DataSource dataSource) throws Exception {
|
||||
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
databaseType = DatabaseType.fromMetaData(dataSource);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void clear() {
|
||||
SimpleJdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "PLAYER_SUMMARY", "GAMES", "PLAYERS");
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "PLAYER_SUMMARY", "GAMES", "PLAYERS");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -76,7 +76,7 @@ public class FootballJobSkipIntegrationTests {
|
||||
if (databaseType == DatabaseType.POSTGRES || databaseType == DatabaseType.ORACLE) {
|
||||
// Extra special test for these platforms (would have failed
|
||||
// the job with UNKNOWN status in Batch 2.0):
|
||||
simpleJdbcTemplate.update("SET CONSTRAINTS ALL DEFERRED");
|
||||
jdbcTemplate.update("SET CONSTRAINTS ALL DEFERRED");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -32,10 +32,10 @@ import org.springframework.batch.core.JobParametersBuilder;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
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;
|
||||
import org.springframework.test.jdbc.SimpleJdbcTestUtils;
|
||||
import org.springframework.batch.support.JdbcTestUtils;
|
||||
|
||||
|
||||
/**
|
||||
@@ -52,19 +52,19 @@ public class ParallelJobIntegrationTests {
|
||||
@Autowired
|
||||
private JobLauncher jobLauncher;
|
||||
|
||||
private SimpleJdbcTemplate simpleJdbcTemplate;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
private Job job;
|
||||
|
||||
@Autowired
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void clear() {
|
||||
SimpleJdbcTestUtils.deleteFromTables(simpleJdbcTemplate, "PLAYER_SUMMARY", "GAMES", "PLAYERS");
|
||||
JdbcTestUtils.deleteFromTables(jdbcTemplate, "PLAYER_SUMMARY", "GAMES", "PLAYERS");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
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;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class JdbcJobRepositoryTests {
|
||||
|
||||
private List<Serializable> list = new ArrayList<Serializable>();
|
||||
|
||||
private SimpleJdbcTemplate simpleJdbcTemplate;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
private JobRepository repository;
|
||||
@@ -67,32 +67,32 @@ public class JdbcJobRepositoryTests {
|
||||
|
||||
@Autowired
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void onSetUpInTransaction() throws Exception {
|
||||
job = new JobSupport("test-job");
|
||||
job.setRestartable(true);
|
||||
simpleJdbcTemplate.update("DELETE FROM BATCH_STEP_EXECUTION_CONTEXT");
|
||||
simpleJdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION_CONTEXT");
|
||||
simpleJdbcTemplate.update("DELETE FROM BATCH_STEP_EXECUTION");
|
||||
simpleJdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION");
|
||||
simpleJdbcTemplate.update("DELETE FROM BATCH_JOB_PARAMS");
|
||||
simpleJdbcTemplate.update("DELETE FROM BATCH_JOB_INSTANCE");
|
||||
jdbcTemplate.update("DELETE FROM BATCH_STEP_EXECUTION_CONTEXT");
|
||||
jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION_CONTEXT");
|
||||
jdbcTemplate.update("DELETE FROM BATCH_STEP_EXECUTION");
|
||||
jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION");
|
||||
jdbcTemplate.update("DELETE FROM BATCH_JOB_PARAMS");
|
||||
jdbcTemplate.update("DELETE FROM BATCH_JOB_INSTANCE");
|
||||
}
|
||||
|
||||
@After
|
||||
public void onTearDownAfterTransaction() throws Exception {
|
||||
for (Long id : jobExecutionIds) {
|
||||
simpleJdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION_CONTEXT where JOB_EXECUTION_ID=?", id);
|
||||
simpleJdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION where JOB_EXECUTION_ID=?", id);
|
||||
jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION_CONTEXT where JOB_EXECUTION_ID=?", id);
|
||||
jdbcTemplate.update("DELETE FROM BATCH_JOB_EXECUTION where JOB_EXECUTION_ID=?", id);
|
||||
}
|
||||
for (Long id : jobIds) {
|
||||
simpleJdbcTemplate.update("DELETE FROM BATCH_JOB_INSTANCE where JOB_INSTANCE_ID=?", id);
|
||||
jdbcTemplate.update("DELETE FROM BATCH_JOB_INSTANCE where JOB_INSTANCE_ID=?", id);
|
||||
}
|
||||
for (Long id : jobIds) {
|
||||
int count = simpleJdbcTemplate.queryForInt(
|
||||
int count = jdbcTemplate.queryForInt(
|
||||
"SELECT COUNT(*) FROM BATCH_JOB_INSTANCE where JOB_INSTANCE_ID=?", id);
|
||||
assertEquals(0, count);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public class JdbcJobRepositoryTests {
|
||||
job.setName("foo");
|
||||
int before = 0;
|
||||
JobExecution execution = repository.createJobExecution(job.getName(), new JobParameters());
|
||||
int after = simpleJdbcTemplate.queryForInt("SELECT COUNT(*) FROM BATCH_JOB_INSTANCE");
|
||||
int after = jdbcTemplate.queryForInt("SELECT COUNT(*) FROM BATCH_JOB_INSTANCE");
|
||||
assertEquals(before + 1, after);
|
||||
assertNotNull(execution.getId());
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class JdbcJobRepositoryTests {
|
||||
JobExecution execution = repository.createJobExecution(job.getName(), new JobParameters());
|
||||
execution.getExecutionContext().put("foo", "bar");
|
||||
repository.updateExecutionContext(execution);
|
||||
int after = simpleJdbcTemplate.queryForInt("SELECT COUNT(*) FROM BATCH_JOB_EXECUTION_CONTEXT");
|
||||
int after = jdbcTemplate.queryForInt("SELECT COUNT(*) FROM BATCH_JOB_EXECUTION_CONTEXT");
|
||||
assertEquals(before + 1, after);
|
||||
assertNotNull(execution.getId());
|
||||
JobExecution last = repository.getLastJobExecution(job.getName(), new JobParameters());
|
||||
@@ -145,7 +145,7 @@ public class JdbcJobRepositoryTests {
|
||||
|
||||
assertNotNull(execution);
|
||||
|
||||
int after = simpleJdbcTemplate.queryForInt("SELECT COUNT(*) FROM BATCH_JOB_INSTANCE");
|
||||
int after = jdbcTemplate.queryForInt("SELECT COUNT(*) FROM BATCH_JOB_INSTANCE");
|
||||
assertNotNull(execution.getId());
|
||||
assertEquals(before + 1, after);
|
||||
|
||||
@@ -166,7 +166,7 @@ public class JdbcJobRepositoryTests {
|
||||
repository.update(execution);
|
||||
execution.setStatus(BatchStatus.FAILED);
|
||||
|
||||
int before = simpleJdbcTemplate.queryForInt("SELECT COUNT(*) FROM BATCH_JOB_INSTANCE");
|
||||
int before = jdbcTemplate.queryForInt("SELECT COUNT(*) FROM BATCH_JOB_INSTANCE");
|
||||
assertEquals(1, before);
|
||||
|
||||
long t0 = System.currentTimeMillis();
|
||||
@@ -179,7 +179,7 @@ public class JdbcJobRepositoryTests {
|
||||
}
|
||||
long t1 = System.currentTimeMillis();
|
||||
|
||||
int after = simpleJdbcTemplate.queryForInt("SELECT COUNT(*) FROM BATCH_JOB_INSTANCE");
|
||||
int after = jdbcTemplate.queryForInt("SELECT COUNT(*) FROM BATCH_JOB_INSTANCE");
|
||||
assertNotNull(execution.getId());
|
||||
assertEquals(before, after);
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ import org.springframework.batch.item.ParseException;
|
||||
import org.springframework.batch.item.UnexpectedInputException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
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.PlatformTransactionManager;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -88,22 +88,22 @@ public class FaultTolerantStepFactoryBeanIntegrationTests {
|
||||
taskExecutor.afterPropertiesSet();
|
||||
factory.setTaskExecutor(taskExecutor);
|
||||
|
||||
SimpleJdbcTestUtils.deleteFromTables(new SimpleJdbcTemplate(dataSource), "ERROR_LOG");
|
||||
JdbcTestUtils.deleteFromTables(new JdbcTemplate(dataSource), "ERROR_LOG");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatesNoRollback() throws Exception {
|
||||
|
||||
SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
writer.write(Arrays.asList("foo", "bar"));
|
||||
processor.process("spam");
|
||||
assertEquals(3, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
|
||||
assertEquals(3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
|
||||
|
||||
writer.clear();
|
||||
processor.clear();
|
||||
assertEquals(0, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
|
||||
assertEquals(0, JdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
|
||||
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class FaultTolerantStepFactoryBeanIntegrationTests {
|
||||
|
||||
for (int i = 0; i < MAX_COUNT; i++) {
|
||||
|
||||
SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
SkipReaderStub reader = new SkipReaderStub();
|
||||
reader.clear();
|
||||
@@ -125,7 +125,7 @@ public class FaultTolerantStepFactoryBeanIntegrationTests {
|
||||
processor.clear();
|
||||
factory.setItemProcessor(processor);
|
||||
|
||||
assertEquals(0, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
|
||||
assertEquals(0, JdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
|
||||
|
||||
try {
|
||||
|
||||
@@ -189,10 +189,10 @@ public class FaultTolerantStepFactoryBeanIntegrationTests {
|
||||
|
||||
private Collection<String> failures = Collections.emptySet();
|
||||
|
||||
private SimpleJdbcTemplate jdbcTemplate;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
public SkipWriterStub(DataSource dataSource) {
|
||||
jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
public List<String> getCommitted() {
|
||||
@@ -230,13 +230,13 @@ public class FaultTolerantStepFactoryBeanIntegrationTests {
|
||||
|
||||
private List<String> processed = new ArrayList<String>();
|
||||
|
||||
private SimpleJdbcTemplate jdbcTemplate;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
/**
|
||||
* @param dataSource
|
||||
*/
|
||||
public SkipProcessorStub(DataSource dataSource) {
|
||||
jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
public List<String> getCommitted() {
|
||||
|
||||
@@ -34,11 +34,11 @@ import org.springframework.batch.item.ParseException;
|
||||
import org.springframework.batch.item.UnexpectedInputException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
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.PlatformTransactionManager;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -86,22 +86,22 @@ public class FaultTolerantStepFactoryBeanRollbackIntegrationTests {
|
||||
factory.setCommitInterval(3);
|
||||
factory.setSkipLimit(10);
|
||||
|
||||
SimpleJdbcTestUtils.deleteFromTables(new SimpleJdbcTemplate(dataSource), "ERROR_LOG");
|
||||
JdbcTestUtils.deleteFromTables(new JdbcTemplate(dataSource), "ERROR_LOG");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdatesNoRollback() throws Exception {
|
||||
|
||||
SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
|
||||
writer.write(Arrays.asList("foo", "bar"));
|
||||
processor.process("spam");
|
||||
assertEquals(3, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
|
||||
assertEquals(3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
|
||||
|
||||
writer.clear();
|
||||
processor.clear();
|
||||
assertEquals(0, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
|
||||
assertEquals(0, JdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
|
||||
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@ public class FaultTolerantStepFactoryBeanRollbackIntegrationTests {
|
||||
logger.info("Starting step: " + i);
|
||||
}
|
||||
|
||||
SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
assertEquals(0, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
|
||||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
assertEquals(0, JdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
|
||||
|
||||
try {
|
||||
|
||||
@@ -210,10 +210,10 @@ public class FaultTolerantStepFactoryBeanRollbackIntegrationTests {
|
||||
|
||||
private Collection<String> failures = Collections.emptySet();
|
||||
|
||||
private SimpleJdbcTemplate jdbcTemplate;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
public SkipWriterStub(DataSource dataSource) {
|
||||
jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
public void setFailures(String... failures) {
|
||||
@@ -255,13 +255,13 @@ public class FaultTolerantStepFactoryBeanRollbackIntegrationTests {
|
||||
|
||||
private List<String> processed = new CopyOnWriteArrayList<String>();
|
||||
|
||||
private SimpleJdbcTemplate jdbcTemplate;
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
/**
|
||||
* @param dataSource
|
||||
*/
|
||||
public SkipProcessorStub(DataSource dataSource) {
|
||||
jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user