INT-1263, added more changes and tests related valdating MessageHistory in every module

This commit is contained in:
Oleg Zhurakousky
2010-09-22 18:44:51 -04:00
parent dee91f6871
commit b6e058c59b
46 changed files with 367 additions and 114 deletions

View File

@@ -25,6 +25,7 @@ import javax.sql.DataSource;
import org.springframework.dao.DataAccessException;
import org.springframework.integration.Message;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.jdbc.core.ColumnMapRowMapper;
@@ -45,7 +46,7 @@ import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
* @author Dave Syer
* @since 2.0
*/
public class JdbcPollingChannelAdapter implements MessageSource<Object> {
public class JdbcPollingChannelAdapter extends IntegrationObjectSupport implements MessageSource<Object> {
private final SimpleJdbcOperations jdbcOperations;
@@ -199,7 +200,9 @@ public class JdbcPollingChannelAdapter implements MessageSource<Object> {
}
return payload;
}
public String getComponentType(){
return "jdbc:inbound-channel-adapter";
}
}

View File

@@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.sql.DataSource;
@@ -34,6 +35,7 @@ import org.springframework.integration.Message;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.jdbc.core.namedparam.AbstractSqlParameterSource;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.transaction.PlatformTransactionManager;
@@ -57,14 +59,17 @@ public class JdbcPollingChannelAdapterParserTests {
private PlatformTransactionManager transactionManager;
@Test
public void testSimpleInboundChannelAdapter(){
public void testSimpleInboundChannelAdapterWithHistory(){
setUp("pollingForMapJdbcInboundChannelAdapterTest.xml", getClass());
this.jdbcTemplate.update("insert into item values(1,'',2)");
Message<?> message = messagingTemplate.receive();
MessageHistory history = MessageHistory.read(message);
assertTrue(history.containsComponent("jdbcAdapter"));
assertNotNull("No message found ", message);
assertTrue("Wrong payload type expected instance of List", message.getPayload() instanceof List<?>);
MessageHistory history = MessageHistory.read(message);
assertNotNull(history);
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "jdbcAdapter", 0);
assertNotNull(componentHistoryRecord);
assertEquals("jdbc:inbound-channel-adapter", componentHistoryRecord.get("type"));
}