IN PROGRESS - BATCH-711: Upgrade ItemWriter and implementations to use parameterized types

This commit is contained in:
robokaso
2008-07-23 09:22:47 +00:00
parent 323bb4155f
commit d882c91297
6 changed files with 35 additions and 29 deletions

View File

@@ -41,7 +41,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
*/
public class BatchSqlUpdateItemWriterTests extends TestCase {
private BatchSqlUpdateItemWriter writer = new BatchSqlUpdateItemWriter();
private BatchSqlUpdateItemWriter<String> writer = new BatchSqlUpdateItemWriter<String>();
private JdbcTemplate jdbcTemplate;

View File

@@ -44,7 +44,7 @@ public class HibernateAwareItemWriterTests extends TestCase {
};
}
private class StubItemWriter implements ItemWriter {
private class StubItemWriter implements ItemWriter<Object> {
public void write(Object item) {
list.add(item);
}
@@ -58,7 +58,7 @@ public class HibernateAwareItemWriterTests extends TestCase {
}
}
HibernateAwareItemWriter writer = new HibernateAwareItemWriter();
HibernateAwareItemWriter<Object> writer = new HibernateAwareItemWriter<Object>();
final List<Object> list = new ArrayList<Object>();
@@ -95,7 +95,7 @@ public class HibernateAwareItemWriterTests extends TestCase {
* @throws Exception
*/
public void testAfterPropertiesSet() throws Exception {
writer = new HibernateAwareItemWriter();
writer = new HibernateAwareItemWriter<Object>();
try {
writer.afterPropertiesSet();
fail("Expected IllegalArgumentException");

View File

@@ -16,7 +16,7 @@ public class HibernateCursorItemReaderCommonTests extends CommonDatabaseItemStre
String hsqlQuery = "from Foo";
HibernateCursorItemReader reader = new HibernateCursorItemReader();
HibernateCursorItemReader<Foo> reader = new HibernateCursorItemReader<Foo>();
reader.setQueryString(hsqlQuery);
reader.setSessionFactory(sessionFactory);
reader.setUseStatelessSession(true);
@@ -36,8 +36,8 @@ public class HibernateCursorItemReaderCommonTests extends CommonDatabaseItemStre
}
protected void pointToEmptyInput(ItemReader tested) throws Exception {
HibernateCursorItemReader reader = (HibernateCursorItemReader) tested;
protected void pointToEmptyInput(ItemReader<Foo> tested) throws Exception {
HibernateCursorItemReader<Foo> reader = (HibernateCursorItemReader<Foo>) tested;
reader.close(new ExecutionContext());
reader.setQueryString("from Foo foo where foo.id = -1");
reader.afterPropertiesSet();

View File

@@ -5,6 +5,7 @@ import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.sample.Foo;
/**
* Tests for {@link HibernateCursorItemReader} using standard hibernate {@link Session}.
@@ -20,13 +21,13 @@ public class HibernateCursorItemReaderStatefulIntegrationTests extends Hibernate
//Ensure close is called on the stateful session correctly.
public void testStatfulClose(){
MockControl sessionFactoryControl = MockControl.createControl(SessionFactory.class);
SessionFactory sessionFactory = (SessionFactory) sessionFactoryControl.getMock();
MockControl sessionControl = MockControl.createControl(Session.class);
Session session = (Session) sessionControl.getMock();
MockControl resultsControl = MockControl.createNiceControl(Query.class);
Query scrollableResults = (Query) resultsControl.getMock();
HibernateCursorItemReader itemReader = new HibernateCursorItemReader();
MockControl<SessionFactory> sessionFactoryControl = MockControl.createControl(SessionFactory.class);
SessionFactory sessionFactory = sessionFactoryControl.getMock();
MockControl<Session> sessionControl = MockControl.createControl(Session.class);
Session session = sessionControl.getMock();
MockControl<Query> resultsControl = MockControl.createNiceControl(Query.class);
Query scrollableResults = resultsControl.getMock();
HibernateCursorItemReader<Foo> itemReader = new HibernateCursorItemReader<Foo>();
itemReader.setSessionFactory(sessionFactory);
itemReader.setQueryString("testQuery");
itemReader.setUseStatelessSession(false);

View File

@@ -18,7 +18,7 @@ import org.springframework.test.AbstractTransactionalDataSourceSpringContextTest
*/
public class HibernateCursorProjectionItemReaderIntegrationTests extends AbstractTransactionalDataSourceSpringContextTests {
protected ItemReader reader;
protected ItemReader<?> reader;
protected ExecutionContext executionContext;
protected String[] getConfigLocations() {
@@ -36,7 +36,7 @@ public class HibernateCursorProjectionItemReaderIntegrationTests extends Abstrac
}
protected ItemReader createItemReader() throws Exception {
protected ItemReader<?> createItemReader() throws Exception {
LocalSessionFactoryBean factoryBean = new LocalSessionFactoryBean();
factoryBean.setDataSource(super.getJdbcTemplate().getDataSource());
factoryBean.setMappingLocations(new Resource[] { new ClassPathResource("Foo.hbm.xml", getClass()) });
@@ -46,7 +46,7 @@ public class HibernateCursorProjectionItemReaderIntegrationTests extends Abstrac
String hsqlQuery = "select f.value, f.name from Foo f";
HibernateCursorItemReader inputSource = new HibernateCursorItemReader();
HibernateCursorItemReader<Object> inputSource = new HibernateCursorItemReader<Object>();
inputSource.setQueryString(hsqlQuery);
inputSource.setSessionFactory(sessionFactory);
inputSource.afterPropertiesSet();