PollableSource now returns a Message rather than an Object from poll(). Now PollableSource implementations may use a MessageMapper, but the "source adapter" no longer does.

This commit is contained in:
Mark Fisher
2008-04-10 21:40:41 +00:00
parent 63680cd570
commit 069e7672e3
24 changed files with 242 additions and 175 deletions

View File

@@ -21,6 +21,7 @@ import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessagingException;
/**
@@ -33,9 +34,10 @@ public class MethodInvokingSourceTests {
MethodInvokingSource<TestBean> source = new MethodInvokingSource<TestBean>();
source.setObject(new TestBean());
source.setMethod("validMethod");
Object result = source.poll();
Message<?> result = source.poll();
assertNotNull(result);
assertEquals("valid", result);
assertNotNull(result.getPayload());
assertEquals("valid", result.getPayload());
}
@Test(expected=MessagingException.class)

View File

@@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Test;
import org.springframework.integration.channel.SimpleChannel;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
/**
@@ -40,7 +41,7 @@ public class PollingSourceAdapterTests {
adapter.setChannel(channel);
adapter.setPeriod(100);
adapter.start();
Message<?> message = channel.receive();
Message<?> message = channel.receive(1000);
assertNotNull("message should not be null", message);
assertEquals("testing.1", message.getPayload());
}
@@ -57,7 +58,7 @@ public class PollingSourceAdapterTests {
adapter.processMessages();
adapter.processMessages();
adapter.stop();
Message<?> message1 = channel.receive();
Message<?> message1 = channel.receive(1000);
assertNotNull("message should not be null", message1);
assertEquals("testing.1", message1.getPayload());
Message<?> message2 = channel.receive(0);
@@ -111,11 +112,11 @@ public class PollingSourceAdapterTests {
this.count.set(0);
}
public String poll() {
public Message<String> poll() {
if (count.get() >= limit) {
return null;
}
return message + "." + count.incrementAndGet();
return new GenericMessage<String>(message + "." + count.incrementAndGet());
}
}

View File

@@ -21,7 +21,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -269,7 +268,7 @@ public class MessageBusTests {
this.latch = latch;
}
public Collection<Object> poll() {
public Message<Object> poll() {
latch.countDown();
throw new RuntimeException("intentional test failure");
}

View File

@@ -97,8 +97,8 @@ public class SynchronousChannelTests {
@Test
public void testReceive() {
SynchronousChannel channel = new SynchronousChannel(new PollableSource<String>() {
public String poll() {
return "foo";
public Message<String> poll() {
return new StringMessage("foo");
}
});
Message<?> message = channel.receive();
@@ -175,7 +175,7 @@ public class SynchronousChannelTests {
}
private static class MessageReturningTestSource implements PollableSource<StringMessage> {
private static class MessageReturningTestSource implements PollableSource<String> {
private final String messageText;