Removed ReplyHandler.

This commit is contained in:
Mark Fisher
2008-07-19 03:09:23 +00:00
parent 0aa8aeb129
commit fcc5d56f81
9 changed files with 38 additions and 184 deletions

View File

@@ -103,18 +103,4 @@ public class EndpointParserTests {
endpoint.send(message);
}
@Test
public void testCustomReplyHandler() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"endpointWithReplyHandler.xml", this.getClass());
MessageTarget endpoint = (MessageTarget) context.getBean("endpoint");
TestReplyHandler replyHandler = (TestReplyHandler) context.getBean("replyHandler");
assertNull(replyHandler.getLastMessage());
Message<?> message = new StringMessage("test");
endpoint.send(message);
Message<?> reply = replyHandler.getLastMessage();
assertNotNull(reply);
assertEquals("foo", reply.getPayload());
}
}

View File

@@ -1,38 +0,0 @@
/*
* Copyright 2002-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.config;
import org.springframework.integration.handler.ReplyHandler;
import org.springframework.integration.message.Message;
/**
* @author Mark Fisher
*/
public class TestReplyHandler implements ReplyHandler {
private volatile Message<?> lastMessage;
public void handle(Message<?> replyMessage, Message<?> originalMessage) {
this.lastMessage = replyMessage;
}
public Message<?> getLastMessage() {
return this.lastMessage;
}
}

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-core-1.0.xsd">
<message-bus/>
<channel id="testChannel"/>
<handler-endpoint id="endpoint" input-channel="testChannel" ref="testHandler" reply-handler="replyHandler"/>
<beans:bean id="testHandler" class="org.springframework.integration.config.TestHandler">
<beans:property name="replyMessageText" value="foo"/>
</beans:bean>
<beans:bean id="replyHandler" class="org.springframework.integration.config.TestReplyHandler"/>
</beans:beans>

View File

@@ -30,8 +30,8 @@ import org.springframework.integration.bus.DefaultMessageBus;
import org.springframework.integration.bus.MessageBus;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.handler.ReplyHandler;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageTarget;
import org.springframework.integration.message.StringMessage;
/**
@@ -66,16 +66,17 @@ public class RequestReplyTemplateTests {
public void testAsynchronousRequestAndReply() throws InterruptedException {
final List<String> replies = new ArrayList<String>(3);
final CountDownLatch latch = new CountDownLatch(3);
ReplyHandler replyHandler = new ReplyHandler() {
public void handle(Message<?> replyMessage, Message<?> originalMessage) {
MessageTarget replyTarget = new MessageTarget() {
public boolean send(Message<?> replyMessage) {
replies.add((String) replyMessage.getPayload());
latch.countDown();
return true;
}
};
RequestReplyTemplate template = new RequestReplyTemplate(requestChannel);
template.request(new StringMessage("test1"), replyHandler);
template.request(new StringMessage("test2"), replyHandler);
template.request(new StringMessage("test3"), replyHandler);
template.request(new StringMessage("test1"), replyTarget);
template.request(new StringMessage("test2"), replyTarget);
template.request(new StringMessage("test3"), replyTarget);
latch.await(2000, TimeUnit.MILLISECONDS);
assertEquals(0, latch.getCount());
assertTrue(replies.contains("TEST1"));