INT-752 added test to validate sample from JIRA

This commit is contained in:
Oleg Zhurakousky
2011-05-17 10:07:11 -04:00
parent a494414b64
commit 58a1af7f4e
2 changed files with 33 additions and 0 deletions

View File

@@ -27,5 +27,11 @@
<bean class="org.springframework.integration.config.xml.PNamespaceTests$TestBean"
p:fname="paris" p:lname="hilton"/>
</si:router>
<si:chain id="sampleChain" input-channel="input">
<si:aggregator >
<bean class="org.springframework.integration.config.xml.PNamespaceTests.SampleAggregator" p:name="Bill"/>
</si:aggregator>
</si:chain>
</beans>

View File

@@ -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;
}
}
}