samples and infrastructure-tests should have no more generics warnings (remaining are easymock deprecations)
This commit is contained in:
@@ -46,13 +46,13 @@ public class BatchMessageListenerContainerTests extends TestCase {
|
||||
template.setCompletionPolicy(new SimpleCompletionPolicy(2));
|
||||
container = getContainer(template);
|
||||
|
||||
MockControl sessionControl = MockControl.createNiceControl(Session.class);
|
||||
MockControl consumerControl = MockControl.createControl(MessageConsumer.class);
|
||||
MockControl messageControl = MockControl.createControl(Message.class);
|
||||
MockControl<Session> sessionControl = MockControl.createNiceControl(Session.class);
|
||||
MockControl<MessageConsumer> consumerControl = MockControl.createControl(MessageConsumer.class);
|
||||
MockControl<Message> messageControl = MockControl.createControl(Message.class);
|
||||
|
||||
Session session = (Session) sessionControl.getMock();
|
||||
MessageConsumer consumer = (MessageConsumer) consumerControl.getMock();
|
||||
Message message = (Message) messageControl.getMock();
|
||||
Session session = sessionControl.getMock();
|
||||
MessageConsumer consumer = consumerControl.getMock();
|
||||
Message message = messageControl.getMock();
|
||||
|
||||
// Expect two calls to consumer (chunk size)...
|
||||
consumerControl.expectAndReturn(consumer.receive(1000), message);
|
||||
@@ -76,11 +76,11 @@ public class BatchMessageListenerContainerTests extends TestCase {
|
||||
template.setCompletionPolicy(new SimpleCompletionPolicy(2));
|
||||
container = getContainer(template);
|
||||
|
||||
MockControl sessionControl = MockControl.createNiceControl(Session.class);
|
||||
MockControl consumerControl = MockControl.createControl(MessageConsumer.class);
|
||||
MockControl<Session> sessionControl = MockControl.createNiceControl(Session.class);
|
||||
MockControl<MessageConsumer> consumerControl = MockControl.createControl(MessageConsumer.class);
|
||||
|
||||
Session session = (Session) sessionControl.getMock();
|
||||
MessageConsumer consumer = (MessageConsumer) consumerControl.getMock();
|
||||
Session session = sessionControl.getMock();
|
||||
MessageConsumer consumer = consumerControl.getMock();
|
||||
Message message = null;
|
||||
|
||||
// Expect one call to consumer (chunk size is 2 but terminates on
|
||||
@@ -137,8 +137,8 @@ public class BatchMessageListenerContainerTests extends TestCase {
|
||||
}
|
||||
|
||||
private BatchMessageListenerContainer getContainer(RepeatTemplate template) {
|
||||
MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory.class);
|
||||
ConnectionFactory connectionFactory = (ConnectionFactory) connectionFactoryControl.getMock();
|
||||
MockControl<ConnectionFactory> connectionFactoryControl = MockControl.createControl(ConnectionFactory.class);
|
||||
ConnectionFactory connectionFactory = connectionFactoryControl.getMock();
|
||||
// Yuck: we need to turn these method in base class to no-ops because the invoker is a private class
|
||||
// we can't create for test purposes...
|
||||
BatchMessageListenerContainer container = new BatchMessageListenerContainer() {
|
||||
@@ -168,13 +168,13 @@ public class BatchMessageListenerContainerTests extends TestCase {
|
||||
}
|
||||
});
|
||||
|
||||
MockControl sessionControl = MockControl.createNiceControl(Session.class);
|
||||
MockControl consumerControl = MockControl.createNiceControl(MessageConsumer.class);
|
||||
MockControl messageControl = MockControl.createNiceControl(Message.class);
|
||||
MockControl<Session> sessionControl = MockControl.createNiceControl(Session.class);
|
||||
MockControl<MessageConsumer> consumerControl = MockControl.createNiceControl(MessageConsumer.class);
|
||||
MockControl<Message> messageControl = MockControl.createNiceControl(Message.class);
|
||||
|
||||
Session session = (Session) sessionControl.getMock();
|
||||
MessageConsumer consumer = (MessageConsumer) consumerControl.getMock();
|
||||
Message message = (Message) messageControl.getMock();
|
||||
Session session = sessionControl.getMock();
|
||||
MessageConsumer consumer = consumerControl.getMock();
|
||||
Message message = messageControl.getMock();
|
||||
|
||||
sessionControl.expectAndReturn(session.getTransacted(), true, expectGetTransactionCount);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.util.ClassUtils;
|
||||
|
||||
public abstract class AbstractStaxEventWriterItemWriterTests extends TestCase {
|
||||
|
||||
private StaxEventItemWriter writer = new StaxEventItemWriter();
|
||||
private StaxEventItemWriter<Trade> writer = new StaxEventItemWriter<Trade>();
|
||||
|
||||
private Resource resource;
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class AbstractStaxEventWriterItemWriterTests extends TestCase {
|
||||
* Write list of domain objects and check the output file.
|
||||
*/
|
||||
public void testWrite() throws Exception {
|
||||
for (Iterator<?> iterator = objects.listIterator(); iterator.hasNext();) {
|
||||
for (Iterator<Trade> iterator = objects.listIterator(); iterator.hasNext();) {
|
||||
writer.write(iterator.next());
|
||||
}
|
||||
writer.close(null);
|
||||
@@ -58,7 +58,7 @@ public abstract class AbstractStaxEventWriterItemWriterTests extends TestCase {
|
||||
resource = new FileSystemResource(outputFile);
|
||||
writer.setResource(resource);
|
||||
|
||||
MarshallingEventWriterSerializer mapper = new MarshallingEventWriterSerializer(getMarshaller());
|
||||
MarshallingEventWriterSerializer<Trade> mapper = new MarshallingEventWriterSerializer<Trade>(getMarshaller());
|
||||
writer.setSerializer(mapper);
|
||||
|
||||
writer.open(new ExecutionContext());
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ItemTransformerItemWriter<I,O> extends DelegatingItemWriter<I,O> {
|
||||
|
||||
private ItemTransformer<I,O> itemTransformer;
|
||||
private ItemTransformer<? super I,? extends O> itemTransformer;
|
||||
|
||||
/**
|
||||
* Transform the item using the {@link #setItemTransformer(ItemTransformer)}.
|
||||
@@ -25,7 +25,7 @@ public class ItemTransformerItemWriter<I,O> extends DelegatingItemWriter<I,O> {
|
||||
* @param itemTransformer will transform the item before
|
||||
* it is passed to {@link ItemWriter}.
|
||||
*/
|
||||
public void setItemTransformer(ItemTransformer<I,O> itemTransformer) {
|
||||
public void setItemTransformer(ItemTransformer<? super I,? extends O> itemTransformer) {
|
||||
this.itemTransformer = itemTransformer;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ import org.springframework.batch.sample.domain.Trade;
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
/**
|
||||
* TODO type safety
|
||||
*/
|
||||
public class TradeFieldSetMapper implements FieldSetMapper {
|
||||
|
||||
public static final int ISIN_COLUMN = 0;
|
||||
|
||||
@@ -16,17 +16,15 @@
|
||||
|
||||
package org.springframework.batch.sample;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.launch.JobLauncher;
|
||||
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Abstract unit test for running functional tests by getting context locations
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.sql.SQLException;
|
||||
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.file.FlatFileItemReader;
|
||||
import org.springframework.batch.item.file.mapping.FieldSetMapper;
|
||||
import org.springframework.batch.item.file.transform.LineTokenizer;
|
||||
import org.springframework.batch.sample.domain.Trade;
|
||||
import org.springframework.batch.sample.mapping.TradeFieldSetMapper;
|
||||
@@ -51,7 +52,7 @@ public class FixedLengthImportJobFunctionalTests extends AbstractValidatingBatch
|
||||
//auto-injected attributes
|
||||
private JdbcOperations jdbcTemplate;
|
||||
private Resource fileLocator;
|
||||
private FlatFileItemReader inputSource;
|
||||
private FlatFileItemReader<Trade> inputSource;
|
||||
private LineTokenizer lineTokenizer;
|
||||
|
||||
@Autowired
|
||||
@@ -69,8 +70,12 @@ public class FixedLengthImportJobFunctionalTests extends AbstractValidatingBatch
|
||||
public void onSetUp() throws Exception {
|
||||
jdbcTemplate.update("delete from TRADE");
|
||||
fileLocator = new ClassPathResource("data/fixedLengthImportJob/input/20070122.teststream.ImportTradeDataStep.txt");
|
||||
inputSource = new FlatFileItemReader();
|
||||
inputSource.setFieldSetMapper(new TradeFieldSetMapper());
|
||||
inputSource = new FlatFileItemReader<Trade>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
FieldSetMapper<Trade> mapper = new TradeFieldSetMapper();
|
||||
inputSource.setFieldSetMapper(mapper);
|
||||
|
||||
inputSource.setLineTokenizer(lineTokenizer);
|
||||
inputSource.setResource(fileLocator);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class RetrySampleFunctionalTests extends AbstractValidatingBatchLauncherT
|
||||
private GeneratingItemReader itemGenerator;
|
||||
|
||||
@Autowired
|
||||
private RetrySampleItemWriter itemProcessor;
|
||||
private RetrySampleItemWriter<?> itemProcessor;
|
||||
|
||||
protected void validatePostConditions() throws Exception {
|
||||
//items processed = items read + 2 exceptions
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SkipSampleFunctionalTests extends AbstractValidatingBatchLauncherTe
|
||||
JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
ItemTrackingItemWriter writer;
|
||||
ItemTrackingItemWriter<?> writer;
|
||||
|
||||
@Autowired
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
|
||||
@@ -94,7 +94,7 @@ public class FlatFileCustomerCreditDaoTests {
|
||||
verify(output);
|
||||
}
|
||||
|
||||
private interface ResourceLifecycleItemWriter extends ItemWriter, ItemStream{
|
||||
private interface ResourceLifecycleItemWriter extends ItemWriter<String>, ItemStream{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.item.file.transform.LineAggregator;
|
||||
import org.springframework.batch.item.support.AbstractItemWriter;
|
||||
@@ -37,25 +37,23 @@ import org.springframework.batch.sample.domain.BillingInfo;
|
||||
import org.springframework.batch.sample.domain.Customer;
|
||||
import org.springframework.batch.sample.domain.LineItem;
|
||||
import org.springframework.batch.sample.domain.Order;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FlatFileOrderWriterTests {
|
||||
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
|
||||
private ItemWriter output = new AbstractItemWriter() {
|
||||
private ItemWriter<Object> output = new AbstractItemWriter<Object>() {
|
||||
public void write(Object output) {
|
||||
list.add(output);
|
||||
}
|
||||
};
|
||||
|
||||
private ItemTransformerItemWriter writer;
|
||||
private ItemTransformerItemWriter<Order, Object> writer;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
//create new writer
|
||||
writer = new ItemTransformerItemWriter();
|
||||
writer = new ItemTransformerItemWriter<Order, Object>();
|
||||
writer.setDelegate(output);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,23 +16,22 @@
|
||||
package org.springframework.batch.sample.dao;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.springframework.batch.sample.domain.Player;
|
||||
import org.springframework.jdbc.core.RowCallbackHandler;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.junit.runner.RunWith;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.sample.domain.Player;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowCallbackHandler;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
|
||||
@@ -16,24 +16,24 @@
|
||||
package org.springframework.batch.sample.dao;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.springframework.batch.sample.domain.Trade;
|
||||
import org.springframework.jdbc.core.RowCallbackHandler;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.sample.domain.Trade;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowCallbackHandler;
|
||||
import org.springframework.jdbc.support.incrementer.AbstractDataFieldMaxValueIncrementer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"/data-source-context.xml"})
|
||||
public class JdbcTradeWriterTests {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.batch.sample.dao;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
@@ -24,8 +23,7 @@ import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.item.file.transform.DelimitedLineAggregator;
|
||||
import org.springframework.batch.item.file.transform.LineAggregator;
|
||||
import org.springframework.batch.sample.domain.Address;
|
||||
|
||||
@@ -36,10 +36,10 @@ public class StagingItemReaderTests {
|
||||
private PlatformTransactionManager transactionManager;
|
||||
|
||||
@Autowired
|
||||
private StagingItemWriter writer;
|
||||
private StagingItemWriter<String> writer;
|
||||
|
||||
@Autowired
|
||||
private StagingItemReader reader;
|
||||
private StagingItemReader<String> reader;
|
||||
|
||||
private Long jobId = 11L;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class StagingItemReaderTests {
|
||||
new Object[] { id }, String.class);
|
||||
assertEquals(StagingItemWriter.NEW, before);
|
||||
|
||||
Object item = reader.read();
|
||||
String item = reader.read();
|
||||
assertEquals("FOO", item);
|
||||
|
||||
String after = (String) getJdbcTemplate().queryForObject("SELECT PROCESSED from BATCH_STAGING where ID=?",
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.junit.Test;
|
||||
|
||||
public class CustomerCreditUpdateProcessorTests {
|
||||
|
||||
private MockControl daoControl;
|
||||
private MockControl<CustomerCreditDao> daoControl;
|
||||
private CustomerCreditDao dao;
|
||||
private CustomerCreditUpdateWriter writer;
|
||||
private static final double CREDIT_FILTER = 355.0;
|
||||
@@ -19,7 +19,7 @@ public class CustomerCreditUpdateProcessorTests {
|
||||
public void setUp() {
|
||||
//create mock writer
|
||||
daoControl = MockControl.createControl(CustomerCreditDao.class);
|
||||
dao = (CustomerCreditDao) daoControl.getMock();
|
||||
dao = daoControl.getMock();
|
||||
//create processor, set writer and credit filter
|
||||
writer = new CustomerCreditUpdateWriter();
|
||||
writer.setDao(dao);
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.junit.Test;
|
||||
*/
|
||||
public class RetrySampleItemWriterTests {
|
||||
|
||||
private RetrySampleItemWriter processor = new RetrySampleItemWriter();
|
||||
private RetrySampleItemWriter<Object> processor = new RetrySampleItemWriter<Object>();
|
||||
|
||||
/**
|
||||
* Processing throws exception on 2nd and 3rd call.
|
||||
|
||||
@@ -17,23 +17,21 @@ package org.springframework.batch.sample.item.writer;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.batch.core.JobExecution;
|
||||
import org.springframework.batch.core.JobInstance;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.StepExecution;
|
||||
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcOperations;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration()
|
||||
@@ -42,7 +40,7 @@ public class StagingItemWriterTests {
|
||||
private JdbcOperations jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
private StagingItemWriter writer;
|
||||
private StagingItemWriter<String> writer;
|
||||
|
||||
public JdbcOperations getJdbcTemplate() {
|
||||
return jdbcTemplate;
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package org.springframework.batch.sample.item.writer;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.springframework.batch.sample.dao.TradeDao;
|
||||
import org.springframework.batch.sample.domain.Trade;
|
||||
import org.springframework.batch.sample.item.writer.TradeWriter;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.batch.sample.dao.TradeDao;
|
||||
import org.springframework.batch.sample.domain.Trade;
|
||||
|
||||
public class TradeProcessorTests {
|
||||
|
||||
private MockControl writerControl;
|
||||
private MockControl<TradeDao> writerControl;
|
||||
private TradeDao writer;
|
||||
private TradeWriter processor;
|
||||
|
||||
@@ -18,7 +17,7 @@ public class TradeProcessorTests {
|
||||
|
||||
//create mock writer
|
||||
writerControl = MockControl.createControl(TradeDao.class);
|
||||
writer = (TradeDao)writerControl.getMock();
|
||||
writer = writerControl.getMock();
|
||||
|
||||
//create processor
|
||||
processor = new TradeWriter();
|
||||
|
||||
@@ -27,7 +27,7 @@ public abstract class AbstractFieldSetMapperTests {
|
||||
* @return mapper which takes <code>this.fieldSet()</code> and maps it to
|
||||
* domain object.
|
||||
*/
|
||||
protected abstract FieldSetMapper fieldSetMapper();
|
||||
protected abstract FieldSetMapper<?> fieldSetMapper();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,8 +19,8 @@ public abstract class AbstractRowMapperTests extends TestCase {
|
||||
private static final int IGNORED_ROW_NUMBER = 0;
|
||||
|
||||
//mock result set
|
||||
private MockControl rsControl = MockControl.createControl(ResultSet.class);
|
||||
private ResultSet rs = (ResultSet) rsControl.getMock();
|
||||
private MockControl<ResultSet> rsControl = MockControl.createControl(ResultSet.class);
|
||||
private ResultSet rs = rsControl.getMock();
|
||||
|
||||
/**
|
||||
* @return Expected result of mapping the mock <code>ResultSet</code> by
|
||||
@@ -36,7 +36,7 @@ public abstract class AbstractRowMapperTests extends TestCase {
|
||||
/**
|
||||
* Define the behaviour of mock <code>ResultSet</code>.
|
||||
*/
|
||||
abstract protected void setUpResultSetMock(ResultSet rs, MockControl rsControl) throws SQLException;
|
||||
abstract protected void setUpResultSetMock(ResultSet rs, MockControl<ResultSet> rsControl) throws SQLException;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,7 +47,7 @@ public class AddressFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
return new DefaultFieldSet(tokens, columnNames);
|
||||
}
|
||||
|
||||
protected FieldSetMapper fieldSetMapper() {
|
||||
protected FieldSetMapper<Address> fieldSetMapper() {
|
||||
return new AddressFieldSetMapper();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class BillingFieldSetMapperTests extends AbstractFieldSetMapperTests{
|
||||
return new DefaultFieldSet(tokens, columnNames);
|
||||
}
|
||||
|
||||
protected FieldSetMapper fieldSetMapper() {
|
||||
protected FieldSetMapper<BillingInfo> fieldSetMapper() {
|
||||
return new BillingFieldSetMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.sql.SQLException;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.springframework.batch.sample.domain.CustomerCredit;
|
||||
import org.springframework.batch.sample.mapping.CustomerCreditRowMapper;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
public class CustomerCreditRowMapperTests extends AbstractRowMapperTests {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class CustomerFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
return new DefaultFieldSet(tokens, columnNames);
|
||||
}
|
||||
|
||||
protected FieldSetMapper fieldSetMapper() {
|
||||
protected FieldSetMapper<Customer> fieldSetMapper() {
|
||||
return new CustomerFieldSetMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class HeaderFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
return new DefaultFieldSet(tokens, columnNames);
|
||||
}
|
||||
|
||||
protected FieldSetMapper fieldSetMapper() {
|
||||
protected FieldSetMapper<Order> fieldSetMapper() {
|
||||
return new HeaderFieldSetMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class OrderItemFieldSetMapperTests extends AbstractFieldSetMapperTests{
|
||||
return new DefaultFieldSet(tokens, columnNames);
|
||||
}
|
||||
|
||||
protected FieldSetMapper fieldSetMapper() {
|
||||
protected FieldSetMapper<LineItem> fieldSetMapper() {
|
||||
return new OrderItemFieldSetMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ShippingFieldSetMapperTests extends AbstractFieldSetMapperTests{
|
||||
return new DefaultFieldSet(tokens, columnNames);
|
||||
}
|
||||
|
||||
protected FieldSetMapper fieldSetMapper() {
|
||||
protected FieldSetMapper<ShippingInfo> fieldSetMapper() {
|
||||
return new ShippingFieldSetMapper();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,14 @@ import org.springframework.batch.sample.domain.Trade;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class TradeFieldSetMapperTests extends AbstractFieldSetMapperTests{
|
||||
public class TradeFieldSetMapperTests extends AbstractFieldSetMapperTests {
|
||||
|
||||
private static final String CUSTOMER = "Mike Tomcat";
|
||||
|
||||
private static final BigDecimal PRICE = new BigDecimal(1.3);
|
||||
|
||||
private static final long QUANTITY = 7;
|
||||
|
||||
private static final String ISIN = "fj893gnsalX";
|
||||
|
||||
protected Object expectedDomainObject() {
|
||||
@@ -32,22 +35,26 @@ public class TradeFieldSetMapperTests extends AbstractFieldSetMapperTests{
|
||||
tokens[TradeFieldSetMapper.QUANTITY_COLUMN] = String.valueOf(QUANTITY);
|
||||
tokens[TradeFieldSetMapper.PRICE_COLUMN] = String.valueOf(PRICE);
|
||||
tokens[TradeFieldSetMapper.CUSTOMER_COLUMN] = CUSTOMER;
|
||||
|
||||
|
||||
return new DefaultFieldSet(tokens);
|
||||
}
|
||||
|
||||
protected FieldSetMapper fieldSetMapper() {
|
||||
return new TradeFieldSetMapper();
|
||||
protected FieldSetMapper<Trade> fieldSetMapper() {
|
||||
@SuppressWarnings("unchecked")
|
||||
FieldSetMapper<Trade> mapper = new TradeFieldSetMapper();
|
||||
return mapper;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBeginRecord() throws Exception {
|
||||
assertEquals(AggregateItemReader.BEGIN_RECORD, fieldSetMapper().mapLine(new DefaultFieldSet(new String[] {"BEGIN"}), -1));
|
||||
assertEquals(AggregateItemReader.BEGIN_RECORD, fieldSetMapper().mapLine(
|
||||
new DefaultFieldSet(new String[] { "BEGIN" }), -1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEndRecord() throws Exception {
|
||||
assertEquals(AggregateItemReader.END_RECORD, fieldSetMapper().mapLine(new DefaultFieldSet(new String[] {"END"}), -1));
|
||||
assertEquals(AggregateItemReader.END_RECORD, fieldSetMapper().mapLine(
|
||||
new DefaultFieldSet(new String[] { "END" }), -1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.sql.SQLException;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.springframework.batch.sample.domain.Trade;
|
||||
import org.springframework.batch.sample.mapping.TradeRowMapper;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
public class TradeRowMapperTests extends AbstractRowMapperTests {
|
||||
|
||||
Reference in New Issue
Block a user