diff --git a/core/spring-cloud-stream/pom.xml b/core/spring-cloud-stream/pom.xml index bd643b9ab..fc7ced2f6 100644 --- a/core/spring-cloud-stream/pom.xml +++ b/core/spring-cloud-stream/pom.xml @@ -9,7 +9,11 @@ spring-cloud-stream Messaging Microservices with Spring Integration - + + 1.7.20-Beta + + + org.springframework.cloud spring-cloud-stream-core 3.2.5-SNAPSHOT @@ -81,7 +85,18 @@ spring-kafka test - + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + + @@ -102,7 +117,57 @@ - + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + src/main/java + src/test/kotlin + + + + + test-compile + test-compile + + test-compile + + + + + 1.8 + + + + org.apache.maven.plugins + maven-compiler-plugin + + + compile + compile + + compile + + + + testCompile + test-compile + + testCompile + + + + + diff --git a/core/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/kotlin/KotlinConfigurationTests.java b/core/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/kotlin/KotlinConfigurationTests.java new file mode 100644 index 000000000..5f8b974c8 --- /dev/null +++ b/core/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/kotlin/KotlinConfigurationTests.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022-2022 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.stream.kotlin; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.WebApplicationType; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.cloud.stream.binder.test.OutputDestination; +import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.messaging.Message; + +import static org.assertj.core.api.Assertions.assertThat; + +public class KotlinConfigurationTests { + + @Test + void testKotlinSupplierPollableBean() { + try (ConfigurableApplicationContext context = new SpringApplicationBuilder( + TestChannelBinderConfiguration.getCompleteConfiguration(KotlinTestConfiguration.class)) + .web(WebApplicationType.NONE) + .run("--spring.jmx.enabled=false", "--spring.cloud.function.definition=produceNames")) { + + OutputDestination output = context.getBean(OutputDestination.class); + Message result = output.receive(1000, "produceNames-out-0"); + assertThat(result.getPayload()).isEqualTo("Ricky".getBytes()); + result = output.receive(1000, "produceNames-out-0"); + assertThat(result.getPayload()).isEqualTo("Julien".getBytes()); + result = output.receive(1000, "produceNames-out-0"); + assertThat(result.getPayload()).isEqualTo("Bubbles".getBytes()); + } + } +} diff --git a/core/spring-cloud-stream/src/test/kotlin/org/springframework/cloud/stream/kotlin/KotlinTestConfiguration.kt b/core/spring-cloud-stream/src/test/kotlin/org/springframework/cloud/stream/kotlin/KotlinTestConfiguration.kt new file mode 100644 index 000000000..350a1278b --- /dev/null +++ b/core/spring-cloud-stream/src/test/kotlin/org/springframework/cloud/stream/kotlin/KotlinTestConfiguration.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2022-2022 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.stream.kotlin + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration +import org.springframework.cloud.function.context.PollableBean +import org.springframework.context.annotation.Configuration +import reactor.core.publisher.Flux + +@Configuration +@EnableAutoConfiguration +open class KotlinTestConfiguration { + + @PollableBean // it doesn't work with Kotlin lambda + open fun produceNames(): () -> Flux = { + Flux.just( + "Ricky", + "Julien", + "Bubbles" + ) + } + +}