Search in sources :

Example 1 with RendezvousChannel

use of org.springframework.integration.channel.RendezvousChannel in project spring-integration by spring-projects.

the class ContentEnricherTests method requestChannelSendTimingOut.

@Test
public void requestChannelSendTimingOut() {
    final String requestChannelName = "Request_Channel";
    final long requestTimeout = 200L;
    QueueChannel replyChannel = new QueueChannel();
    QueueChannel requestChannel = new RendezvousChannel();
    requestChannel.setBeanName(requestChannelName);
    ContentEnricher enricher = new ContentEnricher();
    enricher.setRequestChannel(requestChannel);
    enricher.setRequestTimeout(requestTimeout);
    enricher.setBeanFactory(mock(BeanFactory.class));
    enricher.afterPropertiesSet();
    Target target = new Target("replace me");
    Message<?> requestMessage = MessageBuilder.withPayload(target).setReplyChannel(replyChannel).build();
    try {
        enricher.handleMessage(requestMessage);
    } catch (MessageDeliveryException e) {
        assertThat(e.getMessage(), equalToIgnoringCase("failed to send message to channel '" + requestChannelName + "' within timeout: " + requestTimeout));
    }
}
Also used : RendezvousChannel(org.springframework.integration.channel.RendezvousChannel) QueueChannel(org.springframework.integration.channel.QueueChannel) BeanFactory(org.springframework.beans.factory.BeanFactory) Matchers.containsString(org.hamcrest.Matchers.containsString) MessageDeliveryException(org.springframework.messaging.MessageDeliveryException) Test(org.junit.Test)

Aggregations

Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1 BeanFactory (org.springframework.beans.factory.BeanFactory)1 QueueChannel (org.springframework.integration.channel.QueueChannel)1 RendezvousChannel (org.springframework.integration.channel.RendezvousChannel)1 MessageDeliveryException (org.springframework.messaging.MessageDeliveryException)1