From 5218748f7e22c41e7c86569b6afb3b9a4a164130 Mon Sep 17 00:00:00 2001 From: Chris Schaefer Date: Thu, 13 Dec 2012 23:08:06 -0500 Subject: [PATCH] BATCH-1931: Convert deprecated classes from the org.springframework.jdbc.core.simple package in infrastructure-tests --- .../batch/config/DatasourceTests.java | 12 +++---- .../IbatisPagingItemReaderAsyncTests.java | 10 +++--- .../JdbcPagingItemReaderAsyncTests.java | 10 +++--- .../JdbcPagingQueryIntegrationTests.java | 12 +++---- .../JdbcPagingRestartIntegrationTests.java | 14 ++++---- .../JpaPagingItemReaderAsyncTests.java | 10 +++--- .../batch/jms/ExternalRetryInBatchTests.java | 10 +++--- .../batch/repeat/jms/AsynchronousTests.java | 20 +++++------ .../batch/repeat/jms/SynchronousTests.java | 22 ++++++------ .../batch/retry/jms/ExternalRetryTests.java | 18 +++++----- .../batch/retry/jms/SynchronousTests.java | 34 +++++++++---------- 11 files changed, 86 insertions(+), 86 deletions(-) diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/config/DatasourceTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/config/DatasourceTests.java index 0af5d61b4..3dfe865c3 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/config/DatasourceTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/config/DatasourceTests.java @@ -18,10 +18,10 @@ package org.springframework.batch.config; import static org.junit.Assert.*; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.ContextConfiguration; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; import org.springframework.transaction.annotation.Transactional; import org.junit.runner.RunWith; import org.junit.AfterClass; @@ -34,11 +34,11 @@ import javax.sql.DataSource; @ContextConfiguration(locations = "/org/springframework/batch/jms/jms-context.xml") public class DatasourceTests { - private SimpleJdbcTemplate simpleJdbcTemplate; + private JdbcTemplate jdbcTemplate; @Autowired public void setDataSource(DataSource dataSource) { - this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); + this.jdbcTemplate = new JdbcTemplate(dataSource); } @BeforeClass @@ -54,10 +54,10 @@ public class DatasourceTests { @Transactional @Test public void testTemplate() throws Exception { System.err.println(System.getProperty("java.class.path")); - simpleJdbcTemplate.getJdbcOperations().execute("delete from T_BARS"); - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + jdbcTemplate.execute("delete from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(0, count); - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", 0, "foo"); + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", 0, "foo"); } } diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java index b1732e161..64d8f98e3 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java @@ -22,13 +22,13 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.item.sample.Foo; +import org.springframework.batch.support.JdbcTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.orm.ibatis.SqlMapClientFactoryBean; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.jdbc.SimpleJdbcTestUtils; import com.ibatis.sqlmap.client.SqlMapClient; @@ -55,17 +55,17 @@ public class IbatisPagingItemReaderAsyncTests { @Before public void init() { - SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); maxId = jdbcTemplate.queryForInt("SELECT MAX(ID) from T_FOOS"); for (int i = ITEM_COUNT; i > maxId; i--) { jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i); } - assertEquals(ITEM_COUNT, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); + assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); } @After public void destroy() { - SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.update("DELETE from T_FOOS where ID>?", maxId); } diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderAsyncTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderAsyncTests.java index 5c752d764..deed72038 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderAsyncTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingItemReaderAsyncTests.java @@ -43,12 +43,12 @@ import org.junit.runner.RunWith; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean; import org.springframework.batch.item.sample.Foo; +import org.springframework.batch.support.JdbcTestUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.simple.ParameterizedRowMapper; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.jdbc.SimpleJdbcTestUtils; /** * @author Dave Syer @@ -83,17 +83,17 @@ public class JdbcPagingItemReaderAsyncTests { @Before public void init() { - SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); maxId = jdbcTemplate.queryForInt("SELECT MAX(ID) from T_FOOS"); for (int i = ITEM_COUNT; i > maxId; i--) { jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i); } - assertEquals(ITEM_COUNT, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); + assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); } @After public void destroy() { - SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.update("DELETE from T_FOOS where ID>?", maxId); } diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingQueryIntegrationTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingQueryIntegrationTests.java index 167c995ea..8c17612b3 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingQueryIntegrationTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingQueryIntegrationTests.java @@ -38,11 +38,11 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.item.database.support.AbstractSqlPagingQueryProvider; import org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean; +import org.springframework.batch.support.JdbcTestUtils; 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; /** * @author Dave Syer @@ -60,7 +60,7 @@ public class JdbcPagingQueryIntegrationTests { private int maxId; - private SimpleJdbcTemplate jdbcTemplate; + private JdbcTemplate jdbcTemplate; private int itemCount = 9; @@ -68,7 +68,7 @@ public class JdbcPagingQueryIntegrationTests { @Before public void testInit() { - jdbcTemplate = new SimpleJdbcTemplate(dataSource); + jdbcTemplate = new JdbcTemplate(dataSource); String[] names = {"Foo", "Bar", "Baz", "Foo", "Bar", "Baz", "Foo", "Bar", "Baz"}; String[] codes = {"A", "B", "A", "B", "B", "B", "A", "B", "A"}; jdbcTemplate.update("DELETE from T_FOOS"); @@ -76,7 +76,7 @@ public class JdbcPagingQueryIntegrationTests { jdbcTemplate.update("INSERT into T_FOOS (ID,NAME, CODE, VALUE) values (?, ?, ?, ?)", maxId, names[i], codes[i], i); maxId++; } - assertEquals(itemCount, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); + assertEquals(itemCount, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); } @After @@ -89,7 +89,7 @@ public class JdbcPagingQueryIntegrationTests { PagingQueryProvider queryProvider = getPagingQueryProvider(); - int total = SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"); + int total = JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"); assertTrue(total > pageSize); int pages = total / pageSize; diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingRestartIntegrationTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingRestartIntegrationTests.java index 9ae4d0468..332fc382c 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingRestartIntegrationTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JdbcPagingRestartIntegrationTests.java @@ -39,12 +39,12 @@ import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemStream; import org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean; import org.springframework.batch.item.sample.Foo; +import org.springframework.batch.support.JdbcTestUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.simple.ParameterizedRowMapper; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.jdbc.SimpleJdbcTestUtils; /** * @author Dave Syer @@ -62,7 +62,7 @@ public class JdbcPagingRestartIntegrationTests { private int maxId; - private SimpleJdbcTemplate jdbcTemplate; + private JdbcTemplate jdbcTemplate; private int itemCount = 9; @@ -70,13 +70,13 @@ public class JdbcPagingRestartIntegrationTests { @Before public void init() { - jdbcTemplate = new SimpleJdbcTemplate(dataSource); + jdbcTemplate = new JdbcTemplate(dataSource); maxId = jdbcTemplate.queryForInt("SELECT MAX(ID) from T_FOOS"); for (int i = itemCount; i > maxId; i--) { jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i); } - assertEquals(itemCount, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); + assertEquals(itemCount, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); } @After @@ -89,7 +89,7 @@ public class JdbcPagingRestartIntegrationTests { ItemReader reader = getItemReader(); - int total = SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"); + int total = JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"); ExecutionContext executionContext = new ExecutionContext(); ((ItemStream) reader).open(executionContext); @@ -111,7 +111,7 @@ public class JdbcPagingRestartIntegrationTests { ItemReader reader = getItemReader(); - int total = SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"); + int total = JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS"); int count = (total / pageSize) * pageSize; int pagesToRead = Math.min(3, total/pageSize); if (count >= pagesToRead*pageSize) { diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderAsyncTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderAsyncTests.java index 654ae5bb1..889f8e7c4 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderAsyncTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/JpaPagingItemReaderAsyncTests.java @@ -24,11 +24,11 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.batch.item.ExecutionContext; import org.springframework.batch.item.sample.Foo; +import org.springframework.batch.support.JdbcTestUtils; 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; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "JpaPagingItemReaderCommonTests-context.xml") @@ -58,17 +58,17 @@ public class JpaPagingItemReaderAsyncTests { @Before public void init() { - SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); maxId = jdbcTemplate.queryForInt("SELECT MAX(ID) from T_FOOS"); for (int i = ITEM_COUNT; i > maxId; i--) { jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i); } - assertEquals(ITEM_COUNT, SimpleJdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); + assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); } @After public void destroy() { - SimpleJdbcTemplate jdbcTemplate = new SimpleJdbcTemplate(dataSource); + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); jdbcTemplate.update("DELETE from T_FOOS where ID>?", maxId); } diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/jms/ExternalRetryInBatchTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/jms/ExternalRetryInBatchTests.java index d9f54c31f..4db6913aa 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/jms/ExternalRetryInBatchTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/jms/ExternalRetryInBatchTests.java @@ -36,7 +36,7 @@ import org.springframework.batch.repeat.policy.SimpleCompletionPolicy; import org.springframework.batch.repeat.support.RepeatSynchronizationManager; import org.springframework.batch.repeat.support.RepeatTemplate; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jms.core.JmsTemplate; import org.springframework.retry.RecoveryCallback; import org.springframework.retry.RetryCallback; @@ -65,20 +65,20 @@ public class ExternalRetryInBatchTests { private ItemReader provider; - private SimpleJdbcTemplate jdbcTemplate; + private JdbcTemplate jdbcTemplate; @Autowired private PlatformTransactionManager transactionManager; @Autowired public void setDataSource(DataSource dataSource) { - jdbcTemplate = new SimpleJdbcTemplate(dataSource); + jdbcTemplate = new JdbcTemplate(dataSource); } @Before public void onSetUp() throws Exception { getMessages(); // drain queue - jdbcTemplate.getJdbcOperations().execute("delete from T_BARS"); + jdbcTemplate.execute("delete from T_BARS"); jmsTemplate.convertAndSend("queue", "foo"); jmsTemplate.convertAndSend("queue", "bar"); provider = new ItemReader() { @@ -94,7 +94,7 @@ public class ExternalRetryInBatchTests { @After public void onTearDown() throws Exception { getMessages(); // drain queue - jdbcTemplate.getJdbcOperations().execute("delete from T_BARS"); + jdbcTemplate.execute("delete from T_BARS"); } private void assertInitialState() { diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/repeat/jms/AsynchronousTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/repeat/jms/AsynchronousTests.java index f6bf3a8e8..686ec0cb7 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/repeat/jms/AsynchronousTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/repeat/jms/AsynchronousTests.java @@ -29,7 +29,7 @@ import javax.sql.DataSource; import org.springframework.batch.container.jms.BatchMessageListenerContainer; import org.springframework.batch.jms.ExternalRetryInBatchTests; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.listener.SessionAwareMessageListener; import org.springframework.util.ClassUtils; @@ -56,11 +56,11 @@ public class AsynchronousTests { @Autowired private JmsTemplate jmsTemplate; - private SimpleJdbcTemplate simpleJdbcTemplate; + private JdbcTemplate jdbcTemplate; @Autowired public void setDataSource(DataSource dataSource) { - this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); + this.jdbcTemplate = new JdbcTemplate(dataSource); } @Before @@ -71,7 +71,7 @@ public class AsynchronousTests { foo = (String) jmsTemplate.receiveAndConvert("queue"); count++; } - simpleJdbcTemplate.getJdbcOperations().execute("delete from T_BARS"); + jdbcTemplate.execute("delete from T_BARS"); // Queue is now drained... assertNull(foo); @@ -98,7 +98,7 @@ public class AsynchronousTests { private volatile List list = new ArrayList(); private void assertInitialState() { - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(0, count); } @@ -111,7 +111,7 @@ public class AsynchronousTests { public void onMessage(Message message, Session session) throws JMSException { list.add(message.toString()); String text = ((TextMessage) message).getText(); - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); } }); @@ -122,14 +122,14 @@ public class AsynchronousTests { // Need to sleep for at least a second here... waitFor(list,2,2000); - System.err.println(simpleJdbcTemplate.queryForList("select * from T_BARS")); + System.err.println(jdbcTemplate.queryForList("select * from T_BARS")); assertEquals(2, list.size()); String foo = (String) jmsTemplate.receiveAndConvert("queue"); assertEquals(null, foo); - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(2, count); } @@ -146,7 +146,7 @@ public class AsynchronousTests { public void onMessage(Message message, Session session) throws JMSException { list.add(message.toString()); final String text = ((TextMessage) message).getText(); - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); // This causes the DB to rollback but not the message if (text.equals("bar")) { throw new RuntimeException("Rollback!"); @@ -175,7 +175,7 @@ public class AsynchronousTests { msgs.add(text); } - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(0, count); assertTrue("Foo not on queue", msgs.contains("foo")); diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/repeat/jms/SynchronousTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/repeat/jms/SynchronousTests.java index 16650d592..821c94006 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/repeat/jms/SynchronousTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/repeat/jms/SynchronousTests.java @@ -37,7 +37,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.jms.connection.SessionProxy; import org.springframework.jms.core.JmsTemplate; import org.springframework.jms.core.SessionCallback; @@ -62,7 +62,7 @@ public class SynchronousTests implements ApplicationContextAware { @Autowired private PlatformTransactionManager transactionManager; - private SimpleJdbcTemplate simpleJdbcTemplate; + private JdbcTemplate jdbcTemplate; private ApplicationContext applicationContext; @@ -72,7 +72,7 @@ public class SynchronousTests implements ApplicationContextAware { @Autowired public void setDataSource(DataSource dataSource) { - this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); + this.jdbcTemplate = new JdbcTemplate(dataSource); } @BeforeTransaction @@ -83,13 +83,13 @@ public class SynchronousTests implements ApplicationContextAware { foo = (String) jmsTemplate.receiveAndConvert("queue"); count++; } - simpleJdbcTemplate.getJdbcOperations().execute("delete from T_BARS"); + jdbcTemplate.execute("delete from T_BARS"); jmsTemplate.convertAndSend("queue", "foo"); jmsTemplate.convertAndSend("queue", "bar"); } private void assertInitialState() { - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(0, count); } @@ -105,12 +105,12 @@ public class SynchronousTests implements ApplicationContextAware { public RepeatStatus doInIteration(RepeatContext context) throws Exception { String text = (String) jmsTemplate.receiveAndConvert("queue"); list.add(text); - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); return RepeatStatus.continueIf(text != null); } }); - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(2, count); String text = (String) jmsTemplate.receiveAndConvert("queue"); @@ -129,7 +129,7 @@ public class SynchronousTests implements ApplicationContextAware { public RepeatStatus doInIteration(RepeatContext context) throws Exception { String text = (String) jmsTemplate.receiveAndConvert("queue"); list.add(text); - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); return RepeatStatus.continueIf(text != null); } }); @@ -147,7 +147,7 @@ public class SynchronousTests implements ApplicationContextAware { } // The database portion rolled back... - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(0, count); // ... and so did the message session. The rollback should have restored @@ -174,7 +174,7 @@ public class SynchronousTests implements ApplicationContextAware { public RepeatStatus doInIteration(RepeatContext context) throws Exception { String text = (String) txJmsTemplate.receiveAndConvert("queue"); list.add(text); - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); return RepeatStatus.continueIf(text != null); } }); @@ -210,7 +210,7 @@ public class SynchronousTests implements ApplicationContextAware { } // The database portion committed... - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(2, count); // ...but the JMS session rolled back, so the message is still there diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java index a7c076bee..42eece149 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/ExternalRetryTests.java @@ -31,7 +31,7 @@ import org.junit.runner.RunWith; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jms.core.JmsTemplate; import org.springframework.retry.RecoveryCallback; import org.springframework.retry.RetryCallback; @@ -56,20 +56,20 @@ public class ExternalRetryTests { private ItemReader provider; - private SimpleJdbcTemplate simpleJdbcTemplate; + private JdbcTemplate jdbcTemplate; @Autowired private PlatformTransactionManager transactionManager; @Autowired public void setDataSource(DataSource dataSource) { - simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); + jdbcTemplate = new JdbcTemplate(dataSource); } @Before public void onSetUp() throws Exception { getMessages(); // drain queue - simpleJdbcTemplate.getJdbcOperations().execute("delete from T_BARS"); + jdbcTemplate.execute("delete from T_BARS"); jmsTemplate.convertAndSend("queue", "foo"); provider = new ItemReader() { public String read() { @@ -82,7 +82,7 @@ public class ExternalRetryTests { } private void assertInitialState() { - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(0, count); } @@ -104,7 +104,7 @@ public class ExternalRetryTests { for (Object text : texts) { - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); if (list.size() == 1) { throw new RuntimeException("Rollback!"); @@ -165,7 +165,7 @@ public class ExternalRetryTests { List msgs = getMessages(); // The database portion committed once... - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(1, count); // ... and so did the message session. @@ -183,7 +183,7 @@ public class ExternalRetryTests { final String item = provider.read(); final RetryCallback callback = new RetryCallback() { public String doWithRetry(RetryContext context) throws Exception { - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), item); + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), item); throw new RuntimeException("Rollback!"); } }; @@ -230,7 +230,7 @@ public class ExternalRetryTests { assertEquals(1, recovered.size()); // The database portion committed once... - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(0, count); // ... and so did the message session. diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/SynchronousTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/SynchronousTests.java index ba1285270..73afa89b4 100644 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/SynchronousTests.java +++ b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/retry/jms/SynchronousTests.java @@ -32,7 +32,7 @@ import org.junit.runner.RunWith; import org.springframework.batch.item.jms.JmsItemReader; import org.springframework.batch.jms.ExternalRetryInBatchTests; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; +import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jms.core.JmsTemplate; import org.springframework.retry.RetryCallback; import org.springframework.retry.RetryContext; @@ -60,11 +60,11 @@ public class SynchronousTests { private RetryTemplate retryTemplate; - private SimpleJdbcTemplate simpleJdbcTemplate; + private JdbcTemplate jdbcTemplate; @Autowired public void setDataSource(DataSource dataSource) { - this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); + this.jdbcTemplate = new JdbcTemplate(dataSource); } protected String[] getConfigLocations() { @@ -74,7 +74,7 @@ public class SynchronousTests { @BeforeTransaction public void onSetUpBeforeTransaction() throws Exception { - simpleJdbcTemplate.getJdbcOperations().execute("delete from T_BARS"); + jdbcTemplate.execute("delete from T_BARS"); jmsTemplate.convertAndSend("queue", "foo"); jmsTemplate.convertAndSend("queue", "foo"); final String text = (String) jmsTemplate.receiveAndConvert("queue"); @@ -94,11 +94,11 @@ public class SynchronousTests { foo = (String) jmsTemplate.receiveAndConvert("queue"); count++; } - simpleJdbcTemplate.getJdbcOperations().execute("delete from T_BARS"); + jdbcTemplate.execute("delete from T_BARS"); } private void assertInitialState() { - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(0, count); } @@ -134,7 +134,7 @@ public class SynchronousTests { list.add(text); System.err.println("Inserting: [" + list.size() + "," + text + "]"); - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); if (list.size() == 1) { throw new RuntimeException("Rollback!"); } @@ -151,7 +151,7 @@ public class SynchronousTests { List msgs = getMessages(); // The database portion committed once... - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(1, count); // ... and so did the message session. @@ -184,7 +184,7 @@ public class SynchronousTests { list.add(item); System.err.println("Inserting: [" + list.size() + "," + item + "]"); - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), item); + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), item); if (list.size() == 1) { throw new RuntimeException("Rollback!"); } @@ -202,7 +202,7 @@ public class SynchronousTests { List msgs = getMessages(); // The database portion committed once... - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(1, count); // ... and so did the message session. @@ -245,7 +245,7 @@ public class SynchronousTests { list.add(text); System.err.println("Inserting: [" + list.size() + "," + text + "]"); - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); return text; } @@ -258,7 +258,7 @@ public class SynchronousTests { } // The nested database transaction has committed... - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(1, count); // force rollback... @@ -273,7 +273,7 @@ public class SynchronousTests { List msgs = getMessages(); // The database portion rolled back... - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(0, count); // ... and so did the message session. @@ -303,7 +303,7 @@ public class SynchronousTests { // transaction... final String text = (String) jmsTemplate.receiveAndConvert("queue"); list.add(text); - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); if (list.size() == 1) { throw new RuntimeException("Rollback!"); } @@ -320,7 +320,7 @@ public class SynchronousTests { List msgs = getMessages(); // The database portion committed once... - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(1, count); // ... and so did the message session. @@ -351,7 +351,7 @@ public class SynchronousTests { // transaction... final String text = (String) jmsTemplate.receiveAndConvert("queue"); list.add(text); - simpleJdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); + jdbcTemplate.update("INSERT into T_BARS (id,name,foo_date) values (?,?,null)", list.size(), text); throw new RuntimeException("Rollback!"); } @@ -377,7 +377,7 @@ public class SynchronousTests { List msgs = getMessages(); // The database portion rolled back... - int count = simpleJdbcTemplate.queryForInt("select count(*) from T_BARS"); + int count = jdbcTemplate.queryForInt("select count(*) from T_BARS"); assertEquals(0, count); // ... and so did the message session.