added test for async flows to InnerGatewayWithChainTests
This commit is contained in:
@@ -43,5 +43,27 @@
|
||||
<int:gateway request-channel="requestChannelB"/>
|
||||
</int:chain>
|
||||
|
||||
<int:inbound-channel-adapter id="inboundAdapterDefaultErrorChannel" auto-startup="false" expression="5" channel="requestChannelAAAA">
|
||||
<int:poller fixed-rate="2000"/>
|
||||
</int:inbound-channel-adapter>
|
||||
|
||||
<int:chain input-channel="requestChannelAAAA">
|
||||
<int:service-activator expression="1/(payload-5)"/>
|
||||
<int:gateway request-channel="requestChannelB"/>
|
||||
</int:chain>
|
||||
|
||||
<int:inbound-channel-adapter id="inboundAdapterAssignedErrorChannel" auto-startup="false" expression="5" channel="requestChannelAAAA">
|
||||
<int:poller fixed-rate="2000" error-channel="assignedErrorChannel"/>
|
||||
</int:inbound-channel-adapter>
|
||||
|
||||
<int:chain input-channel="requestChannelAAAA">
|
||||
<int:service-activator expression="1/(payload-5)"/>
|
||||
<int:gateway request-channel="requestChannelB"/>
|
||||
</int:chain>
|
||||
|
||||
<int:publish-subscribe-channel id="assignedErrorChannel"/>
|
||||
|
||||
|
||||
<int:service-activator input-channel="requestChannelB" expression="10/payload"/>
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -16,15 +16,24 @@
|
||||
package org.springframework.integration.gateway;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageHandlingException;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.core.SubscribableChannel;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
*
|
||||
@@ -41,6 +50,20 @@ public class InnerGatewayWithChainTests {
|
||||
|
||||
@Autowired
|
||||
private TestGateway testGatewayWithNoErrorChannelAAA;
|
||||
|
||||
@Autowired
|
||||
private SourcePollingChannelAdapter inboundAdapterDefaultErrorChannel;
|
||||
|
||||
@Autowired
|
||||
private SourcePollingChannelAdapter inboundAdapterAssignedErrorChannel;
|
||||
|
||||
@Autowired
|
||||
private SubscribableChannel errorChannel;
|
||||
|
||||
@Autowired
|
||||
private SubscribableChannel assignedErrorChannel;
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testExceptionHandledByMainGateway(){
|
||||
@@ -66,6 +89,26 @@ public class InnerGatewayWithChainTests {
|
||||
testGatewayWithNoErrorChannelAAA.echo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithSPCADefaultErrorChannel() throws Exception{
|
||||
MessageHandler handler = mock(MessageHandler.class);
|
||||
errorChannel.subscribe(handler);
|
||||
inboundAdapterDefaultErrorChannel.start();
|
||||
Thread.sleep(1000);
|
||||
inboundAdapterDefaultErrorChannel.stop();
|
||||
verify(handler, times(1)).handleMessage(Mockito.any(Message.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithSPCAAssignedErrorChannel() throws Exception{
|
||||
MessageHandler handler = mock(MessageHandler.class);
|
||||
assignedErrorChannel.subscribe(handler);
|
||||
inboundAdapterAssignedErrorChannel.start();
|
||||
Thread.sleep(1000);
|
||||
inboundAdapterAssignedErrorChannel.stop();
|
||||
verify(handler, times(1)).handleMessage(Mockito.any(Message.class));
|
||||
}
|
||||
|
||||
public static interface TestGateway{
|
||||
public String echo(int value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user