diff --git a/applications/sink/redis-sink/src/test/java/org/springframework/cloud/stream/app/sink/redis/RedisSinkTests.java b/applications/sink/redis-sink/src/test/java/org/springframework/cloud/stream/app/sink/redis/RedisSinkTests.java index f89e7c3d8..68ec81b1e 100644 --- a/applications/sink/redis-sink/src/test/java/org/springframework/cloud/stream/app/sink/redis/RedisSinkTests.java +++ b/applications/sink/redis-sink/src/test/java/org/springframework/cloud/stream/app/sink/redis/RedisSinkTests.java @@ -52,6 +52,7 @@ public void testRedisSink() { .getCompleteConfiguration(RedisSinkTestApplication.class)) .web(WebApplicationType.NONE) .run("--spring.cloud.function.definition=redisConsumer", + "--spring.cloud.stream.bindings.redisConsumer-in-0.consumer.use-native-decoding=true", "--spring.data.redis.url=" + RedisTestContainerSupport.getUri(), "--redis.consumer.key=foo")) { diff --git a/applications/sink/s3-sink/README.adoc b/applications/sink/s3-sink/README.adoc index dbf1bc2d7..6ec4d5037 100644 --- a/applications/sink/s3-sink/README.adoc +++ b/applications/sink/s3-sink/README.adoc @@ -44,6 +44,7 @@ $$static$$:: $$$$ *($$String$$, default: `$$$$`)* $$accelerate-mode-enabled$$:: $$Option to enable using the accelerate endpoint when accessing S3. Accelerate endpoints allow faster transfer of objects by using Amazon CloudFront's globally distributed edge locations.$$ *($$Boolean$$, default: `$$$$`)* $$checksum-validation-enabled$$:: $$Option to disable doing a validation of the checksum of an object stored in S3.$$ *($$Boolean$$, default: `$$$$`)* $$chunked-encoding-enabled$$:: $$Option to enable using chunked encoding when signing the request payload for {@link software.amazon.awssdk.services.s3.model.PutObjectRequest} and {@link software.amazon.awssdk.services.s3.model.UploadPartRequest}.$$ *($$Boolean$$, default: `$$$$`)* +$$cross-region-enabled$$:: $$Enables cross-region bucket access.$$ *($$Boolean$$, default: `$$$$`)* $$endpoint$$:: $$Overrides the default endpoint.$$ *($$URI$$, default: `$$$$`)* $$path-style-access-enabled$$:: $$Option to enable using path style access for accessing S3 objects instead of DNS style access. DNS style access is preferred as it will result in better load balancing when accessing S3.$$ *($$Boolean$$, default: `$$$$`)* $$region$$:: $$Overrides the default region.$$ *($$String$$, default: `$$$$`)* diff --git a/applications/source/jms-source/README.adoc b/applications/source/jms-source/README.adoc index d709e6045..6cc0644dc 100644 --- a/applications/source/jms-source/README.adoc +++ b/applications/source/jms-source/README.adoc @@ -30,7 +30,7 @@ $$pub-sub-domain$$:: $$Whether the default destination type is topic.$$ *($$Bool $$acknowledge-mode$$:: $$Acknowledge mode of the container. By default, the listener is transacted with automatic acknowledgment.$$ *($$AcknowledgeMode$$, default: `$$$$`, possible values: `AUTO`,`CLIENT`,`DUPS_OK`)* $$auto-startup$$:: $$Start the container automatically on startup.$$ *($$Boolean$$, default: `$$true$$`)* -$$concurrency$$:: $$Minimum number of concurrent consumers.$$ *($$Integer$$, default: `$$$$`)* +$$concurrency$$:: $$Minimum number of concurrent consumers. When max-concurrency is not specified the minimum will also be used as the maximum.$$ *($$Integer$$, default: `$$$$`)* $$max-concurrency$$:: $$Maximum number of concurrent consumers.$$ *($$Integer$$, default: `$$$$`)* $$receive-timeout$$:: $$Timeout to use for receive calls. Use -1 for a no-wait receive or 0 for no timeout at all. The latter is only feasible if not running within a transaction manager and is generally discouraged since it prevents clean shutdown.$$ *($$Duration$$, default: `$$1s$$`)* //end::configuration-properties[] diff --git a/applications/source/s3-source/README.adoc b/applications/source/s3-source/README.adoc index 588af9e71..77e63f606 100644 --- a/applications/source/s3-source/README.adoc +++ b/applications/source/s3-source/README.adoc @@ -126,6 +126,7 @@ $$static$$:: $$$$ *($$String$$, default: `$$$$`)* $$accelerate-mode-enabled$$:: $$Option to enable using the accelerate endpoint when accessing S3. Accelerate endpoints allow faster transfer of objects by using Amazon CloudFront's globally distributed edge locations.$$ *($$Boolean$$, default: `$$$$`)* $$checksum-validation-enabled$$:: $$Option to disable doing a validation of the checksum of an object stored in S3.$$ *($$Boolean$$, default: `$$$$`)* $$chunked-encoding-enabled$$:: $$Option to enable using chunked encoding when signing the request payload for {@link software.amazon.awssdk.services.s3.model.PutObjectRequest} and {@link software.amazon.awssdk.services.s3.model.UploadPartRequest}.$$ *($$Boolean$$, default: `$$$$`)* +$$cross-region-enabled$$:: $$Enables cross-region bucket access.$$ *($$Boolean$$, default: `$$$$`)* $$endpoint$$:: $$Overrides the default endpoint.$$ *($$URI$$, default: `$$$$`)* $$path-style-access-enabled$$:: $$Option to enable using path style access for accessing S3 objects instead of DNS style access. DNS style access is preferred as it will result in better load balancing when accessing S3.$$ *($$Boolean$$, default: `$$$$`)* $$region$$:: $$Overrides the default region.$$ *($$String$$, default: `$$$$`)* diff --git a/applications/stream-applications-core/pom.xml b/applications/stream-applications-core/pom.xml index f24c4189c..ecd0a9120 100644 --- a/applications/stream-applications-core/pom.xml +++ b/applications/stream-applications-core/pom.xml @@ -20,10 +20,11 @@ 4.0.1-SNAPSHOT springcloud/baseimage:1.0.4 1.5.2 - 1.0.10 - 1.0.10 - 1.0.10 - 2.4.0 + 1.0.14 + 1.0.14 + 1.0.14 + 3.2.0 + 4.0.5 @@ -262,7 +263,7 @@ io.pivotal.spring.cloud spring-cloud-services-starter-config-client - 3.2.0.RELEASE + ${spring-cloud-services.version} diff --git a/clean-apps.sh b/clean-apps.sh new file mode 100755 index 000000000..989afe649 --- /dev/null +++ b/clean-apps.sh @@ -0,0 +1,13 @@ +#!/bin/bash +echo "About to delete the following 'apps' folders:" +find . -type d -name apps +echo "----------------" +echo "Enter 'Y' or 'N':" +read shouldDelete +if [ "$shouldDelete" = "Y" ] || [ "$shouldDelete" = "y" ]; then + echo "Deleting..." + find . -type d -name apps -prune -exec rm -rf {} \; + echo "Done" +else + echo "Not deleting" +fi diff --git a/functions/common/function-test-support/pom.xml b/functions/common/function-test-support/pom.xml index ae755b1a0..5cefb7cad 100644 --- a/functions/common/function-test-support/pom.xml +++ b/functions/common/function-test-support/pom.xml @@ -14,7 +14,7 @@ file consumer - 2.7.0 + 2.9.3 1.2.0 diff --git a/functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AbstractAwsS3ConsumerMockTests.java b/functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AbstractAwsS3ConsumerMockTests.java index c209f9411..a9d85e75f 100644 --- a/functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AbstractAwsS3ConsumerMockTests.java +++ b/functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AbstractAwsS3ConsumerMockTests.java @@ -36,6 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Bean; import org.springframework.http.MediaType; import org.springframework.messaging.Message; @@ -43,16 +44,14 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.willReturn; -import static org.mockito.Mockito.spy; @DirtiesContext @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, - properties = { - "spring.cloud.aws.credentials.accessKey=" + AbstractAwsS3ConsumerMockTests.AWS_ACCESS_KEY, + properties = { "spring.cloud.aws.credentials.accessKey=" + AbstractAwsS3ConsumerMockTests.AWS_ACCESS_KEY, "spring.cloud.aws.credentials.secretKey=" + AbstractAwsS3ConsumerMockTests.AWS_SECRET_KEY, "spring.cloud.aws.region.static=" + AbstractAwsS3ConsumerMockTests.AWS_REGION, "spring.cloud.aws.s3.endpoint=s3://foo", - "s3.consumer.bucket=" + AbstractAwsS3ConsumerMockTests.S3_BUCKET}) + "s3.consumer.bucket=" + AbstractAwsS3ConsumerMockTests.S3_BUCKET }) public abstract class AbstractAwsS3ConsumerMockTests { protected static final String AWS_ACCESS_KEY = "test.accessKey"; @@ -66,7 +65,7 @@ public abstract class AbstractAwsS3ConsumerMockTests { @TempDir protected static Path temporaryRemoteFolder; - @Autowired + @MockBean private S3AsyncClient amazonS3; @Autowired @@ -80,10 +79,7 @@ public abstract class AbstractAwsS3ConsumerMockTests { @BeforeEach public void setupTest() { - S3AsyncClient amazonS3 = spy(this.amazonS3); - - willReturn(CompletableFuture.completedFuture(PutObjectResponse.builder().build())) - .given(amazonS3) + willReturn(CompletableFuture.completedFuture(PutObjectResponse.builder().build())).given(amazonS3) .putObject(any(PutObjectRequest.class), any(AsyncRequestBody.class)); new DirectFieldAccessor(this.s3TransferManager).setPropertyValue("s3AsyncClient", amazonS3); @@ -101,7 +97,6 @@ public CountDownLatch transferCompletedLatch() { public TransferListener transferListener() { return new TransferListener() { - @Override public void transferComplete(Context.TransferComplete context) { transferCompletedLatch().countDown(); diff --git a/functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AmazonS3UploadFileTests.java b/functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AmazonS3UploadFileTests.java index a04a8a828..149f72257 100644 --- a/functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AmazonS3UploadFileTests.java +++ b/functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AmazonS3UploadFileTests.java @@ -32,6 +32,7 @@ import org.springframework.messaging.Message; import org.springframework.messaging.support.MessageBuilder; import org.springframework.test.context.TestPropertySource; +import org.springframework.util.FileCopyUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.atLeastOnce; @@ -42,38 +43,36 @@ public class AmazonS3UploadFileTests extends AbstractAwsS3ConsumerMockTests { @Test public void test() throws Exception { - S3AsyncClient amazonS3Client = - TestUtils.getPropertyValue(this.s3TransferManager, "s3AsyncClient", S3AsyncClient.class); + S3AsyncClient amazonS3Client = TestUtils.getPropertyValue(this.s3TransferManager, "s3AsyncClient", + S3AsyncClient.class); File file = new File(temporaryRemoteFolder.toFile(), "foo.mp3"); - file.createNewFile(); - Message message = MessageBuilder.withPayload(file) - .build(); + FileCopyUtils.copy(new byte[] { 1 }, file); + Message message = MessageBuilder.withPayload(file).build(); this.s3Consumer.accept(message); - ArgumentCaptor putObjectRequestArgumentCaptor = - ArgumentCaptor.forClass(PutObjectRequest.class); - ArgumentCaptor asyncRequestBodyArgumentCaptor = - ArgumentCaptor.forClass(AsyncRequestBody.class); - verify(amazonS3Client, atLeastOnce()) - .putObject(putObjectRequestArgumentCaptor.capture(), asyncRequestBodyArgumentCaptor.capture()); + ArgumentCaptor putObjectRequestArgumentCaptor = ArgumentCaptor.captor(); + ArgumentCaptor asyncRequestBodyArgumentCaptor = ArgumentCaptor.captor(); + verify(amazonS3Client, atLeastOnce()).putObject(putObjectRequestArgumentCaptor.capture(), + asyncRequestBodyArgumentCaptor.capture()); PutObjectRequest putObjectRequest = putObjectRequestArgumentCaptor.getValue(); assertThat(putObjectRequest.bucket()).isEqualTo(S3_BUCKET); assertThat(putObjectRequest.key()).isEqualTo("foo.mp3"); assertThat(putObjectRequest.contentMD5()).isEqualTo(Md5Utils.md5AsBase64(file)); - assertThat(putObjectRequest.contentLength()).isEqualTo(0L); + assertThat(putObjectRequest.contentLength()).isEqualTo(1L); assertThat(putObjectRequest.contentType()).isEqualTo("audio/mpeg"); assertThat(putObjectRequest.acl()).isEqualTo(ObjectCannedACL.PUBLIC_READ_WRITE); AsyncRequestBody asyncRequestBody = asyncRequestBodyArgumentCaptor.getValue(); StepVerifier.create(asyncRequestBody) - .assertNext(buffer -> assertThat(buffer.array()).isEmpty()) + .assertNext((buffer) -> assertThat(buffer.limit()).isEqualTo(1)) .expectComplete() .verify(); assertThat(this.transferCompletedLatch.await(10, TimeUnit.SECONDS)).isTrue(); } + } diff --git a/functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AmazonS3UploadInputStreamTests.java b/functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AmazonS3UploadInputStreamTests.java index 8c1799656..51c335a1c 100644 --- a/functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AmazonS3UploadInputStreamTests.java +++ b/functions/consumer/s3-consumer/src/test/java/org/springframework/cloud/fn/consumer/s3/AmazonS3UploadInputStreamTests.java @@ -17,6 +17,7 @@ package org.springframework.cloud.fn.consumer.s3; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; @@ -42,22 +43,18 @@ public class AmazonS3UploadInputStreamTests extends AbstractAwsS3ConsumerMockTes @Test public void test() throws Exception { - S3AsyncClient amazonS3Client = - TestUtils.getPropertyValue(this.s3TransferManager, "s3AsyncClient", S3AsyncClient.class); + S3AsyncClient amazonS3Client = TestUtils.getPropertyValue(this.s3TransferManager, "s3AsyncClient", + S3AsyncClient.class); InputStream payload = new StringInputStream("a"); - Message message = MessageBuilder.withPayload(payload) - .setHeader("key", "myInputStream") - .build(); + Message message = MessageBuilder.withPayload(payload).setHeader("key", "myInputStream").build(); this.s3Consumer.accept(message); - ArgumentCaptor putObjectRequestArgumentCaptor = - ArgumentCaptor.forClass(PutObjectRequest.class); - ArgumentCaptor asyncRequestBodyArgumentCaptor = - ArgumentCaptor.forClass(AsyncRequestBody.class); - verify(amazonS3Client, atLeastOnce()) - .putObject(putObjectRequestArgumentCaptor.capture(), asyncRequestBodyArgumentCaptor.capture()); + ArgumentCaptor putObjectRequestArgumentCaptor = ArgumentCaptor.captor(); + ArgumentCaptor asyncRequestBodyArgumentCaptor = ArgumentCaptor.captor(); + verify(amazonS3Client, atLeastOnce()).putObject(putObjectRequestArgumentCaptor.capture(), + asyncRequestBodyArgumentCaptor.capture()); PutObjectRequest putObjectRequest = putObjectRequestArgumentCaptor.getValue(); assertThat(putObjectRequest.bucket()).isEqualTo(S3_BUCKET); @@ -67,9 +64,8 @@ public void test() throws Exception { assertThat(putObjectRequest.contentType()).isEqualTo(MediaType.APPLICATION_JSON_VALUE); assertThat(putObjectRequest.contentDisposition()).isEqualTo("test.json"); - AsyncRequestBody asyncRequestBody = asyncRequestBodyArgumentCaptor.getValue(); - StepVerifier.create(asyncRequestBody.map(buffer -> new String(buffer.array()))) + StepVerifier.create(asyncRequestBody.map((buffer) -> StandardCharsets.UTF_8.decode(buffer).toString())) .expectNext("a") .expectComplete() .verify(); diff --git a/stream-applications-build/pom.xml b/stream-applications-build/pom.xml index aaaa6b147..f3c4828c7 100644 --- a/stream-applications-build/pom.xml +++ b/stream-applications-build/pom.xml @@ -36,33 +36,29 @@ true 0.0.35 - 3.1.8 - 6.0.16 - - 3.0.13 - 3.0.10 - - - 2022.0.4 + 3.1.12 + 6.0.21 + 3.0.17 + 3.0.14 + 2022.0.5 4.0.5 4.0.6 4.0.5 - - 1.18.3 - 5.13.2 - 4.0.14 2.5.2 3.1.0 - 3.0.2 - 3.0.2 + 3.0.5 + 3.0.8 5.5.0 - 1 + 1.18.3 + 5.14.2 + 5.13.2 - - ${env.BUILD_NAME} - - ${env.BUILD_NUMBER} + 1 + + ${env.BUILD_NAME} + + ${env.BUILD_NUMBER} https://spring.io/projects/spring-cloud-stream-applications @@ -81,6 +77,13 @@ + + org.mockito + mockito-bom + ${mockito.version} + pom + import + org.springframework.boot spring-boot-dependencies