INT-1382 added tests for DynamicExpression-based transformer, and the default bean name for the ExpressionSource instance is now defined in the XSD as 'expressionSource'

This commit is contained in:
Mark Fisher
2010-10-13 12:48:06 -04:00
parent 4a8984bc0a
commit 6a5efcc7b8
4 changed files with 85 additions and 1 deletions

View File

@@ -2383,7 +2383,7 @@ Name of the header whose value to use.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="source" type="xsd:string" use="required">
<xsd:attribute name="source" type="xsd:string" default="expressionSource">
<xsd:annotation>
<xsd:documentation>
The reference to an ExpressionSource.

View File

@@ -0,0 +1,22 @@
<?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>
<transformer input-channel="input" output-channel="output">
<expression key="test.transform"/>
</transformer>
<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,61 @@
/*
* 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 DynamicExpressionTransformerIntegrationTests {
@Autowired
private MessageChannel input;
@Autowired
private PollableChannel output;
@Test
public void transformWithDynamicExpression() {
Message<?> message = MessageBuilder.withPayload(new TestBean()).setHeader("bar", 123).build();
this.input.send(message);
Message<?> result = output.receive(0);
assertEquals("test123", result.getPayload());
}
static class TestBean {
public String getFoo() {
return "test";
}
}
}

View File

@@ -0,0 +1 @@
test.transform=payload.foo + headers.bar