Added support for the 'throw-exception-on-rejection' attribute for the 'filter' element.

This commit is contained in:
Mark Fisher
2008-11-21 22:52:11 +00:00
parent 2b166d6471
commit b53d96ba1e
4 changed files with 36 additions and 2 deletions

View File

@@ -22,6 +22,8 @@
<filter ref="selectorImpl" input-channel="implementationInput" output-channel="implementationOutput"/>
<filter ref="selectorImpl" input-channel="exceptionInput" output-channel="implementationOutput" throw-exception-on-rejection="true"/>
<beans:bean id="selectorImpl"
class="org.springframework.integration.config.FilterParserTests$TestSelectorImpl"/>

View File

@@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.message.MessageRejectedException;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.selector.MessageSelector;
import org.springframework.test.context.ContextConfiguration;
@@ -53,6 +54,9 @@ public class FilterParserTests {
@Autowired @Qualifier("implementationOutput")
PollableChannel implementationOutput;
@Autowired @Qualifier("exceptionInput")
MessageChannel exceptionInput;
@Test
public void filterWithSelectorAdapterAccepts() {
@@ -84,6 +88,18 @@ public class FilterParserTests {
assertNull(reply);
}
@Test
public void exceptionThrowingFilterAccepts() {
exceptionInput.send(new StringMessage("test"));
Message<?> reply = implementationOutput.receive(0);
assertNotNull(reply);
}
@Test(expected = MessageRejectedException.class)
public void exceptionThrowingFilterRejects() {
exceptionInput.send(new StringMessage(""));
}
public static class TestSelectorBean {