INT-1859 added namespace support for exception-type-router
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd">
|
||||
|
||||
|
||||
<int:exception-type-router input-channel="inChannel" default-output-channel="outputChannel">
|
||||
<int:mapping exception-type="java.lang.NullPointerException" channel="nullPointerChannel"/>
|
||||
<int:mapping exception-type="java.lang.IllegalArgumentException" channel="illegalArgumentChannel"/>
|
||||
</int:exception-type-router>
|
||||
|
||||
<int:channel id="nullPointerChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
<int:channel id="illegalArgumentChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
<int:channel id="outputChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2002-2011 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.router.config;
|
||||
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
*
|
||||
*/
|
||||
public class ExceptionTypeRouterParserTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testExceptionTypeRouterConfig(){
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("ExceptionTypeRouterParserTests-context.xml", this.getClass());
|
||||
MessageChannel inputChannel = context.getBean("inChannel", MessageChannel.class);
|
||||
|
||||
inputChannel.send(new GenericMessage<Throwable>(new NullPointerException()));
|
||||
QueueChannel nullPointerChannel = context.getBean("nullPointerChannel", QueueChannel.class);
|
||||
Message<Throwable> npeMessage = (Message<Throwable>) nullPointerChannel.receive(1000);
|
||||
assertNotNull(npeMessage);
|
||||
assertTrue(npeMessage.getPayload() instanceof NullPointerException);
|
||||
|
||||
inputChannel.send(new GenericMessage<Throwable>(new IllegalArgumentException()));
|
||||
QueueChannel illegalArgumentChannel = context.getBean("illegalArgumentChannel", QueueChannel.class);
|
||||
Message<Throwable> iaMessage = (Message<Throwable>) illegalArgumentChannel.receive(1000);
|
||||
assertNotNull(iaMessage);
|
||||
assertTrue(iaMessage.getPayload() instanceof IllegalArgumentException);
|
||||
|
||||
inputChannel.send(new GenericMessage<String>("Hello"));
|
||||
QueueChannel outputChannel = context.getBean("outputChannel", QueueChannel.class);
|
||||
assertNotNull(outputChannel.receive(1000));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user