TestHandler objects no longer implement MessageHandler.
This commit is contained in:
@@ -28,7 +28,6 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.endpoint.AbstractInOutEndpoint;
|
||||
import org.springframework.integration.endpoint.ServiceActivatorEndpoint;
|
||||
import org.springframework.integration.handler.MessageHandler;
|
||||
import org.springframework.integration.handler.TestHandlers;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageDeliveryException;
|
||||
@@ -223,7 +222,7 @@ public class SimpleDispatcherTests {
|
||||
}
|
||||
|
||||
|
||||
private static ServiceActivatorEndpoint createEndpoint(MessageHandler handler) {
|
||||
private static ServiceActivatorEndpoint createEndpoint(Object handler) {
|
||||
return new ServiceActivatorEndpoint(handler);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,6 +147,7 @@ public class SimpleMessagingGatewayTests {
|
||||
expect(replyChannel.getName()).andReturn("replyChannel").anyTimes();
|
||||
expect(requestChannel.send(isA(Message.class))).andReturn(true);
|
||||
replay(allmocks);
|
||||
this.simpleMessagingGateway.setReplyTimeout(0);
|
||||
this.simpleMessagingGateway.sendAndReceive("test");
|
||||
verify(allmocks);
|
||||
}
|
||||
@@ -184,6 +185,7 @@ public class SimpleMessagingGatewayTests {
|
||||
expect(replyChannel.getName()).andReturn("replyChannel").anyTimes();
|
||||
expect(requestChannel.send(isA(Message.class))).andReturn(true);
|
||||
replay(allmocks);
|
||||
this.simpleMessagingGateway.setReplyTimeout(0);
|
||||
this.simpleMessagingGateway.sendAndReceiveMessage("test");
|
||||
verify(allmocks);
|
||||
}
|
||||
|
||||
@@ -16,17 +16,15 @@
|
||||
|
||||
package org.springframework.integration.gateway;
|
||||
|
||||
import org.springframework.integration.handler.MessageHandler;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class TestHandler implements MessageHandler {
|
||||
public class TestHandler {
|
||||
|
||||
public Message<?> handle(Message<?> message) {
|
||||
return new StringMessage(message.getPayload() + "!!!");
|
||||
public String handle(Message<?> message) {
|
||||
return message.getPayload() + "!!!";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
<channel id="requestChannel"/>
|
||||
|
||||
<service-activator ref="handler" input-channel="requestChannel"/>
|
||||
<service-activator ref="testHandler" input-channel="requestChannel"/>
|
||||
|
||||
<beans:bean id="proxy" class="org.springframework.integration.gateway.GatewayProxyFactoryBean">
|
||||
<beans:property name="serviceInterface" value="org.springframework.integration.gateway.TestService"/>
|
||||
<beans:property name="requestChannel" ref="requestChannel"/>
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean id="handler" class="org.springframework.integration.gateway.TestHandler"/>
|
||||
<beans:bean id="testHandler" class="org.springframework.integration.gateway.TestHandler"/>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
@@ -22,18 +22,18 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.springframework.integration.message.Message;
|
||||
|
||||
/**
|
||||
* Factory for {@link MessageHandler} implementations that are useful for
|
||||
* testing.
|
||||
* Factory for handler beans that are useful for testing.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class TestHandlers {
|
||||
|
||||
/**
|
||||
* Create a {@link MessageHandler} that always returns null.
|
||||
* Create a handler that always returns null.
|
||||
*/
|
||||
public final static MessageHandler nullHandler() {
|
||||
return new MessageHandler() {
|
||||
public final static Object nullHandler() {
|
||||
return new Object() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
return null;
|
||||
}
|
||||
@@ -41,10 +41,10 @@ public abstract class TestHandlers {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link MessageHandler} that simply returns the {@link Message} it receives.
|
||||
* Create a handler that simply returns the {@link Message} it receives.
|
||||
*/
|
||||
public final static MessageHandler echoHandler() {
|
||||
return new MessageHandler() {
|
||||
public final static Object echoHandler() {
|
||||
return new Object() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
return message;
|
||||
}
|
||||
@@ -52,10 +52,10 @@ public abstract class TestHandlers {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link MessageHandler} that throws a {@link MessageHandlerRejectedExecutionException}.
|
||||
* Create a handler that throws a {@link MessageHandlerRejectedExecutionException}.
|
||||
*/
|
||||
public final static MessageHandler rejectingHandler() {
|
||||
return new MessageHandler() {
|
||||
public final static Object rejectingHandler() {
|
||||
return new Object() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
throw new MessageHandlerRejectedExecutionException(message);
|
||||
}
|
||||
@@ -63,11 +63,11 @@ public abstract class TestHandlers {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link MessageHandler} that counts down on the provided latch and
|
||||
* Create a handler that counts down on the provided latch and
|
||||
* then throws a {@link MessageHandlerRejectedExecutionException}.
|
||||
*/
|
||||
public final static MessageHandler rejectingCountDownHandler(final CountDownLatch latch) {
|
||||
return new MessageHandler() {
|
||||
public final static Object rejectingCountDownHandler(final CountDownLatch latch) {
|
||||
return new Object() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
latch.countDown();
|
||||
throw new MessageHandlerRejectedExecutionException(message);
|
||||
@@ -76,10 +76,10 @@ public abstract class TestHandlers {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link MessageHandler} that increments the provided counter.
|
||||
* Create a handler that increments the provided counter.
|
||||
*/
|
||||
public final static MessageHandler countingHandler(final AtomicInteger counter) {
|
||||
return new MessageHandler() {
|
||||
public final static Object countingHandler(final AtomicInteger counter) {
|
||||
return new Object() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
counter.incrementAndGet();
|
||||
return null;
|
||||
@@ -88,10 +88,10 @@ public abstract class TestHandlers {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link MessageHandler} that counts down on the provided latch.
|
||||
* Create a handler that counts down on the provided latch.
|
||||
*/
|
||||
public final static MessageHandler countDownHandler(final CountDownLatch latch) {
|
||||
return new MessageHandler() {
|
||||
public final static Object countDownHandler(final CountDownLatch latch) {
|
||||
return new Object() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
latch.countDown();
|
||||
return null;
|
||||
@@ -100,11 +100,11 @@ public abstract class TestHandlers {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a {@link MessageHandler} that counts down on the provided latch
|
||||
* Create a handler that counts down on the provided latch
|
||||
* and also increments the provided counter.
|
||||
*/
|
||||
public final static MessageHandler countingCountDownHandler(final AtomicInteger counter, final CountDownLatch latch) {
|
||||
return new MessageHandler() {
|
||||
public final static Object countingCountDownHandler(final AtomicInteger counter, final CountDownLatch latch) {
|
||||
return new Object() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
counter.incrementAndGet();
|
||||
latch.countDown();
|
||||
|
||||
Reference in New Issue
Block a user