Removed the Subscription class.

This commit is contained in:
Mark Fisher
2008-07-04 22:39:18 +00:00
parent 96b22fd01b
commit 71da892bcb
11 changed files with 82 additions and 133 deletions

View File

@@ -39,7 +39,6 @@ import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageSource;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.scheduling.PollingSchedule;
import org.springframework.integration.scheduling.Subscription;
/**
* @author Mark Fisher
@@ -47,7 +46,7 @@ import org.springframework.integration.scheduling.Subscription;
public class MessageBusTests {
@Test
public void testOutputChannel() {
public void testRegistrationWithInputChannelReference() {
MessageBus bus = new MessageBus();
MessageChannel sourceChannel = new QueueChannel();
MessageChannel targetChannel = new QueueChannel();
@@ -61,8 +60,29 @@ public class MessageBusTests {
return message;
}
};
Subscription subscription = new Subscription(sourceChannel);
bus.registerHandler("handler", handler, subscription);
bus.registerHandler("handler", handler, sourceChannel, null);
bus.start();
Message<?> result = targetChannel.receive(3000);
assertEquals("test", result.getPayload());
bus.stop();
}
@Test
public void testRegistrationWithInputChannelName() {
MessageBus bus = new MessageBus();
MessageChannel sourceChannel = new QueueChannel();
MessageChannel targetChannel = new QueueChannel();
bus.registerChannel("sourceChannel", sourceChannel);
StringMessage message = new StringMessage("test");
message.getHeader().setReturnAddress("targetChannel");
sourceChannel.send(message);
bus.registerChannel("targetChannel", targetChannel);
MessageHandler handler = new MessageHandler() {
public Message<?> handle(Message<?> message) {
return message;
}
};
bus.registerHandler("handler", handler, "sourceChannel", null);
bus.start();
Message<?> result = targetChannel.receive(3000);
assertEquals("test", result.getPayload());
@@ -117,8 +137,8 @@ public class MessageBusTests {
bus.registerChannel("input", inputChannel);
bus.registerChannel("output1", outputChannel1);
bus.registerChannel("output2", outputChannel2);
bus.registerHandler("handler1", handler1, new Subscription(inputChannel));
bus.registerHandler("handler2", handler2, new Subscription(inputChannel));
bus.registerHandler("handler1", handler1, inputChannel, null);
bus.registerHandler("handler2", handler2, inputChannel, null);
bus.start();
inputChannel.send(new StringMessage(1, "testing"));
Message<?> message1 = outputChannel1.receive(100);
@@ -151,8 +171,8 @@ public class MessageBusTests {
bus.registerChannel("input", inputChannel);
bus.registerChannel("output1", outputChannel1);
bus.registerChannel("output2", outputChannel2);
bus.registerHandler("handler1", handler1, new Subscription(inputChannel));
bus.registerHandler("handler2", handler2, new Subscription(inputChannel));
bus.registerHandler("handler1", handler1, inputChannel, null);
bus.registerHandler("handler2", handler2, inputChannel, null);
bus.start();
inputChannel.send(new StringMessage(1, "testing"));
latch.await(500, TimeUnit.MILLISECONDS);
@@ -207,7 +227,7 @@ public class MessageBusTests {
return null;
}
};
bus.registerHandler("testHandler", handler, new Subscription(MessageBus.ERROR_CHANNEL_NAME));
bus.registerHandler("testHandler", handler, MessageBus.ERROR_CHANNEL_NAME, null);
bus.start();
errorChannel.send(new ErrorMessage(new RuntimeException("test-exception")));
latch.await(1000, TimeUnit.MILLISECONDS);

View File

@@ -40,7 +40,6 @@ import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.dispatcher.DirectChannel;
import org.springframework.integration.handler.TestHandlers;
import org.springframework.integration.scheduling.SimpleTaskScheduler;
import org.springframework.integration.scheduling.Subscription;
/**
* @author Mark Fisher
@@ -71,8 +70,7 @@ public class MessageBusParserTests {
ApplicationContext context = new ClassPathXmlApplicationContext(
"messageBusWithDefaults.xml", this.getClass());
MessageBus bus = (MessageBus) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
Subscription subscription = new Subscription("unknownChannel");
bus.registerHandler("handler", TestHandlers.nullHandler(), subscription);
bus.registerHandler("handler", TestHandlers.nullHandler(), "unknownChannel", null);
}
@Test
@@ -80,8 +78,7 @@ public class MessageBusParserTests {
ApplicationContext context = new ClassPathXmlApplicationContext(
"messageBusWithAutoCreateChannels.xml", this.getClass());
MessageBus bus = (MessageBus) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
Subscription subscription = new Subscription("channelToCreate");
bus.registerHandler("handler", TestHandlers.nullHandler(), subscription);
bus.registerHandler("handler", TestHandlers.nullHandler(), "channelToCreate", null);
bus.start();
assertNotNull(bus.lookupChannel("channelToCreate"));
bus.stop();

View File

@@ -33,7 +33,6 @@ import org.springframework.integration.handler.ReplyHandler;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageHeader;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.scheduling.Subscription;
/**
* @author Mark Fisher
@@ -51,7 +50,7 @@ public class RequestReplyTemplateTests {
};
MessageBus bus = new MessageBus();
bus.registerChannel("requestChannel", requestChannel);
bus.registerHandler("testHandler", testHandler, new Subscription(requestChannel));
bus.registerHandler("testHandler", testHandler, requestChannel, null);
bus.start();
}

View File

@@ -34,7 +34,6 @@ import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessagingException;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.scheduling.Subscription;
/**
* @author Mark Fisher
@@ -88,13 +87,12 @@ public class MethodInvokingTargetTests {
target.setMethodName("foo");
target.afterPropertiesSet();
QueueChannel channel = new QueueChannel();
Subscription subscription = new Subscription(channel);
Message<String> message = new GenericMessage<String>("123", "testing");
channel.send(message);
assertNull(queue.poll());
MessageBus bus = new MessageBus();
bus.registerChannel("channel", channel);
bus.registerHandler("targetAdapter", target, subscription);
bus.registerHandler("targetAdapter", target, channel, null);
bus.start();
String result = queue.poll(500, TimeUnit.MILLISECONDS);
assertNotNull(result);