INT-1263, more MessageHistory related changes
This commit is contained in:
@@ -88,15 +88,6 @@ public class MessageHistory implements List<Properties> {
|
||||
return this.components.contains(o);
|
||||
}
|
||||
|
||||
public boolean containsComponent(String name) {
|
||||
for (Properties properties : components) {
|
||||
if (properties.getProperty("name").equals(name)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
return this.components.containsAll(c);
|
||||
}
|
||||
|
||||
@@ -117,8 +117,6 @@ public class HttpInboundChannelAdapterParserTests {
|
||||
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "postOnlyAdapter", 0);
|
||||
assertNotNull(componentHistoryRecord);
|
||||
assertEquals("http:inbound-channel-adapter", componentHistoryRecord.get("type"));
|
||||
//System.out.println(componentHistoryRecord);
|
||||
assertTrue(history.containsComponent("postOnlyAdapter"));
|
||||
assertNotNull(message);
|
||||
assertEquals("test", message.getPayload());
|
||||
}
|
||||
|
||||
@@ -189,4 +189,7 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler
|
||||
public void setReplyChannel(MessageChannel replyChannel) {
|
||||
this.setOutputChannel(replyChannel);
|
||||
}
|
||||
public String getComponentType(){
|
||||
return "ip:tcp-outbound-gateway";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,4 +85,7 @@ public class TcpReceivingChannelAdapter
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getComponentType(){
|
||||
return "ip:tcp-inbound-channel-adapter";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,4 +161,7 @@ public class TcpSendingMessageHandler extends AbstractMessageHandler implements
|
||||
public void removeDeadConnection(TcpConnection connection) {
|
||||
connections.remove(connection.getConnectionId());
|
||||
}
|
||||
public String getComponentType(){
|
||||
return "ip:tcp-outbound-channel-adapter";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,4 +342,8 @@ public class UnicastSendingMessageHandler extends
|
||||
public void setTaskExecutor(Executor taskExecutor) {
|
||||
this.taskExecutor = taskExecutor;
|
||||
}
|
||||
|
||||
public String getComponentType(){
|
||||
return "ip:udp-outbound-channel-adapter";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +154,8 @@ public class ParserUnitTests {
|
||||
assertEquals(30, dfa.getPropertyValue("soReceiveBufferSize"));
|
||||
assertEquals(31, dfa.getPropertyValue("soSendBufferSize"));
|
||||
assertEquals(32, dfa.getPropertyValue("soTimeout"));
|
||||
assertEquals("testInUdp",udpIn.getComponentName());
|
||||
assertEquals("ip:udp-inbound-channel-adapter", udpIn.getComponentType());
|
||||
assertEquals("127.0.0.1", dfa.getPropertyValue("localAddress"));
|
||||
assertSame(taskExecutor, dfa.getPropertyValue("taskExecutor"));
|
||||
}
|
||||
@@ -176,6 +178,8 @@ public class ParserUnitTests {
|
||||
public void testInTcp() {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(tcpIn);
|
||||
assertSame(cfS1, dfa.getPropertyValue("serverConnectionFactory"));
|
||||
assertEquals("testInTcp",tcpIn.getComponentName());
|
||||
assertEquals("ip:tcp-inbound-channel-adapter", tcpIn.getComponentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -197,6 +201,8 @@ public class ParserUnitTests {
|
||||
assertEquals(54, dfa.getPropertyValue("soTimeout"));
|
||||
assertEquals("127.0.0.1", dfa.getPropertyValue("localAddress"));
|
||||
assertSame(taskExecutor, dfa.getPropertyValue("taskExecutor"));
|
||||
assertEquals("testOutUdp",udpOut.getComponentName());
|
||||
assertEquals("ip:udp-outbound-channel-adapter", udpOut.getComponentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -223,6 +229,8 @@ public class ParserUnitTests {
|
||||
public void testOutTcp() {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(tcpOut);
|
||||
assertSame(cfC1, dfa.getPropertyValue("clientConnectionFactory"));
|
||||
assertEquals("testOutTcpNio",tcpOut.getComponentName());
|
||||
assertEquals("ip:tcp-outbound-channel-adapter", tcpOut.getComponentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -230,6 +238,8 @@ public class ParserUnitTests {
|
||||
DirectFieldAccessor dfa = new DirectFieldAccessor(tcpInboundGateway);
|
||||
assertSame(cfS2, dfa.getPropertyValue("connectionFactory"));
|
||||
assertEquals(456L, dfa.getPropertyValue("replyTimeout"));
|
||||
assertEquals("inGateway",tcpInboundGateway.getComponentName());
|
||||
assertEquals("ip:tcp-inbound-gateway", tcpInboundGateway.getComponentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -238,6 +248,8 @@ public class ParserUnitTests {
|
||||
assertSame(cfC2, dfa.getPropertyValue("connectionFactory"));
|
||||
assertEquals(234L, dfa.getPropertyValue("requestTimeout"));
|
||||
assertEquals(567L, dfa.getPropertyValue("replyTimeout"));
|
||||
assertEquals("outGateway",tcpOutboundGateway.getComponentName());
|
||||
assertEquals("ip:tcp-outbound-gateway", tcpOutboundGateway.getComponentType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -32,6 +34,7 @@ import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -74,7 +77,10 @@ public class SharedConnectionTests {
|
||||
QueueChannel replies = ctx.getBean("replies", QueueChannel.class);
|
||||
Message<?> message = replies.receive(10000);
|
||||
MessageHistory history = MessageHistory.read(message);
|
||||
assertTrue(history.containsComponent("inboundClient"));
|
||||
assertNotNull(history);
|
||||
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "inboundClient", 0);
|
||||
assertNotNull(componentHistoryRecord);
|
||||
assertEquals("ip:tcp-inbound-channel-adapter", componentHistoryRecord.getProperty("type"));
|
||||
assertNotNull(message);
|
||||
assertEquals("Test", message.getPayload());
|
||||
}
|
||||
|
||||
@@ -57,5 +57,9 @@
|
||||
<version>5.3.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-test</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -50,6 +50,7 @@ public class ChannelPublishingJmsMessageListener extends MessagingGatewaySupport
|
||||
implements SessionAwareMessageListener<javax.jms.Message>, InitializingBean {
|
||||
|
||||
private volatile boolean expectReply;
|
||||
private volatile String componentType = "jms:inbound-gateway";
|
||||
|
||||
private volatile MessageConverter messageConverter = new SimpleMessageConverter();
|
||||
|
||||
@@ -72,9 +73,11 @@ public class ChannelPublishingJmsMessageListener extends MessagingGatewaySupport
|
||||
private volatile JmsHeaderMapper headerMapper = new DefaultJmsHeaderMapper();
|
||||
|
||||
public String getComponentType(){
|
||||
return "jms:inbound-gateway";
|
||||
return componentType;
|
||||
}
|
||||
void setComponentType(String componentType){
|
||||
this.componentType = componentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether a JMS reply Message is expected.
|
||||
*/
|
||||
|
||||
@@ -54,6 +54,7 @@ public class JmsMessageDrivenEndpoint extends AbstractEndpoint implements Dispos
|
||||
this.listenerContainer.afterPropertiesSet();
|
||||
}
|
||||
listener.setComponentName(this.getComponentName());
|
||||
listener.setComponentType("jms:message-driven-channel-adapter");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,5 +75,9 @@ public class JmsMessageDrivenEndpoint extends AbstractEndpoint implements Dispos
|
||||
}
|
||||
this.listenerContainer.destroy();
|
||||
}
|
||||
|
||||
public String getComponetType(){
|
||||
return "jms:message-driven-channel-adapter";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import static junit.framework.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
@@ -29,6 +31,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -44,7 +47,10 @@ public class JmsInboundChannelAdapterParserTests {
|
||||
PollableChannel output = (PollableChannel) context.getBean("output");
|
||||
Message<?> message = output.receive(timeoutOnReceive);
|
||||
MessageHistory history = MessageHistory.read(message);
|
||||
assertTrue(history.containsComponent("inboundAdapter"));
|
||||
assertNotNull(history);
|
||||
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "inboundAdapter", 0);
|
||||
assertNotNull(componentHistoryRecord);
|
||||
assertEquals("jms:inbound-channel-adapter", componentHistoryRecord.get("type"));
|
||||
assertNotNull("message should not be null", message);
|
||||
assertEquals("polling-test", message.getPayload());
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.jms.DeliveryMode;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -33,6 +35,7 @@ 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.test.util.TestUtils;
|
||||
import org.springframework.jms.connection.JmsTransactionManager;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.jms.support.destination.JmsDestinationAccessor;
|
||||
@@ -52,7 +55,10 @@ public class JmsInboundGatewayParserTests {
|
||||
context.start();
|
||||
Message<?> message = channel.receive(3000);
|
||||
MessageHistory history = MessageHistory.read(message);
|
||||
assertTrue(history.containsComponent("jmsGateway"));
|
||||
assertNotNull(history);
|
||||
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "jmsGateway", 0);
|
||||
assertNotNull(componentHistoryRecord);
|
||||
assertEquals("jms:inbound-gateway", componentHistoryRecord.get("type"));
|
||||
assertNotNull("message should not be null", message);
|
||||
assertEquals("message-driven-test", message.getPayload());
|
||||
context.stop();
|
||||
|
||||
@@ -20,6 +20,8 @@ import static junit.framework.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
@@ -28,6 +30,7 @@ import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.jms.JmsMessageDrivenEndpoint;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.jms.support.destination.JmsDestinationAccessor;
|
||||
|
||||
/**
|
||||
@@ -35,7 +38,7 @@ import org.springframework.jms.support.destination.JmsDestinationAccessor;
|
||||
*/
|
||||
public class JmsMessageDrivenChannelAdapterParserTests {
|
||||
|
||||
long timeoutOnReceive = 3000;
|
||||
long timeoutOnReceive = 300000;
|
||||
|
||||
@Test
|
||||
public void adapterWithMessageSelector() {
|
||||
@@ -44,7 +47,12 @@ public class JmsMessageDrivenChannelAdapterParserTests {
|
||||
PollableChannel output = (PollableChannel) context.getBean("output2");
|
||||
Message<?> message = output.receive(timeoutOnReceive);
|
||||
MessageHistory history = MessageHistory.read(message);
|
||||
assertTrue(history.containsComponent("messageDrivenAdapter"));
|
||||
assertNotNull(history);
|
||||
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "messageDrivenAdapter", 0);
|
||||
assertNotNull(componentHistoryRecord);
|
||||
JmsMessageDrivenEndpoint o = context.getBean("messageDrivenAdapter", JmsMessageDrivenEndpoint.class);
|
||||
System.out.println(o.getComponentType());
|
||||
assertEquals("jms:message-driven-channel-adapter", componentHistoryRecord.get("type"));
|
||||
assertNotNull("message should not be null", message);
|
||||
assertEquals("test [with selector: TestProperty = 'foo']", message.getPayload());
|
||||
}
|
||||
|
||||
@@ -16,11 +16,14 @@
|
||||
package org.springframework.integration.jms.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
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 java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
@@ -36,6 +39,7 @@ import org.springframework.integration.endpoint.PollingConsumer;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.jms.JmsOutboundGateway;
|
||||
import org.springframework.integration.jms.StubMessageConverter;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
|
||||
/**
|
||||
@@ -77,7 +81,10 @@ public class JmsOutboundGatewayParserTests {
|
||||
MessageHandler handler = new MessageHandler() {
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
MessageHistory history = MessageHistory.read(message);
|
||||
assertTrue(history.containsComponent("inboundGateway"));
|
||||
assertNotNull(history);
|
||||
Properties componentHistoryRecord = TestUtils.locateComponentInHistory(history, "inboundGateway", 0);
|
||||
assertNotNull(componentHistoryRecord);
|
||||
assertEquals("jms:inbound-gateway", componentHistoryRecord.get("type"));
|
||||
new MessagingTemplate((MessageChannel) message.getHeaders().getReplyChannel()).send(message);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user