BATCH-1891: Migrate usage of deprecated classes
This commit is contained in:
committed by
Dave Syer
parent
b1246f99b1
commit
d0e0334674
@@ -38,8 +38,8 @@ import org.springframework.batch.core.repository.dao.AbstractJdbcBatchMetadataDa
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
||||
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.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -64,7 +64,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
|
||||
|
||||
};
|
||||
|
||||
private SimpleJdbcOperations jdbcTemplate;
|
||||
private JdbcOperations jdbcTemplate;
|
||||
|
||||
/**
|
||||
* @see InitializingBean#afterPropertiesSet()
|
||||
@@ -94,7 +94,7 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
|
||||
}
|
||||
|
||||
public final void setDataSource(DataSource dataSource) {
|
||||
jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
jdbcTemplate = new JdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -193,11 +193,9 @@ public class JobRepositoryTestUtils extends AbstractJdbcBatchMetadataDao impleme
|
||||
* {@link JobInstance} and {@link StepExecution} instances from the standard
|
||||
* RDBMS locations used by Spring Batch.
|
||||
*
|
||||
* @param list a list of {@link JobExecution}
|
||||
* @throws DataAccessException if there is a problem
|
||||
*/
|
||||
public void removeJobExecutions() throws DataAccessException {
|
||||
|
||||
jdbcTemplate.update(getQuery("delete from %PREFIX%STEP_EXECUTION_CONTEXT"));
|
||||
jdbcTemplate.update(getQuery("delete from %PREFIX%STEP_EXECUTION"));
|
||||
jdbcTemplate.update(getQuery("delete from %PREFIX%JOB_EXECUTION_CONTEXT"));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user