Removed warnings from AggregateItemReaderTests
This commit is contained in:
@@ -1,61 +1,60 @@
|
||||
package org.springframework.batch.item.support;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.MockControl;
|
||||
import org.springframework.batch.item.ItemReader;
|
||||
import org.springframework.batch.item.support.AggregateItemReader;
|
||||
|
||||
public class AggregateItemReaderTests extends TestCase {
|
||||
|
||||
private MockControl inputControl;
|
||||
private ItemReader<Object> input;
|
||||
|
||||
private AggregateItemReader provider;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setUp() {
|
||||
// create mock for input
|
||||
input = new AbstractItemReader<Object>() {
|
||||
|
||||
//create mock for input
|
||||
inputControl = MockControl.createControl(ItemReader.class);
|
||||
input = (ItemReader<Object>) inputControl.getMock();
|
||||
private int count = 0;
|
||||
|
||||
//create provider
|
||||
public Object read() {
|
||||
switch (count++) {
|
||||
case 0:
|
||||
return AggregateItemReader.BEGIN_RECORD;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
return "line";
|
||||
case 4:
|
||||
return AggregateItemReader.END_RECORD;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
// create provider
|
||||
provider = new AggregateItemReader();
|
||||
provider.setItemReader(input);
|
||||
}
|
||||
|
||||
public void testNext() throws Exception {
|
||||
|
||||
//set-up mock input
|
||||
input.read();
|
||||
inputControl.setReturnValue(AggregateItemReader.BEGIN_RECORD);
|
||||
input.read();
|
||||
inputControl.setReturnValue("line",3);
|
||||
input.read();
|
||||
inputControl.setReturnValue(AggregateItemReader.END_RECORD);
|
||||
input.read();
|
||||
inputControl.setReturnValue(null);
|
||||
inputControl.replay();
|
||||
|
||||
//read object
|
||||
// read object
|
||||
Object result = provider.read();
|
||||
|
||||
//it should be collection of 3 strings "line"
|
||||
// it should be collection of 3 strings "line"
|
||||
assertTrue(result instanceof Collection);
|
||||
Collection<?> lines = (Collection<?>)result;
|
||||
Collection<?> lines = (Collection<?>) result;
|
||||
assertEquals(3, lines.size());
|
||||
|
||||
for (Iterator<?> i = lines.iterator(); i.hasNext();) {
|
||||
assertEquals("line", i.next());
|
||||
for (Object line : lines) {
|
||||
assertEquals("line", line);
|
||||
}
|
||||
|
||||
//read object again - it should return null
|
||||
// read object again - it should return null
|
||||
assertNull(provider.read());
|
||||
|
||||
//verify method calls
|
||||
inputControl.verify();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user