INT-1382 added support for expression sub-elements for header-enricher

This commit is contained in:
Mark Fisher
2010-10-13 16:21:03 -04:00
parent 6c053a9e11
commit 7b70e3dcfe
5 changed files with 105 additions and 4 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd">
<channel id="output">
<queue/>
</channel>
<header-enricher input-channel="input" output-channel="output">
<header name="testHeader">
<expression key="test.header"/>
</header>
</header-enricher>
<beans:bean id="expressionSource" class="org.springframework.integration.expression.ReloadableResourceBundleExpressionSource">
<beans:property name="basename" value="org/springframework/integration/transformer/expressions"/>
</beans:bean>
</beans:beans>

View File

@@ -0,0 +1,53 @@
/*
* Copyright 2002-2010 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.transformer;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class DynamicExpressionHeaderEnricherIntegrationTests {
@Autowired
private MessageChannel input;
@Autowired
private PollableChannel output;
@Test
public void dynamicExpressionHeader() {
Message<?> message = MessageBuilder.withPayload("test").build();
this.input.send(message);
Message<?> result = output.receive(0);
assertEquals("foo", result.getHeaders().get("testHeader"));
}
}

View File

@@ -1 +1,2 @@
test.transform=payload.foo + headers.bar
test.transform=payload.foo + headers.bar
test.header='foo'