Removed the 'registerChannel' method from the ChannelRegistry interface (most likely to be renamed as it is now used solely for lookup).
This commit is contained in:
@@ -35,7 +35,7 @@ public class MessagePublishingInterceptorTests {
|
||||
public void testNonNullReturnValuePublishedWithDefaultChannel() {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
MessagePublishingInterceptor interceptor = new MessagePublishingInterceptor();
|
||||
interceptor.setDefaultChannel(channel);
|
||||
interceptor.setOutputChannel(channel);
|
||||
TestService proxy = (TestService) this.createProxy(new TestServiceImpl("hello world"), interceptor);
|
||||
proxy.messageTest();
|
||||
Message<?> message = channel.receive(0);
|
||||
@@ -47,7 +47,7 @@ public class MessagePublishingInterceptorTests {
|
||||
public void testNullReturnValueNotPublished() {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
MessagePublishingInterceptor interceptor = new MessagePublishingInterceptor();
|
||||
interceptor.setDefaultChannel(channel);
|
||||
interceptor.setOutputChannel(channel);
|
||||
TestService proxy = (TestService) this.createProxy(new TestServiceImpl(null), interceptor);
|
||||
proxy.messageTest();
|
||||
assertNull(channel.receive(0));
|
||||
@@ -57,7 +57,7 @@ public class MessagePublishingInterceptorTests {
|
||||
public void testVoidReturnValueNotPublished() {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
MessagePublishingInterceptor interceptor = new MessagePublishingInterceptor();
|
||||
interceptor.setDefaultChannel(channel);
|
||||
interceptor.setOutputChannel(channel);
|
||||
TestService proxy = (TestService) this.createProxy(new TestServiceImpl(null), interceptor);
|
||||
proxy.voidTest();
|
||||
assertNull(channel.receive(0));
|
||||
|
||||
@@ -41,7 +41,7 @@ public class PublisherAnnotationAdvisorTests {
|
||||
public void testPublisherAnnotation() {
|
||||
final QueueChannel channel = new QueueChannel();
|
||||
channel.setBeanName("testChannel");
|
||||
ChannelRegistry channelRegistry = new TestChannelRegistry();
|
||||
TestChannelRegistry channelRegistry = new TestChannelRegistry();
|
||||
channelRegistry.registerChannel(channel);
|
||||
PublisherAnnotationAdvisor advisor = new PublisherAnnotationAdvisor(channelRegistry);
|
||||
TestService proxy = (TestService) this.createProxy(new TestServiceImpl("hello world"), advisor);
|
||||
@@ -55,7 +55,7 @@ public class PublisherAnnotationAdvisorTests {
|
||||
public void testNoPublisherAnnotation() {
|
||||
final QueueChannel channel = new QueueChannel();
|
||||
channel.setBeanName("testChannel");
|
||||
ChannelRegistry channelRegistry = new TestChannelRegistry();
|
||||
TestChannelRegistry channelRegistry = new TestChannelRegistry();
|
||||
channelRegistry.registerChannel(channel);
|
||||
PublisherAnnotationAdvisor advisor = new PublisherAnnotationAdvisor(channelRegistry);
|
||||
TestService proxy = (TestService) this.createProxy(new TestServiceImpl("hello world"), advisor);
|
||||
@@ -68,7 +68,7 @@ public class PublisherAnnotationAdvisorTests {
|
||||
public void testPublishArguments() {
|
||||
final QueueChannel channel = new QueueChannel();
|
||||
channel.setBeanName("testChannel");
|
||||
ChannelRegistry channelRegistry = new TestChannelRegistry();
|
||||
TestChannelRegistry channelRegistry = new TestChannelRegistry();
|
||||
channelRegistry.registerChannel(channel);
|
||||
PublisherAnnotationAdvisor advisor = new PublisherAnnotationAdvisor(channelRegistry);
|
||||
TestService proxy = (TestService) this.createProxy(new TestServiceImpl("hello world"), advisor);
|
||||
@@ -86,7 +86,7 @@ public class PublisherAnnotationAdvisorTests {
|
||||
public void testPublishException() {
|
||||
final QueueChannel channel = new QueueChannel();
|
||||
channel.setBeanName("testChannel");
|
||||
ChannelRegistry channelRegistry = new TestChannelRegistry();
|
||||
TestChannelRegistry channelRegistry = new TestChannelRegistry();
|
||||
channelRegistry.registerChannel(channel);
|
||||
PublisherAnnotationAdvisor advisor = new PublisherAnnotationAdvisor(channelRegistry);
|
||||
TestService proxy = (TestService) this.createProxy(new TestServiceImpl("hello world"), advisor);
|
||||
@@ -109,7 +109,7 @@ public class PublisherAnnotationAdvisorTests {
|
||||
public void testPublishReturnValue() {
|
||||
final QueueChannel channel = new QueueChannel();
|
||||
channel.setBeanName("testChannel");
|
||||
ChannelRegistry channelRegistry = new TestChannelRegistry();
|
||||
TestChannelRegistry channelRegistry = new TestChannelRegistry();
|
||||
channelRegistry.registerChannel(channel);
|
||||
PublisherAnnotationAdvisor advisor = new PublisherAnnotationAdvisor(channelRegistry);
|
||||
TestService proxy = (TestService) this.createProxy(new TestServiceImpl("hello world"), advisor);
|
||||
|
||||
@@ -22,13 +22,14 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.bus.DefaultMessageBus;
|
||||
import org.springframework.integration.channel.ChannelRegistry;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
@@ -90,7 +91,7 @@ public class ServiceActivatorEndpointTests {
|
||||
public void returnAddressHeaderWithChannelName() {
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
channel.setBeanName("testChannel");
|
||||
ChannelRegistry channelRegistry = new DefaultMessageBus();
|
||||
TestChannelRegistry channelRegistry = new TestChannelRegistry();
|
||||
channelRegistry.registerChannel(channel);
|
||||
ServiceActivatorEndpoint endpoint = this.createEndpoint();
|
||||
endpoint.setChannelRegistry(channelRegistry);
|
||||
@@ -113,16 +114,9 @@ public class ServiceActivatorEndpointTests {
|
||||
}
|
||||
};
|
||||
ServiceActivatorEndpoint endpoint = new ServiceActivatorEndpoint(handler, "handle");
|
||||
endpoint.setChannelRegistry(new ChannelRegistry() {
|
||||
public MessageChannel lookupChannel(String channelName) {
|
||||
if (channelName.equals("replyChannel2")) {
|
||||
return replyChannel2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public void registerChannel(MessageChannel channel) {
|
||||
}
|
||||
});
|
||||
TestChannelRegistry channelRegistry = new TestChannelRegistry();
|
||||
channelRegistry.registerChannel(replyChannel2);
|
||||
endpoint.setChannelRegistry(channelRegistry);
|
||||
Message<String> testMessage1 = MessageBuilder.withPayload("bar")
|
||||
.setReturnAddress(replyChannel1).build();
|
||||
endpoint.onMessage(testMessage1);
|
||||
@@ -365,4 +359,18 @@ public class ServiceActivatorEndpointTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class TestChannelRegistry implements ChannelRegistry {
|
||||
|
||||
private final Map<String, MessageChannel> channels = new HashMap<String, MessageChannel>();
|
||||
|
||||
public MessageChannel lookupChannel(String channelName) {
|
||||
return this.channels.get(channelName);
|
||||
}
|
||||
|
||||
public void registerChannel(MessageChannel channel) {
|
||||
this.channels.put(channel.getName(), channel);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user