INT-2893: fix chain -> router -> bean or script

* add XSD element for nested router type
* add tests on the matter
* polishing for RouterParserTests

JIRA: https://jira.springsource.org/browse/INT-2893

INT-2893: Polishing

INT-2893: after rebasing to 3.0

XSD changes reverted from 2.2 and moved to 3.0

INT-2893 Polishing

Factor out common elements; fixing missing documentation for
`expression` within a `router` within a `chain`.
This commit is contained in:
Artem Bilan
2013-01-23 15:39:09 +02:00
committed by Gary Russell
parent 90c54c5f74
commit dc59207df2
8 changed files with 247 additions and 155 deletions

View File

@@ -23,10 +23,21 @@
<router input-channel="inlineScriptInput">
<int-script:script lang="javascript"><![CDATA[
(function(){
return payload.length > 5 ? "longStrings" : "shortStrings";
})();
(function(){
return payload.length > 5 ? "longStrings" : "shortStrings";
})();
]]></int-script:script>
</router>
<chain input-channel="scriptRouterWithinChainInput">
<router>
<int-script:script lang="javascript"><![CDATA[
(function(){
return payload.length > 5 ? "longStrings" : "shortStrings";
})();
]]></int-script:script>
</router>
</chain>
</beans:beans>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2013 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.
@@ -33,6 +33,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Mark Fisher
* @author David Turanski
* @author Artem Bilan
* @since 2.1
*/
@ContextConfiguration
@@ -45,6 +46,9 @@ public class Jsr223RouterTests {
@Autowired
private MessageChannel inlineScriptInput;
@Autowired
private MessageChannel scriptRouterWithinChainInput;
@Autowired
private PollableChannel longStrings;
@@ -94,4 +98,25 @@ public class Jsr223RouterTests {
assertNull(longStrings.receive(0));
}
@Test
public void testInt2893ScriptRouterWithinChain() {
Message<?> message1 = new GenericMessage<String>("aardvark");
Message<?> message2 = new GenericMessage<String>("bear");
Message<?> message3 = new GenericMessage<String>("cat");
Message<?> message4 = new GenericMessage<String>("dog");
Message<?> message5 = new GenericMessage<String>("elephant");
this.scriptRouterWithinChainInput.send(message1);
this.scriptRouterWithinChainInput.send(message2);
this.scriptRouterWithinChainInput.send(message3);
this.scriptRouterWithinChainInput.send(message4);
this.scriptRouterWithinChainInput.send(message5);
assertEquals("bear", shortStrings.receive(0).getPayload());
assertEquals("cat", shortStrings.receive(0).getPayload());
assertEquals("dog", shortStrings.receive(0).getPayload());
assertEquals("aardvark", longStrings.receive(0).getPayload());
assertEquals("elephant", longStrings.receive(0).getPayload());
assertNull(shortStrings.receive(0));
assertNull(longStrings.receive(0));
}
}