INT-2743: Improve <header-enricher>.<priority>
JIRA: https://jira.spring.io/browse/INT-2743
This commit is contained in:
committed by
Gary Russell
parent
39a7fb3adf
commit
42a13c830d
@@ -1915,38 +1915,16 @@
|
||||
<xsd:element name="expiration-date" type="referenceOrValueHeaderType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Shortcut to specify value for 'expirationDate' header (java.lang.Long)
|
||||
Shortcut to specify a value for the 'expirationDate' header (java.lang.Long).
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="priority">
|
||||
<xsd:element name="priority" type="referenceOrValueHeaderType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Shortcut to specify value for 'priority' header when using PriorityChannel
|
||||
Shortcut to specify a value for the 'priority' header.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="value">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Integer value identifying the value of the 'priority' header.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="overwrite">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Boolean value to indicate whether this header value should overwrite
|
||||
an existing header
|
||||
value
|
||||
for the same name.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:simpleType>
|
||||
<xsd:union memberTypes="xsd:boolean xsd:string" />
|
||||
</xsd:simpleType>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="header" type="userDefinedHeaderType">
|
||||
<xsd:annotation>
|
||||
|
||||
@@ -72,6 +72,10 @@
|
||||
<priority value="42"/>
|
||||
</header-enricher>
|
||||
|
||||
<header-enricher input-channel="priorityExpressionInput">
|
||||
<priority expression="payload.priority"/>
|
||||
</header-enricher>
|
||||
|
||||
<header-enricher input-channel="payloadExpressionInput">
|
||||
<header name="testHeader" expression="payload.name + 'bar'"/>
|
||||
</header-enricher>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 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,22 +21,25 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.transformer.MessageTransformationException;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -155,6 +158,15 @@ public class HeaderEnricherTests {
|
||||
assertEquals(new Integer(42), new IntegrationMessageHeaderAccessor(result).getPriority());
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expressionUsingPayload() {
|
||||
MessagingTemplate template = new MessagingTemplate();
|
||||
|
||||
Reference in New Issue
Block a user