From 58a1af7f4ed9aede989f97537d6267bc33f7e092 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 17 May 2011 10:07:11 -0400 Subject: [PATCH] INT-752 added test to validate sample from JIRA --- .../config/xml/PNamespaceTests-context.xml | 6 +++++ .../config/xml/PNamespaceTests.java | 27 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PNamespaceTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PNamespaceTests-context.xml index 284151ebbc..8da4994635 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PNamespaceTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PNamespaceTests-context.xml @@ -27,5 +27,11 @@ + + + + + + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PNamespaceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PNamespaceTests.java index ef5456281e..bf55c69029 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PNamespaceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/PNamespaceTests.java @@ -18,11 +18,14 @@ package org.springframework.integration.config.xml; import static org.junit.Assert.assertEquals; +import java.util.List; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.integration.aggregator.CorrelatingMessageHandler; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.test.util.TestUtils; import org.springframework.test.context.ContextConfiguration; @@ -52,6 +55,10 @@ public class PNamespaceTests { @Autowired @Qualifier("tr") EventDrivenConsumer transformer; + + @Autowired + @Qualifier("sampleChain") + EventDrivenConsumer sampleChain; @Test @@ -81,6 +88,15 @@ public class PNamespaceTests { assertEquals("paris", bean.getFname()); assertEquals("hilton", bean.getLname()); } + + @Test + public void testPNamespaceChain() { + List handlers = (List) TestUtils.getPropertyValue(sampleChain, "handler.handlers"); + CorrelatingMessageHandler handler = (CorrelatingMessageHandler) handlers.get(0); + SampleAggregator aggregator = + (SampleAggregator) TestUtils.getPropertyValue(handler, "outputProcessor.processor.delegate.targetObject"); + assertEquals("Bill", aggregator.getName()); + } private TestBean prepare(EventDrivenConsumer edc) { @@ -125,4 +141,15 @@ public class PNamespaceTests { } } + public static class SampleAggregator { + private String name; + public SampleAggregator(){} + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } }