diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/FilterParserTests-context.xml b/org.springframework.integration/src/test/java/org/springframework/integration/config/FilterParserTests-context.xml new file mode 100644 index 0000000000..23fd805dfd --- /dev/null +++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/FilterParserTests-context.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/FilterParserTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/FilterParserTests.java new file mode 100644 index 0000000000..86579f340d --- /dev/null +++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/FilterParserTests.java @@ -0,0 +1,73 @@ +/* + * Copyright 2002-2008 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.config; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +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.channel.MessageChannel; +import org.springframework.integration.channel.PollableChannel; +import org.springframework.integration.message.Message; +import org.springframework.integration.message.StringMessage; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.util.StringUtils; + +/** + * @author Mark Fisher + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration +public class FilterParserTests { + + @Autowired @Qualifier("input") + MessageChannel input; + + @Autowired @Qualifier("output") + PollableChannel output; + + + @Test + public void filterAccepts() { + input.send(new StringMessage("test")); + Message reply = output.receive(0); + assertNotNull(reply); + assertEquals("test", reply.getPayload()); + } + + @Test + public void filterRejects() { + input.send(new StringMessage("")); + Message reply = output.receive(0); + assertNull(reply); + } + + + public static class TestSelector { + + public boolean hasText(String s) { + return StringUtils.hasText(s); + } + } + +}