diff --git a/build.gradle b/build.gradle index df03abd..928a285 100644 --- a/build.gradle +++ b/build.gradle @@ -31,12 +31,13 @@ repositories { ext { assertjVersion = '3.12.0' + awaitilityVersion = '3.1.6' dynamodbLockClientVersion = '1.0.0' jacksonVersion = '2.9.8' servletApiVersion = '4.0.1' log4jVersion = '2.11.2' springCloudAwsVersion = '2.1.1.BUILD-SNAPSHOT' - springIntegrationVersion = '5.1.4.BUILD-SNAPSHOT' + springIntegrationVersion = '5.2.0.BUILD-SNAPSHOT' kinesisClientVersion = '2.0.5' kinesisProducerVersion = '0.12.11' @@ -77,17 +78,18 @@ dependencyManagement { } jacoco { - toolVersion = "0.8.2" + toolVersion = "0.8.3" } checkstyle { configFile = file("${rootDir}/src/checkstyle/checkstyle.xml") - toolVersion = "8.17" + toolVersion = "8.18" } dependencies { compile 'org.springframework.integration:spring-integration-core' compile 'org.springframework.cloud:spring-cloud-aws-core' + compile "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion" compile('org.springframework.cloud:spring-cloud-aws-messaging', optional) compile('org.springframework.integration:spring-integration-file', optional) @@ -105,6 +107,10 @@ dependencies { testCompile 'org.springframework.integration:spring-integration-test' testCompile "org.assertj:assertj-core:$assertjVersion" + testCompile ("org.awaitility:awaitility:$awaitilityVersion") { + exclude group: 'org.hamcrest' + } + testRuntime "org.apache.logging.log4j:log4j-slf4j-impl:$log4jVersion" testRuntime "org.apache.logging.log4j:log4j-jcl:$log4jVersion" } diff --git a/gradle.properties b/gradle.properties index 331739f..f212918 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=2.1.0.BUILD-SNAPSHOT +version=2.2.0.BUILD-SNAPSHOT diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 29953ea..87b738c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e0b3fb8..44e7c4d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index cccdd3d..af6708f 100755 --- a/gradlew +++ b/gradlew @@ -28,7 +28,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" diff --git a/gradlew.bat b/gradlew.bat index e95643d..6d57edc 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,84 +1,84 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml index d53a329..5766909 100644 --- a/src/checkstyle/checkstyle.xml +++ b/src/checkstyle/checkstyle.xml @@ -1,15 +1,16 @@ - + - + - - + + @@ -20,83 +21,83 @@ - + - - + + + value="false"/> - + - + - + - - + + - - - - - - + + + + + + - - - - - - - + + + + + + + - + - + - + - + - - + + - + - + + org.mockito.AdditionalAnswers.*, + org.mockito.ArgumentMatchers.*, + org.springframework.integration.test.mock.MockIntegration.*, + org.springframework.integration.test.util.TestUtils.*"/> - - + + - + - - - - - + + + + + @@ -105,7 +106,7 @@ - + @@ -113,72 +114,72 @@ - + - + - + - + - - - + + + - + - + - + value="Line has leading space characters; indentation should be performed with tabs only."/> + - - - - - - - + - + value="Please use BDDMockito instead of Mockito.(when|doThrow|doAnswer)."/> + + + + + + + - - - + + + - - - + + + - - - + + + - - - - - + + + + + diff --git a/src/main/java/org/springframework/integration/aws/inbound/kinesis/KclMessageDrivenChannelAdapter.java b/src/main/java/org/springframework/integration/aws/inbound/kinesis/KclMessageDrivenChannelAdapter.java index 3692a4d..23175eb 100644 --- a/src/main/java/org/springframework/integration/aws/inbound/kinesis/KclMessageDrivenChannelAdapter.java +++ b/src/main/java/org/springframework/integration/aws/inbound/kinesis/KclMessageDrivenChannelAdapter.java @@ -60,8 +60,9 @@ import software.amazon.kinesis.retrieval.KinesisClientRecord; * Kinesis stream(s) using AWS KCL. * * @author Hervé Fortin + * @author Artem Bilan * - * @since 2.1.0 + * @since 2.2.0 */ @ManagedResource @IntegrationManagedResource diff --git a/src/main/java/org/springframework/integration/aws/outbound/KplMessageHandler.java b/src/main/java/org/springframework/integration/aws/outbound/KplMessageHandler.java index b1bbcc8..5d7e576 100644 --- a/src/main/java/org/springframework/integration/aws/outbound/KplMessageHandler.java +++ b/src/main/java/org/springframework/integration/aws/outbound/KplMessageHandler.java @@ -53,8 +53,9 @@ import com.google.common.util.concurrent.MoreExecutors; * The {@link AbstractMessageHandler} implementation for the Amazon Kinesis Producer Library {@code putRecord(s)}. * * @author Arnaud Lecollaire + * @author Artem Bilan * - * @since 2.1.0 + * @since 2.2.0 * * @see AmazonKinesisAsync#putRecord(PutRecordRequest) * @see AmazonKinesisAsync#putRecords(PutRecordsRequest) diff --git a/src/test/java/org/springframework/integration/aws/inbound/KinesisMessageDrivenChannelAdapterTests.java b/src/test/java/org/springframework/integration/aws/inbound/KinesisMessageDrivenChannelAdapterTests.java index ff49b15..0e3834d 100644 --- a/src/test/java/org/springframework/integration/aws/inbound/KinesisMessageDrivenChannelAdapterTests.java +++ b/src/test/java/org/springframework/integration/aws/inbound/KinesisMessageDrivenChannelAdapterTests.java @@ -17,21 +17,18 @@ package org.springframework.integration.aws.inbound; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.awaitility.Awaitility.await; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.springframework.integration.test.matcher.EqualsResultMatcher.equalsResult; -import static org.springframework.integration.test.matcher.EventuallyMatcher.eventually; import java.nio.ByteBuffer; import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -125,7 +122,7 @@ public class KinesisMessageDrivenChannelAdapterTests { Map shardConsumers = TestUtils.getPropertyValue(this.kinesisMessageDrivenChannelAdapter, "shardConsumers", Map.class); - Assert.assertThat(shardConsumers.keySet(), eventually(100, 50, containsInAnyOrder(testOffset1, testOffset2))); + await().untilAsserted(() -> assertThat(shardConsumers.keySet()).contains(testOffset1, testOffset2)); assertThat(shardConsumers).containsKeys(testOffset1, testOffset2); @@ -161,11 +158,11 @@ public class KinesisMessageDrivenChannelAdapterTests { TestUtils.getPropertyValue(this.kinesisMessageDrivenChannelAdapter, "shardConsumerManager.locks", Map.class); - Assert.assertThat(0, eventually(100, 100, equalsResult(forLocking::size))); + await().untilAsserted(() -> assertThat(forLocking).hasSize(0)); - List consumerInvokers = + final List consumerInvokers = TestUtils.getPropertyValue(this.kinesisMessageDrivenChannelAdapter, "consumerInvokers", List.class); - Assert.assertThat(0, eventually(100, 100, equalsResult(consumerInvokers::size))); + await().untilAsserted(() -> assertThat(consumerInvokers).hasSize(0)); this.kinesisMessageDrivenChannelAdapter.setListenerMode(ListenerMode.batch); this.kinesisMessageDrivenChannelAdapter.setCheckpointMode(CheckpointMode.record); @@ -189,13 +186,11 @@ public class KinesisMessageDrivenChannelAdapterTests { assertThat(sequenceNumberHeader).isInstanceOf(List.class); assertThat((List) sequenceNumberHeader).contains("2"); - Assert.assertThat("2", - eventually(100, 100, equalsResult(() -> - this.checkpointStore.get("SpringIntegration" + ":" + STREAM1 + ":" + "1")))); + await().untilAsserted(() -> + assertThat(this.checkpointStore.get("SpringIntegration" + ":" + STREAM1 + ":" + "1")).isEqualTo("2")); - consumerInvokers = - TestUtils.getPropertyValue(this.kinesisMessageDrivenChannelAdapter, "consumerInvokers", List.class); - assertThat(consumerInvokers.size()).isEqualTo(2); + assertThat(TestUtils.getPropertyValue(this.kinesisMessageDrivenChannelAdapter, "consumerInvokers", List.class)) + .hasSize(2); this.kinesisMessageDrivenChannelAdapter.stop(); }