INT-1257, changed convinience method to MessageHistory.containsComponent(string), added/modified tests in XML, WS, JMS to validate MessageHistory
This commit is contained in:
@@ -88,7 +88,7 @@ public class MessageHistory implements List<Properties> {
|
|||||||
return this.components.contains(o);
|
return this.components.contains(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsEntryWithName(String name) {
|
public boolean containsComponent(String name) {
|
||||||
for (Properties properties : components) {
|
for (Properties properties : components) {
|
||||||
if (properties.getProperty("name").equals(name)){
|
if (properties.getProperty("name").equals(name)){
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.springframework.integration.jms.config;
|
package org.springframework.integration.jms.config;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertTrue;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
|||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
import org.springframework.integration.Message;
|
import org.springframework.integration.Message;
|
||||||
import org.springframework.integration.core.PollableChannel;
|
import org.springframework.integration.core.PollableChannel;
|
||||||
|
import org.springframework.integration.history.MessageHistory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
@@ -41,6 +43,8 @@ public class JmsInboundChannelAdapterParserTests {
|
|||||||
"jmsInboundWithJmsTemplate.xml", this.getClass());
|
"jmsInboundWithJmsTemplate.xml", this.getClass());
|
||||||
PollableChannel output = (PollableChannel) context.getBean("output");
|
PollableChannel output = (PollableChannel) context.getBean("output");
|
||||||
Message<?> message = output.receive(timeoutOnReceive);
|
Message<?> message = output.receive(timeoutOnReceive);
|
||||||
|
MessageHistory history = MessageHistory.read(message);
|
||||||
|
assertTrue(history.containsComponent("inboundAdapter"));
|
||||||
assertNotNull("message should not be null", message);
|
assertNotNull("message should not be null", message);
|
||||||
assertEquals("polling-test", message.getPayload());
|
assertEquals("polling-test", message.getPayload());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ import org.springframework.beans.factory.BeanDefinitionStoreException;
|
|||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
import org.springframework.integration.Message;
|
import org.springframework.integration.Message;
|
||||||
import org.springframework.integration.core.PollableChannel;
|
import org.springframework.integration.core.PollableChannel;
|
||||||
|
import org.springframework.integration.history.HistoryWritingMessagePostProcessor;
|
||||||
|
import org.springframework.integration.history.MessageHistory;
|
||||||
import org.springframework.integration.jms.JmsMessageDrivenEndpoint;
|
import org.springframework.integration.jms.JmsMessageDrivenEndpoint;
|
||||||
import org.springframework.jms.connection.JmsTransactionManager;
|
import org.springframework.jms.connection.JmsTransactionManager;
|
||||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||||
@@ -49,6 +51,8 @@ public class JmsInboundGatewayParserTests {
|
|||||||
assertEquals(JmsMessageDrivenEndpoint.class, gateway.getClass());
|
assertEquals(JmsMessageDrivenEndpoint.class, gateway.getClass());
|
||||||
context.start();
|
context.start();
|
||||||
Message<?> message = channel.receive(3000);
|
Message<?> message = channel.receive(3000);
|
||||||
|
MessageHistory history = MessageHistory.read(message);
|
||||||
|
assertTrue(history.containsComponent("jmsGateway"));
|
||||||
assertNotNull("message should not be null", message);
|
assertNotNull("message should not be null", message);
|
||||||
assertEquals("message-driven-test", message.getPayload());
|
assertEquals("message-driven-test", message.getPayload());
|
||||||
context.stop();
|
context.stop();
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.springframework.integration.jms.config;
|
package org.springframework.integration.jms.config;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertTrue;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ import org.springframework.beans.DirectFieldAccessor;
|
|||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
import org.springframework.integration.Message;
|
import org.springframework.integration.Message;
|
||||||
import org.springframework.integration.core.PollableChannel;
|
import org.springframework.integration.core.PollableChannel;
|
||||||
|
import org.springframework.integration.history.MessageHistory;
|
||||||
import org.springframework.integration.jms.JmsMessageDrivenEndpoint;
|
import org.springframework.integration.jms.JmsMessageDrivenEndpoint;
|
||||||
import org.springframework.jms.support.destination.JmsDestinationAccessor;
|
import org.springframework.jms.support.destination.JmsDestinationAccessor;
|
||||||
|
|
||||||
@@ -41,6 +43,8 @@ public class JmsMessageDrivenChannelAdapterParserTests {
|
|||||||
"jmsInboundWithMessageSelector.xml", this.getClass());
|
"jmsInboundWithMessageSelector.xml", this.getClass());
|
||||||
PollableChannel output = (PollableChannel) context.getBean("output2");
|
PollableChannel output = (PollableChannel) context.getBean("output2");
|
||||||
Message<?> message = output.receive(timeoutOnReceive);
|
Message<?> message = output.receive(timeoutOnReceive);
|
||||||
|
MessageHistory history = MessageHistory.read(message);
|
||||||
|
assertTrue(history.containsComponent("messageDrivenAdapter"));
|
||||||
assertNotNull("message should not be null", message);
|
assertNotNull("message should not be null", message);
|
||||||
assertEquals("test [with selector: TestProperty = 'foo']", message.getPayload());
|
assertEquals("test [with selector: TestProperty = 'foo']", message.getPayload());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,23 @@ package org.springframework.integration.jms.config;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import org.springframework.beans.DirectFieldAccessor;
|
import org.springframework.beans.DirectFieldAccessor;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
|
import org.springframework.integration.Message;
|
||||||
|
import org.springframework.integration.MessageChannel;
|
||||||
|
import org.springframework.integration.MessagingException;
|
||||||
|
import org.springframework.integration.core.MessageHandler;
|
||||||
|
import org.springframework.integration.core.MessagingTemplate;
|
||||||
|
import org.springframework.integration.core.SubscribableChannel;
|
||||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||||
import org.springframework.integration.endpoint.PollingConsumer;
|
import org.springframework.integration.endpoint.PollingConsumer;
|
||||||
|
import org.springframework.integration.history.MessageHistory;
|
||||||
import org.springframework.integration.jms.JmsOutboundGateway;
|
import org.springframework.integration.jms.JmsOutboundGateway;
|
||||||
import org.springframework.integration.jms.StubMessageConverter;
|
import org.springframework.integration.jms.StubMessageConverter;
|
||||||
import org.springframework.jms.support.converter.MessageConverter;
|
import org.springframework.jms.support.converter.MessageConverter;
|
||||||
@@ -57,16 +68,26 @@ public class JmsOutboundGatewayParserTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void gatewayMaintainsReplyChannel() {
|
public void gatewayMaintainsReplyChannelAndInboundHistory() {
|
||||||
ActiveMqTestUtils.prepare();
|
ActiveMqTestUtils.prepare();
|
||||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||||
"gatewayMaintainsReplyChannel.xml", this.getClass());
|
"gatewayMaintainsReplyChannel.xml", this.getClass());
|
||||||
SampleGateway gateway = context.getBean("gateway", SampleGateway.class);
|
SampleGateway gateway = context.getBean("gateway", SampleGateway.class);
|
||||||
|
SubscribableChannel jmsInput = context.getBean("jmsInput", SubscribableChannel.class);
|
||||||
|
MessageHandler handler = new MessageHandler() {
|
||||||
|
public void handleMessage(Message<?> message) throws MessagingException {
|
||||||
|
MessageHistory history = MessageHistory.read(message);
|
||||||
|
assertTrue(history.containsComponent("inboundGateway"));
|
||||||
|
new MessagingTemplate((MessageChannel) message.getHeaders().getReplyChannel()).send(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
handler = spy(handler);
|
||||||
|
jmsInput.subscribe(handler);
|
||||||
String result = gateway.echo("hello");
|
String result = gateway.echo("hello");
|
||||||
assertEquals("HELLO", result);
|
verify(handler, times(1)).handleMessage(Mockito.any(Message.class));
|
||||||
|
assertEquals("hello", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static interface SampleGateway{
|
public static interface SampleGateway{
|
||||||
public String echo(String value);
|
public String echo(String value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,20 +7,25 @@
|
|||||||
xmlns:int="http://www.springframework.org/schema/integration"
|
xmlns:int="http://www.springframework.org/schema/integration"
|
||||||
xmlns:int-jms="http://www.springframework.org/schema/integration/jms">
|
xmlns:int-jms="http://www.springframework.org/schema/integration/jms">
|
||||||
|
|
||||||
|
<int:message-history/>
|
||||||
|
|
||||||
<int:gateway id="gateway"
|
<int:gateway id="gateway"
|
||||||
service-interface="org.springframework.integration.jms.config.JmsOutboundGatewayParserTests$SampleGateway"
|
service-interface="org.springframework.integration.jms.config.JmsOutboundGatewayParserTests$SampleGateway"
|
||||||
default-request-channel="requests">
|
default-request-channel="requests">
|
||||||
<int:method name="echo">
|
<int:method name="echo">
|
||||||
<int:header name="foo" value="bar"/>
|
<int:header name="foo" value="bar"/>
|
||||||
</int:method>
|
</int:method>
|
||||||
|
<int:method name="echoAsMaessage">
|
||||||
|
<int:header name="foo" value="bar"/>
|
||||||
|
</int:method>
|
||||||
</int:gateway>
|
</int:gateway>
|
||||||
|
|
||||||
<int:chain input-channel="requests">
|
<int:chain input-channel="requests">
|
||||||
<int-jms:outbound-gateway request-destination="requestQueueA"
|
<int-jms:outbound-gateway request-destination="requestQueueA"
|
||||||
reply-destination="replyQueueB"
|
reply-destination="replyQueueB"
|
||||||
connection-factory="connectionFactory"
|
connection-factory="connectionFactory"
|
||||||
receive-timeout="10000"
|
receive-timeout="100000"
|
||||||
reply-timeout="20000"/>
|
reply-timeout="200000"/>
|
||||||
</int:chain>
|
</int:chain>
|
||||||
|
|
||||||
|
|
||||||
@@ -44,11 +49,11 @@
|
|||||||
<property name="cacheProducers" value="false"/>
|
<property name="cacheProducers" value="false"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<int-jms:inbound-gateway request-channel="jmsInput" request-destination="requestQueueA"/>
|
<int-jms:inbound-gateway id="inboundGateway" request-channel="jmsInput" request-destination="requestQueueA"/>
|
||||||
|
|
||||||
<int:channel id="jmsInput"/>
|
<int:channel id="jmsInput"/>
|
||||||
|
|
||||||
<int:service-activator input-channel="jmsInput">
|
<!-- <int:service-activator input-channel="jmsInput">-->
|
||||||
<bean class="org.springframework.integration.jms.config.JmsOutboundGatewayParserTests$SampleService"/>
|
<!-- <bean class="org.springframework.integration.jms.config.JmsOutboundGatewayParserTests$SampleService"/>-->
|
||||||
</int:service-activator>
|
<!-- </int:service-activator>-->
|
||||||
</beans>
|
</beans>
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
http://www.springframework.org/schema/integration/jms
|
http://www.springframework.org/schema/integration/jms
|
||||||
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
|
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
|
||||||
|
|
||||||
|
<si:message-history/>
|
||||||
|
|
||||||
<si:channel id="requestChannel">
|
<si:channel id="requestChannel">
|
||||||
<si:queue/>
|
<si:queue/>
|
||||||
</si:channel>
|
</si:channel>
|
||||||
|
|||||||
@@ -10,7 +10,9 @@
|
|||||||
http://www.springframework.org/schema/integration/jms
|
http://www.springframework.org/schema/integration/jms
|
||||||
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
|
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
|
||||||
|
|
||||||
<jms:inbound-channel-adapter jms-template="jmsTemplate" channel="output"/>
|
<integration:message-history/>
|
||||||
|
|
||||||
|
<jms:inbound-channel-adapter id="inboundAdapter" jms-template="jmsTemplate" channel="output"/>
|
||||||
|
|
||||||
<integration:channel id="output">
|
<integration:channel id="output">
|
||||||
<integration:queue capacity="1"/>
|
<integration:queue capacity="1"/>
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
http://www.springframework.org/schema/integration/jms
|
http://www.springframework.org/schema/integration/jms
|
||||||
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
|
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd">
|
||||||
|
|
||||||
|
<si:message-history/>
|
||||||
|
|
||||||
<si:channel id="output1">
|
<si:channel id="output1">
|
||||||
<si:queue capacity="1"/>
|
<si:queue capacity="1"/>
|
||||||
</si:channel>
|
</si:channel>
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.springframework.expression.ExpressionException;
|
|||||||
import org.springframework.integration.MessageChannel;
|
import org.springframework.integration.MessageChannel;
|
||||||
import org.springframework.integration.MessagingException;
|
import org.springframework.integration.MessagingException;
|
||||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||||
|
import org.springframework.integration.history.TrackableComponent;
|
||||||
import org.springframework.oxm.Marshaller;
|
import org.springframework.oxm.Marshaller;
|
||||||
import org.springframework.oxm.Unmarshaller;
|
import org.springframework.oxm.Unmarshaller;
|
||||||
import org.springframework.scheduling.TaskScheduler;
|
import org.springframework.scheduling.TaskScheduler;
|
||||||
@@ -37,13 +38,12 @@ import org.springframework.ws.server.endpoint.AbstractMarshallingPayloadEndpoint
|
|||||||
* @since 1.0.2
|
* @since 1.0.2
|
||||||
*/
|
*/
|
||||||
public class MarshallingWebServiceInboundGateway extends AbstractMarshallingPayloadEndpoint
|
public class MarshallingWebServiceInboundGateway extends AbstractMarshallingPayloadEndpoint
|
||||||
implements BeanNameAware, BeanFactoryAware, InitializingBean, SmartLifecycle {
|
implements BeanNameAware, BeanFactoryAware, InitializingBean, SmartLifecycle, TrackableComponent {
|
||||||
|
|
||||||
private final ReentrantLock lifecycleLock = new ReentrantLock();
|
private final ReentrantLock lifecycleLock = new ReentrantLock();
|
||||||
|
|
||||||
private final GatewayDelegate gatewayDelegate = new GatewayDelegate();
|
private final GatewayDelegate gatewayDelegate = new GatewayDelegate();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new <code>MarshallingWebServiceInboundGateway</code>.
|
* Creates a new <code>MarshallingWebServiceInboundGateway</code>.
|
||||||
* The {@link Marshaller} and {@link Unmarshaller} must be injected using properties.
|
* The {@link Marshaller} and {@link Unmarshaller} must be injected using properties.
|
||||||
@@ -196,4 +196,15 @@ public class MarshallingWebServiceInboundGateway extends AbstractMarshallingPayl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getComponentName() {
|
||||||
|
return this.gatewayDelegate.getComponentName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComponentType() {
|
||||||
|
return this.gatewayDelegate.getComponentType();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShouldTrack(boolean shouldTrack) {
|
||||||
|
this.gatewayDelegate.setShouldTrack(shouldTrack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,14 @@
|
|||||||
|
|
||||||
package org.springframework.integration.ws.config;
|
package org.springframework.integration.ws.config;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import javax.xml.transform.Source;
|
||||||
|
|
||||||
import org.springframework.ws.WebServiceMessage;
|
import org.springframework.ws.WebServiceMessage;
|
||||||
import org.springframework.ws.WebServiceMessageFactory;
|
import org.springframework.ws.WebServiceMessageFactory;
|
||||||
|
|
||||||
@@ -28,7 +33,10 @@ import org.springframework.ws.WebServiceMessageFactory;
|
|||||||
public class StubMessageFactory implements WebServiceMessageFactory {
|
public class StubMessageFactory implements WebServiceMessageFactory {
|
||||||
|
|
||||||
public WebServiceMessage createWebServiceMessage() {
|
public WebServiceMessage createWebServiceMessage() {
|
||||||
return null;
|
WebServiceMessage message = mock(WebServiceMessage.class);
|
||||||
|
Source source = mock(Source.class);
|
||||||
|
when(message.getPayloadSource()).thenReturn(source);
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebServiceMessage createWebServiceMessage(InputStream inputStream) throws IOException {
|
public WebServiceMessage createWebServiceMessage(InputStream inputStream) throws IOException {
|
||||||
|
|||||||
@@ -12,14 +12,24 @@
|
|||||||
http://www.springframework.org/schema/util
|
http://www.springframework.org/schema/util
|
||||||
http://www.springframework.org/schema/util/spring-util.xsd">
|
http://www.springframework.org/schema/util/spring-util.xsd">
|
||||||
|
|
||||||
<ws:inbound-gateway id="simple" request-channel="requests" />
|
<si:message-history/>
|
||||||
|
|
||||||
<ws:inbound-gateway id="extractsPayload" request-channel="requests" extract-payload="false"/>
|
<ws:inbound-gateway id="simple" request-channel="requestsVerySimple" />
|
||||||
|
|
||||||
<ws:inbound-gateway id="marshalling" request-channel="requests"
|
<si:channel id="requestsVerySimple"></si:channel>
|
||||||
|
|
||||||
|
<ws:inbound-gateway id="extractsPayload" request-channel="requestsSimple" extract-payload="false"/>
|
||||||
|
|
||||||
|
<ws:inbound-gateway id="marshalling" request-channel="requestsMarshalling"
|
||||||
marshaller="marshaller" unmarshaller="marshaller" />
|
marshaller="marshaller" unmarshaller="marshaller" />
|
||||||
|
|
||||||
<si:channel id="requests" />
|
<si:channel id="requestsMarshalling">
|
||||||
|
<si:queue/>
|
||||||
|
</si:channel>
|
||||||
|
|
||||||
|
<si:channel id="requestsSimple">
|
||||||
|
<si:queue/>
|
||||||
|
</si:channel>
|
||||||
|
|
||||||
<bean id="marshaller" class="org.mockito.Mockito" factory-method="mock">
|
<bean id="marshaller" class="org.mockito.Mockito" factory-method="mock">
|
||||||
<constructor-arg value="org.springframework.oxm.AbstractMarshaller" />
|
<constructor-arg value="org.springframework.oxm.AbstractMarshaller" />
|
||||||
|
|||||||
@@ -15,25 +15,39 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.integration.ws.config;
|
package org.springframework.integration.ws.config;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertTrue;
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static junit.framework.Assert.assertTrue;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
import javax.xml.transform.Source;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
|
import org.mockito.stubbing.Answer;
|
||||||
import org.springframework.beans.DirectFieldAccessor;
|
import org.springframework.beans.DirectFieldAccessor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.integration.Message;
|
||||||
import org.springframework.integration.MessageChannel;
|
import org.springframework.integration.MessageChannel;
|
||||||
|
import org.springframework.integration.core.PollableChannel;
|
||||||
|
import org.springframework.integration.history.MessageHistory;
|
||||||
import org.springframework.integration.ws.MarshallingWebServiceInboundGateway;
|
import org.springframework.integration.ws.MarshallingWebServiceInboundGateway;
|
||||||
import org.springframework.integration.ws.SimpleWebServiceInboundGateway;
|
import org.springframework.integration.ws.SimpleWebServiceInboundGateway;
|
||||||
import org.springframework.oxm.AbstractMarshaller;
|
import org.springframework.oxm.AbstractMarshaller;
|
||||||
|
import org.springframework.oxm.Unmarshaller;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
import org.springframework.ws.context.DefaultMessageContext;
|
||||||
|
import org.springframework.ws.context.MessageContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Iwein Fuld
|
* @author Iwein Fuld
|
||||||
|
* @author Oleg Zhurakousky
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@@ -41,8 +55,16 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||||||
public class WebServiceInboundGatewayParserTests {
|
public class WebServiceInboundGatewayParserTests {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier("requests")
|
@Qualifier("requestsMarshalling")
|
||||||
MessageChannel requestChannel;
|
PollableChannel requestsMarshalling;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("requestsSimple")
|
||||||
|
PollableChannel requestsSimple;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("requestsVerySimple")
|
||||||
|
MessageChannel requestsVerySimple;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void configOk() throws Exception {
|
public void configOk() throws Exception {
|
||||||
@@ -59,7 +81,7 @@ public class WebServiceInboundGatewayParserTests {
|
|||||||
DirectFieldAccessor accessor = new DirectFieldAccessor(simpleGateway);
|
DirectFieldAccessor accessor = new DirectFieldAccessor(simpleGateway);
|
||||||
assertThat(
|
assertThat(
|
||||||
(MessageChannel) accessor.getPropertyValue("requestChannel"),
|
(MessageChannel) accessor.getPropertyValue("requestChannel"),
|
||||||
is(requestChannel));
|
is(requestsVerySimple));
|
||||||
}
|
}
|
||||||
|
|
||||||
//extractPayload = false
|
//extractPayload = false
|
||||||
@@ -78,6 +100,7 @@ public class WebServiceInboundGatewayParserTests {
|
|||||||
//marshalling
|
//marshalling
|
||||||
@Autowired
|
@Autowired
|
||||||
MarshallingWebServiceInboundGateway marshallingGateway;
|
MarshallingWebServiceInboundGateway marshallingGateway;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
AbstractMarshaller marshaller;
|
AbstractMarshaller marshaller;
|
||||||
|
|
||||||
@@ -90,4 +113,23 @@ public class WebServiceInboundGatewayParserTests {
|
|||||||
is(marshaller));
|
is(marshaller));
|
||||||
assertTrue("messaging gateway is not running", marshallingGateway.isRunning());
|
assertTrue("messaging gateway is not running", marshallingGateway.isRunning());
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
public void testMessageHistoryWithMarshallingGateway() throws Exception {
|
||||||
|
MessageContext context = new DefaultMessageContext(new StubMessageFactory());
|
||||||
|
Unmarshaller unmarshaller = mock(Unmarshaller.class);
|
||||||
|
when(unmarshaller.unmarshal((Source)Mockito.any())).thenReturn("hello");
|
||||||
|
marshallingGateway.setUnmarshaller(unmarshaller);
|
||||||
|
marshallingGateway.invoke(context);
|
||||||
|
Message<?> message = requestsMarshalling.receive(100);
|
||||||
|
MessageHistory history = MessageHistory.read(message);
|
||||||
|
assertTrue(history.containsComponent("marshalling"));
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testMessageHistoryWithSimpleGateway() throws Exception {
|
||||||
|
MessageContext context = new DefaultMessageContext(new StubMessageFactory());
|
||||||
|
payloadExtractingGateway.invoke(context);
|
||||||
|
Message<?> message = requestsSimple.receive(100);
|
||||||
|
MessageHistory history = MessageHistory.read(message);
|
||||||
|
assertTrue(history.containsComponent("extractsPayload"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class XsltTransformerTests {
|
|||||||
input.send(message);
|
input.send(message);
|
||||||
Message<?> resultMessage = output.receive();
|
Message<?> resultMessage = output.receive();
|
||||||
MessageHistory history = MessageHistory.read(resultMessage);
|
MessageHistory history = MessageHistory.read(resultMessage);
|
||||||
assertTrue(history.containsEntryWithName("paramHeadersWithStartWildCharacter"));
|
assertTrue(history.containsComponent("paramHeadersWithStartWildCharacter"));
|
||||||
assertEquals("Wrong payload type",String.class, resultMessage.getPayload().getClass());
|
assertEquals("Wrong payload type",String.class, resultMessage.getPayload().getClass());
|
||||||
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
|
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
|
||||||
assertFalse(((String) resultMessage.getPayload()).contains("FOO"));
|
assertFalse(((String) resultMessage.getPayload()).contains("FOO"));
|
||||||
@@ -71,7 +71,7 @@ public class XsltTransformerTests {
|
|||||||
input.send(message);
|
input.send(message);
|
||||||
Message<?> resultMessage = output.receive();
|
Message<?> resultMessage = output.receive();
|
||||||
MessageHistory history = MessageHistory.read(resultMessage);
|
MessageHistory history = MessageHistory.read(resultMessage);
|
||||||
assertTrue(history.containsEntryWithName("paramHeadersWithEndWildCharacter"));
|
assertTrue(history.containsComponent("paramHeadersWithEndWildCharacter"));
|
||||||
assertEquals("Wrong payload type",String.class, resultMessage.getPayload().getClass());
|
assertEquals("Wrong payload type",String.class, resultMessage.getPayload().getClass());
|
||||||
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
|
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
|
||||||
assertTrue(((String) resultMessage.getPayload()).contains("FOO"));
|
assertTrue(((String) resultMessage.getPayload()).contains("FOO"));
|
||||||
@@ -86,7 +86,7 @@ public class XsltTransformerTests {
|
|||||||
input.send(message);
|
input.send(message);
|
||||||
Message<?> resultMessage = output.receive();
|
Message<?> resultMessage = output.receive();
|
||||||
MessageHistory history = MessageHistory.read(resultMessage);
|
MessageHistory history = MessageHistory.read(resultMessage);
|
||||||
assertTrue(history.containsEntryWithName("paramHeadersWithIndividualParameters"));
|
assertTrue(history.containsComponent("paramHeadersWithIndividualParameters"));
|
||||||
assertEquals("Wrong payload type",String.class, resultMessage.getPayload().getClass());
|
assertEquals("Wrong payload type",String.class, resultMessage.getPayload().getClass());
|
||||||
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
|
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
|
||||||
assertTrue(((String) resultMessage.getPayload()).contains("FOO"));
|
assertTrue(((String) resultMessage.getPayload()).contains("FOO"));
|
||||||
@@ -103,7 +103,7 @@ public class XsltTransformerTests {
|
|||||||
input.send(message);
|
input.send(message);
|
||||||
Message<?> resultMessage = output.receive();
|
Message<?> resultMessage = output.receive();
|
||||||
MessageHistory history = MessageHistory.read(resultMessage);
|
MessageHistory history = MessageHistory.read(resultMessage);
|
||||||
assertTrue(history.containsEntryWithName("paramHeadersComboChannel"));
|
assertTrue(history.containsComponent("paramHeadersComboChannel"));
|
||||||
assertEquals("Wrong payload type",String.class, resultMessage.getPayload().getClass());
|
assertEquals("Wrong payload type",String.class, resultMessage.getPayload().getClass());
|
||||||
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
|
assertTrue(((String) resultMessage.getPayload()).contains("testParamValue"));
|
||||||
assertTrue(((String) resultMessage.getPayload()).contains("FOO"));
|
assertTrue(((String) resultMessage.getPayload()).contains("FOO"));
|
||||||
|
|||||||
Reference in New Issue
Block a user