INT-1389 removed all dependencies on StringMessage from unit tests in spring-integration-ip and spring-integration-stream

This commit is contained in:
Mark Fisher
2010-08-30 18:48:54 +00:00
parent 3baa56fb10
commit 432a8ec381
6 changed files with 29 additions and 28 deletions

View File

@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -34,8 +35,8 @@ import org.springframework.integration.MessagingException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.context.BeanFactoryChannelResolver;
import org.springframework.integration.core.ChannelResolver;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
/**
* Sends and receives a simple message through to the Udp channel adapters.
@@ -90,7 +91,7 @@ public class UdpMulticastEndToEndTests implements Runnable {
}
try {
testingIpText = ">>>>>>> Testing IP (multicast) " + new Date();
inputChannel.send(new StringMessage(testingIpText));
inputChannel.send(new GenericMessage<String>(testingIpText));
sentFirst.countDown();
try {
Thread.sleep(hangAroundFor); // give some time for console interaction

View File

@@ -25,6 +25,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -32,8 +33,8 @@ import org.springframework.integration.Message;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.context.BeanFactoryChannelResolver;
import org.springframework.integration.core.ChannelResolver;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.StringMessage;
/**
* Sends and receives a simple message through to the Udp channel adapters.
@@ -85,7 +86,7 @@ public class UdpUnicastEndToEndTests implements Runnable {
}
try {
testingIpText = ">>>>>>> Testing IP " + new Date();
inputChannel.send(new StringMessage(testingIpText));
inputChannel.send(new GenericMessage<String>(testingIpText));
sentFirst.countDown();
try {
Thread.sleep(hangAroundFor); // give some time for console interaction

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -22,9 +22,10 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.core.StringMessage;
import org.springframework.util.Assert;
/**
@@ -58,14 +59,14 @@ public class CharacterStreamReadingMessageSource implements MessageSource<String
}
public StringMessage receive() {
public Message<String> receive() {
try {
synchronized (this.monitor) {
if (!this.reader.ready()) {
return null;
}
String line = this.reader.readLine();
return (line != null) ? new StringMessage(line) : null;
return (line != null) ? new GenericMessage<String>(line) : null;
}
}
catch (IOException e) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -31,7 +31,6 @@ import org.junit.Test;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.endpoint.PollingConsumer;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
@@ -86,7 +85,7 @@ public class ByteStreamWritingMessageHandlerTests {
@Test
public void singleString() {
handler.handleMessage(new StringMessage("foo"));
handler.handleMessage(new GenericMessage<String>("foo"));
byte[] result = stream.toByteArray();
assertEquals(3, result.length);
assertEquals("foo", new String(result));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 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.
@@ -30,7 +30,6 @@ import org.junit.Test;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.endpoint.PollingConsumer;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
@@ -76,15 +75,15 @@ public class CharacterStreamWritingMessageHandlerTests {
@Test
public void singleString() {
handler.handleMessage(new StringMessage("foo"));
handler.handleMessage(new GenericMessage<String>("foo"));
assertEquals("foo", writer.toString());
}
@Test
public void twoStringsAndNoNewLinesByDefault() {
endpoint.setMaxMessagesPerPoll(1);
channel.send(new StringMessage("foo"), 0);
channel.send(new StringMessage("bar"), 0);
channel.send(new GenericMessage<String>("foo"), 0);
channel.send(new GenericMessage<String>("bar"), 0);
endpoint.start();
trigger.await();
endpoint.stop();
@@ -100,8 +99,8 @@ public class CharacterStreamWritingMessageHandlerTests {
public void twoStringsWithNewLines() {
handler.setShouldAppendNewLine(true);
endpoint.setMaxMessagesPerPoll(1);
channel.send(new StringMessage("foo"), 0);
channel.send(new StringMessage("bar"), 0);
channel.send(new GenericMessage<String>("foo"), 0);
channel.send(new GenericMessage<String>("bar"), 0);
endpoint.start();
trigger.await();
endpoint.stop();
@@ -117,8 +116,8 @@ public class CharacterStreamWritingMessageHandlerTests {
@Test
public void maxMessagesPerTaskSameAsMessageCount() {
endpoint.setMaxMessagesPerPoll(2);
channel.send(new StringMessage("foo"), 0);
channel.send(new StringMessage("bar"), 0);
channel.send(new GenericMessage<String>("foo"), 0);
channel.send(new GenericMessage<String>("bar"), 0);
endpoint.start();
trigger.await();
endpoint.stop();
@@ -130,8 +129,8 @@ public class CharacterStreamWritingMessageHandlerTests {
endpoint.setMaxMessagesPerPoll(10);
endpoint.setReceiveTimeout(0);
handler.setShouldAppendNewLine(true);
channel.send(new StringMessage("foo"), 0);
channel.send(new StringMessage("bar"), 0);
channel.send(new GenericMessage<String>("foo"), 0);
channel.send(new GenericMessage<String>("bar"), 0);
endpoint.start();
trigger.await();
endpoint.stop();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2010 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.
@@ -32,7 +32,7 @@ import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.GenericMessage;
import org.springframework.integration.stream.CharacterStreamWritingMessageHandler;
/**
@@ -72,7 +72,7 @@ public class ConsoleOutboundChannelAdapterParserTests {
Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding());
assertEquals(Charset.defaultCharset(), writerCharset);
this.resetStreams();
handler.handleMessage(new StringMessage("foo"));
handler.handleMessage(new GenericMessage<String>("foo"));
assertEquals("foo", out.toString());
assertEquals("", err.toString());
}
@@ -93,7 +93,7 @@ public class ConsoleOutboundChannelAdapterParserTests {
Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding());
assertEquals(Charset.forName("UTF-8"), writerCharset);
this.resetStreams();
handler.handleMessage(new StringMessage("bar"));
handler.handleMessage(new GenericMessage<String>("bar"));
assertEquals("bar", out.toString());
assertEquals("", err.toString());
}
@@ -128,7 +128,7 @@ public class ConsoleOutboundChannelAdapterParserTests {
Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding());
assertEquals(Charset.defaultCharset(), writerCharset);
this.resetStreams();
handler.handleMessage(new StringMessage("bad"));
handler.handleMessage(new GenericMessage<String>("bad"));
assertEquals("", out.toString());
assertEquals("bad", err.toString());
}
@@ -149,7 +149,7 @@ public class ConsoleOutboundChannelAdapterParserTests {
Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding());
assertEquals(Charset.defaultCharset(), writerCharset);
this.resetStreams();
handler.handleMessage(new StringMessage("foo"));
handler.handleMessage(new GenericMessage<String>("foo"));
assertEquals("foo" + System.getProperty("line.separator"), out.toString());
}