From fc71db446a2e0e21e9ef8f5b98972ddaf25602ad Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Fri, 24 Nov 2023 13:44:06 -0500 Subject: [PATCH] Various fixes * Remove `aws-sdk` BOM in favor of one from the SC-AWS * Add `artifactoryPublish.skip = true` for root project * Remove `provided` Gradle feature --- build.gradle | 18 +++---- gradle.properties | 3 +- supplier/jms-supplier/build.gradle | 3 +- supplier/mail-supplier/build.gradle | 1 + .../fn/supplier/mail/ImapIdleFailTests.java | 47 ------------------ .../sftp/SftpSupplierApplicationTests.java | 49 +++++++++++-------- supplier/twitter-supplier/build.gradle | 3 +- 7 files changed, 42 insertions(+), 82 deletions(-) delete mode 100644 supplier/mail-supplier/src/test/java/org/springframework/cloud/fn/supplier/mail/ImapIdleFailTests.java diff --git a/build.gradle b/build.gradle index 0905098e..9108d151 100644 --- a/build.gradle +++ b/build.gradle @@ -9,6 +9,11 @@ plugins { description = 'Spring Functions Catlog' + +if (tasks.findByName('artifactoryPublish')) { + artifactoryPublish.skip = true +} + ext { javaProjects = subprojects - project(':function-dependencies') } @@ -46,7 +51,6 @@ allprojects { imports { mavenBom "org.springframework.boot:spring-boot-dependencies:${property('spring-boot.version')}" mavenBom "org.springframework.cloud:spring-cloud-dependencies:${property('spring-cloud.version')}" - mavenBom "software.amazon.awssdk:bom:${property('aws-sdk.version')}" mavenBom "io.awspring.cloud:spring-cloud-aws-dependencies:${property('spring-cloud-aws.version')}" } @@ -75,14 +79,10 @@ configure(javaProjects) { subproject -> registerFeature('optional') { usingSourceSet(sourceSets.main) } - registerFeature('provided') { - usingSourceSet(sourceSets.main) - } } compileJava { options.release = 17 - options.compilerArgs << '-parameters' } compileTestJava { @@ -107,7 +107,7 @@ configure(javaProjects) { subproject -> // dependencies that are common across all java projects dependencies { - providedImplementation 'org.springframework.boot:spring-boot-configuration-processor' + annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' if (subproject.name != 'config-common') { api project(':config-common') @@ -128,9 +128,7 @@ configure(javaProjects) { subproject -> testRuntimeOnly 'org.apache.logging.log4j:log4j-jcl' } - // enable all compiler warnings; individual projects may customize further - ext.xLintArg = '-Xlint:all,-options,-processing' - [compileJava, compileTestJava]*.options*.compilerArgs = [xLintArg, '-parameters'] + [compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:all,-options,-processing', '-parameters'] test { maxHeapSize = '2g' @@ -149,7 +147,7 @@ configure(javaProjects) { subproject -> 'Created-By': "JDK ${System.properties['java.version']} (${System.properties['java.specification.vendor']})", 'Implementation-Title': subproject.name, 'Implementation-Vendor-Id': subproject.group, - 'Implementation-Vendor': 'Pivotal Software, Inc.', + 'Implementation-Vendor': 'VMware, Inc.', 'Implementation-URL': 'https://spring.io/projects/spring-functions-catalog', 'Automatic-Module-Name': subproject.name.replace('-', '.') ) diff --git a/gradle.properties b/gradle.properties index fd795d19..ff7b1ce6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,13 @@ version=5.0.0-SNAPSHOT +org.gradle.jvmargs=-Xmx1536M -Dfile.encoding=UTF-8 org.gradle.caching=true org.gradle.parallel=true spring-boot.version=3.2.0 spring-cloud.version=2023.0.0-SNAPSHOT -aws-sdk.version=2.20.162 spring-cloud-aws.version=3.0.3 spring-integration-aws.version=3.0.4 +angus-mail.version=2.0.2 debeziumVersion = 2.4.1.Final ftpServerVersion=1.2.0 diff --git a/supplier/jms-supplier/build.gradle b/supplier/jms-supplier/build.gradle index 51f23251..79bdbfb4 100644 --- a/supplier/jms-supplier/build.gradle +++ b/supplier/jms-supplier/build.gradle @@ -1,7 +1,6 @@ dependencies { api 'org.springframework.integration:spring-integration-jms' - - providedImplementation 'jakarta.jms:jakarta.jms-api' + api 'jakarta.jms:jakarta.jms-api' testImplementation 'org.springframework.boot:spring-boot-starter-artemis' testImplementation 'org.apache.activemq:artemis-jakarta-server' diff --git a/supplier/mail-supplier/build.gradle b/supplier/mail-supplier/build.gradle index ddc8b03e..cfb22c05 100644 --- a/supplier/mail-supplier/build.gradle +++ b/supplier/mail-supplier/build.gradle @@ -4,6 +4,7 @@ ext { dependencies { api 'org.springframework.integration:spring-integration-mail' + api 'org.springframework.boot:spring-boot-starter-mail' api 'org.eclipse.angus:jakarta.mail:2.0.2' testImplementation "com.icegreen:greenmail:$greenmailVersion" diff --git a/supplier/mail-supplier/src/test/java/org/springframework/cloud/fn/supplier/mail/ImapIdleFailTests.java b/supplier/mail-supplier/src/test/java/org/springframework/cloud/fn/supplier/mail/ImapIdleFailTests.java deleted file mode 100644 index 001f041e..00000000 --- a/supplier/mail-supplier/src/test/java/org/springframework/cloud/fn/supplier/mail/ImapIdleFailTests.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2020-2020 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. - * You may obtain a copy of the License at - * - * https://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. - */ - -package org.springframework.cloud.fn.supplier.mail; - -import org.junit.jupiter.api.Test; -import reactor.core.publisher.Flux; -import reactor.test.StepVerifier; - -import org.springframework.messaging.Message; -import org.springframework.test.context.TestPropertySource; - -import static org.assertj.core.api.Assertions.assertThat; - -@TestPropertySource(properties = { - "mail.supplier.idle-imap=true", - "mail.supplier.url=imap://user:pw@localhost:${test.mail.server.imap.port}/INBOX"}) -public class ImapIdleFailTests extends AbstractMailSupplierTests { - @Test - public void testSimpleTest() { - // given - sendMessage("test", "foo"); - // when - final Flux> messageFlux = mailSupplier.get(); - // then - StepVerifier.create(messageFlux) - .assertNext((message) -> { - assertThat(((String) message.getPayload())).isNotEqualTo("Test Mail"); - } - ) - .thenCancel() - .verify(); - } -} diff --git a/supplier/sftp-supplier/src/test/java/org/springframework/cloud/fn/supplier/sftp/SftpSupplierApplicationTests.java b/supplier/sftp-supplier/src/test/java/org/springframework/cloud/fn/supplier/sftp/SftpSupplierApplicationTests.java index 5cfd6ffb..c41d09e0 100644 --- a/supplier/sftp-supplier/src/test/java/org/springframework/cloud/fn/supplier/sftp/SftpSupplierApplicationTests.java +++ b/supplier/sftp-supplier/src/test/java/org/springframework/cloud/fn/supplier/sftp/SftpSupplierApplicationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 the original author or authors. + * Copyright 2020-2023 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. @@ -71,6 +71,7 @@ public class SftpSupplierApplicationTests extends SftpTestSupport { } @Test + @SuppressWarnings("unchecked") void supplierForListOnly() { defaultApplicationContextRunner .withPropertyValues("sftp.supplier.listOnly=true") @@ -96,35 +97,38 @@ public class SftpSupplierApplicationTests extends SftpTestSupport { assertThat(message.getHeaders().get(MessageHeaders.CONTENT_TYPE)) .isEqualTo(MediaType.TEXT_PLAIN); }) - .expectTimeout(Duration.ofMillis(1000)) + .thenCancel() .verify(Duration.ofSeconds(30)); }); } @Test + @SuppressWarnings("unchecked") void supplierForListOnlyWithPatternFilter() { defaultApplicationContextRunner - .withPropertyValues("sftp.supplier.listOnly=true", "sftp.supplier.file-name-pattern=.*1.txt") + .withPropertyValues("sftp.supplier.listOnly=true", + "sftp.supplier.file-name-pattern=.*1.txt") .run(context -> { Supplier>> sftpSupplier = context.getBean("sftpSupplier", Supplier.class); SftpSupplierProperties properties = context.getBean(SftpSupplierProperties.class); - final AtomicReference expectedFileName = new AtomicReference<>( - properties.getRemoteDir() + "/sftpSource1.txt"); StepVerifier.create(sftpSupplier.get()) - .assertNext(message -> assertThat(expectedFileName.get()).contains(message.getPayload())) - .expectTimeout(Duration.ofMillis(1000)) + .assertNext(message -> assertThat(message.getPayload()).contains("sftpSource1.txt")) + .thenCancel() .verify(Duration.ofSeconds(30)); }); } @Test + @SuppressWarnings("unchecked") void supplierForListSortedByFilenameAsc() { defaultApplicationContextRunner - .withPropertyValues("sftp.supplier.listOnly=true", "sftp.supplier.sortBy.attribute=filename", "sftp.supplier.sortBy.dir=asc") + .withPropertyValues("sftp.supplier.listOnly=true", + "sftp.supplier.sortBy.attribute=filename", + "sftp.supplier.sortBy.dir=asc") .run(context -> { Supplier>> sftpSupplier = context.getBean("sftpSupplier", Supplier.class); @@ -146,16 +150,19 @@ public class SftpSupplierApplicationTests extends SftpTestSupport { assertThat(message.getHeaders().get(MessageHeaders.CONTENT_TYPE)) .isEqualTo(MediaType.TEXT_PLAIN); }) - .expectTimeout(Duration.ofMillis(1000)) + .thenCancel() .verify(Duration.ofSeconds(30)); }); } @Test + @SuppressWarnings("unchecked") void supplierForListSortedByFilenameDesc() { defaultApplicationContextRunner - .withPropertyValues("sftp.supplier.listOnly=true", "sftp.supplier.sortBy.attribute=filename", "sftp.supplier.sortBy.dir=desc") + .withPropertyValues("sftp.supplier.listOnly=true", + "sftp.supplier.sortBy.attribute=filename", + "sftp.supplier.sortBy.dir=desc") .run(context -> { Supplier>> sftpSupplier = context.getBean("sftpSupplier", Supplier.class); @@ -177,21 +184,21 @@ public class SftpSupplierApplicationTests extends SftpTestSupport { assertThat(message.getHeaders().get(MessageHeaders.CONTENT_TYPE)) .isEqualTo(MediaType.TEXT_PLAIN); }) - .expectTimeout(Duration.ofMillis(1000)) + .thenCancel() .verify(Duration.ofSeconds(30)); }); } @Test + @SuppressWarnings("unchecked") void supplierForFileRef() { defaultApplicationContextRunner .withPropertyValues( "sftp.supplier.localDir=" + getTargetLocalDirectory().getAbsolutePath(), "file.consumer.mode=ref") .run(context -> { - Supplier>> sftpSupplier = context.getBean("sftpSupplier", - Supplier.class); + Supplier>> sftpSupplier = context.getBean("sftpSupplier", Supplier.class); SftpSupplierProperties properties = context.getBean(SftpSupplierProperties.class); MetadataStore metadataStore = context.getBean(MetadataStore.class); HashSet fileNames = new HashSet<>(); @@ -219,14 +226,14 @@ public class SftpSupplierApplicationTests extends SftpTestSupport { } @Test + @SuppressWarnings("unchecked") void deleteRemoteFiles() { defaultApplicationContextRunner .withPropertyValues( "sftp.supplier.stream=true", "sftp.supplier.delete-remote-files=true") .run(context -> { - Supplier>> sftpSupplier = context.getBean("sftpSupplier", - Supplier.class); + Supplier>> sftpSupplier = context.getBean("sftpSupplier", Supplier.class); StepVerifier.create(sftpSupplier.get()) .expectNextMatches(message -> message.getPayload().length > 0) .expectNextMatches(message -> message.getPayload().length > 0) @@ -258,9 +265,9 @@ public class SftpSupplierApplicationTests extends SftpTestSupport { .run(this::doTestRenameRemoteFiles); } + @SuppressWarnings("unchecked") private void doTestRenameRemoteFiles(AssertableApplicationContext context) { - Supplier>> sftpSupplier = context.getBean("sftpSupplier", - Supplier.class); + Supplier>> sftpSupplier = context.getBean("sftpSupplier", Supplier.class); final Set expectedTargetFiles = Arrays.stream(getSourceRemoteDirectory().list()) .collect(Collectors.toSet()); @@ -274,11 +281,12 @@ public class SftpSupplierApplicationTests extends SftpTestSupport { .until(() -> expectedTargetFiles.equals( Arrays.stream(getTargetRemoteDirectory().list()) - .collect(Collectors.toSet())) + .collect(Collectors.toSet())) ); } @Test + @SuppressWarnings("unchecked") public void streamSourceFilesInLineMode() { defaultApplicationContextRunner .withPropertyValues( @@ -291,8 +299,7 @@ public class SftpSupplierApplicationTests extends SftpTestSupport { "file.consumer.with-markers=true", "file.consumer.markers-json=true") .run(context -> { - Supplier>> sftpSupplier = context.getBean("sftpSupplier", - Supplier.class); + Supplier>> sftpSupplier = context.getBean("sftpSupplier", Supplier.class); StepVerifier.create(sftpSupplier.get()) .assertNext(message -> { final Object evaluate; @@ -321,6 +328,7 @@ public class SftpSupplierApplicationTests extends SftpTestSupport { } @Test + @SuppressWarnings("unchecked") void supplierWithMultiSourceAndStreamContentsSource3ComesSecond() throws Exception { Path newSource = createNewRemoteSource( Paths.get(remoteTemporaryFolder.toString(), "sftpSecondSource", "doesNotMatter.txt"), @@ -372,6 +380,7 @@ public class SftpSupplierApplicationTests extends SftpTestSupport { } @Test + @SuppressWarnings("unchecked") void supplierMultiSourceRefTestsFor200Alex() throws Exception { Path newSource = createNewRemoteSource( Paths.get(remoteTemporaryFolder.toString(), "sftpSecondSource", "sftpSource3.txt"), diff --git a/supplier/twitter-supplier/build.gradle b/supplier/twitter-supplier/build.gradle index 49615fd3..6d0f4762 100644 --- a/supplier/twitter-supplier/build.gradle +++ b/supplier/twitter-supplier/build.gradle @@ -5,8 +5,7 @@ ext { dependencies { api project(':twitter-common') api 'org.springframework.integration:spring-integration-jms' - - providedImplementation 'jakarta.jms:jakarta.jms-api' + api 'jakarta.jms:jakarta.jms-api' testImplementation "org.mock-server:mockserver-netty:$mockserverVersion" testImplementation "org.mock-server:mockserver-client-java:$mockserverVersion"