Search in sources :

Example 31 with IntegrationMessageHeaderAccessor

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

the class HeaderEnricherOverwriteTests method priorityExplicitOverwriteFalse.

@Test
public void priorityExplicitOverwriteFalse() {
    MessageChannel input = context.getBean("priorityExplicitOverwriteFalseInput", MessageChannel.class);
    QueueChannel replyChannel = new QueueChannel();
    Message<?> message = MessageBuilder.withPayload("test").setReplyChannel(replyChannel).setPriority(77).build();
    input.send(message);
    Message<?> result = replyChannel.receive(0);
    assertNotNull(result);
    assertEquals(new Integer(77), new IntegrationMessageHeaderAccessor(result).getPriority());
}
Also used : IntegrationMessageHeaderAccessor(org.springframework.integration.IntegrationMessageHeaderAccessor) MessageChannel(org.springframework.messaging.MessageChannel) QueueChannel(org.springframework.integration.channel.QueueChannel) Test(org.junit.Test)

Example 32 with IntegrationMessageHeaderAccessor

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

the class HeaderEnricherTests method testRoutingSlip.

@Test
public void testRoutingSlip() {
    MessagingTemplate template = new MessagingTemplate();
    MessageChannel channel = context.getBean("routingSlipInput", MessageChannel.class);
    Message<?> result = template.sendAndReceive(channel, new GenericMessage<String>("test"));
    assertNotNull(result);
    Object routingSlip = new IntegrationMessageHeaderAccessor(result).getHeader(IntegrationMessageHeaderAccessor.ROUTING_SLIP);
    assertNotNull(routingSlip);
    assertThat(routingSlip, instanceOf(Map.class));
    @SuppressWarnings("unchecked") List<Object> routingSlipPath = (List<Object>) ((Map<?, ?>) routingSlip).keySet().iterator().next();
    assertEquals("fooChannel", routingSlipPath.get(0));
    assertThat(routingSlipPath.get(1), instanceOf(ExpressionEvaluatingRoutingSlipRouteStrategy.class));
    assertEquals("bazRoutingSlip", routingSlipPath.get(2));
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) IntegrationMessageHeaderAccessor(org.springframework.integration.IntegrationMessageHeaderAccessor) MessageChannel(org.springframework.messaging.MessageChannel) ExpressionEvaluatingRoutingSlipRouteStrategy(org.springframework.integration.routingslip.ExpressionEvaluatingRoutingSlipRouteStrategy) List(java.util.List) Map(java.util.Map) Test(org.junit.Test)

Example 33 with IntegrationMessageHeaderAccessor

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

the class HeaderEnricherTests method correlationIdValueWithType.

@Test
public void correlationIdValueWithType() {
    MessagingTemplate template = new MessagingTemplate();
    MessageChannel channel = context.getBean("correlationIdValueWithTypeInput", MessageChannel.class);
    Message<?> result = template.sendAndReceive(channel, new GenericMessage<String>("test"));
    assertNotNull(result);
    Object correlationId = new IntegrationMessageHeaderAccessor(result).getCorrelationId();
    assertEquals(Long.class, correlationId.getClass());
    assertEquals(123L, correlationId);
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) IntegrationMessageHeaderAccessor(org.springframework.integration.IntegrationMessageHeaderAccessor) MessageChannel(org.springframework.messaging.MessageChannel) Test(org.junit.Test)

Example 34 with IntegrationMessageHeaderAccessor

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

the class HeaderEnricherTests method correlationIdRef.

@Test
public void correlationIdRef() {
    MessagingTemplate template = new MessagingTemplate();
    MessageChannel channel = context.getBean("correlationIdRefInput", MessageChannel.class);
    Message<?> result = template.sendAndReceive(channel, new GenericMessage<String>("test"));
    assertNotNull(result);
    assertEquals(123, new IntegrationMessageHeaderAccessor(result).getCorrelationId());
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) IntegrationMessageHeaderAccessor(org.springframework.integration.IntegrationMessageHeaderAccessor) MessageChannel(org.springframework.messaging.MessageChannel) Test(org.junit.Test)

Example 35 with IntegrationMessageHeaderAccessor

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

the class HeaderEnricherTests method priorityExpression.

@Test
public void priorityExpression() {
    MessagingTemplate template = new MessagingTemplate();
    MessageChannel channel = context.getBean("priorityExpressionInput", MessageChannel.class);
    Message<?> result = template.sendAndReceive(channel, new GenericMessage<Map<String, String>>(Collections.singletonMap("priority", "-10")));
    assertNotNull(result);
    assertEquals(new Integer(-10), new IntegrationMessageHeaderAccessor(result).getPriority());
}
Also used : MessagingTemplate(org.springframework.integration.core.MessagingTemplate) IntegrationMessageHeaderAccessor(org.springframework.integration.IntegrationMessageHeaderAccessor) MessageChannel(org.springframework.messaging.MessageChannel) Map(java.util.Map) Test(org.junit.Test)

Aggregations

IntegrationMessageHeaderAccessor (org.springframework.integration.IntegrationMessageHeaderAccessor)68 Test (org.junit.Test)56 QueueChannel (org.springframework.integration.channel.QueueChannel)32 Message (org.springframework.messaging.Message)21 GenericMessage (org.springframework.messaging.support.GenericMessage)19 MessageChannel (org.springframework.messaging.MessageChannel)15 ArrayList (java.util.ArrayList)10 MessagingTemplate (org.springframework.integration.core.MessagingTemplate)9 DirectChannel (org.springframework.integration.channel.DirectChannel)8 ServiceActivatingHandler (org.springframework.integration.handler.ServiceActivatingHandler)6 List (java.util.List)5 BeanFactory (org.springframework.beans.factory.BeanFactory)5 MessageSequenceComparator (org.springframework.integration.aggregator.MessageSequenceComparator)4 Aggregator (org.springframework.integration.annotation.Aggregator)4 InputStream (java.io.InputStream)3 LinkedList (java.util.LinkedList)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)3 MessageGroup (org.springframework.integration.store.MessageGroup)3 SimpleMessageGroup (org.springframework.integration.store.SimpleMessageGroup)3