INT-657 added namespace support for 'discard-channel' on 'filter' elements
This commit is contained in:
@@ -15,6 +15,14 @@
|
||||
<queue capacity="1"/>
|
||||
</channel>
|
||||
|
||||
<channel id="discardOutput">
|
||||
<queue capacity="1"/>
|
||||
</channel>
|
||||
|
||||
<channel id="discardAndExceptionOutput">
|
||||
<queue capacity="1"/>
|
||||
</channel>
|
||||
|
||||
<filter ref="selectorBean" method="hasText" input-channel="adapterInput" output-channel="adapterOutput"/>
|
||||
|
||||
<beans:bean id="selectorBean"
|
||||
@@ -27,4 +35,17 @@
|
||||
<beans:bean id="selectorImpl"
|
||||
class="org.springframework.integration.config.FilterParserTests$TestSelectorImpl"/>
|
||||
|
||||
<filter ref="selectorBean"
|
||||
method="hasText"
|
||||
input-channel="discardInput"
|
||||
output-channel="adapterOutput"
|
||||
discard-channel="discardOutput"/>
|
||||
|
||||
<filter ref="selectorBean"
|
||||
method="hasText"
|
||||
input-channel="discardAndExceptionInput"
|
||||
output-channel="adapterOutput"
|
||||
discard-channel="discardAndExceptionOutput"
|
||||
throw-exception-on-rejection="true"/>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
@@ -57,6 +57,18 @@ public class FilterParserTests {
|
||||
@Autowired @Qualifier("exceptionInput")
|
||||
MessageChannel exceptionInput;
|
||||
|
||||
@Autowired @Qualifier("discardInput")
|
||||
MessageChannel discardInput;
|
||||
|
||||
@Autowired @Qualifier("discardOutput")
|
||||
PollableChannel discardOutput;
|
||||
|
||||
@Autowired @Qualifier("discardAndExceptionInput")
|
||||
MessageChannel discardAndExceptionInput;
|
||||
|
||||
@Autowired @Qualifier("discardAndExceptionOutput")
|
||||
PollableChannel discardAndExceptionOutput;
|
||||
|
||||
|
||||
@Test
|
||||
public void filterWithSelectorAdapterAccepts() {
|
||||
@@ -100,6 +112,31 @@ public class FilterParserTests {
|
||||
exceptionInput.send(new StringMessage(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterWithDiscardChannel() {
|
||||
discardInput.send(new StringMessage(""));
|
||||
Message<?> discard = discardOutput.receive(0);
|
||||
assertNotNull(discard);
|
||||
assertEquals("", discard.getPayload());
|
||||
assertNull(adapterOutput.receive(0));
|
||||
}
|
||||
|
||||
@Test(expected = MessageRejectedException.class)
|
||||
public void filterWithDiscardChannelAndException() throws Exception {
|
||||
Exception exception = null;
|
||||
try {
|
||||
discardAndExceptionInput.send(new StringMessage(""));
|
||||
}
|
||||
catch (Exception e) {
|
||||
exception = e;
|
||||
}
|
||||
Message<?> discard = discardAndExceptionOutput.receive(0);
|
||||
assertNotNull(discard);
|
||||
assertEquals("", discard.getPayload());
|
||||
assertNull(adapterOutput.receive(0));
|
||||
throw exception;
|
||||
}
|
||||
|
||||
|
||||
public static class TestSelectorBean {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user