From 6a5efcc7b848d6e47e05f65fe3fa9306ca0e50c5 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Wed, 13 Oct 2010 12:48:06 -0400 Subject: [PATCH] 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' --- .../config/xml/spring-integration-2.0.xsd | 2 +- ...ionTransformerIntegrationTests-context.xml | 22 +++++++ ...ExpressionTransformerIntegrationTests.java | 61 +++++++++++++++++++ .../transformer/expressions.properties | 1 + 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 spring-integration-core/src/test/java/org/springframework/integration/transformer/DynamicExpressionTransformerIntegrationTests-context.xml create mode 100644 spring-integration-core/src/test/java/org/springframework/integration/transformer/DynamicExpressionTransformerIntegrationTests.java create mode 100644 spring-integration-core/src/test/java/org/springframework/integration/transformer/expressions.properties diff --git a/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-2.0.xsd b/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-2.0.xsd index 32dc2233e0..ba96804367 100644 --- a/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-2.0.xsd +++ b/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-2.0.xsd @@ -2383,7 +2383,7 @@ Name of the header whose value to use. - + The reference to an ExpressionSource. diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/DynamicExpressionTransformerIntegrationTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/transformer/DynamicExpressionTransformerIntegrationTests-context.xml new file mode 100644 index 0000000000..77186977b2 --- /dev/null +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/DynamicExpressionTransformerIntegrationTests-context.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/DynamicExpressionTransformerIntegrationTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/DynamicExpressionTransformerIntegrationTests.java new file mode 100644 index 0000000000..241782fea9 --- /dev/null +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/DynamicExpressionTransformerIntegrationTests.java @@ -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"; + } + } + +} diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/expressions.properties b/spring-integration-core/src/test/java/org/springframework/integration/transformer/expressions.properties new file mode 100644 index 0000000000..77ccc19867 --- /dev/null +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/expressions.properties @@ -0,0 +1 @@ +test.transform=payload.foo + headers.bar \ No newline at end of file