diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..0679d88a9
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,14 @@
+# EditorConfig is awesome: http://EditorConfig.org
+
+# top-most EditorConfig file
+root = true
+
+[*]
+indent_style = tab
+indent_size = 4
+end_of_line = lf
+insert_final_newline = true
+
+[*.yml]
+indent_style = space
+indent_size = 2
diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java
new file mode 100755
index 000000000..fa4f7b499
--- /dev/null
+++ b/.mvn/wrapper/MavenWrapperDownloader.java
@@ -0,0 +1,110 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+*/
+
+import java.net.*;
+import java.io.*;
+import java.nio.channels.*;
+import java.util.Properties;
+
+public class MavenWrapperDownloader {
+
+ /**
+ * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
+ */
+ private static final String DEFAULT_DOWNLOAD_URL =
+ "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
+
+ /**
+ * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
+ * use instead of the default one.
+ */
+ private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
+ ".mvn/wrapper/maven-wrapper.properties";
+
+ /**
+ * Path where the maven-wrapper.jar will be saved to.
+ */
+ private static final String MAVEN_WRAPPER_JAR_PATH =
+ ".mvn/wrapper/maven-wrapper.jar";
+
+ /**
+ * Name of the property which should be used to override the default download url for the wrapper.
+ */
+ private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
+
+ public static void main(String args[]) {
+ System.out.println("- Downloader started");
+ File baseDirectory = new File(args[0]);
+ System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
+
+ // If the maven-wrapper.properties exists, read it and check if it contains a custom
+ // wrapperUrl parameter.
+ File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
+ String url = DEFAULT_DOWNLOAD_URL;
+ if(mavenWrapperPropertyFile.exists()) {
+ FileInputStream mavenWrapperPropertyFileInputStream = null;
+ try {
+ mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
+ Properties mavenWrapperProperties = new Properties();
+ mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
+ url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
+ } catch (IOException e) {
+ System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
+ } finally {
+ try {
+ if(mavenWrapperPropertyFileInputStream != null) {
+ mavenWrapperPropertyFileInputStream.close();
+ }
+ } catch (IOException e) {
+ // Ignore ...
+ }
+ }
+ }
+ System.out.println("- Downloading from: : " + url);
+
+ File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
+ if(!outputFile.getParentFile().exists()) {
+ if(!outputFile.getParentFile().mkdirs()) {
+ System.out.println(
+ "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
+ }
+ }
+ System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
+ try {
+ downloadFileFromURL(url, outputFile);
+ System.out.println("Done");
+ System.exit(0);
+ } catch (Throwable e) {
+ System.out.println("- Error downloading");
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+ private static void downloadFileFromURL(String urlString, File destination) throws Exception {
+ URL website = new URL(urlString);
+ ReadableByteChannel rbc;
+ rbc = Channels.newChannel(website.openStream());
+ FileOutputStream fos = new FileOutputStream(destination);
+ fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
+ fos.close();
+ rbc.close();
+ }
+
+}
diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar
old mode 100644
new mode 100755
index 5fd4d5023..01e679973
Binary files a/.mvn/wrapper/maven-wrapper.jar and b/.mvn/wrapper/maven-wrapper.jar differ
diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties
old mode 100644
new mode 100755
index 6637cedb2..00d32aab1
--- a/.mvn/wrapper/maven-wrapper.properties
+++ b/.mvn/wrapper/maven-wrapper.properties
@@ -1 +1 @@
-distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
\ No newline at end of file
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip
\ No newline at end of file
diff --git a/.settings.xml b/.settings.xml
index 6c355129e..6f542c940 100644
--- a/.settings.xml
+++ b/.settings.xml
@@ -1,66 +1,68 @@
-
-
- repo.spring.io
- ${env.CI_DEPLOY_USERNAME}
- ${env.CI_DEPLOY_PASSWORD}
-
-
-
-
-
- spring
- true
-
-
- spring-snapshots
- Spring Snapshots
- http://repo.spring.io/libs-snapshot-local
-
- true
-
-
-
- spring-milestones
- Spring Milestones
- http://repo.spring.io/libs-milestone-local
-
- false
-
-
-
- spring-releases
- Spring Releases
- http://repo.spring.io/release
-
- false
-
-
-
-
-
- spring-snapshots
- Spring Snapshots
- http://repo.spring.io/libs-snapshot-local
-
- true
-
-
-
- spring-milestones
- Spring Milestones
- http://repo.spring.io/libs-milestone-local
-
- false
-
-
-
-
-
+
+
+ repo.spring.io
+ ${env.CI_DEPLOY_USERNAME}
+ ${env.CI_DEPLOY_PASSWORD}
+
+
+
+
+
+ spring
+
+ true
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ http://repo.spring.io/libs-snapshot-local
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ http://repo.spring.io/libs-milestone-local
+
+ false
+
+
+
+ spring-releases
+ Spring Releases
+ http://repo.spring.io/release
+
+ false
+
+
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ http://repo.spring.io/libs-snapshot-local
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ http://repo.spring.io/libs-milestone-local
+
+ false
+
+
+
+
+
diff --git a/spring-cloud-stream-tools/.jdk8 b/.springformat
similarity index 100%
rename from spring-cloud-stream-tools/.jdk8
rename to .springformat
diff --git a/docs/pom.xml b/docs/pom.xml
index 7485e6976..33199fd55 100644
--- a/docs/pom.xml
+++ b/docs/pom.xml
@@ -1,5 +1,7 @@
-
+
4.0.0
spring-cloud-stream-core-docs
@@ -15,36 +17,35 @@
${basedir}/..
-
- docs
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- org.asciidoctor
- asciidoctor-maven-plugin
- false
-
-
- com.agilejava.docbkx
- docbkx-maven-plugin
-
-
- org.apache.maven.plugins
- maven-antrun-plugin
- false
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
- false
-
-
-
-
-
+
+ docs
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ org.asciidoctor
+ asciidoctor-maven-plugin
+ false
+
+
+ com.agilejava.docbkx
+ docbkx-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ false
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ false
+
+
+
+
+
-
\ No newline at end of file
diff --git a/docs/src/main/asciidoc/spring-cloud-stream.adoc b/docs/src/main/asciidoc/spring-cloud-stream.adoc
index 576f753d0..74021c2d2 100644
--- a/docs/src/main/asciidoc/spring-cloud-stream.adoc
+++ b/docs/src/main/asciidoc/spring-cloud-stream.adoc
@@ -88,7 +88,7 @@ public class StreamApplicationTests {
@Test
public void contextLoads() {
- assertNotNull(this.sink.input());
+ assertThat(this.sink.input()).isNotNull();
}
}
----
diff --git a/mvnw b/mvnw
index 0a7dac221..5551fde8e 100755
--- a/mvnw
+++ b/mvnw
@@ -54,38 +54,16 @@ case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
- #
- # Look for the Apple JDKs first to preserve the existing behaviour, and then look
- # for the new JDKs provided by Oracle.
- #
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
- #
- # Oracle JDKs
- #
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
- fi
-
- if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
- #
- # Apple JDKs
- #
- export JAVA_HOME=`/usr/libexec/java_home`
- fi
- ;;
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ export JAVA_HOME="`/usr/libexec/java_home`"
+ else
+ export JAVA_HOME="/Library/Java/Home"
+ fi
+ fi
+ ;;
esac
if [ -z "$JAVA_HOME" ] ; then
@@ -130,7 +108,7 @@ if $cygwin ; then
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
-# For Migwn, ensure paths are in UNIX format before anything is touched
+# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
@@ -184,27 +162,28 @@ fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin; then
- [ -n "$M2_HOME" ] &&
- M2_HOME=`cygpath --path --windows "$M2_HOME"`
- [ -n "$JAVA_HOME" ] &&
- JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
-fi
-
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
- local basedir=$(pwd)
- local wdir=$(pwd)
+
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
- wdir=$(cd "$wdir/.."; pwd)
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=`cd "$wdir/.."; pwd`
+ fi
+ # end of workaround
done
echo "${basedir}"
}
@@ -216,30 +195,92 @@ concat_lines() {
fi
}
-export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found .mvn/wrapper/maven-wrapper.jar"
+ fi
+else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+ fi
+ jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+ while IFS="=" read key value; do
+ case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
+ esac
+ done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Downloading from: $jarUrl"
+ fi
+ wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
+
+ if command -v wget > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found wget ... using wget"
+ fi
+ wget "$jarUrl" -O "$wrapperJarPath"
+ elif command -v curl > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found curl ... using curl"
+ fi
+ curl -o "$wrapperJarPath" "$jarUrl"
+ else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Falling back to using Java to download"
+ fi
+ javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ if [ -e "$javaClass" ]; then
+ if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Compiling MavenWrapperDownloader.java ..."
+ fi
+ # Compiling the Java class
+ ("$JAVA_HOME/bin/javac" "$javaClass")
+ fi
+ if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
+ # Running the downloader
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo " - Running MavenWrapperDownloader.java ..."
+ fi
+ ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
+ fi
+ fi
+ fi
+fi
+##########################################################################################
+# End of extension
+##########################################################################################
+
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
+if [ "$MVNW_VERBOSE" = true ]; then
+ echo $MAVEN_PROJECTBASEDIR
+fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
-# Provide a "standardized" way to retrieve the CLI args that will
-# work with both Windows and non-Windows executions.
-MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
-export MAVEN_CMD_LINE_ARGS
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --path --windows "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
+ [ -n "$MAVEN_PROJECTBASEDIR" ] &&
+ MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
+fi
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-echo "Running version check"
-VERSION=$( sed '\!//' -e 's!.*$!!' )
-echo "The found version is [${VERSION}]"
-
-if echo $VERSION | egrep -q 'M|RC'; then
- echo Activating \"milestone\" profile for version=\"$VERSION\"
- echo $MAVEN_ARGS | grep -q milestone || MAVEN_ARGS="$MAVEN_ARGS -Pmilestone"
-else
- echo Deactivating \"milestone\" profile for version=\"$VERSION\"
- echo $MAVEN_ARGS | grep -q milestone && MAVEN_ARGS=$(echo $MAVEN_ARGS | sed -e 's/-Pmilestone//')
-fi
-
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
- ${WRAPPER_LAUNCHER} ${MAVEN_ARGS} "$@"
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/mvnw.cmd b/mvnw.cmd
old mode 100644
new mode 100755
index fc8302432..48363fa60
--- a/mvnw.cmd
+++ b/mvnw.cmd
@@ -35,6 +35,8 @@
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
+@REM set title of command window
+title %0
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@@ -80,8 +82,6 @@ goto error
:init
-set MAVEN_CMD_LINE_ARGS=%*
-
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
@@ -117,11 +117,27 @@ for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do s
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
-
-set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar""
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
-%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
+ IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ echo Found %WRAPPER_JAR%
+) else (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
+ echo Finished downloading %WRAPPER_JAR%
+)
+@REM End of extension
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
diff --git a/pom.xml b/pom.xml
index 6b5a6ef4d..2609cc4f9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,282 +1,276 @@
-
- 4.0.0
- spring-cloud-stream-parent
- 2.1.1.BUILD-SNAPSHOT
- pom
-
- org.springframework.cloud
- spring-cloud-build
- 2.1.0.BUILD-SNAPSHOT
-
-
-
- https://github.com/spring-cloud/spring-cloud-stream
- scm:git:git://github.com/spring-cloud/spring-cloud-stream.git
- scm:git:ssh://git@github.com/spring-cloud/spring-cloud-stream.git
- HEAD
-
-
- 1.8
- 1.0.0.RELEASE
- 1.0.0.RELEASE
- Californium-RELEASE
- 3.0.3
- 2.1
- 2.0.0.BUILD-SNAPSHOT
-
-
-
-
- org.springframework.cloud
- spring-cloud-function-context
- ${spring-cloud-function.version}
-
-
- org.springframework.cloud
- spring-cloud-stream
- ${project.version}
-
-
- org.springframework.cloud
- spring-cloud-stream-tools
- ${project.version}
-
-
- org.springframework.cloud
- spring-cloud-stream-schema-server
- ${project.version}
-
-
- org.springframework.cloud
- spring-cloud-stream-binder-test
- ${project.version}
-
-
- org.springframework
- spring-tuple
- ${spring.tuple.version}
-
-
- org.springframework.integration
- spring-integration-tuple
- ${spring.integration.tuple.version}
-
-
- org.springframework.cloud
- spring-cloud-stream-test-support
- ${project.version}
-
-
- org.springframework.cloud
- spring-cloud-stream-test-support-internal
- ${project.version}
-
-
- com.esotericsoftware
- kryo-shaded
- ${kryo-shaded.version}
-
-
- io.projectreactor
- reactor-bom
- ${reactor.version}
- pom
- import
-
-
- org.objenesis
- objenesis
- ${objenesis.version}
-
-
- org.springframework.cloud
- spring-cloud-stream
- ${project.version}
- test-jar
- test
- test-binder
-
-
-
-
- spring-cloud-stream
- spring-cloud-stream-binder-test
- spring-cloud-stream-test-support
- spring-cloud-stream-test-support-internal
- spring-cloud-stream-integration-tests
- spring-cloud-stream-reactive
- spring-cloud-stream-schema
- spring-cloud-stream-schema-server
- spring-cloud-stream-tools
+
+ 4.0.0
+ spring-cloud-stream-parent
+ 2.1.1.BUILD-SNAPSHOT
+ pom
+
+ org.springframework.cloud
+ spring-cloud-build
+ 2.1.3.BUILD-SNAPSHOT
+
+
+
+ https://github.com/spring-cloud/spring-cloud-stream
+ scm:git:git://github.com/spring-cloud/spring-cloud-stream.git
+
+
+ scm:git:ssh://git@github.com/spring-cloud/spring-cloud-stream.git
+
+ HEAD
+
+
+ 1.8
+ 1.0.0.RELEASE
+ 1.0.0.RELEASE
+ Californium-RELEASE
+ 3.0.3
+ 2.1
+ 2.0.0.BUILD-SNAPSHOT
+
+
+ true
+ true
+
+ true
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-function-context
+ ${spring-cloud-function.version}
+
+
+ org.springframework.cloud
+ spring-cloud-stream
+ ${project.version}
+
+
+ org.springframework.cloud
+ spring-cloud-stream-tools
+ ${project.version}
+
+
+ org.springframework.cloud
+ spring-cloud-stream-schema-server
+ ${project.version}
+
+
+ org.springframework.cloud
+ spring-cloud-stream-binder-test
+ ${project.version}
+
+
+ org.springframework
+ spring-tuple
+ ${spring.tuple.version}
+
+
+ org.springframework.integration
+ spring-integration-tuple
+ ${spring.integration.tuple.version}
+
+
+ org.springframework.cloud
+ spring-cloud-stream-test-support
+ ${project.version}
+
+
+ org.springframework.cloud
+ spring-cloud-stream-test-support-internal
+ ${project.version}
+
+
+ com.esotericsoftware
+ kryo-shaded
+ ${kryo-shaded.version}
+
+
+ io.projectreactor
+ reactor-bom
+ ${reactor.version}
+ pom
+ import
+
+
+ org.objenesis
+ objenesis
+ ${objenesis.version}
+
+
+ org.springframework.cloud
+ spring-cloud-stream
+ ${project.version}
+ test-jar
+ test
+ test-binder
+
+
+
+
+ spring-cloud-stream
+ spring-cloud-stream-binder-test
+ spring-cloud-stream-test-support
+ spring-cloud-stream-test-support-internal
+ spring-cloud-stream-integration-tests
+ spring-cloud-stream-reactive
+ spring-cloud-stream-schema
+ spring-cloud-stream-schema-server
docs
-
-
-
-
-
- org.apache.maven.plugins
- maven-antrun-plugin
- 1.7
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
- 2.17
-
-
- com.puppycrawl.tools
- checkstyle
- 7.1
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
-
- true
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- true
-
-
-
-
-
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ 1.7
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+
+
+
+
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
- ${java.version}
- ${java.version}
- -parameters
-
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+ ${java.version}
+ ${java.version}
+ -parameters
+
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
-
- checkstyle-validation
- validate
-
- spring-cloud-stream-tools/src/main/resources/checkstyle.xml
- spring-cloud-stream-tools/src/main/resources/checkstyle-header.txt
- spring-cloud-stream-tools/src/main/resources/checkstyle-suppressions.xml
- UTF-8
- true
- true
- true
-
-
- check
-
-
-
-
-
-
-
-
- spring
-
-
- spring-snapshots
- Spring Snapshots
- https://repo.spring.io/libs-snapshot-local
-
- true
-
-
- false
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/libs-milestone-local
-
- false
-
-
-
- spring-releases
- Spring Releases
- https://repo.spring.io/release
-
- false
-
-
-
-
-
- spring-snapshots
- Spring Snapshots
- https://repo.spring.io/libs-snapshot-local
-
- true
-
-
- false
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/libs-milestone-local
-
- false
-
-
-
- spring-releases
- Spring Releases
- https://repo.spring.io/libs-release-local
-
- false
-
-
-
-
-
- coverage
-
-
- env.TRAVIS
- true
-
-
-
-
-
- org.jacoco
- jacoco-maven-plugin
- 0.7.9
-
-
- agent
-
- prepare-agent
-
-
-
- report
- test
-
- report
-
-
-
-
-
-
-
-
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+ io.spring.javaformat
+ spring-javaformat-maven-plugin
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+
+
+
+
+ spring
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/libs-snapshot-local
+
+ true
+
+
+ false
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/libs-milestone-local
+
+ false
+
+
+
+ spring-releases
+ Spring Releases
+ https://repo.spring.io/release
+
+ false
+
+
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/libs-snapshot-local
+
+ true
+
+
+ false
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/libs-milestone-local
+
+ false
+
+
+
+ spring-releases
+ Spring Releases
+ https://repo.spring.io/libs-release-local
+
+ false
+
+
+
+
+
+ coverage
+
+
+ env.TRAVIS
+ true
+
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.7.9
+
+
+ agent
+
+ prepare-agent
+
+
+
+ report
+ test
+
+ report
+
+
+
+
+
+
+
+
diff --git a/spring-cloud-stream-binder-test/pom.xml b/spring-cloud-stream-binder-test/pom.xml
index dcc11a58f..7b94c05a3 100644
--- a/spring-cloud-stream-binder-test/pom.xml
+++ b/spring-cloud-stream-binder-test/pom.xml
@@ -1,5 +1,7 @@
-
+
4.0.0
spring-cloud-stream-binder-test
diff --git a/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/AbstractBinderTests.java b/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/AbstractBinderTests.java
index 2d02e4650..7660c83b5 100644
--- a/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/AbstractBinderTests.java
+++ b/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/AbstractBinderTests.java
@@ -63,8 +63,6 @@ import org.springframework.util.MimeTypeUtils;
import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
/**
* @author Gary Russell
@@ -76,20 +74,18 @@ import static org.junit.Assert.assertTrue;
* @author Jacob Severson
* @author Artem Bilan
*/
+// @checkstyle:off
@SuppressWarnings("unchecked")
public abstract class AbstractBinderTests, CP, PP>, CP extends ConsumerProperties, PP extends ProducerProperties> {
+ // @checkstyle:on
+
protected final Log logger = LogFactory.getLog(this.getClass());
protected B testBinder;
protected SmartMessageConverter messageConverter;
- @Before
- public void before() {
- this.messageConverter = new CompositeMessageConverterFactory().getMessageConverterForAllRegistered();
- }
-
/**
* Subclasses may override this default value to have tests wait longer for a message
* receive, for example if running in an environment that is known to be slow (e.g.
@@ -97,6 +93,12 @@ public abstract class AbstractBinderTests receive(PollableChannel channel, int additionalMultiplier) {
long startTime = System.currentTimeMillis();
Message> receive = channel
- .receive((int) (1000 * timeoutMultiplier * additionalMultiplier));
+ .receive((int) (1000 * this.timeoutMultiplier * additionalMultiplier));
long elapsed = System.currentTimeMillis() - startTime;
- logger.debug("receive() took " + elapsed / 1000 + " seconds");
+ this.logger.debug("receive() took " + elapsed / 1000 + " seconds");
return receive;
}
@@ -124,20 +126,25 @@ public abstract class AbstractBinderTests foo0ProducerBinding = binder.bindProducer(String.format("foo%s0",
- getDestinationNameDelimiter()), this.createBindableChannel("output", new BindingProperties()),
+ Binding foo0ProducerBinding = binder.bindProducer(
+ String.format("foo%s0", getDestinationNameDelimiter()),
+ this.createBindableChannel("output", new BindingProperties()),
createProducerProperties());
- Binding foo0ConsumerBinding = binder.bindConsumer(String.format("foo%s0",
- getDestinationNameDelimiter()), "testClean", this.createBindableChannel("input",
- new BindingProperties()), createConsumerProperties());
- Binding foo1ProducerBinding = binder.bindProducer(String.format("foo%s1",
- getDestinationNameDelimiter()), this.createBindableChannel("output", new BindingProperties()),
+ Binding foo0ConsumerBinding = binder.bindConsumer(
+ String.format("foo%s0", getDestinationNameDelimiter()), "testClean",
+ this.createBindableChannel("input", new BindingProperties()),
+ createConsumerProperties());
+ Binding foo1ProducerBinding = binder.bindProducer(
+ String.format("foo%s1", getDestinationNameDelimiter()),
+ this.createBindableChannel("output", new BindingProperties()),
createProducerProperties());
- Binding foo1ConsumerBinding = binder.bindConsumer(String.format("foo%s1",
- getDestinationNameDelimiter()), "testClean", this.createBindableChannel("input",
- new BindingProperties()), createConsumerProperties());
- Binding foo2ProducerBinding = binder.bindProducer(String.format("foo%s2",
- getDestinationNameDelimiter()), this.createBindableChannel("output", new BindingProperties()),
+ Binding foo1ConsumerBinding = binder.bindConsumer(
+ String.format("foo%s1", getDestinationNameDelimiter()), "testClean",
+ this.createBindableChannel("input", new BindingProperties()),
+ createConsumerProperties());
+ Binding foo2ProducerBinding = binder.bindProducer(
+ String.format("foo%s2", getDestinationNameDelimiter()),
+ this.createBindableChannel("output", new BindingProperties()),
createProducerProperties());
foo0ProducerBinding.unbind();
assertThat(TestUtils
@@ -165,18 +172,25 @@ public abstract class AbstractBinderTests producerBinding = binder.bindProducer(String.format("foo%s0",
- getDestinationNameDelimiter()), moduleOutputChannel, outputBindingProperties.getProducer());
- Binding consumerBinding = binder.bindConsumer(String.format("foo%s0",
- getDestinationNameDelimiter()), "testSendAndReceive", moduleInputChannel, inputBindingProperties.getConsumer());
- Message> message = MessageBuilder.withPayload("foo").setHeader(MessageHeaders.CONTENT_TYPE, "text/plain")
- .build();
+ Binding producerBinding = binder.bindProducer(
+ String.format("foo%s0", getDestinationNameDelimiter()),
+ moduleOutputChannel, outputBindingProperties.getProducer());
+ Binding consumerBinding = binder.bindConsumer(
+ String.format("foo%s0", getDestinationNameDelimiter()),
+ "testSendAndReceive", moduleInputChannel,
+ inputBindingProperties.getConsumer());
+ Message> message = MessageBuilder.withPayload("foo")
+ .setHeader(MessageHeaders.CONTENT_TYPE, "text/plain").build();
// Let the consumer actually bind to the producer before sending a msg
binderBindUnbindLatency();
@@ -195,44 +209,39 @@ public abstract class AbstractBinderTests producerBinding = binder.bindProducer(String.format("foo%s0x",
- getDestinationNameDelimiter()), moduleOutputChannel, outputBindingProperties.getProducer());
- Binding consumerBinding = binder.bindConsumer(String.format("foo%s0x",
- getDestinationNameDelimiter()), "testSendAndReceiveKryo", moduleInputChannel, inputBindingProperties.getConsumer());
+ Binding producerBinding = binder.bindProducer(
+ String.format("foo%s0x", getDestinationNameDelimiter()),
+ moduleOutputChannel, outputBindingProperties.getProducer());
+ Binding consumerBinding = binder.bindConsumer(
+ String.format("foo%s0x", getDestinationNameDelimiter()),
+ "testSendAndReceiveKryo", moduleInputChannel,
+ inputBindingProperties.getConsumer());
Foo foo = new Foo();
foo.setName("Bill");
- Message> message = MessageBuilder.withPayload(foo).setHeader(MessageHeaders.CONTENT_TYPE, MessageConverterUtils.X_JAVA_OBJECT)
- .build();
+ Message> message = MessageBuilder.withPayload(foo).setHeader(
+ MessageHeaders.CONTENT_TYPE, MessageConverterUtils.X_JAVA_OBJECT).build();
// Let the consumer actually bind to the producer before sending a msg
binderBindUnbindLatency();
@@ -252,34 +261,41 @@ public abstract class AbstractBinderTests producerBinding = binder.bindProducer(String.format("foo%s0y",
- getDestinationNameDelimiter()), moduleOutputChannel, outputBindingProperties.getProducer());
+ Binding producerBinding = binder.bindProducer(
+ String.format("foo%s0y", getDestinationNameDelimiter()),
+ moduleOutputChannel, outputBindingProperties.getProducer());
- Binding consumerBinding = binder.bindConsumer(String.format("foo%s0y",
- getDestinationNameDelimiter()), "testSendAndReceiveJavaSerialization", moduleInputChannel,
+ Binding consumerBinding = binder.bindConsumer(
+ String.format("foo%s0y", getDestinationNameDelimiter()),
+ "testSendAndReceiveJavaSerialization", moduleInputChannel,
inputBindingProperties.getConsumer());
SerializableFoo foo = new SerializableFoo();
- Message> message =
- MessageBuilder.withPayload(foo)
- .setHeader(MessageHeaders.CONTENT_TYPE, MessageConverterUtils.X_JAVA_SERIALIZED_OBJECT)
- .build();
+ Message> message = MessageBuilder.withPayload(foo)
+ .setHeader(MessageHeaders.CONTENT_TYPE,
+ MessageConverterUtils.X_JAVA_SERIALIZED_OBJECT)
+ .build();
// Let the consumer actually bind to the producer before sending a msg
binderBindUnbindLatency();
@@ -298,10 +314,13 @@ public abstract class AbstractBinderTests producerBinding1 = binder.bindProducer(String.format("foo%sxy",
- getDestinationNameDelimiter()), moduleOutputChannel1, producerBindingProperties.getProducer());
- Binding producerBinding2 = binder.bindProducer(String.format("foo%syz",
+ Binding producerBinding1 = binder.bindProducer(
+ String.format("foo%sxy", getDestinationNameDelimiter()),
+ moduleOutputChannel1, producerBindingProperties.getProducer());
+ Binding producerBinding2 = binder.bindProducer(
+ String.format("foo%syz",
- getDestinationNameDelimiter()), moduleOutputChannel2, producerBindingProperties.getProducer());
+ getDestinationNameDelimiter()),
+ moduleOutputChannel2, producerBindingProperties.getProducer());
- Binding consumerBinding1 = binder.bindConsumer(String.format("foo%sxy",
- getDestinationNameDelimiter()), "testSendAndReceiveMultipleTopics", moduleInputChannel,
+ Binding consumerBinding1 = binder.bindConsumer(
+ String.format("foo%sxy", getDestinationNameDelimiter()),
+ "testSendAndReceiveMultipleTopics", moduleInputChannel,
createConsumerProperties());
- Binding consumerBinding2 = binder.bindConsumer(String.format("foo%syz",
- getDestinationNameDelimiter()), "testSendAndReceiveMultipleTopics", moduleInputChannel,
+ Binding consumerBinding2 = binder.bindConsumer(
+ String.format("foo%syz", getDestinationNameDelimiter()),
+ "testSendAndReceiveMultipleTopics", moduleInputChannel,
createConsumerProperties());
String testPayload1 = "foo" + UUID.randomUUID().toString();
@@ -373,12 +400,16 @@ public abstract class AbstractBinderTests producerBinding = binder.bindProducer(String.format("bar%s0",
- getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());
- Binding consumerBinding = binder.bindConsumer(String.format("bar%s0",
- getDestinationNameDelimiter()), "testSendAndReceiveNoOriginalContentType", moduleInputChannel,
+ BindingProperties inputBindingProperties = createConsumerBindingProperties(
+ createConsumerProperties());
+ DirectChannel moduleInputChannel = createBindableChannel("input",
+ inputBindingProperties);
+ Binding producerBinding = binder.bindProducer(
+ String.format("bar%s0", getDestinationNameDelimiter()),
+ moduleOutputChannel, producerBindingProperties.getProducer());
+ Binding consumerBinding = binder.bindConsumer(
+ String.format("bar%s0", getDestinationNameDelimiter()),
+ "testSendAndReceiveNoOriginalContentType", moduleInputChannel,
createConsumerProperties());
binderBindUnbindLatency();
@@ -400,8 +431,8 @@ public abstract class AbstractBinderTests producerBinding = binder.bindProducer(String.format("bad%s0a",
- getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());
+ Binding producerBinding = binder.bindProducer(
+ String.format("bad%s0a", getDestinationNameDelimiter()),
+ moduleOutputChannel, producerBindingProperties.getProducer());
- Binding consumerBinding = binder.bindConsumer(String.format("bad%s0a",
- getDestinationNameDelimiter()), "test-1", moduleInputChannel, consumerBindingProperties.getConsumer());
+ Binding consumerBinding = binder.bindConsumer(
+ String.format("bad%s0a", getDestinationNameDelimiter()), "test-1",
+ moduleInputChannel, consumerBindingProperties.getConsumer());
Station station = new Station();
Message> message = MessageBuilder.withPayload(station).build();
@@ -530,7 +573,7 @@ public abstract class AbstractBinderTests replyMessage = replyChannel.receive(5000);
- assertTrue(replyMessage.getPayload() instanceof Station);
+ assertThat(replyMessage.getPayload() instanceof Station).isTrue();
producerBinding.unbind();
consumerBinding.unbind();
}
@@ -543,19 +586,25 @@ public abstract class AbstractBinderTests producerBinding = binder.bindProducer(String.format("bad%s0b",
- getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());
+ Binding producerBinding = binder.bindProducer(
+ String.format("bad%s0b", getDestinationNameDelimiter()),
+ moduleOutputChannel, producerBindingProperties.getProducer());
- Binding consumerBinding = binder.bindConsumer(String.format("bad%s0b",
- getDestinationNameDelimiter()), "test-2", moduleInputChannel, consumerBindingProperties.getConsumer());
+ Binding consumerBinding = binder.bindConsumer(
+ String.format("bad%s0b", getDestinationNameDelimiter()), "test-2",
+ moduleInputChannel, consumerBindingProperties.getConsumer());
Station station = new Station();
Message> message = MessageBuilder.withPayload(station).setHeader(
@@ -566,7 +615,7 @@ public abstract class AbstractBinderTests replyMessage = replyChannel.receive(5000);
- assertTrue(replyMessage.getPayload() instanceof Station);
+ assertThat(replyMessage.getPayload() instanceof Station).isTrue();
producerBinding.unbind();
consumerBinding.unbind();
}
@@ -576,19 +625,25 @@ public abstract class AbstractBinderTests producerBinding = binder.bindProducer(String.format("bad%s0c",
- getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());
+ Binding producerBinding = binder.bindProducer(
+ String.format("bad%s0c", getDestinationNameDelimiter()),
+ moduleOutputChannel, producerBindingProperties.getProducer());
- Binding consumerBinding = binder.bindConsumer(String.format("bad%s0c",
- getDestinationNameDelimiter()), "test-3", moduleInputChannel, consumerBindingProperties.getConsumer());
+ Binding consumerBinding = binder.bindConsumer(
+ String.format("bad%s0c", getDestinationNameDelimiter()), "test-3",
+ moduleInputChannel, consumerBindingProperties.getConsumer());
try {
Station station = new Station();
Message> message = MessageBuilder.withPayload(station)
@@ -610,22 +665,29 @@ public abstract class AbstractBinderTests producerBinding = binder.bindProducer(String.format("bad%s0d",
- getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());
+ Binding producerBinding = binder.bindProducer(
+ String.format("bad%s0d", getDestinationNameDelimiter()),
+ moduleOutputChannel, producerBindingProperties.getProducer());
- Binding consumerBinding = binder.bindConsumer(String.format("bad%s0d",
- getDestinationNameDelimiter()), "test-4", moduleInputChannel, consumerBindingProperties.getConsumer());
+ Binding consumerBinding = binder.bindConsumer(
+ String.format("bad%s0d", getDestinationNameDelimiter()), "test-4",
+ moduleInputChannel, consumerBindingProperties.getConsumer());
String value = "{\"readings\":[{\"stationid\":\"fgh\","
- + "\"customerid\":\"12345\",\"timestamp\":null},{\"stationid\":\"hjk\",\"customerid\":\"222\",\"timestamp\":null}]}";
+ + "\"customerid\":\"12345\",\"timestamp\":null},"
+ + "{\"stationid\":\"hjk\",\"customerid\":\"222\",\"timestamp\":null}]}";
Message> message = MessageBuilder.withPayload(value)
.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)
@@ -637,8 +699,8 @@ public abstract class AbstractBinderTests reply = (Message) channel.receive(5000);
- assertNotNull(reply);
- assertTrue(reply.getPayload() instanceof Station);
+ assertThat(reply).isNotNull();
+ assertThat(reply.getPayload() instanceof Station).isTrue();
producerBinding.unbind();
consumerBinding.unbind();
}
@@ -650,22 +712,29 @@ public abstract class AbstractBinderTests producerBinding = binder.bindProducer(String.format("bad%s0e",
- getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());
+ Binding producerBinding = binder.bindProducer(
+ String.format("bad%s0e", getDestinationNameDelimiter()),
+ moduleOutputChannel, producerBindingProperties.getProducer());
- Binding consumerBinding = binder.bindConsumer(String.format("bad%s0e",
- getDestinationNameDelimiter()), "test-5", moduleInputChannel, consumerBindingProperties.getConsumer());
+ Binding consumerBinding = binder.bindConsumer(
+ String.format("bad%s0e", getDestinationNameDelimiter()), "test-5",
+ moduleInputChannel, consumerBindingProperties.getConsumer());
String value = "{\"readings\":[{\"stationid\":\"fgh\","
- + "\"customerid\":\"12345\",\"timestamp\":null},{\"stationid\":\"hjk\",\"customerid\":\"222\",\"timestamp\":null}]}";
+ + "\"customerid\":\"12345\",\"timestamp\":null},"
+ + "{\"stationid\":\"hjk\",\"customerid\":\"222\",\"timestamp\":null}]}";
Message> message = MessageBuilder.withPayload(value)
.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)
@@ -677,8 +746,8 @@ public abstract class AbstractBinderTests reply = (Message) channel.receive(5000);
- assertNotNull(reply);
- assertTrue(reply.getPayload() instanceof String);
+ assertThat(reply).isNotNull();
+ assertThat(reply.getPayload() instanceof String).isTrue();
producerBinding.unbind();
consumerBinding.unbind();
}
@@ -690,19 +759,25 @@ public abstract class AbstractBinderTests producerBinding = binder.bindProducer(String.format("bad%s0f",
- getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());
+ Binding producerBinding = binder.bindProducer(
+ String.format("bad%s0f", getDestinationNameDelimiter()),
+ moduleOutputChannel, producerBindingProperties.getProducer());
- Binding consumerBinding = binder.bindConsumer(String.format("bad%s0f",
- getDestinationNameDelimiter()), "test-6", moduleInputChannel, consumerBindingProperties.getConsumer());
+ Binding consumerBinding = binder.bindConsumer(
+ String.format("bad%s0f", getDestinationNameDelimiter()), "test-6",
+ moduleInputChannel, consumerBindingProperties.getConsumer());
Readings r1 = new Readings();
r1.setCustomerid("123");
@@ -722,8 +797,8 @@ public abstract class AbstractBinderTests reply = (Message) channel.receive(5000);
- assertNotNull(reply);
- assertTrue(reply.getPayload() instanceof Station);
+ assertThat(reply).isNotNull();
+ assertThat(reply.getPayload() instanceof Station).isTrue();
producerBinding.unbind();
consumerBinding.unbind();
}
@@ -756,7 +831,7 @@ public abstract class AbstractBinderTests readings = new ArrayList<>();
public List getReadings() {
- return readings;
+ return this.readings;
}
public void setReadings(List readings) {
@@ -786,7 +861,7 @@ public abstract class AbstractBinderTests binder type
+ * @param consumer properties type
+ * @param producer properties type
* @author Gary Russell
* @since 2.0
- *
*/
-public abstract class AbstractPollableConsumerTestBinder,
- CP extends ConsumerProperties, PP extends ProducerProperties> extends AbstractTestBinder
- implements PollableConsumerBinder{
+// @checkstyle:off
+public abstract class AbstractPollableConsumerTestBinder, CP extends ConsumerProperties, PP extends ProducerProperties>
+ extends AbstractTestBinder
+ implements PollableConsumerBinder {
+
+ // @checkstyle:on
private PollableConsumerBinder binder;
@SuppressWarnings("unchecked")
- public void setPollableConsumerBinder(PollableConsumerBinder binder) {
+ public void setPollableConsumerBinder(
+ PollableConsumerBinder binder) {
super.setBinder((C) binder);
this.binder = binder;
}
@Override
- public Binding> bindPollableConsumer(String name, String group,
- PollableSource inboundBindTarget, CP consumerProperties) {
- return this.binder.bindPollableConsumer(name, group, inboundBindTarget, consumerProperties);
+ public Binding> bindPollableConsumer(String name,
+ String group, PollableSource inboundBindTarget,
+ CP consumerProperties) {
+ return this.binder.bindPollableConsumer(name, group, inboundBindTarget,
+ consumerProperties);
}
}
diff --git a/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/AbstractTestBinder.java b/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/AbstractTestBinder.java
index 46f8e6041..afe51db2c 100644
--- a/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/AbstractTestBinder.java
+++ b/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/AbstractTestBinder.java
@@ -16,7 +16,6 @@
package org.springframework.cloud.stream.binder;
-
import java.util.HashSet;
import java.util.Set;
@@ -28,34 +27,41 @@ import org.springframework.util.CollectionUtils;
/**
* Abstract class that adds test support for {@link Binder}.
*
+ * @param binder type
+ * @param consumer properties type
+ * @param producer properties type
* @author Ilayaperumal Gopinathan
* @author Gary Russell
* @author Mark Fisher
* @author Oleg Zhurakousky
*/
+// @checkstyle:off
public abstract class AbstractTestBinder, CP extends ConsumerProperties, PP extends ProducerProperties>
implements Binder {
+ // @checkstyle:on
+
protected Set queues = new HashSet();
private C binder;
@Override
- public Binding bindConsumer(String name, String group, MessageChannel moduleInputChannel,
- CP properties) {
+ public Binding bindConsumer(String name, String group,
+ MessageChannel moduleInputChannel, CP properties) {
this.checkChannelIsConfigured(moduleInputChannel, properties);
- queues.add(name);
- return binder.bindConsumer(name, group, moduleInputChannel, properties);
+ this.queues.add(name);
+ return this.binder.bindConsumer(name, group, moduleInputChannel, properties);
}
@Override
- public Binding bindProducer(String name, MessageChannel moduleOutputChannel, PP properties) {
- queues.add(name);
- return binder.bindProducer(name, moduleOutputChannel, properties);
+ public Binding bindProducer(String name,
+ MessageChannel moduleOutputChannel, PP properties) {
+ this.queues.add(name);
+ return this.binder.bindProducer(name, moduleOutputChannel, properties);
}
public C getCoreBinder() {
- return binder;
+ return this.binder;
}
public abstract void cleanup();
@@ -76,13 +82,19 @@ public abstract class AbstractTestBinder propertiesToAdd = new HashMap<>();
- propertiesToAdd.put("logging.pattern.console", "%d{ISO8601} %5p %t %c{2}:%L - %m%n");
+ propertiesToAdd.put("logging.pattern.console",
+ "%d{ISO8601} %5p %t %c{2}:%L - %m%n");
propertiesToAdd.put("logging.level.root", "WARN");
- environment.getPropertySources().addLast(new MapPropertySource("binderTestPropertiesConfig", propertiesToAdd));
+ environment.getPropertySources().addLast(
+ new MapPropertySource("binderTestPropertiesConfig", propertiesToAdd));
}
+
}
diff --git a/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/BinderTestUtils.java b/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/BinderTestUtils.java
index e4874f621..0cc9830cc 100644
--- a/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/BinderTestUtils.java
+++ b/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/BinderTestUtils.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 the original author or authors.
+ * Copyright 2014-2019 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.
@@ -26,21 +26,30 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
- *
* @author Gary Russell
*/
public abstract class BinderTestUtils {
- public static final AbstractApplicationContext MOCK_AC = mock(AbstractApplicationContext.class);
+ /**
+ * Mocked application context.
+ */
+ public static final AbstractApplicationContext MOCK_AC = mock(
+ AbstractApplicationContext.class);
- public static final ConfigurableListableBeanFactory MOCK_BF = mock(ConfigurableListableBeanFactory.class);
+ /**
+ * Mocked application bean factory.
+ */
+ public static final ConfigurableListableBeanFactory MOCK_BF = mock(
+ ConfigurableListableBeanFactory.class);
private static final MessageBuilderFactory mbf = new MutableMessageBuilderFactory();
static {
- when(MOCK_BF.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME,
+ when(MOCK_BF.getBean(
+ IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME,
MessageBuilderFactory.class)).thenReturn(mbf);
- when(MOCK_AC.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME,
+ when(MOCK_AC.getBean(
+ IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME,
MessageBuilderFactory.class)).thenReturn(mbf);
when(MOCK_AC.getBeanFactory()).thenReturn(MOCK_BF);
}
diff --git a/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/PartitionCapableBinderTests.java b/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/PartitionCapableBinderTests.java
index c0b2219c1..cec011d27 100644
--- a/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/PartitionCapableBinderTests.java
+++ b/spring-cloud-stream-binder-test/src/main/java/org/springframework/cloud/stream/binder/PartitionCapableBinderTests.java
@@ -46,30 +46,39 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Marius Bogoevici
* @author Vinicius Carvalho
*/
+// @checkstyle:off
public abstract class PartitionCapableBinderTests, CP, PP>, CP extends ConsumerProperties, PP extends ProducerProperties>
extends AbstractBinderTests {
+ // @checkstyle:on
+
protected static final SpelExpressionParser spelExpressionParser = new SpelExpressionParser();
@Test
@SuppressWarnings("unchecked")
public void testAnonymousGroup() throws Exception {
B binder = getBinder();
- BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());
+ BindingProperties producerBindingProperties = createProducerBindingProperties(
+ createProducerProperties());
DirectChannel output = createBindableChannel("output", producerBindingProperties);
- Binding producerBinding = binder.bindProducer(String.format("defaultGroup%s0",
- getDestinationNameDelimiter()), output, (PP) producerBindingProperties.getProducer());
+ Binding producerBinding = binder.bindProducer(
+ String.format("defaultGroup%s0", getDestinationNameDelimiter()), output,
+ (PP) producerBindingProperties.getProducer());
QueueChannel input1 = new QueueChannel();
- Binding binding1 = binder.bindConsumer(String.format("defaultGroup%s0",
- getDestinationNameDelimiter()), null, input1, createConsumerProperties());
+ Binding binding1 = binder.bindConsumer(
+ String.format("defaultGroup%s0", getDestinationNameDelimiter()), null,
+ input1, createConsumerProperties());
QueueChannel input2 = new QueueChannel();
- Binding binding2 = binder.bindConsumer(String.format("defaultGroup%s0",
- getDestinationNameDelimiter()), null, input2, createConsumerProperties());
+ Binding binding2 = binder.bindConsumer(
+ String.format("defaultGroup%s0", getDestinationNameDelimiter()), null,
+ input2, createConsumerProperties());
String testPayload1 = "foo-" + UUID.randomUUID().toString();
- output.send(MessageBuilder.withPayload(testPayload1).setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN).build());
+ output.send(MessageBuilder.withPayload(testPayload1)
+ .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN)
+ .build());
Message receivedMessage1 = (Message) receive(input1);
assertThat(receivedMessage1).isNotNull();
@@ -82,12 +91,17 @@ public abstract class PartitionCapableBinderTests) receive(input1);
assertThat(receivedMessage1).isNotNull();
@@ -109,23 +123,29 @@ public abstract class PartitionCapableBinderTests producerBinding = binder.bindProducer(testDestination, output, producerProperties);
+ Binding producerBinding = binder.bindProducer(testDestination,
+ output, producerProperties);
String testPayload = "foo-" + UUID.randomUUID().toString();
- output.send(MessageBuilder.withPayload(testPayload).setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN).build());
+ output.send(MessageBuilder.withPayload(testPayload)
+ .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN)
+ .build());
QueueChannel inbound1 = new QueueChannel();
- Binding consumerBinding = binder.bindConsumer(testDestination, "test1", inbound1,
- createConsumerProperties());
+ Binding consumerBinding = binder.bindConsumer(testDestination,
+ "test1", inbound1, createConsumerProperties());
Message> receivedMessage1 = receive(inbound1);
assertThat(receivedMessage1).isNotNull();
- assertThat(new String((byte[]) receivedMessage1.getPayload())).isEqualTo(testPayload);
+ assertThat(new String((byte[]) receivedMessage1.getPayload()))
+ .isEqualTo(testPayload);
producerBinding.unbind();
consumerBinding.unbind();
@@ -136,29 +156,36 @@ public abstract class PartitionCapableBinderTests producerBinding = binder.bindProducer(testDestination, output, producerProperties);
+ Binding producerBinding = binder.bindProducer(testDestination,
+ output, producerProperties);
String testPayload = "foo-" + UUID.randomUUID().toString();
- output.send(MessageBuilder.withPayload(testPayload).setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN).build());
+ output.send(MessageBuilder.withPayload(testPayload)
+ .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN)
+ .build());
QueueChannel inbound1 = new QueueChannel();
- Binding consumerBinding1 = binder.bindConsumer(testDestination, "test1", inbound1,
- createConsumerProperties());
+ Binding consumerBinding1 = binder.bindConsumer(testDestination,
+ "test1", inbound1, createConsumerProperties());
QueueChannel inbound2 = new QueueChannel();
- Binding consumerBinding2 = binder.bindConsumer(testDestination, "test2", inbound2,
- createConsumerProperties());
+ Binding consumerBinding2 = binder.bindConsumer(testDestination,
+ "test2", inbound2, createConsumerProperties());
Message> receivedMessage1 = receive(inbound1);
assertThat(receivedMessage1).isNotNull();
- assertThat(new String((byte[]) receivedMessage1.getPayload())).isEqualTo(testPayload);
+ assertThat(new String((byte[]) receivedMessage1.getPayload()))
+ .isEqualTo(testPayload);
Message> receivedMessage2 = receive(inbound2);
assertThat(receivedMessage2).isNotNull();
- assertThat(new String((byte[]) receivedMessage2.getPayload())).isEqualTo(testPayload);
+ assertThat(new String((byte[]) receivedMessage2.getPayload()))
+ .isEqualTo(testPayload);
consumerBinding1.unbind();
consumerBinding2.unbind();
@@ -176,28 +203,35 @@ public abstract class PartitionCapableBinderTests input0Binding = binder.bindConsumer(String.format("part%s0",
- getDestinationNameDelimiter()), "testPartitionedModuleSpEL", input0, consumerProperties);
+ Binding input0Binding = binder.bindConsumer(
+ String.format("part%s0", getDestinationNameDelimiter()),
+ "testPartitionedModuleSpEL", input0, consumerProperties);
consumerProperties.setInstanceIndex(1);
QueueChannel input1 = new QueueChannel();
input1.setBeanName("test.input1S");
- Binding input1Binding = binder.bindConsumer(String.format("part%s0",
- getDestinationNameDelimiter()), "testPartitionedModuleSpEL", input1, consumerProperties);
+ Binding input1Binding = binder.bindConsumer(
+ String.format("part%s0", getDestinationNameDelimiter()),
+ "testPartitionedModuleSpEL", input1, consumerProperties);
consumerProperties.setInstanceIndex(2);
QueueChannel input2 = new QueueChannel();
input2.setBeanName("test.input2S");
- Binding input2Binding = binder.bindConsumer(String.format("part%s0",
- getDestinationNameDelimiter()), "testPartitionedModuleSpEL", input2, consumerProperties);
+ Binding input2Binding = binder.bindConsumer(
+ String.format("part%s0", getDestinationNameDelimiter()),
+ "testPartitionedModuleSpEL", input2, consumerProperties);
PP producerProperties = createProducerProperties();
- producerProperties.setPartitionKeyExpression(spelExpressionParser.parseExpression("payload"));
- producerProperties.setPartitionSelectorExpression(spelExpressionParser.parseExpression("hashCode()"));
+ producerProperties.setPartitionKeyExpression(
+ spelExpressionParser.parseExpression("payload"));
+ producerProperties.setPartitionSelectorExpression(
+ spelExpressionParser.parseExpression("hashCode()"));
producerProperties.setPartitionCount(3);
- DirectChannel output = createBindableChannel("output", createProducerBindingProperties(producerProperties));
+ DirectChannel output = createBindableChannel("output",
+ createProducerBindingProperties(producerProperties));
output.setBeanName("test.output");
- Binding outputBinding = binder.bindProducer(String.format("part%s0",
- getDestinationNameDelimiter()), output, producerProperties);
+ Binding outputBinding = binder.bindProducer(
+ String.format("part%s0", getDestinationNameDelimiter()), output,
+ producerProperties);
try {
Object endpoint = extractEndpoint(outputBinding);
checkRkExpressionForPartitionedModuleSpEL(endpoint);
@@ -207,12 +241,16 @@ public abstract class PartitionCapableBinderTests message2 = MessageBuilder.withPayload("2")
.setHeader(IntegrationMessageHeaderAccessor.CORRELATION_ID, "foo")
- .setHeader(MessageHeaders.CONTENT_TYPE,MimeTypeUtils.TEXT_PLAIN)
+ .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN)
.setHeader(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, 42)
.setHeader(IntegrationMessageHeaderAccessor.SEQUENCE_SIZE, 43).build();
output.send(message2);
- output.send(MessageBuilder.withPayload("1").setHeader(MessageHeaders.CONTENT_TYPE,MimeTypeUtils.TEXT_PLAIN).build());
- output.send(MessageBuilder.withPayload("0").setHeader(MessageHeaders.CONTENT_TYPE,MimeTypeUtils.TEXT_PLAIN).build());
+ output.send(MessageBuilder.withPayload("1")
+ .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN)
+ .build());
+ output.send(MessageBuilder.withPayload("0")
+ .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN)
+ .build());
Message> receive0 = receive(input0);
assertThat(receive0).isNotNull();
@@ -224,8 +262,10 @@ public abstract class PartitionCapableBinderTests> correlationHeadersForPayload2 = new Condition>() {
@Override
public boolean matches(Message> value) {
- IntegrationMessageHeaderAccessor accessor = new IntegrationMessageHeaderAccessor(value);
- return "foo".equals(accessor.getCorrelationId()) && 42 == accessor.getSequenceNumber()
+ IntegrationMessageHeaderAccessor accessor = new IntegrationMessageHeaderAccessor(
+ value);
+ return "foo".equals(accessor.getCorrelationId())
+ && 42 == accessor.getSequenceNumber()
&& 43 == accessor.getSequenceSize();
}
};
@@ -237,8 +277,10 @@ public abstract class PartitionCapableBinderTests> receivedMessages = Arrays.asList(receive0, receive1, receive2);
- assertThat(receivedMessages).extracting("payload").containsExactlyInAnyOrder("0".getBytes(), "1".getBytes(), "2".getBytes());
+ List> receivedMessages = Arrays.asList(receive0, receive1,
+ receive2);
+ assertThat(receivedMessages).extracting("payload").containsExactlyInAnyOrder(
+ "0".getBytes(), "1".getBytes(), "2".getBytes());
Condition> payloadIs2 = new Condition>() {
@Override
@@ -246,7 +288,8 @@ public abstract class PartitionCapableBinderTests input0Binding = binder.bindConsumer(String.format("partJ%s0",
- getDestinationNameDelimiter()), "testPartitionedModuleJava", input0, consumerProperties);
+ Binding input0Binding = binder.bindConsumer(
+ String.format("partJ%s0", getDestinationNameDelimiter()),
+ "testPartitionedModuleJava", input0, consumerProperties);
consumerProperties.setInstanceIndex(1);
QueueChannel input1 = new QueueChannel();
input1.setBeanName("test.input1J");
- Binding input1Binding = binder.bindConsumer(String.format("partJ%s0",
- getDestinationNameDelimiter()), "testPartitionedModuleJava", input1, consumerProperties);
+ Binding input1Binding = binder.bindConsumer(
+ String.format("partJ%s0", getDestinationNameDelimiter()),
+ "testPartitionedModuleJava", input1, consumerProperties);
consumerProperties.setInstanceIndex(2);
QueueChannel input2 = new QueueChannel();
input2.setBeanName("test.input2J");
- Binding input2Binding = binder.bindConsumer(String.format("partJ%s0",
- getDestinationNameDelimiter()), "testPartitionedModuleJava", input2, consumerProperties);
+ Binding input2Binding = binder.bindConsumer(
+ String.format("partJ%s0", getDestinationNameDelimiter()),
+ "testPartitionedModuleJava", input2, consumerProperties);
PP producerProperties = createProducerProperties();
producerProperties.setPartitionKeyExtractorClass(PartitionTestSupport.class);
producerProperties.setPartitionSelectorClass(PartitionTestSupport.class);
producerProperties.setPartitionCount(3);
- DirectChannel output = createBindableChannel("output", createProducerBindingProperties(producerProperties));
+ DirectChannel output = createBindableChannel("output",
+ createProducerBindingProperties(producerProperties));
output.setBeanName("test.output");
- Binding outputBinding = binder.bindProducer("partJ.0", output, producerProperties);
+ Binding outputBinding = binder.bindProducer("partJ.0", output,
+ producerProperties);
if (usesExplicitRouting()) {
Object endpoint = extractEndpoint(outputBinding);
- assertThat(getEndpointRouting(endpoint)).contains(getExpectedRoutingBaseDestination(
- String.format("partJ%s0", getDestinationNameDelimiter()), "testPartitionedModuleJava")
- + "-' + headers['" + BinderHeaders.PARTITION_HEADER + "']");
+ assertThat(getEndpointRouting(endpoint))
+ .contains(getExpectedRoutingBaseDestination(
+ String.format("partJ%s0", getDestinationNameDelimiter()),
+ "testPartitionedModuleJava") + "-' + headers['"
+ + BinderHeaders.PARTITION_HEADER + "']");
}
- output.send(MessageBuilder.withPayload("2").setHeader(MessageHeaders.CONTENT_TYPE,MimeTypeUtils.TEXT_PLAIN).build());
- output.send(MessageBuilder.withPayload("1").setHeader(MessageHeaders.CONTENT_TYPE,MimeTypeUtils.TEXT_PLAIN).build());
- output.send(MessageBuilder.withPayload("0").setHeader(MessageHeaders.CONTENT_TYPE,MimeTypeUtils.TEXT_PLAIN).build());
+ output.send(MessageBuilder.withPayload("2")
+ .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN)
+ .build());
+ output.send(MessageBuilder.withPayload("1")
+ .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN)
+ .build());
+ output.send(MessageBuilder.withPayload("0")
+ .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN)
+ .build());
Message> receive0 = receive(input0);
assertThat(receive0).isNotNull();
@@ -317,8 +374,10 @@ public abstract class PartitionCapableBinderTests> receivedMessages = Arrays.asList(receive0, receive1, receive2);
- assertThat(receivedMessages).extracting("payload").containsExactlyInAnyOrder("0".getBytes(), "1".getBytes(), "2".getBytes());
+ List> receivedMessages = Arrays.asList(receive0, receive1,
+ receive2);
+ assertThat(receivedMessages).extracting("payload").containsExactlyInAnyOrder(
+ "0".getBytes(), "1".getBytes(), "2".getBytes());
}
input0Binding.unbind();
@@ -358,4 +417,5 @@ public abstract class PartitionCapableBinderTests
-
+
4.0.0
spring-cloud-stream-integration-tests
diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/ContentTypeOutboundSourceTests.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/ContentTypeOutboundSourceTests.java
index 2be956abd..2d805c850 100644
--- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/ContentTypeOutboundSourceTests.java
+++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/ContentTypeOutboundSourceTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 the original author or authors.
+ * Copyright 2015-2019 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.
@@ -53,11 +53,13 @@ public class ContentTypeOutboundSourceTests {
@Test
@SuppressWarnings("unchecked")
public void testMessageHeaderWhenNoExplicitContentTypeOnMessage() throws Exception {
- testSource.output().send(MessageBuilder.withPayload("{\"message\":\"Hi\"}").setHeader(MessageHeaders.CONTENT_TYPE,"text/plain").build());
- Message received = (Message) ((TestSupportBinder) binderFactory.getBinder(null,
- MessageChannel.class))
- .messageCollector().forChannel(testSource.output()).poll();
- assertThat(received.getHeaders().get(MessageHeaders.CONTENT_TYPE).toString()).contains("text/plain");
+ this.testSource.output().send(MessageBuilder.withPayload("{\"message\":\"Hi\"}")
+ .setHeader(MessageHeaders.CONTENT_TYPE, "text/plain").build());
+ Message received = (Message) ((TestSupportBinder) this.binderFactory
+ .getBinder(null, MessageChannel.class)).messageCollector()
+ .forChannel(this.testSource.output()).poll();
+ assertThat(received.getHeaders().get(MessageHeaders.CONTENT_TYPE).toString())
+ .contains("text/plain");
assertThat("{\"message\":\"Hi\"}").isEqualTo(received.getPayload());
}
@@ -67,4 +69,5 @@ public class ContentTypeOutboundSourceTests {
public static class TestSource {
}
+
}
diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/CustomHeaderPropagationTests.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/CustomHeaderPropagationTests.java
index 83c534368..502ced321 100644
--- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/CustomHeaderPropagationTests.java
+++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/CustomHeaderPropagationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 the original author or authors.
+ * Copyright 2017-2019 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.
@@ -42,11 +42,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oleg Zhurakousky
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = CustomHeaderPropagationTests.HeaderPropagationProcessor.class,
- webEnvironment = SpringBootTest.WebEnvironment.NONE,
- properties = {"spring.cloud.stream.integration.messageHandlerNotPropagatedHeaders=bar,contentType"})
+// @checkstyle:off
+@SpringBootTest(classes = CustomHeaderPropagationTests.HeaderPropagationProcessor.class, webEnvironment = SpringBootTest.WebEnvironment.NONE, properties = {
+ "spring.cloud.stream.integration.messageHandlerNotPropagatedHeaders=bar,contentType" })
public class CustomHeaderPropagationTests {
+ // @checkstyle:on
+
@Autowired
private Processor testProcessor;
@@ -55,19 +57,19 @@ public class CustomHeaderPropagationTests {
@Test
/**
- * @since 2.0 The behavior of content type handling has changed.
- * All input/output channels have a default content type of application/json
- * When a processor or a source returns a String, and if the content type is json it will be quoted
+ * @since 2.0 The behavior of content type handling has changed. All input/output
+ * channels have a default content type of application/json When a processor or a
+ * source returns a String, and if the content type is json it will be quoted
*/
public void testCustomHeaderPropagation() throws Exception {
- testProcessor.input().send(MessageBuilder.withPayload("{'name':'foo'}")
+ this.testProcessor.input().send(MessageBuilder.withPayload("{'name':'foo'}")
.setHeader(MessageHeaders.CONTENT_TYPE, "application/json")
- .setHeader("foo", "fooValue")
- .setHeader("bar", "barValue")
- .build());
+ .setHeader("foo", "fooValue").setHeader("bar", "barValue").build());
@SuppressWarnings("unchecked")
- Message received = (Message) ((TestSupportBinder) binderFactory.getBinder(null, MessageChannel.class))
- .messageCollector().forChannel(testProcessor.output()).poll(10, TimeUnit.SECONDS);
+ Message received = (Message) ((TestSupportBinder) this.binderFactory
+ .getBinder(null, MessageChannel.class)).messageCollector()
+ .forChannel(this.testProcessor.output())
+ .poll(10, TimeUnit.SECONDS);
assertThat(received).isNotNull();
assertThat(received.getHeaders()).containsEntry("foo", "fooValue");
assertThat(received.getHeaders()).doesNotContainKey("bar");
@@ -81,9 +83,12 @@ public class CustomHeaderPropagationTests {
@ServiceActivator(inputChannel = "input", outputChannel = "output")
public Message consume(String data) {
- //if we don't force content to be String, it will be quoted on the outbound channel
- return MessageBuilder.withPayload(data).setHeader(MessageHeaders.CONTENT_TYPE,"text/plain").build();
+ // if we don't force content to be String, it will be quoted on the outbound
+ // channel
+ return MessageBuilder.withPayload(data)
+ .setHeader(MessageHeaders.CONTENT_TYPE, "text/plain").build();
}
}
+
}
diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/CustomMessageConverterTests.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/CustomMessageConverterTests.java
index bd0bc4f33..b01f714e3 100644
--- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/CustomMessageConverterTests.java
+++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/CustomMessageConverterTests.java
@@ -19,7 +19,6 @@ package org.springframework.cloud.stream.config;
import java.util.List;
import java.util.concurrent.TimeUnit;
-import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -44,7 +43,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.MimeType;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.hamcrest.Matchers.notNullValue;
/**
* @author Ilayaperumal Gopinathan
@@ -66,16 +64,17 @@ public class CustomMessageConverterTests {
@Test
public void testCustomMessageConverter() throws Exception {
- assertThat(customMessageConverters).hasSize(2);
- assertThat(customMessageConverters).extracting("class").contains(FooConverter.class,
- BarConverter.class);
- testSource.output().send(MessageBuilder.withPayload(new Foo("hi")).build());
+ assertThat(this.customMessageConverters).hasSize(2);
+ assertThat(this.customMessageConverters).extracting("class")
+ .contains(FooConverter.class, BarConverter.class);
+ this.testSource.output().send(MessageBuilder.withPayload(new Foo("hi")).build());
@SuppressWarnings("unchecked")
- Message received = (Message) ((TestSupportBinder) binderFactory.getBinder(null,
- MessageChannel.class))
- .messageCollector().forChannel(testSource.output()).poll(1, TimeUnit.SECONDS);
- Assert.assertThat(received, notNullValue());
- assertThat(received.getHeaders().get(MessageHeaders.CONTENT_TYPE)).isEqualTo(MimeType.valueOf("test/foo"));
+ Message received = (Message) ((TestSupportBinder) this.binderFactory
+ .getBinder(null, MessageChannel.class)).messageCollector()
+ .forChannel(this.testSource.output()).poll(1, TimeUnit.SECONDS);
+ assertThat(received).isNotNull();
+ assertThat(received.getHeaders().get(MessageHeaders.CONTENT_TYPE))
+ .isEqualTo(MimeType.valueOf("test/foo"));
}
@EnableBinding(Source.class)
@@ -95,6 +94,7 @@ public class CustomMessageConverterTests {
public MessageConverter barConverter() {
return new BarConverter();
}
+
}
public static class FooConverter extends AbstractMessageConverter {
@@ -109,7 +109,8 @@ public class CustomMessageConverterTests {
}
@Override
- protected Object convertToInternal(Object payload, MessageHeaders headers, Object conversionHint) {
+ protected Object convertToInternal(Object payload, MessageHeaders headers,
+ Object conversionHint) {
Object result = null;
try {
if (payload instanceof Foo) {
@@ -118,11 +119,12 @@ public class CustomMessageConverterTests {
}
}
catch (Exception e) {
- logger.error(e.getMessage(), e);
+ this.logger.error(e.getMessage(), e);
return null;
}
return result;
}
+
}
public static class BarConverter extends AbstractMessageConverter {
@@ -137,7 +139,8 @@ public class CustomMessageConverterTests {
}
@Override
- protected Object convertToInternal(Object payload, MessageHeaders headers, Object conversionHint) {
+ protected Object convertToInternal(Object payload, MessageHeaders headers,
+ Object conversionHint) {
Object result = null;
try {
if (payload instanceof Bar) {
@@ -146,11 +149,12 @@ public class CustomMessageConverterTests {
}
}
catch (Exception e) {
- logger.error(e.getMessage(), e);
+ this.logger.error(e.getMessage(), e);
return null;
}
return result;
}
+
}
public static class Foo {
@@ -170,5 +174,7 @@ public class CustomMessageConverterTests {
public Bar(String testing) {
this.testing = testing;
}
+
}
+
}
diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/DefaultHeaderPropagationTests.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/DefaultHeaderPropagationTests.java
index 32657c4ff..baab08ae1 100644
--- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/DefaultHeaderPropagationTests.java
+++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/DefaultHeaderPropagationTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 the original author or authors.
+ * Copyright 2017-2019 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.
@@ -42,10 +42,11 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oleg Zhurakousky
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = DefaultHeaderPropagationTests.HeaderPropagationProcessor.class,
- webEnvironment = SpringBootTest.WebEnvironment.NONE)
+// @checkstyle:off
+@SpringBootTest(classes = DefaultHeaderPropagationTests.HeaderPropagationProcessor.class, webEnvironment = SpringBootTest.WebEnvironment.NONE)
public class DefaultHeaderPropagationTests {
+ // @checkstyle:on
@Autowired
private Processor testProcessor;
@@ -54,14 +55,14 @@ public class DefaultHeaderPropagationTests {
@Test
public void testDefaultHeaderPropagation() throws Exception {
- testProcessor.input().send(MessageBuilder.withPayload("{'name':'foo'}")
+ this.testProcessor.input().send(MessageBuilder.withPayload("{'name':'foo'}")
.setHeader(MessageHeaders.CONTENT_TYPE, "application/json")
- .setHeader("foo", "fooValue")
- .setHeader("bar", "barValue")
- .build());
+ .setHeader("foo", "fooValue").setHeader("bar", "barValue").build());
@SuppressWarnings("unchecked")
- Message received = (Message) ((TestSupportBinder) binderFactory.getBinder(null, MessageChannel.class))
- .messageCollector().forChannel(testProcessor.output()).poll(1, TimeUnit.SECONDS);
+ Message received = (Message) ((TestSupportBinder) this.binderFactory
+ .getBinder(null, MessageChannel.class)).messageCollector()
+ .forChannel(this.testProcessor.output())
+ .poll(1, TimeUnit.SECONDS);
assertThat(received).isNotNull();
assertThat(received.getHeaders()).containsEntry("foo", "fooValue");
assertThat(received.getHeaders()).containsEntry("bar", "barValue");
@@ -75,8 +76,10 @@ public class DefaultHeaderPropagationTests {
@ServiceActivator(inputChannel = "input", outputChannel = "output")
public Message consume(String data) {
- return MessageBuilder.withPayload(data).setHeader(MessageHeaders.CONTENT_TYPE,"text/plain").build();
+ return MessageBuilder.withPayload(data)
+ .setHeader(MessageHeaders.CONTENT_TYPE, "text/plain").build();
}
}
+
}
diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/DefaultHeaderPropagationWithApplicationProvidedHeaderTests.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/DefaultHeaderPropagationWithApplicationProvidedHeaderTests.java
index 9cbe974c8..8f6207d3b 100644
--- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/DefaultHeaderPropagationWithApplicationProvidedHeaderTests.java
+++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/DefaultHeaderPropagationWithApplicationProvidedHeaderTests.java
@@ -35,17 +35,19 @@ import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Marius Bogoevici
* @author Oleg Zhurakousky
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = DefaultHeaderPropagationWithApplicationProvidedHeaderTests.HeaderPropagationProcessor.class,
- webEnvironment = SpringBootTest.WebEnvironment.NONE)
+// @checkstyle:off
+@SpringBootTest(classes = DefaultHeaderPropagationWithApplicationProvidedHeaderTests.HeaderPropagationProcessor.class, webEnvironment = SpringBootTest.WebEnvironment.NONE)
public class DefaultHeaderPropagationWithApplicationProvidedHeaderTests {
+ // @checkstyle:on
+
@Autowired
private Processor testProcessor;
@@ -54,16 +56,16 @@ public class DefaultHeaderPropagationWithApplicationProvidedHeaderTests {
@Test
public void testHeaderPropagationIfSetByApplication() throws Exception {
- testProcessor.input().send(MessageBuilder.withPayload("{'name':'foo'}")
+ this.testProcessor.input().send(MessageBuilder.withPayload("{'name':'foo'}")
.setHeader(MessageHeaders.CONTENT_TYPE, "application/json")
- .setHeader("foo", "fooValue")
- .setHeader("bar", "barValue")
- .build());
+ .setHeader("foo", "fooValue").setHeader("bar", "barValue").build());
@SuppressWarnings("unchecked")
- Message received = (Message) ((TestSupportBinder) binderFactory.getBinder(null, MessageChannel.class))
- .messageCollector().forChannel(testProcessor.output()).poll(1, TimeUnit.SECONDS);
- assertEquals("fooValue", received.getHeaders().get("foo"));
- assertEquals("barValue", received.getHeaders().get("bar"));
+ Message received = (Message) ((TestSupportBinder) this.binderFactory
+ .getBinder(null, MessageChannel.class)).messageCollector()
+ .forChannel(this.testProcessor.output())
+ .poll(1, TimeUnit.SECONDS);
+ assertThat(received.getHeaders().get("foo")).isEqualTo("fooValue");
+ assertThat(received.getHeaders().get("bar")).isEqualTo("barValue");
}
@EnableBinding(Processor.class)
@@ -72,8 +74,10 @@ public class DefaultHeaderPropagationWithApplicationProvidedHeaderTests {
@ServiceActivator(inputChannel = "input", outputChannel = "output")
public Message> consume(String data) {
- return MessageBuilder.withPayload(data).setHeader(MessageHeaders.CONTENT_TYPE, "text/plain").build();
+ return MessageBuilder.withPayload(data)
+ .setHeader(MessageHeaders.CONTENT_TYPE, "text/plain").build();
}
}
+
}
diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/DeserializeJSONToJavaTypeTests.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/DeserializeJSONToJavaTypeTests.java
index 4ca9e380a..995887775 100644
--- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/DeserializeJSONToJavaTypeTests.java
+++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/DeserializeJSONToJavaTypeTests.java
@@ -54,11 +54,13 @@ public class DeserializeJSONToJavaTypeTests {
@Test
public void testMessageDeserialized() throws Exception {
- testProcessor.input().send(
- MessageBuilder.withPayload("{\"name\":\"Bar\"}").setHeader("contentType", "application/json").build());
+ this.testProcessor.input().send(MessageBuilder.withPayload("{\"name\":\"Bar\"}")
+ .setHeader("contentType", "application/json").build());
@SuppressWarnings("unchecked")
- Message received = (Message) ((TestSupportBinder) binderFactory.getBinder(null, MessageChannel.class))
- .messageCollector().forChannel(testProcessor.output()).poll(1, TimeUnit.SECONDS);
+ Message received = (Message) ((TestSupportBinder) this.binderFactory
+ .getBinder(null, MessageChannel.class)).messageCollector()
+ .forChannel(this.testProcessor.output())
+ .poll(1, TimeUnit.SECONDS);
assertThat(received).isNotNull();
assertThat(received.getPayload()).isEqualTo("{\"name\":\"Bar\"}");
}
@@ -73,6 +75,7 @@ public class DeserializeJSONToJavaTypeTests {
public Foo consume(Foo foo) {
return foo;
}
+
}
public static class Foo {
@@ -80,11 +83,13 @@ public class DeserializeJSONToJavaTypeTests {
private String name;
public String getName() {
- return name;
+ return this.name;
}
public void setName(String name) {
this.name = name;
}
+
}
+
}
diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/InboundJsonToTupleConversionTest.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/InboundJsonToTupleConversionTest.java
index 111e4c358..7bfa8719e 100644
--- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/InboundJsonToTupleConversionTest.java
+++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/InboundJsonToTupleConversionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 the original author or authors.
+ * Copyright 2017-2019 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.
@@ -56,14 +56,17 @@ public class InboundJsonToTupleConversionTest {
@Test
public void testInboundJsonTupleConversion() throws Exception {
- testProcessor.input().send(MessageBuilder.withPayload("{'name':'foo'}")
- .build());
+ this.testProcessor.input()
+ .send(MessageBuilder.withPayload("{'name':'foo'}").build());
@SuppressWarnings("unchecked")
- Message received = (Message) ((TestSupportBinder) binderFactory.getBinder(null, MessageChannel.class))
- .messageCollector().forChannel(testProcessor.output()).poll(1, TimeUnit.SECONDS);
+ Message received = (Message) ((TestSupportBinder) this.binderFactory
+ .getBinder(null, MessageChannel.class)).messageCollector()
+ .forChannel(this.testProcessor.output())
+ .poll(1, TimeUnit.SECONDS);
assertThat(received).isNotNull();
String payload = new String(received.getPayload(), StandardCharsets.UTF_8);
- assertThat(TupleBuilder.fromString(payload)).isEqualTo(TupleBuilder.tuple().of("name", "foo"));
+ assertThat(TupleBuilder.fromString(payload))
+ .isEqualTo(TupleBuilder.tuple().of("name", "foo"));
}
@EnableBinding(Processor.class)
diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/LegacyContentTypeTests.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/LegacyContentTypeTests.java
index 9b59403c1..def84027c 100644
--- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/LegacyContentTypeTests.java
+++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/LegacyContentTypeTests.java
@@ -43,30 +43,35 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Oleg Zhurakousky
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = { LegacyContentTypeTests.LegacyTestSink.class})
+@SpringBootTest(classes = { LegacyContentTypeTests.LegacyTestSink.class })
public class LegacyContentTypeTests {
@Autowired
private Sink testSink;
@Test
- public void testOriginalContentTypeIsRetrievedForLegacyContentHeaderType() throws Exception {
+ public void testOriginalContentTypeIsRetrievedForLegacyContentHeaderType()
+ throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
MessageHandler messageHandler = new MessageHandler() {
@Override
public void handleMessage(Message> message) throws MessagingException {
assertThat(message.getPayload()).isInstanceOf(byte[].class);
- assertThat(((byte[])message.getPayload())).isEqualTo("{\"message\":\"Hi\"}".getBytes(StandardCharsets.UTF_8));
- assertThat(message.getHeaders().get(MessageHeaders.CONTENT_TYPE).toString()).isEqualTo("application/json");
+ assertThat(((byte[]) message.getPayload())).isEqualTo(
+ "{\"message\":\"Hi\"}".getBytes(StandardCharsets.UTF_8));
+ assertThat(
+ message.getHeaders().get(MessageHeaders.CONTENT_TYPE).toString())
+ .isEqualTo("application/json");
latch.countDown();
}
};
- testSink.input().subscribe(messageHandler);
- testSink.input().send(MessageBuilder.withPayload("{\"message\":\"Hi\"}".getBytes())
- .setHeader(BinderHeaders.BINDER_ORIGINAL_CONTENT_TYPE, "application/json")
- .build());
+ this.testSink.input().subscribe(messageHandler);
+ this.testSink.input().send(MessageBuilder
+ .withPayload("{\"message\":\"Hi\"}".getBytes())
+ .setHeader(BinderHeaders.BINDER_ORIGINAL_CONTENT_TYPE, "application/json")
+ .build());
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
- testSink.input().unsubscribe(messageHandler);
+ this.testSink.input().unsubscribe(messageHandler);
}
@EnableBinding(Sink.class)
@@ -74,4 +79,5 @@ public class LegacyContentTypeTests {
public static class LegacyTestSink {
}
+
}
diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/MessageChannelConfigurerTests.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/MessageChannelConfigurerTests.java
index a7a12f930..f0bb1c299 100644
--- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/MessageChannelConfigurerTests.java
+++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/MessageChannelConfigurerTests.java
@@ -45,7 +45,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.MimeTypeUtils;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertNull;
/**
* @author Ilayaperumal Gopinathan
@@ -54,7 +53,8 @@ import static org.junit.Assert.assertNull;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = { MessageChannelConfigurerTests.TestSink.class,
- MessageChannelConfigurerTests.TestSource.class, SpelExpressionConverterConfiguration.class})
+ MessageChannelConfigurerTests.TestSource.class,
+ SpelExpressionConverterConfiguration.class })
public class MessageChannelConfigurerTests {
@Autowired
@@ -71,8 +71,10 @@ public class MessageChannelConfigurerTests {
@Test
public void testChannelTypes() throws Exception {
- DirectWithAttributesChannel inputChannel = (DirectWithAttributesChannel) testSink.input();
- DirectWithAttributesChannel outputChannel = (DirectWithAttributesChannel) testSource.output();
+ DirectWithAttributesChannel inputChannel = (DirectWithAttributesChannel) this.testSink
+ .input();
+ DirectWithAttributesChannel outputChannel = (DirectWithAttributesChannel) this.testSource
+ .output();
assertThat(inputChannel.getAttribute("type")).isEqualTo(Sink.INPUT);
assertThat(outputChannel.getAttribute("type")).isEqualTo(Source.OUTPUT);
}
@@ -85,42 +87,48 @@ public class MessageChannelConfigurerTests {
assertThat(message.getPayload()).isEqualTo("{\"message\":\"Hi\"}".getBytes());
latch.countDown();
};
- testSink.input().subscribe(messageHandler);
- testSink.input().send(MessageBuilder.withPayload("{\"message\":\"Hi\"}".getBytes()).build());
+ this.testSink.input().subscribe(messageHandler);
+ this.testSink.input().send(
+ MessageBuilder.withPayload("{\"message\":\"Hi\"}".getBytes()).build());
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
- testSink.input().unsubscribe(messageHandler);
+ this.testSink.input().unsubscribe(messageHandler);
}
@Test
public void testObjectMapperConfig() throws Exception {
- CompositeMessageConverter converters = (CompositeMessageConverter) messageConverterFactory
+ CompositeMessageConverter converters = (CompositeMessageConverter) this.messageConverterFactory
.getMessageConverterForType(MimeTypeUtils.APPLICATION_JSON);
for (MessageConverter converter : converters.getConverters()) {
DirectFieldAccessor converterAccessor = new DirectFieldAccessor(converter);
- ObjectMapper objectMapper = (ObjectMapper) converterAccessor.getPropertyValue("objectMapper");
+ ObjectMapper objectMapper = (ObjectMapper) converterAccessor
+ .getPropertyValue("objectMapper");
// assert that the ObjectMapper used by the converters is compliant with the
// Boot configuration
- assertThat(!objectMapper.getSerializationConfig().isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS))
- .withFailMessage("SerializationFeature 'WRITE_DATES_AS_TIMESTAMPS' should be disabled");
+ assertThat(!objectMapper.getSerializationConfig().isEnabled(
+ SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)).withFailMessage(
+ "SerializationFeature 'WRITE_DATES_AS_TIMESTAMPS' should be disabled");
// assert that the globally set bean is used by the converters
}
}
@Test
public void testPartitionHeader() throws Exception {
- this.testSource.output().send(MessageBuilder.withPayload("{\"message\":\"Hi\"}").build());
- Message> message = this.messageCollector.forChannel(testSource.output()).poll(1, TimeUnit.SECONDS);
+ this.testSource.output()
+ .send(MessageBuilder.withPayload("{\"message\":\"Hi\"}").build());
+ Message> message = this.messageCollector.forChannel(this.testSource.output())
+ .poll(1, TimeUnit.SECONDS);
assertThat(message.getHeaders().get(BinderHeaders.PARTITION_HEADER).equals(0));
- assertNull(message.getHeaders().get(BinderHeaders.PARTITION_OVERRIDE));
+ assertThat(message.getHeaders().get(BinderHeaders.PARTITION_OVERRIDE)).isNull();
}
@Test
public void testPartitionHeaderWithPartitionOverride() throws Exception {
this.testSource.output().send(MessageBuilder.withPayload("{\"message\":\"Hi\"}")
.setHeader(BinderHeaders.PARTITION_OVERRIDE, 123).build());
- Message> message = this.messageCollector.forChannel(testSource.output()).poll(1, TimeUnit.SECONDS);
+ Message> message = this.messageCollector.forChannel(this.testSource.output())
+ .poll(1, TimeUnit.SECONDS);
assertThat(message.getHeaders().get(BinderHeaders.PARTITION_HEADER).equals(123));
- assertNull(message.getHeaders().get(BinderHeaders.PARTITION_OVERRIDE));
+ assertThat(message.getHeaders().get(BinderHeaders.PARTITION_OVERRIDE)).isNull();
}
@EnableBinding(Sink.class)
@@ -136,4 +144,5 @@ public class MessageChannelConfigurerTests {
public static class TestSource {
}
+
}
diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/MessageChannelWithNativeDecodingTests.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/MessageChannelWithNativeDecodingTests.java
index 55d30e651..188f497d1 100644
--- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/MessageChannelWithNativeDecodingTests.java
+++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/MessageChannelWithNativeDecodingTests.java
@@ -41,19 +41,21 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Soby Chacko
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = { MessageChannelWithNativeDecodingTests.NativeDecodingSink.class})
+@SpringBootTest(classes = {
+ MessageChannelWithNativeDecodingTests.NativeDecodingSink.class })
public class MessageChannelWithNativeDecodingTests {
@Autowired
private Sink nativeDecodingSink;
@Test
- public void testMessageConverterInterceptorsAreSkippedWhenNativeDecodingIsEnabled() throws Exception {
+ public void testMessageConverterInterceptorsAreSkippedWhenNativeDecodingIsEnabled()
+ throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
byte[] serializedData;
ObjectOutput out;
- try(ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
+ try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
out = new ObjectOutputStream(bos);
out.writeObject(123);
out.flush();
@@ -61,17 +63,18 @@ public class MessageChannelWithNativeDecodingTests {
}
MessageHandler messageHandler = message -> {
- //ensure that the data is not deserialized becasue of native decoding
- //and the content type set in the properties file didn't take any effect
+ // ensure that the data is not deserialized becasue of native decoding
+ // and the content type set in the properties file didn't take any effect
assertThat(message.getPayload()).isInstanceOf(byte[].class);
assertThat(message.getPayload()).isEqualTo(serializedData);
latch.countDown();
};
- nativeDecodingSink.input().subscribe(messageHandler);
+ this.nativeDecodingSink.input().subscribe(messageHandler);
- nativeDecodingSink.input().send(MessageBuilder.withPayload(serializedData).build());
+ this.nativeDecodingSink.input()
+ .send(MessageBuilder.withPayload(serializedData).build());
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
- nativeDecodingSink.input().unsubscribe(messageHandler);
+ this.nativeDecodingSink.input().unsubscribe(messageHandler);
}
@EnableBinding(Sink.class)
@@ -80,4 +83,5 @@ public class MessageChannelWithNativeDecodingTests {
public static class NativeDecodingSink {
}
+
}
diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/MessageChannelWithNativeEncodingTests.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/MessageChannelWithNativeEncodingTests.java
index 9aa43a3bb..03f914c42 100644
--- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/MessageChannelWithNativeEncodingTests.java
+++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/MessageChannelWithNativeEncodingTests.java
@@ -39,7 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Soby Chacko
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = { MessageChannelWithNativeEncodingTests.NativeEncodingSource.class})
+@SpringBootTest(classes = {
+ MessageChannelWithNativeEncodingTests.NativeEncodingSource.class })
public class MessageChannelWithNativeEncodingTests {
@Autowired
@@ -49,11 +50,15 @@ public class MessageChannelWithNativeEncodingTests {
private MessageCollector messageCollector;
@Test
- public void testOutboundContentTypeInterceptorIsSkippedWhenNativeEncodingIsEnabled() throws Exception {
- this.nativeEncodingSource.output().send(MessageBuilder.withPayload("hello foobar!").build());
- Message> message = this.messageCollector.forChannel(this.nativeEncodingSource.output()).poll(1, TimeUnit.SECONDS);
- //should not convert the payload to byte[] even though we set a contentType on the channel.
- //This is becasue, we are using native encoding.
+ public void testOutboundContentTypeInterceptorIsSkippedWhenNativeEncodingIsEnabled()
+ throws Exception {
+ this.nativeEncodingSource.output()
+ .send(MessageBuilder.withPayload("hello foobar!").build());
+ Message> message = this.messageCollector
+ .forChannel(this.nativeEncodingSource.output()).poll(1, TimeUnit.SECONDS);
+ // should not convert the payload to byte[] even though we set a contentType on
+ // the channel.
+ // This is becasue, we are using native encoding.
assertThat(message.getPayload()).isInstanceOf(String.class);
assertThat(message.getPayload()).isEqualTo("hello foobar!");
assertThat(message.getHeaders().get(MessageHeaders.CONTENT_TYPE)).isNull();
@@ -65,4 +70,5 @@ public class MessageChannelWithNativeEncodingTests {
public static class NativeEncodingSource {
}
+
}
diff --git a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/StreamListenerAnnotatedMethodArgumentsTests.java b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/StreamListenerAnnotatedMethodArgumentsTests.java
index afef15c37..c5ed31907 100644
--- a/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/StreamListenerAnnotatedMethodArgumentsTests.java
+++ b/spring-cloud-stream-integration-tests/src/test/java/org/springframework/cloud/stream/config/StreamListenerAnnotatedMethodArgumentsTests.java
@@ -44,7 +44,7 @@ import org.springframework.messaging.handler.annotation.support.MethodArgumentNo
import org.springframework.util.MimeType;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.fail;
import static org.springframework.cloud.stream.binding.StreamListenerErrorMessages.INVALID_DECLARATIVE_METHOD_PARAMETERS;
/**
@@ -63,33 +63,39 @@ public class StreamListenerAnnotatedMethodArgumentsTests {
@Test
@SuppressWarnings("unchecked")
public void testAnnotatedArguments() {
- ConfigurableApplicationContext context = SpringApplication.run(TestPojoWithAnnotatedArguments.class,
- "--server.port=0");
+ ConfigurableApplicationContext context = SpringApplication
+ .run(TestPojoWithAnnotatedArguments.class, "--server.port=0");
TestPojoWithAnnotatedArguments testPojoWithAnnotatedArguments = context
.getBean(TestPojoWithAnnotatedArguments.class);
Sink sink = context.getBean(Sink.class);
String id = UUID.randomUUID().toString();
- sink.input().send(MessageBuilder.withPayload("{\"foo\":\"barbar" + id + "\"}")
- .setHeader("contentType", MimeType.valueOf("application/json")).setHeader("testHeader", "testValue").build());
+ sink.input()
+ .send(MessageBuilder.withPayload("{\"foo\":\"barbar" + id + "\"}")
+ .setHeader("contentType", MimeType.valueOf("application/json"))
+ .setHeader("testHeader", "testValue").build());
assertThat(testPojoWithAnnotatedArguments.receivedArguments).hasSize(3);
assertThat(testPojoWithAnnotatedArguments.receivedArguments.get(0))
.isInstanceOf(StreamListenerTestUtils.FooPojo.class);
- assertThat(testPojoWithAnnotatedArguments.receivedArguments.get(0)).hasFieldOrPropertyWithValue("foo",
- "barbar" + id);
- assertThat(testPojoWithAnnotatedArguments.receivedArguments.get(1)).isInstanceOf(Map.class);
- assertThat((Map) testPojoWithAnnotatedArguments.receivedArguments.get(1))
- .containsEntry(MessageHeaders.CONTENT_TYPE, MimeType.valueOf("application/json"));
- assertThat((Map) testPojoWithAnnotatedArguments.receivedArguments.get(1))
- .containsEntry("testHeader", "testValue");
- assertThat(testPojoWithAnnotatedArguments.receivedArguments.get(2)).isEqualTo("application/json");
+ assertThat(testPojoWithAnnotatedArguments.receivedArguments.get(0))
+ .hasFieldOrPropertyWithValue("foo", "barbar" + id);
+ assertThat(testPojoWithAnnotatedArguments.receivedArguments.get(1))
+ .isInstanceOf(Map.class);
+ assertThat((Map) testPojoWithAnnotatedArguments.receivedArguments
+ .get(1)).containsEntry(MessageHeaders.CONTENT_TYPE,
+ MimeType.valueOf("application/json"));
+ assertThat((Map) testPojoWithAnnotatedArguments.receivedArguments
+ .get(1)).containsEntry("testHeader", "testValue");
+ assertThat(testPojoWithAnnotatedArguments.receivedArguments.get(2))
+ .isEqualTo("application/json");
context.close();
}
@Test
public void testInputAnnotationAtMethodParameter() {
try {
- SpringApplication.run(TestPojoWithInvalidInputAnnotatedArgument.class, "--server.port=0");
+ SpringApplication.run(TestPojoWithInvalidInputAnnotatedArgument.class,
+ "--server.port=0");
fail("Exception expected: " + INVALID_DECLARATIVE_METHOD_PARAMETERS);
}
catch (IllegalArgumentException e) {
@@ -99,30 +105,36 @@ public class StreamListenerAnnotatedMethodArgumentsTests {
@Test
public void testValidAnnotationAtMethodParameterWithPojoThatPassesValidation() {
- ConfigurableApplicationContext context = SpringApplication.run(TestPojoWithValidAnnotationThatPassesValidation.class,
- "--server.port=0");
+ ConfigurableApplicationContext context = SpringApplication.run(
+ TestPojoWithValidAnnotationThatPassesValidation.class, "--server.port=0");
- TestPojoWithValidAnnotationThatPassesValidation testPojoWithValidAnnotationThatPassesValidation = context.getBean(TestPojoWithValidAnnotationThatPassesValidation.class);
+ TestPojoWithValidAnnotationThatPassesValidation testPojoWithValidAnnotationThatPassesValidation = context
+ .getBean(TestPojoWithValidAnnotationThatPassesValidation.class);
Sink sink = context.getBean(Sink.class);
String id = UUID.randomUUID().toString();
sink.input().send(MessageBuilder.withPayload("{\"foo\":\"" + id + "\"}")
.setHeader("contentType", MimeType.valueOf("application/json")).build());
- assertThat(testPojoWithValidAnnotationThatPassesValidation.receivedArguments.get(0)).hasFieldOrPropertyWithValue("foo", id);
+ assertThat(
+ testPojoWithValidAnnotationThatPassesValidation.receivedArguments.get(0))
+ .hasFieldOrPropertyWithValue("foo", id);
context.close();
}
@Test
public void testValidAnnotationAtMethodParameterWithPojoThatFailsValidation() {
- ConfigurableApplicationContext context = SpringApplication.run(TestPojoWithValidAnnotationThatPassesValidation.class,
- "--server.port=0");
+ ConfigurableApplicationContext context = SpringApplication.run(
+ TestPojoWithValidAnnotationThatPassesValidation.class, "--server.port=0");
Sink sink = context.getBean(Sink.class);
try {
sink.input().send(MessageBuilder.withPayload("{\"foo\":\"\"}")
- .setHeader("contentType", MimeType.valueOf("application/json")).build());
+ .setHeader("contentType", MimeType.valueOf("application/json"))
+ .build());
fail("Exception expected: MethodArgumentNotValidException!");
- } catch(MethodArgumentNotValidException e) {
- assertThat(e.getMessage()).contains("default message [foo]]; default message [must not be blank]]");
+ }
+ catch (MethodArgumentNotValidException e) {
+ assertThat(e.getMessage()).contains(
+ "default message [foo]]; default message [must not be blank]]");
}
context.close();
}
@@ -141,6 +153,7 @@ public class StreamListenerAnnotatedMethodArgumentsTests {
this.receivedArguments.add(headers);
this.receivedArguments.add(contentType);
}
+
}
@EnableBinding(Sink.class)
@@ -158,6 +171,7 @@ public class StreamListenerAnnotatedMethodArgumentsTests {
this.receivedArguments.add(headers);
this.receivedArguments.add(contentType);
}
+
}
@EnableBinding(Processor.class)
@@ -167,9 +181,11 @@ public class StreamListenerAnnotatedMethodArgumentsTests {
List