RESOLVED - issue BATCH-1102: Classes with "listener" annotations should be auto-registered

Added convenience methods to *ListenerFactoryBean and then used in *StepFactoryBean
This commit is contained in:
dsyer
2009-02-25 16:03:39 +00:00
parent 044a91eddf
commit 8bd116006c
13 changed files with 427 additions and 199 deletions

View File

@@ -39,7 +39,6 @@
<listeners>
<listener ref="skipCheckingListener"/>
<listener ref="promotionListener"/>
<listener ref="tradeWriter"/>
</listeners>
</step>

View File

@@ -15,11 +15,14 @@
*/
package org.springframework.batch.sample.common;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.util.ArrayList;
import java.util.List;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStream;
@@ -34,15 +37,15 @@ import org.springframework.batch.item.UnexpectedInputException;
* @author Lucas Ward
*
*/
public class CustomItemReaderTests extends TestCase {
public class CustomItemReaderTests {
ItemReader<String> itemReader;
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
@Before
public void setUp() throws Exception {
List<String> items = new ArrayList<String>();
items.add("1");
@@ -52,6 +55,7 @@ public class CustomItemReaderTests extends TestCase {
itemReader = new CustomItemReader<String>(items);
}
@Test
public void testRead() throws Exception{
assertEquals("1", itemReader.read());
@@ -60,6 +64,7 @@ public class CustomItemReaderTests extends TestCase {
assertNull(itemReader.read());
}
@Test
public void testRestart() throws Exception{
ExecutionContext executionContext = new ExecutionContext();

View File

@@ -41,7 +41,7 @@ public class StagingItemReaderTests {
@Autowired
private StagingItemReader<String> reader;
private Long jobId = 11L;
private Long jobId = 113L;
@Autowired
public void setDataSource(DataSource dataSource) {

View File

@@ -1,12 +1,13 @@
package org.springframework.batch.sample.support;
import static org.easymock.EasyMock.*;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.replay;
import static org.junit.Assert.assertEquals;
import java.sql.ResultSet;
import java.sql.SQLException;
import junit.framework.TestCase;
import org.junit.Test;
import org.springframework.jdbc.core.RowMapper;
/**
@@ -14,38 +15,38 @@ import org.springframework.jdbc.core.RowMapper;
*
* @author Robert Kasanicky
*/
public abstract class AbstractRowMapperTests extends TestCase {
public abstract class AbstractRowMapperTests {
//row number should be irrelevant
// row number should be irrelevant
private static final int IGNORED_ROW_NUMBER = 0;
//mock result set
// mock result set
private ResultSet rs = createMock(ResultSet.class);
/**
* @return Expected result of mapping the mock <code>ResultSet</code> by
* the mapper being tested.
* @return Expected result of mapping the mock <code>ResultSet</code> by the
* mapper being tested.
*/
abstract protected Object expectedDomainObject();
/**
* @return <code>RowMapper</code> implementation that is being tested.
*/
abstract protected RowMapper rowMapper();
/*
* Define the behaviour of mock <code>ResultSet</code>.
*/
abstract protected void setUpResultSetMock(ResultSet rs) throws SQLException;
/*
* Regular usage scenario.
*/
@Test
public void testRegularUse() throws SQLException {
setUpResultSetMock(rs);
replay(rs);
assertEquals(expectedDomainObject(), rowMapper().mapRow(rs, IGNORED_ROW_NUMBER));
}
}