This commit is contained in:
Mark Fisher
2009-12-23 06:45:51 +00:00
parent a4e7fe36e6
commit 18213fcdac
3 changed files with 61 additions and 0 deletions

View File

@@ -27,9 +27,11 @@ import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.core.Message;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.selector.MessageSelector;
/**
* @author Mark Fisher
* @author Grzegorz Grzybek
*/
public class FilterContextTests {
@@ -55,4 +57,34 @@ public class FilterContextTests {
assertEquals("foobar", reply.getPayload());
}
@Test
public void filterWithEmbeddedSelector() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"filterContextTests.xml", this.getClass());
MessageChannel input = (MessageChannel) context.getBean("input-embedded-selector");
PollableChannel output = (PollableChannel) context.getBean("output-embedded-selector");
input.send(new StringMessage("foo"));
Message<?> reply = output.receive(0);
assertNull(reply);
}
@Test
public void filterWithEmbeddedBean() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"filterContextTests.xml", this.getClass());
MessageChannel input = (MessageChannel) context.getBean("input-embedded");
PollableChannel output = (PollableChannel) context.getBean("output-embedded");
input.send(new StringMessage("foo"));
Message<?> reply = output.receive(0);
assertNull(reply);
}
static class TestSelector implements MessageSelector {
public boolean accept(Message<?> message) {
return false;
}
}
}

View File

@@ -19,5 +19,28 @@
output-channel="output"/>
<beans:bean id="testBean" class="org.springframework.integration.filter.TestBean"/>
<channel id="input-embedded-selector"/>
<channel id="output-embedded-selector">
<queue capacity="50"/>
</channel>
<filter input-channel="input-embedded-selector"
output-channel="output-embedded-selector">
<beans:bean class="org.springframework.integration.filter.FilterContextTests$TestSelector" />
</filter>
<channel id="input-embedded"/>
<channel id="output-embedded">
<queue capacity="50"/>
</channel>
<filter input-channel="input-embedded"
method="acceptStringWithMoreThanThreeChars"
output-channel="output-embedded">
<beans:bean class="org.springframework.integration.filter.TestBean" />
</filter>
</beans:beans>