Added namespace support for creating a MessageSelectorChain (INT-227).

This commit is contained in:
Mark Fisher
2008-06-24 21:11:30 +00:00
parent bacc093ca0
commit 00436b9071
6 changed files with 181 additions and 1 deletions

View File

@@ -0,0 +1,50 @@
/*
* 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 java.util.List;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.message.selector.MessageSelector;
import org.springframework.integration.message.selector.MessageSelectorChain;
/**
* @author Mark Fisher
*/
public class SelectorChainParserTests {
@Test
@SuppressWarnings("unchecked")
public void testSelectorChain() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"selectorChainParserTests.xml", this.getClass());
MessageSelector selector1 = (MessageSelector) context.getBean("selector1");
MessageSelector selector2 = (MessageSelector) context.getBean("selector2");
MessageSelectorChain chain = (MessageSelectorChain) context.getBean("selectorChain");
DirectFieldAccessor accessor = new DirectFieldAccessor(chain);
List<MessageSelector> selectors = (List<MessageSelector>)
accessor.getPropertyValue("selectors");
assertEquals(selector1, selectors.get(0));
assertEquals(selector2, selectors.get(1));
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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 org.springframework.integration.message.Message;
import org.springframework.integration.message.selector.MessageSelector;
/**
* @author Mark Fisher
*/
public class StubMessageSelector implements MessageSelector {
public boolean accept(Message<?> message) {
return true;
}
}

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-core-1.0.xsd">
<selector-chain id="selectorChain">
<selector ref="selector1"/>
<selector ref="selector2"/>
</selector-chain>
<beans:bean id="selector1" class="org.springframework.integration.config.StubMessageSelector"/>
<beans:bean id="selector2" class="org.springframework.integration.config.StubMessageSelector"/>
</beans:beans>