This commit is contained in:
Jonas Partner
2008-11-13 22:11:07 +00:00
parent 6a77b2b642
commit f8aff7d281
5 changed files with 171 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2002-2007 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.endpoint;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.core.Message;
import org.springframework.integration.message.ErrorMessage;
/**
*
* @author Jonas Partner
*
*/
public class PollingEndpointErrorHandlingTests {
@SuppressWarnings("unchecked")
@Test
public void checkExcpetionPlacedOnErrorChannel() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"pollingEndpointErrorHandlingTests.xml", this.getClass());
PollableChannel errorChannel = (PollableChannel) context.getBean("errorChannel");
Message errorMessage = errorChannel.receive(5000);
assertNotNull("No error message received", errorMessage);
assertEquals("Message recevied was not an ErrorMessage" ,ErrorMessage.class,errorMessage.getClass());
}
}

View File

@@ -0,0 +1,25 @@
/*
* Copyright 2002-2007 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.endpoint;
public class PollingEndpointStub extends AbstractPollingEndpoint {
@Override
protected boolean doPoll() {
throw new RuntimeException("Poll failed");
}
}

View File

@@ -0,0 +1,20 @@
<?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:si="http://www.springframework.org/schema/integration"
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-1.0.xsd">
<si:channel id="errorChannel">
<si:queue capacity="10"/>
</si:channel>
<bean id="testEndpoint" class="org.springframework.integration.endpoint.PollingEndpointStub">
<property name="taskExecutor" ref="taskExecutor" />
</bean>
<si:thread-pool-task-executor id="taskExecutor" core-size="1" rejection-policy="CALLER_RUNS"/>
</beans>