BATCH-1940: Replace org.springframework.batch.support.JdbcTestUtils with org.springframework.test.jdbc.JdbcTestUtils

This commit is contained in:
Chris Schaefer
2012-12-28 15:48:42 -05:00
committed by Michael Minella
parent e9680c7f61
commit a6ab68bbbb
20 changed files with 24 additions and 74 deletions

View File

@@ -24,10 +24,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.batch.core.BatchStatus;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.support.JdbcTestUtils;
import org.springframework.test.jdbc.JdbcTestUtils;
import org.springframework.batch.test.JobLauncherTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -40,7 +39,7 @@ public class ParallelJobFunctionalTests {
@Autowired
private JobLauncherTestUtils jobLauncherTestUtils;
private JdbcOperations jdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
public void setDataSource(DataSource dataSource) {

View File

@@ -24,7 +24,7 @@ import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteExcep
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.batch.sample.common.SkipCheckingListener;
import org.springframework.batch.sample.domain.trade.internal.TradeWriter;
import org.springframework.batch.support.JdbcTestUtils;
import org.springframework.test.jdbc.JdbcTestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcOperations;
@@ -167,7 +167,7 @@ public class SkipSampleFunctionalTests {
private void validateLaunchWithSkips(JobExecution jobExecution) {
// Step1: 9 input records, 1 skipped in read, 1 skipped in write =>
// 7 written to output
assertEquals(7, JdbcTestUtils.countRowsInTable(jdbcTemplate, "TRADE"));
assertEquals(7, JdbcTestUtils.countRowsInTable((JdbcTemplate) jdbcTemplate, "TRADE"));
// Step2: 7 input records, 1 skipped on process, 1 on write => 5 written
// to output
@@ -178,7 +178,7 @@ public class SkipSampleFunctionalTests {
assertEquals(1, SkipCheckingListener.getProcessSkips());
// Both steps contained skips
assertEquals(2, JdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
assertEquals(2, JdbcTestUtils.countRowsInTable((JdbcTemplate) jdbcTemplate, "ERROR_LOG"));
assertEquals("2 records were skipped!", jdbcTemplate.queryForObject(
"SELECT MESSAGE from ERROR_LOG where JOB_NAME = ? and STEP_NAME = ?", String.class, "skipJob", "step1"));
@@ -197,13 +197,13 @@ public class SkipSampleFunctionalTests {
private void validateLaunchWithoutSkips(JobExecution jobExecution) {
// Step1: 5 input records => 5 written to output
assertEquals(5, JdbcTestUtils.countRowsInTable(jdbcTemplate, "TRADE"));
assertEquals(5, JdbcTestUtils.countRowsInTable((JdbcTemplate) jdbcTemplate, "TRADE"));
// Step2: 5 input records => 5 written to output
assertEquals(5, jdbcTemplate.queryForInt("SELECT COUNT(*) from TRADE where VERSION=?", 1));
// Neither step contained skips
assertEquals(0, JdbcTestUtils.countRowsInTable(jdbcTemplate, "ERROR_LOG"));
assertEquals(0, JdbcTestUtils.countRowsInTable((JdbcTemplate) jdbcTemplate, "ERROR_LOG"));
assertEquals(new BigDecimal("270.75"), jobExecution.getExecutionContext().get(TradeWriter.TOTAL_AMOUNT_KEY));