INT-1029: Support for outbound-gateways in chain
XSD refactoring: remove use="required" from 'request-channel' attribute of all 'outbound-gateways' Tests for all 'outbound-gateways' inside the <chain>
This commit is contained in:
committed by
Oleg Zhurakousky
parent
c3860e14b7
commit
5bc41bc60b
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -16,29 +16,52 @@
|
||||
|
||||
package org.springframework.integration.ws;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
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.core.PollableChannel;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
import org.springframework.ws.WebServiceMessageFactory;
|
||||
import org.springframework.ws.client.core.WebServiceMessageCallback;
|
||||
import org.springframework.ws.client.support.destination.DestinationProvider;
|
||||
import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.SoapMessageFactory;
|
||||
import org.springframework.ws.transport.WebServiceConnection;
|
||||
import org.springframework.ws.transport.WebServiceMessageSender;
|
||||
import org.springframework.xml.namespace.QNameUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @since 2.0
|
||||
*/
|
||||
public class SimpleWebServiceOutboundGatewayTests {
|
||||
|
||||
private static final String response = "<response><name>Test Name</name></response>";
|
||||
|
||||
private static final String responseSoapMessage = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> " +
|
||||
"<soap:Body> " +
|
||||
response +
|
||||
"</soap:Body> " +
|
||||
"</soap:Envelope>";
|
||||
|
||||
@Test // INT-1051
|
||||
public void soapActionAndCustomCallback() {
|
||||
String uri = "http://www.example.org";
|
||||
@@ -66,6 +89,32 @@ public class SimpleWebServiceOutboundGatewayTests {
|
||||
}
|
||||
|
||||
|
||||
@Test //INT-1029
|
||||
public void testWsOutboundGatewayInsideChain() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("WebServiceOutboundGatewayInsideChainTests-context.xml", this.getClass());
|
||||
MessageChannel channel = context.getBean("wsOutboundGatewayInsideChain", MessageChannel.class);
|
||||
channel.send(MessageBuilder.withPayload("<test>foo</test>").build());
|
||||
PollableChannel replyChannel = context.getBean("replyChannel", PollableChannel.class);
|
||||
Message<?> replyMessage = replyChannel.receive();
|
||||
assertThat(replyMessage.getPayload().toString(), Matchers.endsWith(response));
|
||||
}
|
||||
|
||||
public static WebServiceMessageSender createMockMessageSender() throws Exception {
|
||||
WebServiceMessageSender messageSender = Mockito.mock(WebServiceMessageSender.class);
|
||||
WebServiceConnection wsConnection = Mockito.mock(WebServiceConnection.class);
|
||||
Mockito.when(messageSender.createConnection(Mockito.any(URI.class))).thenReturn(wsConnection);
|
||||
Mockito.when(messageSender.supports(Mockito.any(URI.class))).thenReturn(true);
|
||||
|
||||
Mockito.doAnswer(new Answer() {
|
||||
public Object answer(InvocationOnMock invocation) throws Exception{
|
||||
Object[] args = invocation.getArguments();
|
||||
WebServiceMessageFactory factory = (WebServiceMessageFactory) args[0];
|
||||
return factory.createWebServiceMessage(new ByteArrayInputStream(responseSoapMessage.getBytes()));
|
||||
}}).when(wsConnection).receive(Mockito.any(WebServiceMessageFactory.class));
|
||||
|
||||
return messageSender;
|
||||
}
|
||||
|
||||
private static class TestDestinationProvider implements DestinationProvider {
|
||||
|
||||
private final URI uri;
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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"
|
||||
xmlns:ws="http://www.springframework.org/schema/integration/ws"
|
||||
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.xsd
|
||||
http://www.springframework.org/schema/integration/ws
|
||||
http://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd">
|
||||
|
||||
<si:channel id="replyChannel">
|
||||
<si:queue/>
|
||||
</si:channel>
|
||||
|
||||
<si:chain input-channel="wsOutboundGatewayInsideChain" output-channel="replyChannel">
|
||||
<ws:outbound-gateway uri="http://test.example.org"
|
||||
message-sender="mockMessageSender"/>
|
||||
</si:chain>
|
||||
|
||||
<bean id="mockMessageSender" class="org.springframework.integration.ws.SimpleWebServiceOutboundGatewayTests"
|
||||
factory-method="createMockMessageSender"/>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user