Refactoring lifecycle code for endpoint hierarchy.

This commit is contained in:
Mark Fisher
2008-07-01 23:01:42 +00:00
parent 9dad71117b
commit 570cee8f9b
4 changed files with 81 additions and 52 deletions

View File

@@ -27,6 +27,7 @@ import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.message.CommandMessage;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageHandlingException;
import org.springframework.integration.message.PollCommand;
import org.springframework.integration.message.MessageSource;
@@ -40,12 +41,22 @@ public class SourceEndpointTests {
TestSource source = new TestSource("testing", 1);
QueueChannel channel = new QueueChannel();
SourceEndpoint endpoint = new SourceEndpoint(source, channel);
endpoint.afterPropertiesSet();
endpoint.invoke(new CommandMessage(new PollCommand()));
Message<?> message = channel.receive(1000);
assertNotNull("message should not be null", message);
assertEquals("testing.1", message.getPayload());
}
@Test(expected = MessageHandlingException.class)
public void testAutoStartupDisabled() {
TestSource source = new TestSource("testing", 1);
QueueChannel channel = new QueueChannel();
SourceEndpoint endpoint = new SourceEndpoint(source, channel);
endpoint.setAutoStartup(false);
endpoint.afterPropertiesSet();
endpoint.invoke(new CommandMessage(new PollCommand()));
}
private static class TestSource implements MessageSource<String> {