Initial Changes for SPR 4.0.0.RC1
- MessageConverter
This commit is contained in:
@@ -25,7 +25,7 @@ allprojects {
|
||||
group = 'org.springframework.integration'
|
||||
|
||||
repositories {
|
||||
maven { url 'http://repo.springsource.org/libs-milestone' }
|
||||
maven { url 'http://repo.springsource.org/libs-snapshot' }
|
||||
maven { url 'http://repo.springsource.org/plugins-release' }
|
||||
mavenCentral()
|
||||
}
|
||||
@@ -60,7 +60,7 @@ subprojects { subproject ->
|
||||
ftpServerVersion = '1.0.6'
|
||||
|
||||
|
||||
springVersionDefault = '4.0.0.M3'
|
||||
springVersionDefault = '4.0.0.BUILD-SNAPSHOT'
|
||||
springVersion = project.hasProperty('springVersion') ? getProperty('springVersion') : springVersionDefault
|
||||
|
||||
springAmqpVersion = '1.2.0.RELEASE'
|
||||
|
||||
@@ -121,7 +121,7 @@ public class AsyncMessagingTemplate extends GenericMessagingTemplate implements
|
||||
public <R> Future<R> asyncReceiveAndConvert() {
|
||||
return this.executor.submit(new Callable<R>() {
|
||||
public R call() throws Exception {
|
||||
return (R) receiveAndConvert();
|
||||
return (R) receiveAndConvert(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class AsyncMessagingTemplate extends GenericMessagingTemplate implements
|
||||
public <R> Future<R> asyncReceiveAndConvert(final PollableChannel channel) {
|
||||
return this.executor.submit(new Callable<R>() {
|
||||
public R call() throws Exception {
|
||||
return (R) receiveAndConvert(channel);
|
||||
return (R) receiveAndConvert(channel, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class AsyncMessagingTemplate extends GenericMessagingTemplate implements
|
||||
public <R> Future<R> asyncReceiveAndConvert(final String channelName) {
|
||||
return this.executor.submit(new Callable<R>() {
|
||||
public R call() throws Exception {
|
||||
return (R) receiveAndConvert(channelName);
|
||||
return (R) receiveAndConvert(channelName, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class AsyncMessagingTemplate extends GenericMessagingTemplate implements
|
||||
public <R> Future<R> asyncConvertSendAndReceive(final Object request) {
|
||||
return this.executor.submit(new Callable<R>() {
|
||||
public R call() throws Exception {
|
||||
return (R) convertSendAndReceive(request);
|
||||
return (R) convertSendAndReceive(request, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public class AsyncMessagingTemplate extends GenericMessagingTemplate implements
|
||||
public <R> Future<R> asyncConvertSendAndReceive(final MessageChannel channel, final Object request) {
|
||||
return this.executor.submit(new Callable<R>() {
|
||||
public R call() throws Exception {
|
||||
return (R) convertSendAndReceive(channel, request);
|
||||
return (R) convertSendAndReceive(channel, request, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class AsyncMessagingTemplate extends GenericMessagingTemplate implements
|
||||
public <R> Future<R> asyncConvertSendAndReceive(final String channelName, final Object request) {
|
||||
return this.executor.submit(new Callable<R>() {
|
||||
public R call() throws Exception {
|
||||
return (R) convertSendAndReceive(channelName, request);
|
||||
return (R) convertSendAndReceive(channelName, request, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -199,7 +199,7 @@ public class AsyncMessagingTemplate extends GenericMessagingTemplate implements
|
||||
public <R> Future<R> asyncConvertSendAndReceive(final Object request, final MessagePostProcessor requestPostProcessor) {
|
||||
return this.executor.submit(new Callable<R>() {
|
||||
public R call() throws Exception {
|
||||
return (R) convertSendAndReceive(request, requestPostProcessor);
|
||||
return (R) convertSendAndReceive(request, null, requestPostProcessor);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public class AsyncMessagingTemplate extends GenericMessagingTemplate implements
|
||||
public <R> Future<R> asyncConvertSendAndReceive(final MessageChannel channel, final Object request, final MessagePostProcessor requestPostProcessor) {
|
||||
return this.executor.submit(new Callable<R>() {
|
||||
public R call() throws Exception {
|
||||
return (R) convertSendAndReceive(channel, request, requestPostProcessor);
|
||||
return (R) convertSendAndReceive(channel, request, null, requestPostProcessor);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public class AsyncMessagingTemplate extends GenericMessagingTemplate implements
|
||||
public <R> Future<R> asyncConvertSendAndReceive(final String channelName, final Object request, final MessagePostProcessor requestPostProcessor) {
|
||||
return this.executor.submit(new Callable<R>() {
|
||||
public R call() throws Exception {
|
||||
return (R) convertSendAndReceive(channelName, request, requestPostProcessor);
|
||||
return (R) convertSendAndReceive(channelName, request, null, requestPostProcessor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint implement
|
||||
this.initializeIfNecessary();
|
||||
Assert.state(this.replyChannel != null && (this.replyChannel instanceof PollableChannel),
|
||||
"receive is not supported, because no pollable reply channel has been configured");
|
||||
return this.messagingTemplate.receiveAndConvert((PollableChannel) this.replyChannel);
|
||||
return this.messagingTemplate.receiveAndConvert((PollableChannel) this.replyChannel, null);
|
||||
}
|
||||
|
||||
protected Object sendAndReceive(Object object) {
|
||||
@@ -221,7 +221,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint implement
|
||||
Throwable error = null;
|
||||
try {
|
||||
if (shouldConvert) {
|
||||
reply = this.messagingTemplate.convertSendAndReceive(this.requestChannel, object, this.historyWritingPostProcessor);
|
||||
reply = this.messagingTemplate.convertSendAndReceive(this.requestChannel, object, null, this.historyWritingPostProcessor);
|
||||
if (reply instanceof Throwable) {
|
||||
error = (Throwable) reply;
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
package org.springframework.integration.support.converter;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.support.converter.MessageConverter;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.util.Assert;
|
||||
* @since 3.0
|
||||
*
|
||||
*/
|
||||
public class MapMessageConverter implements MessageConverter<Object> {
|
||||
public class MapMessageConverter implements MessageConverter {
|
||||
|
||||
private volatile String[] headerNames;
|
||||
|
||||
@@ -58,7 +58,8 @@ public class MapMessageConverter implements MessageConverter<Object> {
|
||||
this.filterHeadersInToMessage = filterHeadersInToMessage;
|
||||
}
|
||||
|
||||
public <P> Message<P> toMessage(Object object) {
|
||||
@Override
|
||||
public Message<?> toMessage(Object object, MessageHeaders messageHeaders) {
|
||||
Assert.isInstanceOf(Map.class, object, "This converter expects a Map");
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, ?> map = (Map<String, ?>) object;
|
||||
@@ -78,12 +79,12 @@ public class MapMessageConverter implements MessageConverter<Object> {
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Message<P> convertedMessage = (Message<P>) messageBuilder.build();
|
||||
Message<?> convertedMessage = messageBuilder.build();
|
||||
return convertedMessage;
|
||||
}
|
||||
|
||||
public Object fromMessage(Message<?> message, Type type) {
|
||||
@Override
|
||||
public Object fromMessage(Message<?> message, Class<?> clazz) {
|
||||
Map<String,Object> map = new HashMap<String, Object>();
|
||||
map.put("payload", message.getPayload());
|
||||
Map<String, Object> headers = new HashMap<String, Object>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2013 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,12 +16,11 @@
|
||||
|
||||
package org.springframework.integration.support.converter;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import org.springframework.integration.mapping.InboundMessageMapper;
|
||||
import org.springframework.integration.mapping.OutboundMessageMapper;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.support.converter.MessageConversionException;
|
||||
import org.springframework.messaging.support.converter.MessageConverter;
|
||||
|
||||
@@ -30,7 +29,7 @@ import org.springframework.messaging.support.converter.MessageConverter;
|
||||
* @since 2.0
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public class SimpleMessageConverter implements MessageConverter<Object> {
|
||||
public class SimpleMessageConverter implements MessageConverter {
|
||||
|
||||
private volatile InboundMessageMapper inboundMessageMapper;
|
||||
|
||||
@@ -65,7 +64,7 @@ public class SimpleMessageConverter implements MessageConverter<Object> {
|
||||
this.outboundMessageMapper = (outboundMessageMapper != null) ? outboundMessageMapper : new DefaultOutboundMessageMapper();
|
||||
}
|
||||
|
||||
public <P> Message<P> toMessage(Object object) {
|
||||
public Message<?> toMessage(Object object, MessageHeaders headers) {
|
||||
try {
|
||||
return this.inboundMessageMapper.toMessage(object);
|
||||
}
|
||||
@@ -74,7 +73,7 @@ public class SimpleMessageConverter implements MessageConverter<Object> {
|
||||
}
|
||||
}
|
||||
|
||||
public Object fromMessage(Message<?> message, Type targetClass) {
|
||||
public Object fromMessage(Message<?> message, Class<?> targetClass) {
|
||||
try {
|
||||
return this.outboundMessageMapper.fromMessage(message);
|
||||
}
|
||||
|
||||
@@ -22,14 +22,15 @@ import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.annotation.Aggregator;
|
||||
import org.springframework.integration.annotation.CorrelationStrategy;
|
||||
import org.springframework.integration.annotation.ReleaseStrategy;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -54,8 +55,8 @@ public class AnnotationAggregatorTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
Message<String> result = (Message<String>) output.receive();
|
||||
String payload = result.getPayload();
|
||||
assertTrue("Wrong payload: "+payload, payload.contains("Payload=a"));
|
||||
assertTrue("Wrong payload: "+payload, payload.contains("Payload=b"));
|
||||
assertTrue("Wrong payload: "+payload, payload.contains("Payload String content=a"));
|
||||
assertTrue("Wrong payload: "+payload, payload.contains("Payload String content=b"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -65,12 +66,12 @@ public class AnnotationAggregatorTests {
|
||||
public Message<?> aggregate(final List<Message<?>> messages) {
|
||||
return MessageBuilder.withPayload(messages.toString()).build();
|
||||
}
|
||||
|
||||
|
||||
@ReleaseStrategy
|
||||
public boolean release(final List<Message<?>> messages) {
|
||||
return messages.size()>1;
|
||||
}
|
||||
|
||||
|
||||
@CorrelationStrategy
|
||||
public Object getKey(Message<?> message) {
|
||||
return "1";
|
||||
|
||||
@@ -22,6 +22,7 @@ import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
@@ -203,7 +204,7 @@ public class ServiceActivatorParserTests {
|
||||
GenericMessagingTemplate template = new GenericMessagingTemplate();
|
||||
template.setDefaultDestination(channel);
|
||||
|
||||
return template.convertSendAndReceive(payload);
|
||||
return template.convertSendAndReceive(payload, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -232,9 +233,9 @@ public class ServiceActivatorParserTests {
|
||||
@SuppressWarnings("unused")
|
||||
private static class TestPerson {
|
||||
|
||||
private String firstName;
|
||||
private final String firstName;
|
||||
|
||||
private String lastName;
|
||||
private final String lastName;
|
||||
|
||||
public TestPerson(String firstName, String lastName) {
|
||||
this.firstName = firstName;
|
||||
|
||||
@@ -24,8 +24,9 @@ import static org.junit.Assert.fail;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
@@ -56,17 +57,17 @@ public class MapMessageConverterTests {
|
||||
assertNull(headers.get("baz"));
|
||||
|
||||
headers.put("baz", "qux");
|
||||
message = converter.toMessage(map);
|
||||
assertEquals("foo", message.getPayload());
|
||||
assertEquals("baz", message.getHeaders().get("bar"));
|
||||
assertEquals("qux", message.getHeaders().get("baz"));
|
||||
Message<?> converted = converter.toMessage(map, null);
|
||||
assertEquals("foo", converted.getPayload());
|
||||
assertEquals("baz", converted.getHeaders().get("bar"));
|
||||
assertEquals("qux", converted.getHeaders().get("baz"));
|
||||
|
||||
converter.setFilterHeadersInToMessage(true);
|
||||
|
||||
message = converter.toMessage(map);
|
||||
assertEquals("foo", message.getPayload());
|
||||
assertEquals("baz", message.getHeaders().get("bar"));
|
||||
assertNull(message.getHeaders().get("baz"));
|
||||
converted = converter.toMessage(map, null);
|
||||
assertEquals("foo", converted.getPayload());
|
||||
assertEquals("baz", converted.getHeaders().get("bar"));
|
||||
assertNull(converted.getHeaders().get("baz"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -83,7 +84,7 @@ public class MapMessageConverterTests {
|
||||
map.remove("payload");
|
||||
|
||||
try {
|
||||
converter.toMessage(map);
|
||||
converter.toMessage(map, null);
|
||||
fail("Expected exception");
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
@@ -105,8 +106,8 @@ public class MapMessageConverterTests {
|
||||
assertNotNull(headers);
|
||||
assertEquals(0, headers.size());
|
||||
map.remove("headers");
|
||||
message = converter.toMessage(map);
|
||||
assertEquals("foo", message.getPayload());
|
||||
Message<?> converted = converter.toMessage(map, null);
|
||||
assertEquals("foo", converted.getPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
*/
|
||||
package org.springframework.integration.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
@@ -54,14 +54,14 @@ import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
import org.springframework.integration.handler.ServiceActivatingHandler;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.support.context.NamedComponent;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
|
||||
@@ -27,19 +27,19 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class MessageConvertingTcpMessageMapper extends TcpMessageMapper {
|
||||
|
||||
private final MessageConverter<Object> messageConverter;
|
||||
private final MessageConverter messageConverter;
|
||||
|
||||
public MessageConvertingTcpMessageMapper(MessageConverter<Object> messageConverter) {
|
||||
public MessageConvertingTcpMessageMapper(MessageConverter messageConverter) {
|
||||
Assert.notNull(messageConverter, "'messasgeConverter' must not be null");
|
||||
this.messageConverter = messageConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message<Object> toMessage(TcpConnection connection) throws Exception {
|
||||
public Message<?> toMessage(TcpConnection connection) throws Exception {
|
||||
Object data = connection.getPayload();
|
||||
if (data != null) {
|
||||
Message<Object> message = this.messageConverter.toMessage(data);
|
||||
MessageBuilder<Object> messageBuilder = MessageBuilder.fromMessage(message);
|
||||
Message<?> message = this.messageConverter.toMessage(data, null);
|
||||
MessageBuilder<?> messageBuilder = MessageBuilder.fromMessage(message);
|
||||
this.addStandardHeaders(connection, messageBuilder);
|
||||
this.addCustomHeaders(connection, messageBuilder);
|
||||
return messageBuilder.build();
|
||||
|
||||
@@ -54,7 +54,7 @@ public class TcpMessageMapper implements
|
||||
|
||||
private volatile boolean applySequence = false;
|
||||
|
||||
public Message<Object> toMessage(TcpConnection connection) throws Exception {
|
||||
public Message<?> toMessage(TcpConnection connection) throws Exception {
|
||||
Message<Object> message = null;
|
||||
Object payload = connection.getPayload();
|
||||
if (payload != null) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.Map;
|
||||
import javax.net.SocketFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.serializer.DefaultDeserializer;
|
||||
import org.springframework.core.serializer.DefaultSerializer;
|
||||
import org.springframework.integration.EiMessageHeaderAccessor;
|
||||
@@ -56,7 +57,7 @@ public class TcpMessageMapperTests {
|
||||
when(connection.getHostName()).thenReturn("MyHost");
|
||||
when(connection.getHostAddress()).thenReturn("1.1.1.1");
|
||||
when(connection.getPort()).thenReturn(1234);
|
||||
Message<Object> message = mapper.toMessage(connection);
|
||||
Message<?> message = mapper.toMessage(connection);
|
||||
assertEquals(TEST_PAYLOAD, new String((byte[]) message.getPayload()));
|
||||
assertEquals("MyHost", message
|
||||
.getHeaders().get(IpHeaders.HOSTNAME));
|
||||
@@ -101,7 +102,7 @@ public class TcpMessageMapperTests {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Message<Object> message = mapper.toMessage(connection);
|
||||
Message<?> message = mapper.toMessage(connection);
|
||||
assertEquals(TEST_PAYLOAD, new String((byte[]) message.getPayload()));
|
||||
assertEquals("MyHost", message
|
||||
.getHeaders().get(IpHeaders.HOSTNAME));
|
||||
@@ -163,7 +164,7 @@ public class TcpMessageMapperTests {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Message<Object> message = mapper.toMessage(connection);
|
||||
Message<?> message = mapper.toMessage(connection);
|
||||
assertEquals(TEST_PAYLOAD, new String((byte[]) message.getPayload()));
|
||||
assertEquals("MyHost", message
|
||||
.getHeaders().get(IpHeaders.HOSTNAME));
|
||||
|
||||
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.jmx.export.MBeanExporter;
|
||||
@@ -41,7 +42,7 @@ public class ControlBusParserTests {
|
||||
MessageChannel control = this.context.getBean("controlChannel", MessageChannel.class);
|
||||
GenericMessagingTemplate messagingTemplate = new GenericMessagingTemplate();
|
||||
Object value = messagingTemplate.convertSendAndReceive(control,
|
||||
"@integrationMbeanExporter.getChannelSendRate('testChannel').count");
|
||||
"@integrationMbeanExporter.getChannelSendRate('testChannel').count", null);
|
||||
assertEquals(new Integer(0), value);
|
||||
MBeanExporter exporter = this.context.getBean(MBeanExporter.class);
|
||||
exporter.destroy();
|
||||
|
||||
@@ -183,7 +183,7 @@ public class SubscribableRedisChannel extends AbstractMessageChannel implements
|
||||
|
||||
@SuppressWarnings({ "unused", "unchecked" })
|
||||
public void handleMessage(String s) {
|
||||
Message<?> siMessage = messageConverter.toMessage(s);
|
||||
Message<?> siMessage = messageConverter.toMessage(s, null);
|
||||
try {
|
||||
dispatcher.dispatch(siMessage);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class RedisInboundChannelAdapter extends MessageProducerSupport {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Message<?> convertMessage(String s) {
|
||||
return this.messageConverter.toMessage(s);
|
||||
return this.messageConverter.toMessage(s, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,21 +17,23 @@
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.xml.config.StubResultFactory.StubStringResult;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.xml.config.StubResultFactory.StubStringResult;
|
||||
import org.springframework.xml.transform.StringResult;
|
||||
|
||||
/**
|
||||
@@ -62,7 +64,7 @@ public class MarshallingTransformerParserTests {
|
||||
Document doc = (Document) ((DOMResult) result.getPayload()).getNode();
|
||||
assertEquals("Wrong payload", "hello", doc.getDocumentElement().getTextContent());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDefaultWithResultTransformer() throws Exception {
|
||||
MessageChannel input = (MessageChannel) appContext.getBean("marshallingTransformerWithResultTransformer");
|
||||
@@ -93,7 +95,7 @@ public class MarshallingTransformerParserTests {
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Wrong payload type", result.getPayload() instanceof StringResult);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCustomResultFactory() throws Exception {
|
||||
MessageChannel input = (MessageChannel) appContext.getBean("marshallingTransformerCustomResultFactory");
|
||||
@@ -111,8 +113,10 @@ public class MarshallingTransformerParserTests {
|
||||
Message<?> result = output.receive(0);
|
||||
assertTrue("Wrong payload type", result.getPayload() instanceof DOMResult);
|
||||
Document doc = (Document) ((DOMResult) result.getPayload()).getNode();
|
||||
String expected = "[Payload=hello][Headers=";
|
||||
assertEquals("Wrong payload", expected, doc.getDocumentElement().getTextContent().substring(0, expected.length()));
|
||||
String expected = "[Payload String content=hello]";
|
||||
String actual = doc.getDocumentElement().getTextContent();
|
||||
assertThat(actual, Matchers.containsString(expected));
|
||||
assertThat(actual, Matchers.containsString("[Headers="));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user