From 432a8ec381adc769c6a249ad6c80ae05e09cb969 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Mon, 30 Aug 2010 18:48:54 +0000 Subject: [PATCH] INT-1389 removed all dependencies on StringMessage from unit tests in spring-integration-ip and spring-integration-stream --- .../ip/udp/UdpMulticastEndToEndTests.java | 5 +++-- .../ip/udp/UdpUnicastEndToEndTests.java | 5 +++-- .../CharacterStreamReadingMessageSource.java | 9 ++++---- .../ByteStreamWritingMessageHandlerTests.java | 5 ++--- ...acterStreamWritingMessageHandlerTests.java | 21 +++++++++---------- ...soleOutboundChannelAdapterParserTests.java | 12 +++++------ 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpMulticastEndToEndTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpMulticastEndToEndTests.java index 99196b9c21..3bc4beb404 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpMulticastEndToEndTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpMulticastEndToEndTests.java @@ -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(testingIpText)); sentFirst.countDown(); try { Thread.sleep(hangAroundFor); // give some time for console interaction diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpUnicastEndToEndTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpUnicastEndToEndTests.java index 96f19e5702..b52d5df21e 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpUnicastEndToEndTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/udp/UdpUnicastEndToEndTests.java @@ -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(testingIpText)); sentFirst.countDown(); try { Thread.sleep(hangAroundFor); // give some time for console interaction diff --git a/spring-integration-stream/src/main/java/org/springframework/integration/stream/CharacterStreamReadingMessageSource.java b/spring-integration-stream/src/main/java/org/springframework/integration/stream/CharacterStreamReadingMessageSource.java index 497bc6d3ee..76fd23bb1a 100644 --- a/spring-integration-stream/src/main/java/org/springframework/integration/stream/CharacterStreamReadingMessageSource.java +++ b/spring-integration-stream/src/main/java/org/springframework/integration/stream/CharacterStreamReadingMessageSource.java @@ -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 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(line) : null; } } catch (IOException e) { diff --git a/spring-integration-stream/src/test/java/org/springframework/integration/stream/ByteStreamWritingMessageHandlerTests.java b/spring-integration-stream/src/test/java/org/springframework/integration/stream/ByteStreamWritingMessageHandlerTests.java index 46f926af35..981f18509c 100644 --- a/spring-integration-stream/src/test/java/org/springframework/integration/stream/ByteStreamWritingMessageHandlerTests.java +++ b/spring-integration-stream/src/test/java/org/springframework/integration/stream/ByteStreamWritingMessageHandlerTests.java @@ -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("foo")); byte[] result = stream.toByteArray(); assertEquals(3, result.length); assertEquals("foo", new String(result)); diff --git a/spring-integration-stream/src/test/java/org/springframework/integration/stream/CharacterStreamWritingMessageHandlerTests.java b/spring-integration-stream/src/test/java/org/springframework/integration/stream/CharacterStreamWritingMessageHandlerTests.java index 3f315c8b66..943ee036aa 100644 --- a/spring-integration-stream/src/test/java/org/springframework/integration/stream/CharacterStreamWritingMessageHandlerTests.java +++ b/spring-integration-stream/src/test/java/org/springframework/integration/stream/CharacterStreamWritingMessageHandlerTests.java @@ -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("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("foo"), 0); + channel.send(new GenericMessage("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("foo"), 0); + channel.send(new GenericMessage("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("foo"), 0); + channel.send(new GenericMessage("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("foo"), 0); + channel.send(new GenericMessage("bar"), 0); endpoint.start(); trigger.await(); endpoint.stop(); diff --git a/spring-integration-stream/src/test/java/org/springframework/integration/stream/config/ConsoleOutboundChannelAdapterParserTests.java b/spring-integration-stream/src/test/java/org/springframework/integration/stream/config/ConsoleOutboundChannelAdapterParserTests.java index befbb0047d..17237ddcd8 100644 --- a/spring-integration-stream/src/test/java/org/springframework/integration/stream/config/ConsoleOutboundChannelAdapterParserTests.java +++ b/spring-integration-stream/src/test/java/org/springframework/integration/stream/config/ConsoleOutboundChannelAdapterParserTests.java @@ -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("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("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("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("foo")); assertEquals("foo" + System.getProperty("line.separator"), out.toString()); }