GH-2748: Add bean definition info into exceptions (#2986)

* GH-2748: Add bean definition info into exceptions

Fixes https://github.com/spring-projects/spring-integration/issues/2748

In many cases Spring Integration stack traces doesn't contain any
relations to end-user code.
Just because a target project code mostly contains only a configuration
for out-of-the-box components without any custom code.
When exception is thrown from such an out-of-the-box component, it is
hard from the stack trace to determine a configuration source for those
components.

* Add a logic into the `IntegrationObjectSupport` to obtain a its own
`BeanDefinition` from the `BeanFactory` to include a `resource` and
`source` (if any) into the `toString()` representation, as well as add
a new `getBeanDescription()` to get such an info at runtime
* The `toString()` is simply used by `this` reference in the message
for `MessagingException` thrown from the `IntegrationObjectSupport`
implementations
* Modify an exception message for the `MessageTransformingHandler` and
`MessageFilter` to make it based on `this`.
The `AbstractMessageHandler` already includes `this` into its exception
message
* Modify a `AbstractConsumerEndpointParser` and
`AbstractAmqpInboundAdapterParser` (as a sample) to include a `resource`
and `source` into a `MessageHandler` `BeanDefinition`.
* Include an `IntegrationFlow` `BeanDefinition` `resource`
(`@Configuration` class) and its bean method as a `source` into all
child beans declared during flow parsing in the `IntegrationFlowBeanPostProcessor`
* Add `IntegrationFlowRegistrationBuilder.setSource()` for manually
registered flows: there is no configuration parsing phase to extract
such an info from `BeanFactory`
* Propagate that `source` into all the child beans provided by the
`IntegrationFlow`
* Modify a `LambdaMessageProcessor` exception message to include a
method info in case of `InvocationTargetException`

* Do not cast explicitly for `ConfigurableListableBeanFactory` in the
`IntegrationObjectSupport` to avoid tests modifications for mocking
directly into `ConfigurableListableBeanFactory`.
Use `instanceof` instead in the `getBeanDescription()`

* * Fix Checkstyle issues

* * Fix `IntegrationGraphServer` and  `IntegrationMBeanExporter`
to rely on the `NamedComponent` for channel names instead of
always call `toString()` which is now much more than just a bean name
* Don't describe a `componentName` if it is the same as a `beanName`
* Check for parent `BeanDefinition` in the `IntegrationFlowBeanPostProcessor`
before calling its meta-info
* Fix tests according new `IntegrationObjectSupport.toString()` behavior
This commit is contained in:
Artem Bilan
2019-07-17 15:11:10 -04:00
committed by Gary Russell
parent ebb22c2ed4
commit c712416b63
25 changed files with 330 additions and 202 deletions

View File

@@ -94,7 +94,6 @@ public class AggregatorIntegrationTests {
Message<?> receive = output.receive(10000);
assertThat(receive).isNotNull();
assertThat(receive.getPayload()).isEqualTo(1 + 2 + 3 + 4);
assertThat(receive.getHeaders().get(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER)).isEqualTo(0);
}
@Test
@@ -187,7 +186,8 @@ public class AggregatorIntegrationTests {
@Test
public void testGroupTimeoutExpressionScheduling() {
// Since group-timeout-expression="size() >= 2 ? 100 : null". The first message won't be scheduled to 'forceComplete'
// Since group-timeout-expression="size() >= 2 ? 100 : null". The first message won't be scheduled to
// 'forceComplete'
this.groupTimeoutExpressionAggregatorInput.send(new GenericMessage<>(1, stubHeaders(1, 6, 1)));
assertThat(this.output.receive(0)).isNull();
assertThat(this.discard.receive(0)).isNull();
@@ -239,7 +239,9 @@ public class AggregatorIntegrationTests {
ErrorMessage em = (ErrorMessage) this.errors.receive(10000);
assertThat(em).isNotNull();
assertThat(em.getPayload().getMessage().toLowerCase())
.contains("failed to send message to channel 'output' within timeout: 10");
.contains("failed to send message to channel")
.contains("output")
.contains("within timeout: 10");
}
finally {
this.output.purge(null);
@@ -261,6 +263,7 @@ public class AggregatorIntegrationTests {
}
public static class SummingAggregator {
public Integer sum(List<Integer> numbers) {
int result = 0;
for (Integer number : numbers) {
@@ -268,8 +271,8 @@ public class AggregatorIntegrationTests {
}
return result;
}
}
}

View File

@@ -156,9 +156,9 @@ public class MessagingAnnotationsWithBeanAnnotationTests {
assertThat(receive).isInstanceOf(ErrorMessage.class);
assertThat(receive.getPayload()).isInstanceOf(MessageRejectedException.class);
MessageRejectedException exception = (MessageRejectedException) receive.getPayload();
assertThat(exception.getMessage()).contains("MessageFilter " +
"'messagingAnnotationsWithBeanAnnotationTests.ContextConfiguration.filter.filter.handler'" +
" rejected Message");
assertThat(exception.getMessage())
.contains("message has been rejected in filter: bean " +
"'messagingAnnotationsWithBeanAnnotationTests.ContextConfiguration.filter.filter.handler'");
}
for (Message<?> message : this.collector) {
@@ -166,12 +166,12 @@ public class MessagingAnnotationsWithBeanAnnotationTests {
MessageHistory messageHistory = MessageHistory.read(message);
assertThat(messageHistory).isNotNull();
String messageHistoryString = messageHistory.toString();
assertThat(messageHistoryString).contains("routerChannel");
assertThat(messageHistoryString).contains("filterChannel");
assertThat(messageHistoryString).contains("aggregatorChannel");
assertThat(messageHistoryString).contains("splitterChannel");
assertThat(messageHistoryString).contains("serviceChannel");
assertThat(messageHistoryString).doesNotContain("discardChannel");
assertThat(messageHistoryString).contains("routerChannel")
.contains("filterChannel")
.contains("aggregatorChannel")
.contains("splitterChannel")
.contains("serviceChannel")
.doesNotContain("discardChannel");
}
assertThat(this.skippedServiceActivator).isNull();

View File

@@ -17,9 +17,9 @@
package org.springframework.integration.config.xml;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@@ -30,68 +30,77 @@ import org.springframework.integration.transformer.MessageTransformationExceptio
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/**
* @author Mark Fisher
* @author Artem Bilan
*
* @since 2.0
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class HeaderEnricherParserTests {
@SpringJUnitConfig
class HeaderEnricherParserTests {
@Autowired
private ApplicationContext context;
@Test // INT-1154
public void sendTimeoutDefault() {
@Test
void sendTimeoutDefault() {
Object endpoint = context.getBean("headerEnricherWithDefaults");
long sendTimeout = TestUtils.getPropertyValue(endpoint, "handler.messagingTemplate.sendTimeout", Long.class);
assertThat(sendTimeout).isEqualTo(-1L);
}
@Test // INT-1154
public void sendTimeoutConfigured() {
@Test
void sendTimeoutConfigured() {
Object endpoint = context.getBean("headerEnricherWithSendTimeout");
long sendTimeout = TestUtils.getPropertyValue(endpoint, "handler.messagingTemplate.sendTimeout", Long.class);
assertThat(sendTimeout).isEqualTo(1234L);
}
@Test // INT-1167
public void shouldSkipNullsDefault() {
@Test
void shouldSkipNullsDefault() {
Object endpoint = context.getBean("headerEnricherWithDefaults");
Boolean shouldSkipNulls = TestUtils.getPropertyValue(endpoint, "handler.transformer.shouldSkipNulls", Boolean.class);
Boolean shouldSkipNulls = TestUtils
.getPropertyValue(endpoint, "handler.transformer.shouldSkipNulls", Boolean.class);
assertThat(shouldSkipNulls).isEqualTo(Boolean.TRUE);
}
@Test // INT-1167
public void shouldSkipNullsFalseConfigured() {
Object endpoint = context.getBean("headerEnricherWithShouldSkipNullsFalse");
Boolean shouldSkipNulls = TestUtils.getPropertyValue(endpoint, "handler.transformer.shouldSkipNulls", Boolean.class);
assertThat(shouldSkipNulls).isEqualTo(Boolean.FALSE);
}
@Test // INT-1167
public void shouldSkipNullsTrueConfigured() {
Object endpoint = context.getBean("headerEnricherWithShouldSkipNullsTrue");
Boolean shouldSkipNulls = TestUtils.getPropertyValue(endpoint, "handler.transformer.shouldSkipNulls", Boolean.class);
assertThat(shouldSkipNulls).isEqualTo(Boolean.TRUE);
}
@Test(expected = MessageTransformationException.class)
public void testStringPriorityHeader() {
MessageHandler messageHandler =
TestUtils.getPropertyValue(context.getBean("headerEnricherWithPriorityAsString"), "handler", MessageHandler.class);
Message<?> message = new GenericMessage<String>("hello");
messageHandler.handleMessage(message);
}
@Test
public void testStringPriorityHeaderWithType() {
void shouldSkipNullsFalseConfigured() {
Object endpoint = context.getBean("headerEnricherWithShouldSkipNullsFalse");
Boolean shouldSkipNulls = TestUtils
.getPropertyValue(endpoint, "handler.transformer.shouldSkipNulls", Boolean.class);
assertThat(shouldSkipNulls).isEqualTo(Boolean.FALSE);
}
@Test
void shouldSkipNullsTrueConfigured() {
Object endpoint = context.getBean("headerEnricherWithShouldSkipNullsTrue");
Boolean shouldSkipNulls = TestUtils
.getPropertyValue(endpoint, "handler.transformer.shouldSkipNulls", Boolean.class);
assertThat(shouldSkipNulls).isEqualTo(Boolean.TRUE);
}
@Test
void testStringPriorityHeader() {
MessageHandler messageHandler =
TestUtils.getPropertyValue(context.getBean("headerEnricherWithPriorityAsStringAndType"), "handler", MessageHandler.class);
TestUtils.getPropertyValue(this.context.getBean("headerEnricherWithPriorityAsString"),
"handler", MessageHandler.class);
Message<?> message = new GenericMessage<>("hello");
assertThatExceptionOfType(MessageTransformationException.class)
.isThrownBy(() -> messageHandler.handleMessage(message))
.withMessageContaining(
"; defined in: 'class path resource " +
"[org/springframework/integration/config/xml/HeaderEnricherParserTests-context.xml]'");
}
@Test
void testStringPriorityHeaderWithType() {
MessageHandler messageHandler =
TestUtils.getPropertyValue(context.getBean("headerEnricherWithPriorityAsStringAndType"),
"handler", MessageHandler.class);
QueueChannel replyChannel = new QueueChannel();
Message<?> message = MessageBuilder.withPayload("foo").setReplyChannel(replyChannel).build();
messageHandler.handleMessage(message);

View File

@@ -31,7 +31,6 @@ import org.springframework.integration.handler.LambdaMessageProcessor;
import org.springframework.integration.support.converter.ConfigurableCompositeMessageConverter;
import org.springframework.integration.transformer.GenericTransformer;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.messaging.converter.MessageConverter;
import org.springframework.messaging.support.GenericMessage;
@@ -61,12 +60,12 @@ public class LambdaMessageProcessorTests {
LambdaMessageProcessor lmp = new LambdaMessageProcessor(
new GenericTransformer<Message<?>, Message<?>>() { // Must not be lambda
@Override
public Message<?> transform(Message<?> source) {
return messageTransformer(source);
}
@Override
public Message<?> transform(Message<?> source) {
return messageTransformer(source);
}
}, null);
}, null);
lmp.setBeanFactory(mock(BeanFactory.class));
GenericMessage<String> testMessage = new GenericMessage<>("foo");
Object result = lmp.processMessage(testMessage);
@@ -79,7 +78,7 @@ public class LambdaMessageProcessorTests {
(GenericTransformer<Message<?>, Message<?>>) this::messageTransformer, null);
lmp.setBeanFactory(mock(BeanFactory.class));
GenericMessage<String> testMessage = new GenericMessage<>("foo");
assertThatExceptionOfType(MessageHandlingException.class)
assertThatExceptionOfType(IllegalStateException.class)
.isThrownBy(() -> lmp.processMessage(testMessage))
.withCauseInstanceOf(ClassCastException.class);
}

View File

@@ -17,6 +17,7 @@
package org.springframework.integration.dsl.flows;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.fail;
import java.io.Serializable;
@@ -40,7 +41,6 @@ import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@@ -233,15 +233,11 @@ public class IntegrationFlowTests {
assertThat(this.beanFactory.containsBean("bridgeFlow2.channel#0")).isTrue();
assertThat(this.beanFactory.getBean("bridgeFlow2.channel#0")).isInstanceOf(FixedSubscriberChannel.class);
try {
this.bridgeFlow2Input.send(message);
fail("Expected MessageDispatchingException");
}
catch (Exception e) {
assertThat(e).isInstanceOf(MessageDeliveryException.class);
assertThat(e.getCause()).isInstanceOf(MessageDispatchingException.class);
assertThat(e.getMessage()).contains("Dispatcher has no subscribers");
}
assertThatExceptionOfType(MessageDeliveryException.class)
.isThrownBy(() -> this.bridgeFlow2Input.send(message))
.withCauseInstanceOf(MessageDispatchingException.class)
.withMessageContaining("Dispatcher has no subscribers");
this.controlBus.send("@bridge.start()");
this.bridgeFlow2Input.send(message);
reply = this.bridgeFlow2Output.receive(10000);
@@ -252,21 +248,10 @@ public class IntegrationFlowTests {
@Test
public void testWrongLastMessageChannel() {
ConfigurableApplicationContext context = null;
try {
context = new AnnotationConfigApplicationContext(InvalidLastMessageChannelFlowContext.class);
fail("BeanCreationException expected");
}
catch (Exception e) {
assertThat(e).isInstanceOf(BeanCreationException.class);
assertThat(e.getMessage()).contains("'.fixedSubscriberChannel()' " +
"can't be the last EIP-method in the 'IntegrationFlow' definition");
}
finally {
if (context != null) {
context.close();
}
}
assertThatExceptionOfType(BeanCreationException.class)
.isThrownBy(() -> new AnnotationConfigApplicationContext(InvalidLastMessageChannelFlowContext.class))
.withMessageContaining("'.fixedSubscriberChannel()' " +
"can't be the last EIP-method in the 'IntegrationFlow' definition");
}
@Test

View File

@@ -78,7 +78,12 @@ public class GatewayDslTests {
assertThat(receive).isNotNull();
assertThat(receive).isInstanceOf(ErrorMessage.class);
assertThat(receive.getPayload()).isInstanceOf(MessageRejectedException.class);
assertThat(((Exception) receive.getPayload()).getMessage()).contains("' rejected Message");
String exceptionMessage = ((Exception) receive.getPayload()).getMessage();
assertThat(exceptionMessage)
.contains("message has been rejected in filter")
.contains("defined in: " +
"'org.springframework.integration.dsl.gateway.GatewayDslTests$ContextConfiguration'; " +
"from source: 'bean method gatewayRequestFlow'");
}
@Autowired
@@ -89,7 +94,7 @@ public class GatewayDslTests {
void testNestedGatewayErrorPropagation() {
assertThatExceptionOfType(RuntimeException.class)
.isThrownBy(() -> this.nestedGatewayErrorPropagationFlowInput.send(new GenericMessage<>("test")))
.withMessageContaining("intentional");
.withStackTraceContaining("intentional");
}
@Configuration

View File

@@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.fail;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@@ -73,6 +74,7 @@ import org.springframework.integration.handler.BridgeHandler;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.support.SmartLifecycleRoleController;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.integration.transformer.MessageTransformationException;
import org.springframework.integration.transformer.MessageTransformingHandler;
import org.springframework.integration.util.NoBeansOverrideAnnotationConfigContextLoader;
import org.springframework.messaging.Message;
@@ -86,6 +88,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ReflectionUtils;
import reactor.core.publisher.Flux;
@@ -521,6 +524,24 @@ public class ManualFlowTests {
.withMessageContaining("Invalid bean definition with name 'doNotOverrideChannel'");
}
@Test
public void testBeanDefinitionInfoInTheException() {
IntegrationFlow testFlow = f -> f.<String, String>transform(String::toUpperCase);
Method source = ReflectionUtils.findMethod(ManualFlowTests.class, "testBeanDefinitionInfoInTheException");
IntegrationFlowRegistration flowRegistration =
this.integrationFlowContext.registration(testFlow)
.setSource(source)
.register();
assertThatExceptionOfType(MessageTransformationException.class)
.isThrownBy(() -> flowRegistration.getInputChannel().send(new GenericMessage<>(new Date())))
.withCauseExactlyInstanceOf(IllegalStateException.class)
.withRootCauseInstanceOf(ClassCastException.class)
.withMessageContaining("from source: '" + source + "'")
.withStackTraceContaining("java.util.Date cannot be cast to java.lang.String");
flowRegistration.destroy();
}
@Configuration
@EnableIntegration
@EnableMessageHistory

View File

@@ -123,7 +123,7 @@ public class AdvisedMessageHandlerTests {
handler.setComponentName(componentName);
QueueChannel replies = new QueueChannel();
handler.setOutputChannel(replies);
Message<String> message = new GenericMessage<String>("Hello, world!");
Message<String> message = new GenericMessage<>("Hello, world!");
// no advice
handler.handleMessage(message);
@@ -142,7 +142,7 @@ public class AdvisedMessageHandlerTests {
List<Advice> adviceChain = new ArrayList<Advice>();
adviceChain.add(advice);
final AtomicReference<String> compName = new AtomicReference<String>();
final AtomicReference<String> compName = new AtomicReference<>();
adviceChain.add(new AbstractRequestHandlerAdvice() {
@Override
@@ -229,7 +229,7 @@ public class AdvisedMessageHandlerTests {
};
QueueChannel replies = new QueueChannel();
handler.setOutputChannel(replies);
Message<String> message = new GenericMessage<String>("Hello, world!");
Message<String> message = new GenericMessage<>("Hello, world!");
PollableChannel successChannel = new QueueChannel();
PollableChannel failureChannel = new QueueChannel();
@@ -293,7 +293,7 @@ public class AdvisedMessageHandlerTests {
};
QueueChannel replies = new QueueChannel();
handler.setOutputChannel(replies);
Message<String> message = new GenericMessage<String>("Hello, world!");
Message<String> message = new GenericMessage<>("Hello, world!");
PollableChannel successChannel = new QueueChannel();
PollableChannel failureChannel = new QueueChannel();
@@ -375,7 +375,7 @@ public class AdvisedMessageHandlerTests {
advice.setThreshold(2);
advice.setHalfOpenAfter(1000);
List<Advice> adviceChain = new ArrayList<Advice>();
List<Advice> adviceChain = new ArrayList<>();
adviceChain.add(advice);
handler.setAdviceChain(adviceChain);
handler.setBeanFactory(mock(BeanFactory.class));
@@ -402,7 +402,7 @@ public class AdvisedMessageHandlerTests {
fail("Expected failure");
}
catch (Exception e) {
assertThat(e.getMessage()).isEqualTo("Circuit Breaker is Open for baz");
assertThat(e.getMessage()).isEqualTo("Circuit Breaker is Open for bean 'baz'");
assertThat(((MessagingException) e).getFailedMessage()).isSameAs(message);
}
@@ -426,7 +426,7 @@ public class AdvisedMessageHandlerTests {
fail("Expected failure");
}
catch (Exception e) {
assertThat(e.getMessage()).isEqualTo("Circuit Breaker is Open for baz");
assertThat(e.getMessage()).isEqualTo("Circuit Breaker is Open for bean 'baz'");
}
// Simulate some timeout in between requests
@@ -454,7 +454,7 @@ public class AdvisedMessageHandlerTests {
fail("Expected failure");
}
catch (Exception e) {
assertThat(e.getMessage()).isEqualTo("Circuit Breaker is Open for baz");
assertThat(e.getMessage()).isEqualTo("Circuit Breaker is Open for bean 'baz'");
}
}
@@ -475,7 +475,7 @@ public class AdvisedMessageHandlerTests {
handler.setOutputChannel(replies);
RequestHandlerRetryAdvice advice = new RequestHandlerRetryAdvice();
List<Advice> adviceChain = new ArrayList<Advice>();
List<Advice> adviceChain = new ArrayList<>();
adviceChain.add(advice);
handler.setAdviceChain(adviceChain);
handler.setBeanFactory(mock(BeanFactory.class));
@@ -937,7 +937,7 @@ public class AdvisedMessageHandlerTests {
MessageFilter filter = new MessageFilter(message -> false);
final QueueChannel discardChannel = new QueueChannel();
filter.setDiscardChannel(discardChannel);
List<Advice> adviceChain = new ArrayList<Advice>();
List<Advice> adviceChain = new ArrayList<>();
final AtomicReference<Message<?>> discardedWithinAdvice = new AtomicReference<Message<?>>();
adviceChain.add(new AbstractRequestHandlerAdvice() {
@@ -1017,7 +1017,7 @@ public class AdvisedMessageHandlerTests {
RetryTemplate retryTemplate = new RetryTemplate();
Map<Class<? extends Throwable>, Boolean> retryableExceptions = new HashMap<Class<? extends Throwable>, Boolean>();
Map<Class<? extends Throwable>, Boolean> retryableExceptions = new HashMap<>();
retryableExceptions.put(MyException.class, retryForMyException);
retryTemplate.setRetryPolicy(new SimpleRetryPolicy(3, retryableExceptions, true));

View File

@@ -17,6 +17,7 @@
package org.springframework.integration.transformer;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.fail;
import static org.mockito.Mockito.mock;
@@ -143,7 +144,8 @@ public class ContentEnricherTests {
}
catch (ReplyRequiredException e) {
assertThat(e.getMessage())
.isEqualTo("No reply produced by handler 'Enricher', and its 'requiresReply' property is set to true.");
.isEqualTo("No reply produced by handler 'Enricher', and its 'requiresReply' property is set to " +
"true.");
return;
}
finally {
@@ -174,14 +176,11 @@ public class ContentEnricherTests {
Target target = new Target("replace me");
Message<?> requestMessage = MessageBuilder.withPayload(target).setReplyChannel(replyChannel).build();
try {
enricher.handleMessage(requestMessage);
}
catch (MessageDeliveryException e) {
assertThat(e.getMessage()).isEqualToIgnoringCase("failed to send message to channel '" + requestChannelName
+ "' within timeout: " + requestTimeout);
}
assertThatExceptionOfType(MessageDeliveryException.class)
.isThrownBy(() -> enricher.handleMessage(requestMessage))
.withMessageContaining("Failed to send message to channel")
.withMessageContaining(requestChannelName)
.withMessageContaining("within timeout: " + requestTimeout);
}
@Test
@@ -189,6 +188,7 @@ public class ContentEnricherTests {
QueueChannel replyChannel = new QueueChannel();
DirectChannel requestChannel = new DirectChannel();
requestChannel.subscribe(new AbstractReplyProducingMessageHandler() {
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
return new Source("John", "Doe");
@@ -199,7 +199,7 @@ public class ContentEnricherTests {
enricher.setRequestChannel(requestChannel);
SpelExpressionParser parser = new SpelExpressionParser();
Map<String, Expression> propertyExpressions = new HashMap<String, Expression>();
Map<String, Expression> propertyExpressions = new HashMap<>();
propertyExpressions.put("name", parser.parseExpression("payload.lastName + ', ' + payload.firstName"));
enricher.setPropertyExpressions(propertyExpressions);
enricher.setBeanFactory(mock(BeanFactory.class));
@@ -308,6 +308,7 @@ public class ContentEnricherTests {
QueueChannel replyChannel = new QueueChannel();
DirectChannel requestChannel = new DirectChannel();
requestChannel.subscribe(new AbstractReplyProducingMessageHandler() {
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
return new Source("John", "Doe");
@@ -337,6 +338,7 @@ public class ContentEnricherTests {
QueueChannel replyChannel = new QueueChannel();
DirectChannel requestChannel = new DirectChannel();
requestChannel.subscribe(new AbstractReplyProducingMessageHandler() {
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
return new Source("John", "Doe");
@@ -367,6 +369,7 @@ public class ContentEnricherTests {
QueueChannel replyChannel = new QueueChannel();
DirectChannel requestChannel = new DirectChannel();
requestChannel.subscribe(new AbstractReplyProducingMessageHandler() {
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
return new Source("John", "Doe");
@@ -400,6 +403,7 @@ public class ContentEnricherTests {
QueueChannel replyChannel = new QueueChannel();
DirectChannel requestChannel = new DirectChannel();
requestChannel.subscribe(new AbstractReplyProducingMessageHandler() {
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
return new Source("John", "Doe");
@@ -450,6 +454,7 @@ public class ContentEnricherTests {
DirectChannel requestChannel = new DirectChannel();
requestChannel.subscribe(new AbstractReplyProducingMessageHandler() {
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
return new Source("John", "Doe");
@@ -483,6 +488,7 @@ public class ContentEnricherTests {
final DirectChannel requestChannel = new DirectChannel();
requestChannel.subscribe(new AbstractReplyProducingMessageHandler() {
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
throw new RuntimeException();
@@ -492,6 +498,7 @@ public class ContentEnricherTests {
final DirectChannel errorChannel = new DirectChannel();
errorChannel.subscribe(new AbstractReplyProducingMessageHandler() {
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
return new Target("failed");