From fe14643a8d6960c9b19faa35cc320691ee007c8b Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Thu, 18 Sep 2008 12:40:38 +0000 Subject: [PATCH] Refactored stream targets to outboundChannelAdapters. --- ... => ByteStreamOutboundChannelAdapter.java} | 8 +-- ...haracterStreamOutboundChannelAdapter.java} | 30 ++++----- ...> ConsoleInboundChannelAdapterParser.java} | 2 +- ... ConsoleOutboundChannelAdapterParser.java} | 6 +- .../stream/config/StreamNamespaceHandler.java | 6 +- ...yteStreamOutboundChannelAdapterTests.java} | 22 +++---- ...terStreamOutboundChannelAdapterTests.java} | 18 +++--- ...soleInboundChannelAdapterParserTests.java} | 16 ++--- ...oleOutboundChannelAdapterParserTests.java} | 64 +++++++++---------- ...nsoleInboundChannelAdapterParserTests.xml} | 4 +- ...soleOutboundChannelAdapterParserTests.xml} | 8 +-- ...nsoleInboundChannelAdapterParserTests.xml} | 2 +- ...soleOutboundChannelAdapterParserTests.xml} | 2 +- 13 files changed, 94 insertions(+), 94 deletions(-) rename org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/{ByteStreamTarget.java => ByteStreamOutboundChannelAdapter.java} (86%) rename org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/{CharacterStreamTarget.java => CharacterStreamOutboundChannelAdapter.java} (75%) rename org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/{ConsoleSourceParser.java => ConsoleInboundChannelAdapterParser.java} (94%) rename org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/{ConsoleTargetParser.java => ConsoleOutboundChannelAdapterParser.java} (93%) rename org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/{ByteStreamTargetTests.java => ByteStreamOutboundChannelAdapterTests.java} (87%) rename org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/{CharacterStreamTargetTests.java => CharacterStreamOutboundChannelAdapterTests.java} (84%) rename org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/{ConsoleSourceParserTests.java => ConsoleInboundChannelAdapterParserTests.java} (86%) rename org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/{ConsoleTargetParserTests.java => ConsoleOutboundChannelAdapterParserTests.java} (68%) rename org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/{consoleSourceParserTests.xml => consoleInboundChannelAdapterParserTests.xml} (84%) rename org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/{consoleTargetParserTests.xml => consoleOutboundChannelAdapterParserTests.xml} (69%) rename org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/{invalidConsoleTargetParserTests.xml => invalidConsoleInboundChannelAdapterParserTests.xml} (92%) rename org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/{invalidConsoleSourceParserTests.xml => invalidConsoleOutboundChannelAdapterParserTests.xml} (89%) diff --git a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/ByteStreamTarget.java b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/ByteStreamOutboundChannelAdapter.java similarity index 86% rename from org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/ByteStreamTarget.java rename to org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/ByteStreamOutboundChannelAdapter.java index dec6ddd91e..ac3fc01989 100644 --- a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/ByteStreamTarget.java +++ b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/ByteStreamOutboundChannelAdapter.java @@ -28,22 +28,22 @@ import org.springframework.integration.message.Message; import org.springframework.integration.message.MessagingException; /** - * A target that writes a byte array to an {@link OutputStream}. + * An outbound Channel Adapter that writes a byte array to an {@link OutputStream}. * * @author Mark Fisher */ -public class ByteStreamTarget extends AbstractMessageConsumingEndpoint { +public class ByteStreamOutboundChannelAdapter extends AbstractMessageConsumingEndpoint { private final Log logger = LogFactory.getLog(this.getClass()); private final BufferedOutputStream stream; - public ByteStreamTarget(OutputStream stream) { + public ByteStreamOutboundChannelAdapter(OutputStream stream) { this(stream, -1); } - public ByteStreamTarget(OutputStream stream, int bufferSize) { + public ByteStreamOutboundChannelAdapter(OutputStream stream, int bufferSize) { if (bufferSize > 0) { this.stream = new BufferedOutputStream(stream, bufferSize); } diff --git a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/CharacterStreamTarget.java b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/CharacterStreamOutboundChannelAdapter.java similarity index 75% rename from org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/CharacterStreamTarget.java rename to org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/CharacterStreamOutboundChannelAdapter.java index ea7c66ce83..cc0cfb7450 100644 --- a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/CharacterStreamTarget.java +++ b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/CharacterStreamOutboundChannelAdapter.java @@ -33,15 +33,15 @@ import org.springframework.integration.message.MessagingException; import org.springframework.util.Assert; /** - * A target that writes to a {@link Writer}. String-based objects will be - * written directly, but if the object is not itself a {@link String}, the - * target will write the result of the object's {@link #toString()} method. - * To append a new-line after each write, set the {@link #shouldAppendNewLine} - * flag to true. It is false by default. + * An outbound Channel Adapter that writes to a {@link Writer}. String-based objects + * will be written directly, but if the object is not itself a {@link String}, the + * target will write the result of the object's {@link #toString()} method. To + * append a new-line after each write, set the {@link #shouldAppendNewLine} flag to + * true. It is false by default. * * @author Mark Fisher */ -public class CharacterStreamTarget extends AbstractMessageConsumingEndpoint { +public class CharacterStreamOutboundChannelAdapter extends AbstractMessageConsumingEndpoint { private final Log logger = LogFactory.getLog(this.getClass()); @@ -50,11 +50,11 @@ public class CharacterStreamTarget extends AbstractMessageConsumingEndpoint { private volatile boolean shouldAppendNewLine = false; - public CharacterStreamTarget(Writer writer) { + public CharacterStreamOutboundChannelAdapter(Writer writer) { this(writer, -1); } - public CharacterStreamTarget(Writer writer, int bufferSize) { + public CharacterStreamOutboundChannelAdapter(Writer writer, int bufferSize) { Assert.notNull(writer, "writer must not be null"); if (writer instanceof BufferedWriter) { this.writer = (BufferedWriter) writer; @@ -72,7 +72,7 @@ public class CharacterStreamTarget extends AbstractMessageConsumingEndpoint { * Factory method that creates a target for stdout (System.out) with the * default charset encoding. */ - public static CharacterStreamTarget stdout() { + public static CharacterStreamOutboundChannelAdapter stdout() { return stdout(null); } @@ -80,7 +80,7 @@ public class CharacterStreamTarget extends AbstractMessageConsumingEndpoint { * Factory method that creates a target for stdout (System.out) with the * specified charset encoding. */ - public static CharacterStreamTarget stdout(String charsetName) { + public static CharacterStreamOutboundChannelAdapter stdout(String charsetName) { return createTargetForStream(System.out, charsetName); } @@ -88,7 +88,7 @@ public class CharacterStreamTarget extends AbstractMessageConsumingEndpoint { * Factory method that creates a target for stderr (System.err) with the * default charset encoding. */ - public static CharacterStreamTarget stderr() { + public static CharacterStreamOutboundChannelAdapter stderr() { return stderr(null); } @@ -96,16 +96,16 @@ public class CharacterStreamTarget extends AbstractMessageConsumingEndpoint { * Factory method that creates a target for stderr (System.err) with the * specified charset encoding. */ - public static CharacterStreamTarget stderr(String charsetName) { + public static CharacterStreamOutboundChannelAdapter stderr(String charsetName) { return createTargetForStream(System.err, charsetName); } - private static CharacterStreamTarget createTargetForStream(OutputStream stream, String charsetName) { + private static CharacterStreamOutboundChannelAdapter createTargetForStream(OutputStream stream, String charsetName) { if (charsetName == null) { - return new CharacterStreamTarget(new OutputStreamWriter(stream)); + return new CharacterStreamOutboundChannelAdapter(new OutputStreamWriter(stream)); } try { - return new CharacterStreamTarget(new OutputStreamWriter(stream, charsetName)); + return new CharacterStreamOutboundChannelAdapter(new OutputStreamWriter(stream, charsetName)); } catch (UnsupportedEncodingException e) { throw new ConfigurationException("unsupported encoding: " + charsetName, e); diff --git a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/ConsoleSourceParser.java b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/ConsoleInboundChannelAdapterParser.java similarity index 94% rename from org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/ConsoleSourceParser.java rename to org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/ConsoleInboundChannelAdapterParser.java index f0ef8c019e..ef5d360ccc 100644 --- a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/ConsoleSourceParser.java +++ b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/ConsoleInboundChannelAdapterParser.java @@ -30,7 +30,7 @@ import org.springframework.util.StringUtils; * * @author Mark Fisher */ -public class ConsoleSourceParser extends AbstractPollingInboundChannelAdapterParser { +public class ConsoleInboundChannelAdapterParser extends AbstractPollingInboundChannelAdapterParser { @Override protected String parseSource(Element element, ParserContext parserContext) { diff --git a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/ConsoleTargetParser.java b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/ConsoleOutboundChannelAdapterParser.java similarity index 93% rename from org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/ConsoleTargetParser.java rename to org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/ConsoleOutboundChannelAdapterParser.java index 2a258154d7..5260c2cc3f 100644 --- a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/ConsoleTargetParser.java +++ b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/ConsoleOutboundChannelAdapterParser.java @@ -27,7 +27,7 @@ import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.ConfigurationException; import org.springframework.integration.channel.DirectChannel; -import org.springframework.integration.stream.CharacterStreamTarget; +import org.springframework.integration.stream.CharacterStreamOutboundChannelAdapter; import org.springframework.util.StringUtils; /** @@ -35,11 +35,11 @@ import org.springframework.util.StringUtils; * * @author Mark Fisher */ -public class ConsoleTargetParser extends AbstractSingleBeanDefinitionParser { +public class ConsoleOutboundChannelAdapterParser extends AbstractSingleBeanDefinitionParser { @Override protected Class getBeanClass(Element element) { - return CharacterStreamTarget.class; + return CharacterStreamOutboundChannelAdapter.class; } @Override diff --git a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/StreamNamespaceHandler.java b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/StreamNamespaceHandler.java index 1ba118de66..a2aa7a0d8c 100644 --- a/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/StreamNamespaceHandler.java +++ b/org.springframework.integration.stream/src/main/java/org/springframework/integration/stream/config/StreamNamespaceHandler.java @@ -24,9 +24,9 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport; public class StreamNamespaceHandler extends NamespaceHandlerSupport { public void init() { - this.registerBeanDefinitionParser("stdin-channel-adapter", new ConsoleSourceParser()); - this.registerBeanDefinitionParser("stdout-channel-adapter", new ConsoleTargetParser()); - this.registerBeanDefinitionParser("stderr-channel-adapter", new ConsoleTargetParser()); + this.registerBeanDefinitionParser("stdin-channel-adapter", new ConsoleInboundChannelAdapterParser()); + this.registerBeanDefinitionParser("stdout-channel-adapter", new ConsoleOutboundChannelAdapterParser()); + this.registerBeanDefinitionParser("stderr-channel-adapter", new ConsoleOutboundChannelAdapterParser()); } } diff --git a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/ByteStreamTargetTests.java b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/ByteStreamOutboundChannelAdapterTests.java similarity index 87% rename from org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/ByteStreamTargetTests.java rename to org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/ByteStreamOutboundChannelAdapterTests.java index a45dc22375..9c57de0a42 100644 --- a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/ByteStreamTargetTests.java +++ b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/ByteStreamOutboundChannelAdapterTests.java @@ -33,7 +33,7 @@ import org.springframework.integration.scheduling.PollingSchedule; /** * @author Mark Fisher */ -public class ByteStreamTargetTests { +public class ByteStreamOutboundChannelAdapterTests { private QueueChannel channel; @@ -50,8 +50,8 @@ public class ByteStreamTargetTests { @Test public void testSingleByteArray() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ByteStreamTarget target = new ByteStreamTarget(stream); - target.onMessage(new GenericMessage(new byte[] {1,2,3})); + ByteStreamOutboundChannelAdapter adapter = new ByteStreamOutboundChannelAdapter(stream); + adapter.onMessage(new GenericMessage(new byte[] {1,2,3})); byte[] result = stream.toByteArray(); assertEquals(3, result.length); assertEquals(1, result[0]); @@ -62,7 +62,7 @@ public class ByteStreamTargetTests { @Test public void testSingleString() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ByteStreamTarget target = new ByteStreamTarget(stream); + ByteStreamOutboundChannelAdapter target = new ByteStreamOutboundChannelAdapter(stream); target.onMessage(new StringMessage("foo")); byte[] result = stream.toByteArray(); assertEquals(3, result.length); @@ -72,7 +72,7 @@ public class ByteStreamTargetTests { @Test public void testMaxMessagesPerTaskSameAsMessageCount() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ByteStreamTarget target = new ByteStreamTarget(stream); + ByteStreamOutboundChannelAdapter target = new ByteStreamOutboundChannelAdapter(stream); poller.setMaxMessagesPerPoll(3); poller.subscribe(target); channel.send(new GenericMessage(new byte[] {1,2,3}), 0); @@ -88,7 +88,7 @@ public class ByteStreamTargetTests { @Test public void testMaxMessagesPerTaskLessThanMessageCount() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ByteStreamTarget target = new ByteStreamTarget(stream); + ByteStreamOutboundChannelAdapter target = new ByteStreamOutboundChannelAdapter(stream); poller.setMaxMessagesPerPoll(2); poller.subscribe(target); channel.send(new GenericMessage(new byte[] {1,2,3}), 0); @@ -103,7 +103,7 @@ public class ByteStreamTargetTests { @Test public void testMaxMessagesPerTaskExceedsMessageCount() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ByteStreamTarget target = new ByteStreamTarget(stream); + ByteStreamOutboundChannelAdapter target = new ByteStreamOutboundChannelAdapter(stream); poller.setMaxMessagesPerPoll(5); poller.setReceiveTimeout(0); poller.subscribe(target); @@ -119,7 +119,7 @@ public class ByteStreamTargetTests { @Test public void testMaxMessagesLessThanMessageCountWithMultipleDispatches() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ByteStreamTarget target = new ByteStreamTarget(stream); + ByteStreamOutboundChannelAdapter target = new ByteStreamOutboundChannelAdapter(stream); poller.setMaxMessagesPerPoll(2); poller.setReceiveTimeout(0); poller.subscribe(target); @@ -140,7 +140,7 @@ public class ByteStreamTargetTests { @Test public void testMaxMessagesExceedsMessageCountWithMultipleDispatches() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ByteStreamTarget target = new ByteStreamTarget(stream); + ByteStreamOutboundChannelAdapter target = new ByteStreamOutboundChannelAdapter(stream); poller.setMaxMessagesPerPoll(5); poller.setReceiveTimeout(0); poller.subscribe(target); @@ -160,7 +160,7 @@ public class ByteStreamTargetTests { @Test public void testStreamResetBetweenDispatches() { ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ByteStreamTarget target = new ByteStreamTarget(stream); + ByteStreamOutboundChannelAdapter target = new ByteStreamOutboundChannelAdapter(stream); poller.setMaxMessagesPerPoll(2); poller.setReceiveTimeout(0); poller.subscribe(target); @@ -180,7 +180,7 @@ public class ByteStreamTargetTests { @Test public void testStreamWriteBetweenDispatches() throws IOException { ByteArrayOutputStream stream = new ByteArrayOutputStream(); - ByteStreamTarget target = new ByteStreamTarget(stream); + ByteStreamOutboundChannelAdapter target = new ByteStreamOutboundChannelAdapter(stream); poller.setMaxMessagesPerPoll(2); poller.setReceiveTimeout(0); poller.subscribe(target); diff --git a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/CharacterStreamTargetTests.java b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/CharacterStreamOutboundChannelAdapterTests.java similarity index 84% rename from org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/CharacterStreamTargetTests.java rename to org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/CharacterStreamOutboundChannelAdapterTests.java index 1c575704ce..6ed3378c7a 100644 --- a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/CharacterStreamTargetTests.java +++ b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/CharacterStreamOutboundChannelAdapterTests.java @@ -32,7 +32,7 @@ import org.springframework.integration.scheduling.PollingSchedule; /** * @author Mark Fisher */ -public class CharacterStreamTargetTests { +public class CharacterStreamOutboundChannelAdapterTests { private QueueChannel channel; @@ -49,7 +49,7 @@ public class CharacterStreamTargetTests { @Test public void testSingleString() { StringWriter writer = new StringWriter(); - CharacterStreamTarget target = new CharacterStreamTarget(writer); + CharacterStreamOutboundChannelAdapter target = new CharacterStreamOutboundChannelAdapter(writer); target.onMessage(new StringMessage("foo")); assertEquals("foo", writer.toString()); } @@ -57,7 +57,7 @@ public class CharacterStreamTargetTests { @Test public void testTwoStringsAndNoNewLinesByDefault() { StringWriter writer = new StringWriter(); - CharacterStreamTarget target = new CharacterStreamTarget(writer); + CharacterStreamOutboundChannelAdapter target = new CharacterStreamOutboundChannelAdapter(writer); poller.subscribe(target); poller.setMaxMessagesPerPoll(1); channel.send(new StringMessage("foo"), 0); @@ -71,7 +71,7 @@ public class CharacterStreamTargetTests { @Test public void testTwoStringsWithNewLines() { StringWriter writer = new StringWriter(); - CharacterStreamTarget target = new CharacterStreamTarget(writer); + CharacterStreamOutboundChannelAdapter target = new CharacterStreamOutboundChannelAdapter(writer); target.setShouldAppendNewLine(true); poller.subscribe(target); poller.setMaxMessagesPerPoll(1); @@ -87,7 +87,7 @@ public class CharacterStreamTargetTests { @Test public void testMaxMessagesPerTaskSameAsMessageCount() { StringWriter writer = new StringWriter(); - CharacterStreamTarget target = new CharacterStreamTarget(writer); + CharacterStreamOutboundChannelAdapter target = new CharacterStreamOutboundChannelAdapter(writer); poller.setMaxMessagesPerPoll(2); poller.subscribe(target); channel.send(new StringMessage("foo"), 0); @@ -99,7 +99,7 @@ public class CharacterStreamTargetTests { @Test public void testMaxMessagesPerTaskExceedsMessageCountWithAppendedNewLines() { StringWriter writer = new StringWriter(); - CharacterStreamTarget target = new CharacterStreamTarget(writer); + CharacterStreamOutboundChannelAdapter target = new CharacterStreamOutboundChannelAdapter(writer); poller.setMaxMessagesPerPoll(10); poller.setReceiveTimeout(0); poller.subscribe(target); @@ -114,7 +114,7 @@ public class CharacterStreamTargetTests { @Test public void testSingleNonStringObject() { StringWriter writer = new StringWriter(); - CharacterStreamTarget target = new CharacterStreamTarget(writer); + CharacterStreamOutboundChannelAdapter target = new CharacterStreamOutboundChannelAdapter(writer); poller.subscribe(target); poller.setMaxMessagesPerPoll(1); TestObject testObject = new TestObject("foo"); @@ -126,7 +126,7 @@ public class CharacterStreamTargetTests { @Test public void testTwoNonStringObjectWithOutNewLines() { StringWriter writer = new StringWriter(); - CharacterStreamTarget target = new CharacterStreamTarget(writer); + CharacterStreamOutboundChannelAdapter target = new CharacterStreamOutboundChannelAdapter(writer); poller.setReceiveTimeout(0); poller.setMaxMessagesPerPoll(2); poller.subscribe(target); @@ -141,7 +141,7 @@ public class CharacterStreamTargetTests { @Test public void testTwoNonStringObjectWithNewLines() { StringWriter writer = new StringWriter(); - CharacterStreamTarget target = new CharacterStreamTarget(writer); + CharacterStreamOutboundChannelAdapter target = new CharacterStreamOutboundChannelAdapter(writer); target.setShouldAppendNewLine(true); poller.setReceiveTimeout(0); poller.setMaxMessagesPerPoll(2); diff --git a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleSourceParserTests.java b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleInboundChannelAdapterParserTests.java similarity index 86% rename from org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleSourceParserTests.java rename to org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleInboundChannelAdapterParserTests.java index 20093b0000..16d47a4759 100644 --- a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleSourceParserTests.java +++ b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleInboundChannelAdapterParserTests.java @@ -40,7 +40,7 @@ import org.springframework.integration.message.PollableSource; /** * @author Mark Fisher */ -public class ConsoleSourceParserTests { +public class ConsoleInboundChannelAdapterParserTests { @Before public void writeTestInput() { @@ -49,11 +49,11 @@ public class ConsoleSourceParserTests { } @Test - public void testConsoleSourceWithDefaultCharset() { + public void adapterWithDefaultCharset() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( - "consoleSourceParserTests.xml", ConsoleSourceParserTests.class); + "consoleInboundChannelAdapterParserTests.xml", ConsoleInboundChannelAdapterParserTests.class); SourcePollingChannelAdapter adapter = - (SourcePollingChannelAdapter) context.getBean("sourceWithDefaultCharset.adapter"); + (SourcePollingChannelAdapter) context.getBean("adapterWithDefaultCharset.adapter"); PollableSource source = (PollableSource) new DirectFieldAccessor(adapter).getPropertyValue("source"); DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(source); Reader bufferedReader = (Reader) sourceAccessor.getPropertyValue("reader"); @@ -69,11 +69,11 @@ public class ConsoleSourceParserTests { } @Test - public void testConsoleSourceWithProvidedCharset() { + public void adapterWithProvidedCharset() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( - "consoleSourceParserTests.xml", ConsoleSourceParserTests.class); + "consoleInboundChannelAdapterParserTests.xml", ConsoleInboundChannelAdapterParserTests.class); SourcePollingChannelAdapter adapter = - (SourcePollingChannelAdapter) context.getBean("sourceWithProvidedCharset.adapter"); + (SourcePollingChannelAdapter) context.getBean("adapterWithProvidedCharset.adapter"); PollableSource source = (PollableSource) new DirectFieldAccessor(adapter).getPropertyValue("source"); DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(source); Reader bufferedReader = (Reader) sourceAccessor.getPropertyValue("reader"); @@ -93,7 +93,7 @@ public class ConsoleSourceParserTests { BeanCreationException beanCreationException = null; try { new ClassPathXmlApplicationContext( - "invalidConsoleSourceParserTests.xml", ConsoleSourceParserTests.class); + "invalidConsoleInboundChannelAdapterParserTests.xml", ConsoleInboundChannelAdapterParserTests.class); } catch (BeanCreationException e) { beanCreationException = e; diff --git a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleTargetParserTests.java b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleOutboundChannelAdapterParserTests.java similarity index 68% rename from org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleTargetParserTests.java rename to org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleOutboundChannelAdapterParserTests.java index a554f9d310..4433f539ac 100644 --- a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleTargetParserTests.java +++ b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/ConsoleOutboundChannelAdapterParserTests.java @@ -34,12 +34,12 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.ConfigurationException; import org.springframework.integration.message.StringMessage; -import org.springframework.integration.stream.CharacterStreamTarget; +import org.springframework.integration.stream.CharacterStreamOutboundChannelAdapter; /** * @author Mark Fisher */ -public class ConsoleTargetParserTests { +public class ConsoleOutboundChannelAdapterParserTests { private final ByteArrayOutputStream err = new ByteArrayOutputStream(); @@ -58,13 +58,13 @@ public class ConsoleTargetParserTests { } @Test - public void testConsoleTargetWithDefaultCharset() { + public void stdoutAdapterWithDefaultCharset() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( - "consoleTargetParserTests.xml", ConsoleTargetParserTests.class); - CharacterStreamTarget target = - (CharacterStreamTarget) context.getBean("targetWithDefaultCharset"); - DirectFieldAccessor targetAccessor = new DirectFieldAccessor(target); - Writer bufferedWriter = (Writer) targetAccessor.getPropertyValue("writer"); + "consoleOutboundChannelAdapterParserTests.xml", ConsoleOutboundChannelAdapterParserTests.class); + CharacterStreamOutboundChannelAdapter adapter = + (CharacterStreamOutboundChannelAdapter) context.getBean("stdoutAdapterWithDefaultCharset"); + DirectFieldAccessor accessor = new DirectFieldAccessor(adapter); + Writer bufferedWriter = (Writer) accessor.getPropertyValue("writer"); assertEquals(BufferedWriter.class, bufferedWriter.getClass()); DirectFieldAccessor bufferedWriterAccessor = new DirectFieldAccessor(bufferedWriter); Writer writer = (Writer) bufferedWriterAccessor.getPropertyValue("out"); @@ -72,19 +72,19 @@ public class ConsoleTargetParserTests { Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding()); assertEquals(Charset.defaultCharset(), writerCharset); this.resetStreams(); - target.onMessage(new StringMessage("foo")); + adapter.onMessage(new StringMessage("foo")); assertEquals("foo", out.toString()); assertEquals("", err.toString()); } @Test - public void testConsoleTargetWithProvidedCharset() { + public void stdoutAdapterWithProvidedCharset() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( - "consoleTargetParserTests.xml", ConsoleTargetParserTests.class); - CharacterStreamTarget target = - (CharacterStreamTarget) context.getBean("targetWithProvidedCharset"); - DirectFieldAccessor targetAccessor = new DirectFieldAccessor(target); - Writer bufferedWriter = (Writer) targetAccessor.getPropertyValue("writer"); + "consoleOutboundChannelAdapterParserTests.xml", ConsoleOutboundChannelAdapterParserTests.class); + CharacterStreamOutboundChannelAdapter adapter = + (CharacterStreamOutboundChannelAdapter) context.getBean("stdoutAdapterWithProvidedCharset"); + DirectFieldAccessor accessor = new DirectFieldAccessor(adapter); + Writer bufferedWriter = (Writer) accessor.getPropertyValue("writer"); assertEquals(BufferedWriter.class, bufferedWriter.getClass()); DirectFieldAccessor bufferedWriterAccessor = new DirectFieldAccessor(bufferedWriter); Writer writer = (Writer) bufferedWriterAccessor.getPropertyValue("out"); @@ -92,17 +92,17 @@ public class ConsoleTargetParserTests { Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding()); assertEquals(Charset.forName("UTF-8"), writerCharset); this.resetStreams(); - target.onMessage(new StringMessage("bar")); + adapter.onMessage(new StringMessage("bar")); assertEquals("bar", out.toString()); assertEquals("", err.toString()); } @Test - public void testConsoleTargetWithInvalidCharset() { + public void stdoutAdapterWithInvalidCharset() { BeanCreationException beanCreationException = null; try { new ClassPathXmlApplicationContext( - "invalidConsoleTargetParserTests.xml", ConsoleTargetParserTests.class); + "invalidConsoleOutboundChannelAdapterParserTests.xml", ConsoleOutboundChannelAdapterParserTests.class); } catch (BeanCreationException e) { beanCreationException = e; @@ -114,13 +114,13 @@ public class ConsoleTargetParserTests { } @Test - public void testErrorTarget() { + public void stderrAdapter() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( - "consoleTargetParserTests.xml", ConsoleTargetParserTests.class); - CharacterStreamTarget target = - (CharacterStreamTarget) context.getBean("stderrTarget"); - DirectFieldAccessor targetAccessor = new DirectFieldAccessor(target); - Writer bufferedWriter = (Writer) targetAccessor.getPropertyValue("writer"); + "consoleOutboundChannelAdapterParserTests.xml", ConsoleOutboundChannelAdapterParserTests.class); + CharacterStreamOutboundChannelAdapter adapter = + (CharacterStreamOutboundChannelAdapter) context.getBean("stderrAdapter"); + DirectFieldAccessor accessor = new DirectFieldAccessor(adapter); + Writer bufferedWriter = (Writer) accessor.getPropertyValue("writer"); assertEquals(BufferedWriter.class, bufferedWriter.getClass()); DirectFieldAccessor bufferedWriterAccessor = new DirectFieldAccessor(bufferedWriter); Writer writer = (Writer) bufferedWriterAccessor.getPropertyValue("out"); @@ -128,19 +128,19 @@ public class ConsoleTargetParserTests { Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding()); assertEquals(Charset.defaultCharset(), writerCharset); this.resetStreams(); - target.onMessage(new StringMessage("bad")); + adapter.onMessage(new StringMessage("bad")); assertEquals("", out.toString()); assertEquals("bad", err.toString()); } @Test - public void testAppendNewLine() { + public void stdoutAdatperWithAppendNewLine() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( - "consoleTargetParserTests.xml", ConsoleTargetParserTests.class); - CharacterStreamTarget target = - (CharacterStreamTarget) context.getBean("newlineTarget"); - DirectFieldAccessor targetAccessor = new DirectFieldAccessor(target); - Writer bufferedWriter = (Writer) targetAccessor.getPropertyValue("writer"); + "consoleOutboundChannelAdapterParserTests.xml", ConsoleOutboundChannelAdapterParserTests.class); + CharacterStreamOutboundChannelAdapter adapter = + (CharacterStreamOutboundChannelAdapter) context.getBean("newlineAdapter"); + DirectFieldAccessor accessor = new DirectFieldAccessor(adapter); + Writer bufferedWriter = (Writer) accessor.getPropertyValue("writer"); assertEquals(BufferedWriter.class, bufferedWriter.getClass()); DirectFieldAccessor bufferedWriterAccessor = new DirectFieldAccessor(bufferedWriter); Writer writer = (Writer) bufferedWriterAccessor.getPropertyValue("out"); @@ -148,7 +148,7 @@ public class ConsoleTargetParserTests { Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding()); assertEquals(Charset.defaultCharset(), writerCharset); this.resetStreams(); - target.onMessage(new StringMessage("foo")); + adapter.onMessage(new StringMessage("foo")); assertEquals("foo\n", out.toString()); } diff --git a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/consoleSourceParserTests.xml b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/consoleInboundChannelAdapterParserTests.xml similarity index 84% rename from org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/consoleSourceParserTests.xml rename to org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/consoleInboundChannelAdapterParserTests.xml index 1a007129c8..46c54a7bb5 100644 --- a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/consoleSourceParserTests.xml +++ b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/consoleInboundChannelAdapterParserTests.xml @@ -10,8 +10,8 @@ http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd"> - + - + \ No newline at end of file diff --git a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/consoleTargetParserTests.xml b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/consoleOutboundChannelAdapterParserTests.xml similarity index 69% rename from org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/consoleTargetParserTests.xml rename to org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/consoleOutboundChannelAdapterParserTests.xml index d2bf4c0bc1..d7b252bec3 100644 --- a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/consoleTargetParserTests.xml +++ b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/consoleOutboundChannelAdapterParserTests.xml @@ -12,12 +12,12 @@ - + - + - + - + \ No newline at end of file diff --git a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/invalidConsoleTargetParserTests.xml b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/invalidConsoleInboundChannelAdapterParserTests.xml similarity index 92% rename from org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/invalidConsoleTargetParserTests.xml rename to org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/invalidConsoleInboundChannelAdapterParserTests.xml index 03b7f16d98..591d35b4a0 100644 --- a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/invalidConsoleTargetParserTests.xml +++ b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/invalidConsoleInboundChannelAdapterParserTests.xml @@ -10,6 +10,6 @@ http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd"> - + \ No newline at end of file diff --git a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/invalidConsoleSourceParserTests.xml b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/invalidConsoleOutboundChannelAdapterParserTests.xml similarity index 89% rename from org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/invalidConsoleSourceParserTests.xml rename to org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/invalidConsoleOutboundChannelAdapterParserTests.xml index b70efc6f4f..41b7172c0b 100644 --- a/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/invalidConsoleSourceParserTests.xml +++ b/org.springframework.integration.stream/src/test/java/org/springframework/integration/stream/config/invalidConsoleOutboundChannelAdapterParserTests.xml @@ -10,6 +10,6 @@ http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream-1.0.xsd"> - + \ No newline at end of file