diff --git a/docs/src/main/asciidoc/spring-cloud-stream.adoc b/docs/src/main/asciidoc/spring-cloud-stream.adoc index abcb020bf..7ec774cb5 100644 --- a/docs/src/main/asciidoc/spring-cloud-stream.adoc +++ b/docs/src/main/asciidoc/spring-cloud-stream.adoc @@ -2864,18 +2864,7 @@ testImplementation("org.springframework.cloud:spring-cloud-stream") { } --- -***Remove the dependency for `spring-cloud-stream-test-support`*** -To avoid conflicts with the existing test binder you must remove the following entry - -[source,xml] ----- - - org.springframework.cloud - spring-cloud-stream-test-support - test - ----- ==== Test Binder usage diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/test/InputDestination.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/test/InputDestination.java index 8351eb57d..c3817c3f0 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/test/InputDestination.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/test/InputDestination.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2020 the original author or authors. + * Copyright 2017-2021 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. @@ -48,13 +48,45 @@ public class InputDestination extends AbstractDestination { } /** - * Allows the {@link Message} to be sent to a Binder to be delegated to a named binding - * destination (e.g., "function-in-0" for cases where you want to send input to function with the name 'function'). - * @param message message to send - * @param bindingName binding name + * Allows the {@link Message} to be sent to a Binder's destination.
+ * This needs a bit of clarification. Just like with any binder, 'destination' + * name and 'binding' name are usually the same unless additional configuration + * is provided. For example; Assume you have a function 'uppercase'. The + * 'binding' names for this function would be 'uppercase-in-0' (for input) and + * 'uppercase-out-0' (for output). The 'destination' names would match as well + * unless you decide to provide something like + * 'spring.cloud.stream.bindings.uppercase-in-0.destination=upper' at which + * point the binding names and destination names are different.
+ *
+ * So, it is important to remember that since this binder's goal is to emulate + * real binders and real messaging systems you are sending TO and receiving FROM + * destination (as if it was real broker destination) and binder will map and + * delegate what you send to the binder's destination to individual bindings as + * would the real binder. + * + * * + * + *
+	 *
+	 * // assume the following properties
+	 * "--spring.cloud.fuunction.definition=uppercase",
+	 * "--spring.cloud.stream.bindings.uppercase-in-0.destination=upper",
+	 * "--spring.cloud.stream.bindings.uppercase-out-0.destination=upperout"
+	 *
+	 * // send/receive
+	 * inputDestination.send(message, "upper");
+	 * Message<byte[]> resultMessage = outputDestination.receive(1000, "upperout");
+	 *
+	 * // if 'destination' property is not provided for both input and output
+	 * inputDestination.send(message, "uppercase-in-0");
+	 * Message<byte[]> resultMessage = outputDestination.receive(1000, "upprecase-out-0");
+	 * 
+ * + * @param message message to send + * @param destinationName the name of the destination */ - public void send(Message message, String bindingName) { - this.getChannelByName(bindingName).send(message); + public void send(Message message, String destinationName) { + this.getChannelByName(destinationName).send(message); } } diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/test/TestChannelBinder.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/test/TestChannelBinder.java index 7cce8644b..bbf19939f 100644 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/test/TestChannelBinder.java +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/test/TestChannelBinder.java @@ -111,6 +111,7 @@ public class TestChannelBinder extends private Message lastError; + @SuppressWarnings({ "unchecked", "rawtypes" }) private MessageSource messageSourceDelegate = () -> new GenericMessage<>( "polled data", new MapBuilder() .put(MessageHeaders.CONTENT_TYPE, "text/plain")