INT-3349 BeanFactory Propagation
JIRA: https://jira.spring.io/browse/INT-3349 Several FactoryBeans did not propagate the BeanFactory to their created object(s). Beans that create messages must have access to a bean factory to get the message builder factory. Fix the FactoryBeans and add a mock FB to all tests that need one. Add a runtime environment variable to make any infractions fatal. This should be set to `true` on CI builds and on framework developer environments.
This commit is contained in:
@@ -86,6 +86,11 @@ public abstract class IntegrationContextUtils {
|
||||
|
||||
public static final String GLOBAL_CHANNEL_INTERCEPTOR_PROCESSOR_BEAN_NAME = "globalChannelInterceptorProcessor";
|
||||
|
||||
/**
|
||||
* Should be set to TRUE on CI plans and framework developer systems.
|
||||
*/
|
||||
public static final boolean fatalWhenNoBeanFactory = Boolean.valueOf(System.getenv("SI_FATAL_WHEN_NO_BEANFACTORY"));
|
||||
|
||||
/**
|
||||
* @param beanFactory BeanFactory for lookup, must not be null.
|
||||
* @return The {@link MetadataStore} bean whose name is "metadataStore".
|
||||
@@ -195,6 +200,9 @@ public abstract class IntegrationContextUtils {
|
||||
logger.warn("No 'beanFactory' supplied; cannot find MessageBuilderFactory"
|
||||
+ ", using default.");
|
||||
}
|
||||
if (fatalWhenNoBeanFactory) {
|
||||
throw new RuntimeException("All Message creators need a BeanFactory");
|
||||
}
|
||||
}
|
||||
if (messageBuilderFactory == null) {
|
||||
messageBuilderFactory = new DefaultMessageBuilderFactory();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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
|
||||
@@ -18,11 +18,13 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
@@ -36,6 +38,7 @@ import org.springframework.messaging.MessageHeaders;
|
||||
* @author Mark Fisher
|
||||
* @author Marius Bogoevici
|
||||
* @author Iwein Fuld
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class AggregatorTests {
|
||||
|
||||
@@ -47,6 +50,7 @@ public class AggregatorTests {
|
||||
@Before
|
||||
public void configureAggregator() {
|
||||
this.aggregator = new AggregatingMessageHandler(new MultiplyingProcessor(), store);
|
||||
this.aggregator.setBeanFactory(mock(BeanFactory.class));
|
||||
this.aggregator.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@@ -218,6 +222,7 @@ public class AggregatorTests {
|
||||
|
||||
|
||||
private class MultiplyingProcessor implements MessageGroupProcessor {
|
||||
@Override
|
||||
public Object processMessageGroup(MessageGroup group) {
|
||||
Integer product = 1;
|
||||
for (Message<?> message : group.getMessages()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
@@ -33,19 +34,20 @@ import org.springframework.messaging.MessageChannel;
|
||||
|
||||
public class CorrelatingMessageHandlerIntegrationTests {
|
||||
|
||||
private MessageGroupStore store = new SimpleMessageStore(100);
|
||||
private final MessageGroupStore store = new SimpleMessageStore(100);
|
||||
|
||||
private MessageChannel outputChannel = mock(MessageChannel.class);
|
||||
private final MessageChannel outputChannel = mock(MessageChannel.class);
|
||||
|
||||
private MessageGroupProcessor processor = new PassThroughMessageGroupProcessor();
|
||||
private final MessageGroupProcessor processor = new PassThroughMessageGroupProcessor();
|
||||
|
||||
private AggregatingMessageHandler defaultHandler = new AggregatingMessageHandler(processor, store);
|
||||
private final AggregatingMessageHandler defaultHandler = new AggregatingMessageHandler(processor, store);
|
||||
|
||||
@Before
|
||||
public void setupHandler() {
|
||||
when(outputChannel.send(isA(Message.class))).thenReturn(true);
|
||||
defaultHandler.setOutputChannel(outputChannel);
|
||||
defaultHandler.setSendTimeout(-1);
|
||||
defaultHandler.setBeanFactory(mock(BeanFactory.class));
|
||||
defaultHandler.afterPropertiesSet();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -28,6 +29,8 @@ import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
@@ -42,6 +45,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
* @author Dave Syer
|
||||
* @author Iwein Fuld
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class ResequencerTests {
|
||||
|
||||
@@ -54,6 +58,7 @@ public class ResequencerTests {
|
||||
@Before
|
||||
public void configureResequencer() {
|
||||
this.resequencer = new ResequencingMessageHandler(processor, store, null, null);
|
||||
this.resequencer.setBeanFactory(mock(BeanFactory.class));
|
||||
this.resequencer.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@@ -82,6 +87,7 @@ public class ResequencerTests {
|
||||
SequenceSizeReleaseStrategy releaseStrategy = new SequenceSizeReleaseStrategy();
|
||||
releaseStrategy.setReleasePartialSequences(true);
|
||||
this.resequencer = new ResequencingMessageHandler(processor, store, null, releaseStrategy);
|
||||
this.resequencer.setBeanFactory(mock(BeanFactory.class));
|
||||
this.resequencer.afterPropertiesSet();
|
||||
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
@@ -102,10 +108,12 @@ public class ResequencerTests {
|
||||
this.resequencer = new ResequencingMessageHandler(processor, store, null, releaseStrategy);
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
this.resequencer.setCorrelationStrategy(new CorrelationStrategy() {
|
||||
@Override
|
||||
public Object getCorrelationKey(Message<?> message) {
|
||||
return "A";
|
||||
}
|
||||
});
|
||||
this.resequencer.setBeanFactory(mock(BeanFactory.class));
|
||||
this.resequencer.afterPropertiesSet();
|
||||
|
||||
//Message<?> message0 = MessageBuilder.withPayload("0").setSequenceNumber(0).build();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -17,23 +17,26 @@
|
||||
package org.springframework.integration.endpoint;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.PublishSubscribeChannel;
|
||||
import org.springframework.integration.handler.ServiceActivatingHandler;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.support.ErrorMessage;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public class MessageProducerSupportTests {
|
||||
@@ -43,6 +46,7 @@ public class MessageProducerSupportTests {
|
||||
DirectChannel outChannel = new DirectChannel();
|
||||
|
||||
outChannel.subscribe(new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
throw new RuntimeException("problems");
|
||||
}
|
||||
@@ -59,12 +63,14 @@ public class MessageProducerSupportTests {
|
||||
public void validateExceptionIfSendToErrorChannelFails() {
|
||||
DirectChannel outChannel = new DirectChannel();
|
||||
outChannel.subscribe(new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
throw new RuntimeException("problems");
|
||||
}
|
||||
});
|
||||
PublishSubscribeChannel errorChannel = new PublishSubscribeChannel();
|
||||
errorChannel.subscribe(new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
throw new RuntimeException("ooops");
|
||||
}
|
||||
@@ -82,6 +88,7 @@ public class MessageProducerSupportTests {
|
||||
public void validateSuccessfulErrorFlowDoesNotThrowErrors() {
|
||||
DirectChannel outChannel = new DirectChannel();
|
||||
outChannel.subscribe(new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
throw new RuntimeException("problems");
|
||||
}
|
||||
@@ -89,6 +96,7 @@ public class MessageProducerSupportTests {
|
||||
PublishSubscribeChannel errorChannel = new PublishSubscribeChannel();
|
||||
SuccessfulErrorService errorService = new SuccessfulErrorService();
|
||||
ServiceActivatingHandler handler = new ServiceActivatingHandler(errorService);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
errorChannel.subscribe(handler);
|
||||
MessageProducerSupport mps = new MessageProducerSupport() {};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -129,6 +129,7 @@ public class GatewayProxyFactoryBeanTests {
|
||||
proxyFactory.setDefaultRequestChannel(new DirectChannel());
|
||||
proxyFactory.setDefaultReplyChannel(replyChannel);
|
||||
proxyFactory.setBeanName("testGateway");
|
||||
proxyFactory.setBeanFactory(mock(BeanFactory.class));
|
||||
proxyFactory.afterPropertiesSet();
|
||||
TestService service = (TestService) proxyFactory.getObject();
|
||||
String result = service.solicitResponse();
|
||||
|
||||
@@ -19,18 +19,19 @@ package org.springframework.integration.gateway;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.PublishSubscribeChannel;
|
||||
import org.springframework.integration.handler.ServiceActivatingHandler;
|
||||
@@ -48,6 +49,7 @@ import org.springframework.messaging.PollableChannel;
|
||||
* @author Iwein Fuld
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class MessagingGatewayTests {
|
||||
@@ -249,12 +251,14 @@ public class MessagingGatewayTests {
|
||||
public void validateErroMessageCanNotBeReplyMessage() {
|
||||
DirectChannel reqChannel = new DirectChannel();
|
||||
reqChannel.subscribe(new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
throw new RuntimeException("ooops");
|
||||
}
|
||||
});
|
||||
PublishSubscribeChannel errorChannel = new PublishSubscribeChannel();
|
||||
ServiceActivatingHandler handler = new ServiceActivatingHandler(new MyErrorService());
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
errorChannel.subscribe(handler);
|
||||
|
||||
@@ -263,6 +267,7 @@ public class MessagingGatewayTests {
|
||||
this.messagingGateway.setRequestChannel(reqChannel);
|
||||
this.messagingGateway.setErrorChannel(errorChannel);
|
||||
this.messagingGateway.setReplyChannel(null);
|
||||
this.messagingGateway.setBeanFactory(mock(BeanFactory.class));
|
||||
this.messagingGateway.afterPropertiesSet();
|
||||
this.messagingGateway.start();
|
||||
|
||||
@@ -274,12 +279,14 @@ public class MessagingGatewayTests {
|
||||
public void validateErrorChannelWithSuccessfulReply() {
|
||||
DirectChannel reqChannel = new DirectChannel();
|
||||
reqChannel.subscribe(new MessageHandler() {
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
throw new RuntimeException("ooops");
|
||||
}
|
||||
});
|
||||
PublishSubscribeChannel errorChannel = new PublishSubscribeChannel();
|
||||
ServiceActivatingHandler handler = new ServiceActivatingHandler(new MyOneWayErrorService());
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
errorChannel.subscribe(handler);
|
||||
|
||||
@@ -288,6 +295,7 @@ public class MessagingGatewayTests {
|
||||
this.messagingGateway.setRequestChannel(reqChannel);
|
||||
this.messagingGateway.setErrorChannel(errorChannel);
|
||||
this.messagingGateway.setReplyChannel(null);
|
||||
this.messagingGateway.setBeanFactory(mock(BeanFactory.class));
|
||||
this.messagingGateway.afterPropertiesSet();
|
||||
this.messagingGateway.start();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -17,16 +17,19 @@
|
||||
package org.springframework.integration.gateway;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class NestedGatewayTests {
|
||||
|
||||
@@ -42,6 +45,7 @@ public class NestedGatewayTests {
|
||||
});
|
||||
final MessagingGatewaySupport innerGateway = new MessagingGatewaySupport() {};
|
||||
innerGateway.setRequestChannel(innerChannel);
|
||||
innerGateway.setBeanFactory(mock(BeanFactory.class));
|
||||
innerGateway.afterPropertiesSet();
|
||||
outerChannel.subscribe(new AbstractReplyProducingMessageHandler() {
|
||||
@Override
|
||||
@@ -52,6 +56,7 @@ public class NestedGatewayTests {
|
||||
});
|
||||
MessagingGatewaySupport outerGateway = new MessagingGatewaySupport() {};
|
||||
outerGateway.setRequestChannel(outerChannel);
|
||||
outerGateway.setBeanFactory(mock(BeanFactory.class));
|
||||
outerGateway.afterPropertiesSet();
|
||||
Message<?> reply = outerGateway.sendAndReceiveMessage("test");
|
||||
assertEquals("pre-test-reply-post", reply.getPayload());
|
||||
@@ -69,6 +74,7 @@ public class NestedGatewayTests {
|
||||
});
|
||||
MessagingGatewaySupport gateway = new MessagingGatewaySupport() {};
|
||||
gateway.setRequestChannel(requestChannel);
|
||||
gateway.setBeanFactory(mock(BeanFactory.class));
|
||||
gateway.afterPropertiesSet();
|
||||
Message<?> message = MessageBuilder.withPayload("test")
|
||||
.setReplyChannel(replyChannel).build();
|
||||
@@ -89,6 +95,7 @@ public class NestedGatewayTests {
|
||||
});
|
||||
MessagingGatewaySupport gateway = new MessagingGatewaySupport() {};
|
||||
gateway.setRequestChannel(requestChannel);
|
||||
gateway.setBeanFactory(mock(BeanFactory.class));
|
||||
gateway.afterPropertiesSet();
|
||||
Message<?> message = MessageBuilder.withPayload("test")
|
||||
.setErrorChannel(errorChannel).build();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -18,8 +18,11 @@ package org.springframework.integration.handler;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.annotation.Header;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
@@ -30,6 +33,7 @@ import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
public class HeaderAnnotationTransformerTests {
|
||||
@@ -39,6 +43,7 @@ public class HeaderAnnotationTransformerTests {
|
||||
Object target = new TestTransformer();
|
||||
MethodInvokingTransformer transformer = new MethodInvokingTransformer(target, "appendCorrelationId");
|
||||
MessageTransformingHandler handler = new MessageTransformingHandler(transformer);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
QueueChannel outputChannel = new QueueChannel();
|
||||
handler.setOutputChannel(outputChannel);
|
||||
@@ -54,6 +59,7 @@ public class HeaderAnnotationTransformerTests {
|
||||
Object target = new TestTransformer();
|
||||
MethodInvokingTransformer transformer = new MethodInvokingTransformer(target, "evalCorrelationId");
|
||||
MessageTransformingHandler handler = new MessageTransformingHandler(transformer);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
QueueChannel outputChannel = new QueueChannel();
|
||||
handler.setOutputChannel(outputChannel);
|
||||
@@ -69,6 +75,7 @@ public class HeaderAnnotationTransformerTests {
|
||||
Object target = new TestTransformer();
|
||||
MethodInvokingTransformer transformer = new MethodInvokingTransformer(target, "appendFoo");
|
||||
MessageTransformingHandler handler = new MessageTransformingHandler(transformer);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
QueueChannel outputChannel = new QueueChannel();
|
||||
handler.setOutputChannel(outputChannel);
|
||||
@@ -84,6 +91,7 @@ public class HeaderAnnotationTransformerTests {
|
||||
Object target = new TestTransformer();
|
||||
MethodInvokingTransformer transformer = new MethodInvokingTransformer(target, "evalFoo");
|
||||
MessageTransformingHandler handler = new MessageTransformingHandler(transformer);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
QueueChannel outputChannel = new QueueChannel();
|
||||
handler.setOutputChannel(outputChannel);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.integration.handler;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,6 +28,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.core.MessageProducer;
|
||||
@@ -96,6 +99,7 @@ public class MessageHandlerChainTests {
|
||||
chain.setBeanName("testChain");
|
||||
chain.setHandlers(handlers);
|
||||
chain.setOutputChannel(outputChannel);
|
||||
chain.setBeanFactory(mock(BeanFactory.class));
|
||||
chain.afterPropertiesSet();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
|
||||
package org.springframework.integration.handler;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
@@ -37,16 +37,18 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.expression.spel.SpelEvaluationException;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.integration.annotation.Header;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.gateway.GatewayProxyFactoryBean;
|
||||
import org.springframework.integration.gateway.RequestReplyExchanger;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.util.MessagingMethodInvokerHelper;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -349,6 +351,7 @@ public class MethodInvokingMessageProcessorTests {
|
||||
@Test
|
||||
public void gatewayTest() throws Exception {
|
||||
GatewayProxyFactoryBean gwFactoryBean = new GatewayProxyFactoryBean();
|
||||
gwFactoryBean.setBeanFactory(mock(BeanFactory.class));
|
||||
gwFactoryBean.afterPropertiesSet();
|
||||
Object target = gwFactoryBean.getObject();
|
||||
// just instantiate a helper with a simple target; we're going to invoke getTargetClass with reflection
|
||||
@@ -365,14 +368,17 @@ public class MethodInvokingMessageProcessorTests {
|
||||
|
||||
class Foo {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String handleMessage(Message<Number> message) {
|
||||
return "" + (message.getPayload().intValue() * 2);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String objectMethod(Integer foo) {
|
||||
return foo.toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String voidMethod() {
|
||||
return "foo";
|
||||
}
|
||||
@@ -390,10 +396,12 @@ public class MethodInvokingMessageProcessorTests {
|
||||
|
||||
class Foo {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String getFoo() {
|
||||
return "foo";
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String getBar() {
|
||||
return "foo";
|
||||
}
|
||||
@@ -414,14 +422,17 @@ public class MethodInvokingMessageProcessorTests {
|
||||
|
||||
class Foo {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String m1(Message<String> message) {
|
||||
return message.getPayload();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Integer m2(Message<Integer> message) {
|
||||
return message.getPayload();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Object m3(Message<?> message) {
|
||||
return message.getPayload();
|
||||
}
|
||||
@@ -441,14 +452,17 @@ public class MethodInvokingMessageProcessorTests {
|
||||
|
||||
class Foo {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String m1(String payload) {
|
||||
return payload;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Integer m2(Integer payload) {
|
||||
return payload;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Object m3(Object payload) {
|
||||
return payload;
|
||||
}
|
||||
@@ -468,15 +482,18 @@ public class MethodInvokingMessageProcessorTests {
|
||||
|
||||
class Foo {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Object m1(Message<String> message) {
|
||||
fail("This method must not be invoked");
|
||||
return message;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Object m2(String payload) {
|
||||
return payload;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public Object m3() {
|
||||
return "FOO";
|
||||
}
|
||||
@@ -506,6 +523,7 @@ public class MethodInvokingMessageProcessorTests {
|
||||
return type.isAssignableFrom(cause.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("cause to be ").appendValue(type).appendText("but was ").appendValue(cause);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -54,7 +54,6 @@ import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.endpoint.PollingConsumer;
|
||||
@@ -62,14 +61,15 @@ import org.springframework.integration.filter.MessageFilter;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice.MessageHandlingExpressionEvaluatingAdviceException;
|
||||
import org.springframework.integration.message.AdviceMessage;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.ErrorMessage;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.retry.RecoveryCallback;
|
||||
import org.springframework.retry.RetryContext;
|
||||
import org.springframework.retry.RetryState;
|
||||
@@ -198,6 +198,7 @@ public class AdvisedMessageHandlerTests {
|
||||
List<Advice> adviceChain = new ArrayList<Advice>();
|
||||
adviceChain.add(advice);
|
||||
handler.setAdviceChain(adviceChain);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
// failing advice with success
|
||||
@@ -259,6 +260,7 @@ public class AdvisedMessageHandlerTests {
|
||||
List<Advice> adviceChain = new ArrayList<Advice>();
|
||||
adviceChain.add(advice);
|
||||
handler.setAdviceChain(adviceChain);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
// failing advice with failure
|
||||
@@ -326,6 +328,7 @@ public class AdvisedMessageHandlerTests {
|
||||
List<Advice> adviceChain = new ArrayList<Advice>();
|
||||
adviceChain.add(advice);
|
||||
handler.setAdviceChain(adviceChain);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
doFail.set(true);
|
||||
@@ -413,6 +416,7 @@ public class AdvisedMessageHandlerTests {
|
||||
List<Advice> adviceChain = new ArrayList<Advice>();
|
||||
adviceChain.add(advice);
|
||||
handler.setAdviceChain(adviceChain);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
Message<String> message = new GenericMessage<String>("Hello, world!");
|
||||
@@ -442,6 +446,7 @@ public class AdvisedMessageHandlerTests {
|
||||
RequestHandlerRetryAdvice advice = new RequestHandlerRetryAdvice();
|
||||
|
||||
advice.setRetryStateGenerator(new RetryStateGenerator() {
|
||||
@Override
|
||||
public RetryState determineRetryState(Message<?> message) {
|
||||
return new DefaultRetryState(message.getHeaders().getId());
|
||||
}
|
||||
@@ -450,6 +455,7 @@ public class AdvisedMessageHandlerTests {
|
||||
List<Advice> adviceChain = new ArrayList<Advice>();
|
||||
adviceChain.add(advice);
|
||||
handler.setAdviceChain(adviceChain);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
Message<String> message = new GenericMessage<String>("Hello, world!");
|
||||
@@ -486,6 +492,7 @@ public class AdvisedMessageHandlerTests {
|
||||
RequestHandlerRetryAdvice advice = new RequestHandlerRetryAdvice();
|
||||
|
||||
advice.setRetryStateGenerator(new RetryStateGenerator() {
|
||||
@Override
|
||||
public RetryState determineRetryState(Message<?> message) {
|
||||
return new DefaultRetryState(message.getHeaders().getId());
|
||||
}
|
||||
@@ -522,6 +529,7 @@ public class AdvisedMessageHandlerTests {
|
||||
AbstractReplyProducingMessageHandler handler, QueueChannel replies, RequestHandlerRetryAdvice advice) {
|
||||
advice.setRecoveryCallback(new RecoveryCallback<Object>() {
|
||||
|
||||
@Override
|
||||
public Object recover(RetryContext context) throws Exception {
|
||||
return "baz";
|
||||
}
|
||||
@@ -530,6 +538,7 @@ public class AdvisedMessageHandlerTests {
|
||||
List<Advice> adviceChain = new ArrayList<Advice>();
|
||||
adviceChain.add(advice);
|
||||
handler.setAdviceChain(adviceChain);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
Message<String> message = new GenericMessage<String>("Hello, world!");
|
||||
@@ -563,6 +572,7 @@ public class AdvisedMessageHandlerTests {
|
||||
List<Advice> adviceChain = new ArrayList<Advice>();
|
||||
adviceChain.add(advice);
|
||||
handler.setAdviceChain(adviceChain);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
Message<String> message = new GenericMessage<String>("Hello, world!");
|
||||
@@ -595,11 +605,13 @@ public class AdvisedMessageHandlerTests {
|
||||
}
|
||||
});
|
||||
advice.setRetryTemplate(retryTemplate);
|
||||
advice.setBeanFactory(mock(BeanFactory.class));
|
||||
advice.afterPropertiesSet();
|
||||
|
||||
List<Advice> adviceChain = new ArrayList<Advice>();
|
||||
adviceChain.add(advice);
|
||||
handler.setAdviceChain(adviceChain);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
Message<String> message = new GenericMessage<String>("Hello, world!");
|
||||
@@ -626,12 +638,14 @@ public class AdvisedMessageHandlerTests {
|
||||
|
||||
adviceChain.add(new RequestHandlerRetryAdvice());
|
||||
adviceChain.add(new MethodInterceptor() {
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
counter.getAndDecrement();
|
||||
throw new RuntimeException("intentional");
|
||||
}
|
||||
});
|
||||
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.setAdviceChain(adviceChain);
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
@@ -680,12 +694,14 @@ public class AdvisedMessageHandlerTests {
|
||||
adviceChain.add(expressionAdvice);
|
||||
adviceChain.add(new RequestHandlerRetryAdvice());
|
||||
adviceChain.add(new MethodInterceptor() {
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
throw new RuntimeException("intentional: " + counter.incrementAndGet());
|
||||
}
|
||||
});
|
||||
|
||||
handler.setAdviceChain(adviceChain);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
handler.handleMessage(new GenericMessage<String>("test"));
|
||||
@@ -719,12 +735,14 @@ public class AdvisedMessageHandlerTests {
|
||||
adviceChain.add(new RequestHandlerRetryAdvice());
|
||||
adviceChain.add(expressionAdvice);
|
||||
adviceChain.add(new MethodInterceptor() {
|
||||
@Override
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
throw new RuntimeException("intentional: " + counter.incrementAndGet());
|
||||
}
|
||||
});
|
||||
|
||||
handler.setAdviceChain(adviceChain);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
try {
|
||||
@@ -772,6 +790,7 @@ public class AdvisedMessageHandlerTests {
|
||||
when(methodInvocation.getArguments()).thenReturn(new Object[] {new GenericMessage<String>("foo")});
|
||||
try {
|
||||
doAnswer(new Answer<Object>() {
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||
throw theThrowable;
|
||||
}
|
||||
@@ -838,6 +857,7 @@ public class AdvisedMessageHandlerTests {
|
||||
public void handleError(Throwable t) {
|
||||
}
|
||||
}));
|
||||
consumer.setBeanFactory(mock(BeanFactory.class));
|
||||
consumer.afterPropertiesSet();
|
||||
|
||||
Callable<?> pollingTask = TestUtils.getPropertyValue(consumer, "poller.pollingTask", Callable.class);
|
||||
@@ -898,6 +918,7 @@ public class AdvisedMessageHandlerTests {
|
||||
}
|
||||
});
|
||||
filter.setAdviceChain(adviceChain);
|
||||
filter.setBeanFactory(mock(BeanFactory.class));
|
||||
filter.afterPropertiesSet();
|
||||
filter.handleMessage(new GenericMessage<String>("foo"));
|
||||
assertNotNull(discardedWithinAdvice.get());
|
||||
@@ -928,6 +949,7 @@ public class AdvisedMessageHandlerTests {
|
||||
});
|
||||
filter.setAdviceChain(adviceChain);
|
||||
filter.setDiscardWithinAdvice(false);
|
||||
filter.setBeanFactory(mock(BeanFactory.class));
|
||||
filter.afterPropertiesSet();
|
||||
filter.handleMessage(new GenericMessage<String>("foo"));
|
||||
assertTrue(adviceCalled.get());
|
||||
@@ -979,6 +1001,7 @@ public class AdvisedMessageHandlerTests {
|
||||
List<Advice> adviceChain = new ArrayList<Advice>();
|
||||
adviceChain.add(advice);
|
||||
handler.setAdviceChain(adviceChain);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
Message<String> message = new GenericMessage<String>("Hello, world!");
|
||||
@@ -1007,6 +1030,7 @@ public class AdvisedMessageHandlerTests {
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object handleRequestMessage(Message<?> message) throws Throwable {
|
||||
throw this.throwable;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -19,24 +19,28 @@ package org.springframework.integration.router;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.router.RecipientListRouter.Recipient;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class RecipientListRouterTests {
|
||||
|
||||
@@ -50,6 +54,7 @@ public class RecipientListRouterTests {
|
||||
channels.add(channel2);
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setChannels(channels);
|
||||
router.setBeanFactory(mock(BeanFactory.class));
|
||||
router.afterPropertiesSet();
|
||||
List<Recipient> recipients = (List<Recipient>)
|
||||
new DirectFieldAccessor(router).getPropertyValue("recipients");
|
||||
@@ -67,6 +72,7 @@ public class RecipientListRouterTests {
|
||||
channels.add(channel2);
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setChannels(channels);
|
||||
router.setBeanFactory(mock(BeanFactory.class));
|
||||
router.afterPropertiesSet();
|
||||
Message<String> message = new GenericMessage<String>("test");
|
||||
router.handleMessage(message);
|
||||
@@ -350,6 +356,7 @@ public class RecipientListRouterTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void noChannelListFailsInitialization() {
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setBeanFactory(mock(BeanFactory.class));
|
||||
router.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@@ -404,6 +411,7 @@ public class RecipientListRouterTests {
|
||||
|
||||
private static class AlwaysTrueSelector implements MessageSelector {
|
||||
|
||||
@Override
|
||||
public boolean accept(Message<?> message) {
|
||||
return true;
|
||||
}
|
||||
@@ -412,6 +420,7 @@ public class RecipientListRouterTests {
|
||||
|
||||
private static class AlwaysFalseSelector implements MessageSelector {
|
||||
|
||||
@Override
|
||||
public boolean accept(Message<?> message) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -34,7 +34,6 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.NullChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
@@ -47,6 +46,7 @@ import org.springframework.integration.handler.ReplyRequiredException;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.scheduling.support.PeriodicTrigger;
|
||||
|
||||
@@ -124,6 +124,7 @@ public class ContentEnricherTests {
|
||||
|
||||
};
|
||||
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
|
||||
final PollingConsumer consumer = new PollingConsumer(requestChannel, handler);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2014 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.
|
||||
@@ -19,20 +19,21 @@ package org.springframework.integration.transformer;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.transformer.HeaderFilter;
|
||||
import org.springframework.integration.transformer.MessageTransformingHandler;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
public class HeaderFilterTests {
|
||||
@@ -62,6 +63,7 @@ public class HeaderFilterTests {
|
||||
.build();
|
||||
HeaderFilter filter = new HeaderFilter("x", "z");
|
||||
MessageTransformingHandler handler = new MessageTransformingHandler(filter);
|
||||
handler.setBeanFactory(mock(BeanFactory.class));
|
||||
handler.afterPropertiesSet();
|
||||
handler.handleMessage(message);
|
||||
Message<?> result = replyChannel.receive(0);
|
||||
|
||||
Reference in New Issue
Block a user