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

@@ -11,7 +11,7 @@ import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.test.sample.SampleTasklet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.annotation.Repeat;
import org.springframework.test.context.ContextConfiguration;
@@ -25,7 +25,7 @@ import org.springframework.test.context.ContextConfiguration;
@ContextConfiguration(locations = { "/simple-job-launcher-context.xml", "/job-runner-context.xml" })
public abstract class AbstractSampleJobTests {
private SimpleJdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
@Autowired
private JobLauncherTestUtils jobLauncherTestUtils;
@@ -35,7 +35,7 @@ public abstract class AbstractSampleJobTests {
private SampleTasklet tasklet2;
@Autowired
public void setJdbcTemplate(SimpleJdbcTemplate jdbcTemplate) {
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}

View File

@@ -32,10 +32,10 @@ import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.JobParametersIncrementer;
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;
import org.springframework.test.jdbc.SimpleJdbcTestUtils;
import org.springframework.batch.support.JdbcTestUtils;
/**
* @author Dave Syer
@@ -53,7 +53,7 @@ public class JobRepositoryTestUtilsTests {
@Autowired
private DataSource dataSource;
private SimpleJdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
private int beforeJobs;
@@ -61,9 +61,9 @@ public class JobRepositoryTestUtilsTests {
@Before
public void init() {
jdbcTemplate = new SimpleJdbcTemplate(dataSource);
beforeJobs = SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION");
beforeSteps = SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
jdbcTemplate = new JdbcTemplate(dataSource);
beforeJobs = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION");
beforeSteps = JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION");
}
@Test(expected=IllegalArgumentException.class)
@@ -84,11 +84,11 @@ public class JobRepositoryTestUtilsTests {
utils = new JobRepositoryTestUtils(jobRepository, dataSource);
List<JobExecution> list = utils.createJobExecutions(3);
assertEquals(3, list.size());
assertEquals(beforeJobs + 3, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeSteps + 3, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION"));
assertEquals(beforeJobs + 3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeSteps + 3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION"));
utils.removeJobExecutions(list);
assertEquals(beforeJobs, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeSteps, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION"));
assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeSteps, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION"));
}
@Test
@@ -101,9 +101,9 @@ public class JobRepositoryTestUtilsTests {
jobRepository.update(jobExecution);
jobExecution = jobRepository.createJobExecution("job", new JobParameters());
list.add(jobExecution);
assertEquals(beforeJobs + 2, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeJobs + 2, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
utils.removeJobExecutions(list);
assertEquals(beforeJobs, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
}
@Test
@@ -111,11 +111,11 @@ public class JobRepositoryTestUtilsTests {
utils = new JobRepositoryTestUtils(jobRepository, dataSource);
List<JobExecution> list = utils.createJobExecutions("foo",new String[] {"bar", "spam"}, 3);
assertEquals(3, list.size());
assertEquals(beforeJobs + 3, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeSteps + 6, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION"));
assertEquals(beforeJobs + 3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeSteps + 6, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION"));
utils.removeJobExecutions(list);
assertEquals(beforeJobs, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeSteps, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION"));
assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeSteps, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_STEP_EXECUTION"));
}
@Test
@@ -123,11 +123,11 @@ public class JobRepositoryTestUtilsTests {
utils = new JobRepositoryTestUtils(jobRepository, dataSource);
List<JobExecution> list1 = utils.createJobExecutions(3);
List<JobExecution> list2 = utils.createJobExecutions(2);
assertEquals(beforeJobs + 5, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeJobs + 5, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
utils.removeJobExecutions(list2);
assertEquals(beforeJobs + 3, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeJobs + 3, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
utils.removeJobExecutions(list1);
assertEquals(beforeJobs, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
}
@Test
@@ -142,7 +142,6 @@ public class JobRepositoryTestUtilsTests {
assertEquals(1, list.size());
assertEquals("bar", list.get(0).getJobInstance().getJobParameters().getString("foo"));
utils.removeJobExecutions(list);
assertEquals(beforeJobs, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
assertEquals(beforeJobs, JdbcTestUtils.countRowsInTable(jdbcTemplate, "BATCH_JOB_EXECUTION"));
}
}

View File

@@ -14,7 +14,7 @@ import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
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;
@@ -23,7 +23,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
public class SampleStepTests implements ApplicationContextAware {
@Autowired
private SimpleJdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
private StepRunner stepRunner;

View File

@@ -9,12 +9,12 @@ import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.item.ExecutionContext;
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;
public class SampleTasklet implements Tasklet {
@Autowired
private SimpleJdbcTemplate jdbcTemplate;
private JdbcTemplate jdbcTemplate;
private JobExecution jobExecution;

View File

@@ -9,7 +9,7 @@
<import resource="classpath:/data-source-context.xml" />
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<constructor-arg ref="dataSource" />
</bean>