BATCH-2003: Updated per code review comments
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
package org.springframework.batch.core.jsr.partition;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Queue;
|
||||
@@ -24,50 +23,17 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import javax.batch.api.partition.PartitionCollector;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PartitionCollectorAdapterTests {
|
||||
|
||||
private PartitionCollectorAdapter adapter;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
adapter = new PartitionCollectorAdapter();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPropertiesSeet() throws Exception {
|
||||
try {
|
||||
adapter.afterPropertiesSet();
|
||||
fail("Did not check for a PartitionCollector instance");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
assertEquals(iae.getMessage(), "A PartitionCollector instance is required");
|
||||
}
|
||||
|
||||
adapter.setPartitionCollector(new PartitionCollector() {
|
||||
|
||||
@Override
|
||||
public Serializable collectPartitionData() throws Exception {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
adapter.afterPropertiesSet();
|
||||
fail("Did not check for a queue");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
assertEquals(iae.getMessage(), "A thread safe Queue instance is required");
|
||||
}
|
||||
|
||||
adapter.setPartitionQueue(new ConcurrentLinkedQueue<Serializable>());
|
||||
|
||||
adapter.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAfterChunkSuccessful() throws Exception {
|
||||
adapter.setPartitionCollector(new PartitionCollector() {
|
||||
Queue<Serializable> dataQueue = new ConcurrentLinkedQueue<Serializable>();
|
||||
|
||||
adapter = new PartitionCollectorAdapter(dataQueue, new PartitionCollector() {
|
||||
|
||||
private int count = 0;
|
||||
|
||||
@@ -77,10 +43,6 @@ public class PartitionCollectorAdapterTests {
|
||||
}
|
||||
});
|
||||
|
||||
Queue<Serializable> dataQueue = new ConcurrentLinkedQueue<Serializable>();
|
||||
adapter.setPartitionQueue(dataQueue);
|
||||
adapter.afterPropertiesSet();
|
||||
|
||||
adapter.afterChunk(null);
|
||||
adapter.afterChunk(null);
|
||||
adapter.afterChunk(null);
|
||||
@@ -90,10 +52,4 @@ public class PartitionCollectorAdapterTests {
|
||||
assertEquals("1", dataQueue.remove());
|
||||
assertEquals("2", dataQueue.remove());
|
||||
}
|
||||
|
||||
@Test(expected=PartitionException.class)
|
||||
public void testAfterChunkException() {
|
||||
// Throws an NPE due to a null collector
|
||||
adapter.afterChunk(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user