From 0fd268ff02d98490215d61e29fbfab97173ea143 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Wed, 2 Feb 2022 11:55:21 +0100 Subject: [PATCH] Address .todo tests commented as a result of removal of annotation configuration Fix ErrorHandlingTests Remove stub binders from tests remove dead test classes --- pom.xml | 9 +- .../stream/binder/stub1/StubBinder1.java | 74 ----------- .../stub1/StubBinder1Configuration.java | 61 --------- .../stream/binder/stub2/StubBinder2.java | 59 --------- .../stub2/StubBinder2ConfigurationA.java | 34 ----- .../stub2/StubBinder2ConfigurationB.java | 33 ----- .../binder/stub2/StubBinder2Dependency.java | 24 ---- .../stream/binder/tck/ErrorHandlingTests.java | 108 ++++++++++++++++ .../binder/tck/ErrorHandlingTests.java.todo | 104 --------------- .../binder/test/SampleStreamApp.java.todo | 91 ------------- .../BinderConfigurationParsingTests.java | 120 ------------------ .../cloud/stream/function/pojo/Baz.java | 36 ------ .../cloud/stream/function/pojo/ErrorBaz.java | 36 ------ 13 files changed, 112 insertions(+), 677 deletions(-) delete mode 100644 spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub1/StubBinder1.java delete mode 100644 spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub1/StubBinder1Configuration.java delete mode 100644 spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2.java delete mode 100644 spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2ConfigurationA.java delete mode 100644 spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2ConfigurationB.java delete mode 100644 spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2Dependency.java create mode 100644 spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/tck/ErrorHandlingTests.java delete mode 100644 spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/tck/ErrorHandlingTests.java.todo delete mode 100644 spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/test/SampleStreamApp.java.todo delete mode 100644 spring-cloud-stream/src/test/java/org/springframework/cloud/stream/config/BinderConfigurationParsingTests.java delete mode 100644 spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/pojo/Baz.java delete mode 100644 spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/pojo/ErrorBaz.java diff --git a/pom.xml b/pom.xml index 556208732..0132ce108 100644 --- a/pom.xml +++ b/pom.xml @@ -153,17 +153,16 @@ org.apache.maven.plugins maven-compiler-plugin - ${maven-compiler-plugin.version} ${java.version} ${java.version} -parameters - - org.apache.maven.plugins - maven-checkstyle-plugin - + + + + diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub1/StubBinder1.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub1/StubBinder1.java deleted file mode 100644 index f18f24c07..000000000 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub1/StubBinder1.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2015-2016 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.binder.stub1; - -import org.springframework.cloud.stream.binder.Binder; -import org.springframework.cloud.stream.binder.Binding; -import org.springframework.cloud.stream.binder.ConsumerProperties; -import org.springframework.cloud.stream.binder.ProducerProperties; -import org.springframework.context.ConfigurableApplicationContext; - -/** - * @author Marius Bogoevici - * @author Mark Fisher - * @author Soby Chacko - */ -public class StubBinder1 - implements Binder { - - private String name; - - private ConfigurableApplicationContext outerContext; - - private String fromCustomization; - - public ConfigurableApplicationContext getOuterContext() { - return this.outerContext; - } - - public void setOuterContext(ConfigurableApplicationContext outerContext) { - this.outerContext = outerContext; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public Binding bindConsumer(String name, String group, - Object inboundBindTarget, ConsumerProperties properties) { - return null; - } - - @Override - public Binding bindProducer(String name, Object outboundBindTarget, - ProducerProperties properties) { - return null; - } - - public String getFromCustomization() { - return fromCustomization; - } - - public void setFromCustomization(String fromCustomization) { - this.fromCustomization = fromCustomization; - } -} diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub1/StubBinder1Configuration.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub1/StubBinder1Configuration.java deleted file mode 100644 index bf1c16e24..000000000 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub1/StubBinder1Configuration.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2015-2016 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.binder.stub1; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.BeanFactory; -import org.springframework.boot.actuate.health.HealthIndicator; -import org.springframework.boot.actuate.health.PingHealthIndicator; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.cloud.stream.binder.Binder; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author Marius Bogoevici - * @author Soby Chacko - */ -@Configuration -@EnableConfigurationProperties -public class StubBinder1Configuration { - - @Bean - @ConfigurationProperties("binder1") - public Binder binder(BeanFactory beanFactory) { - StubBinder1 stubBinder1 = new StubBinder1(); - ConfigurableApplicationContext outerContext = null; - try { - outerContext = (ConfigurableApplicationContext) beanFactory - .getBean("outerContext"); - } - catch (BeansException be) { - // Pass through - } - if (outerContext != null) { - stubBinder1.setOuterContext(outerContext); - } - return stubBinder1; - } - - @Bean - public HealthIndicator binderHealthIndicator() { - return new PingHealthIndicator(); - } - -} diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2.java deleted file mode 100644 index 48a6da9a7..000000000 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2015-2016 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.binder.stub2; - -import org.springframework.cloud.stream.binder.Binder; -import org.springframework.cloud.stream.binder.Binding; -import org.springframework.cloud.stream.binder.ConsumerProperties; -import org.springframework.cloud.stream.binder.ProducerProperties; - -/** - * @author Marius Bogoevici - * @author Mark Fisher - */ -public class StubBinder2 - implements Binder { - - @SuppressWarnings("unused") - private final StubBinder2Dependency stubBinder2Dependency; - - private String fromCustomization; - - public StubBinder2(StubBinder2Dependency stubBinder2Dependency) { - this.stubBinder2Dependency = stubBinder2Dependency; - } - - @Override - public Binding bindConsumer(String name, String group, - Object inboundBindTarget, ConsumerProperties properties) { - return null; - } - - @Override - public Binding bindProducer(String name, Object outboundBindTarget, - ProducerProperties properties) { - return null; - } - - public String getFromCustomization() { - return fromCustomization; - } - - public void setFromCustomization(String fromCustomization) { - this.fromCustomization = fromCustomization; - } -} diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2ConfigurationA.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2ConfigurationA.java deleted file mode 100644 index 97e0e9123..000000000 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2ConfigurationA.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2015-2016 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.binder.stub2; - -import org.springframework.cloud.stream.binder.Binder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author Marius Bogoevici - */ -@Configuration -public class StubBinder2ConfigurationA { - - @Bean - public Binder binder(StubBinder2Dependency dependency) { - return new StubBinder2(dependency); - } - -} diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2ConfigurationB.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2ConfigurationB.java deleted file mode 100644 index cf227c5e0..000000000 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2ConfigurationB.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - * 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.binder.stub2; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author Marius Bogoevici - */ -@Configuration -public class StubBinder2ConfigurationB { - - @Bean - public StubBinder2Dependency dependency() { - return new StubBinder2Dependency(); - } - -} diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2Dependency.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2Dependency.java deleted file mode 100644 index 3bb1d4dfe..000000000 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/stub2/StubBinder2Dependency.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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. - * 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.binder.stub2; - -/** - * @author Marius Bogoevici - */ -public class StubBinder2Dependency { - -} diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/tck/ErrorHandlingTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/tck/ErrorHandlingTests.java new file mode 100644 index 000000000..3e7eb7197 --- /dev/null +++ b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/tck/ErrorHandlingTests.java @@ -0,0 +1,108 @@ +/* + * Copyright 2019-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. + * 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.binder.tck; + +import org.junit.Test; + +import org.springframework.boot.WebApplicationType; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.cloud.stream.binder.test.InputDestination; +import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Import; +import org.springframework.integration.annotation.ServiceActivator; +import org.springframework.messaging.Message; +import org.springframework.messaging.support.GenericMessage; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.function.Function; + +/** + * @author Oleg Zhurakousky + * + */ +public class ErrorHandlingTests { + + @Test + public void testGlobalErrorWithMessage() { + ApplicationContext context = new SpringApplicationBuilder( + GlobalErrorHandlerWithErrorMessageConfig.class) + .web(WebApplicationType.NONE).run("--spring.jmx.enabled=false"); + InputDestination source = context.getBean(InputDestination.class); + source.send(new GenericMessage<>("foo".getBytes())); + GlobalErrorHandlerWithErrorMessageConfig config = context + .getBean(GlobalErrorHandlerWithErrorMessageConfig.class); + assertThat(config.globalErroInvoked).isTrue(); + } + + @Test + public void testGlobalErrorWithThrowable() { + ApplicationContext context = new SpringApplicationBuilder( + GlobalErrorHandlerWithThrowableConfig.class).web(WebApplicationType.NONE) + .run("--spring.jmx.enabled=false"); + InputDestination source = context.getBean(InputDestination.class); + source.send(new GenericMessage<>("foo".getBytes())); + GlobalErrorHandlerWithThrowableConfig config = context + .getBean(GlobalErrorHandlerWithThrowableConfig.class); + assertThat(config.globalErroInvoked).isTrue(); + } + + + @Import(TestChannelBinderConfiguration.class) + @EnableAutoConfiguration + public static class GlobalErrorHandlerWithErrorMessageConfig { + + private boolean globalErroInvoked; + + @Bean + public Function func() { + return v -> { + throw new RuntimeException("test exception"); + }; + } + + @ServiceActivator(inputChannel="errorChannel") + public void generalError(Message message) { + this.globalErroInvoked = true; + } + + } + + @Import(TestChannelBinderConfiguration.class) + @EnableAutoConfiguration + public static class GlobalErrorHandlerWithThrowableConfig { + + private boolean globalErroInvoked; + + @Bean + public Function func() { + return v -> { + throw new RuntimeException("test exception"); + }; + } + + @ServiceActivator(inputChannel="errorChannel") + public void generalError(Throwable exception) { + this.globalErroInvoked = true; + } + + } + +} diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/tck/ErrorHandlingTests.java.todo b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/tck/ErrorHandlingTests.java.todo deleted file mode 100644 index 848ec84ce..000000000 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/tck/ErrorHandlingTests.java.todo +++ /dev/null @@ -1,104 +0,0 @@ -///* -// * Copyright 2019-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. -// * 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.binder.tck; -// -//import org.junit.Test; -// -//import org.springframework.boot.WebApplicationType; -//import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -//import org.springframework.boot.builder.SpringApplicationBuilder; -//import org.springframework.cloud.stream.annotation.EnableBinding; -//import org.springframework.cloud.stream.annotation.StreamListener; -//import org.springframework.cloud.stream.binder.test.InputDestination; -//import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration; -//import org.springframework.cloud.stream.messaging.Processor; -//import org.springframework.context.ApplicationContext; -//import org.springframework.context.annotation.Import; -//import org.springframework.messaging.Message; -//import org.springframework.messaging.support.GenericMessage; -// -//import static org.assertj.core.api.Assertions.assertThat; -// -///** -// * @author Oleg Zhurakousky -// * -// */ -//public class ErrorHandlingTests { -// -// @Test -// public void testGlobalErrorWithMessage() { -// ApplicationContext context = new SpringApplicationBuilder( -// GlobalErrorHandlerWithErrorMessageConfig.class) -// .web(WebApplicationType.NONE).run("--spring.jmx.enabled=false"); -// InputDestination source = context.getBean(InputDestination.class); -// source.send(new GenericMessage<>("foo".getBytes())); -// GlobalErrorHandlerWithErrorMessageConfig config = context -// .getBean(GlobalErrorHandlerWithErrorMessageConfig.class); -// assertThat(config.globalErroInvoked).isTrue(); -// } -// -// @Test -// public void testGlobalErrorWithThrowable() { -// ApplicationContext context = new SpringApplicationBuilder( -// GlobalErrorHandlerWithThrowableConfig.class).web(WebApplicationType.NONE) -// .run("--spring.jmx.enabled=false"); -// InputDestination source = context.getBean(InputDestination.class); -// source.send(new GenericMessage<>("foo".getBytes())); -// GlobalErrorHandlerWithThrowableConfig config = context -// .getBean(GlobalErrorHandlerWithThrowableConfig.class); -// assertThat(config.globalErroInvoked).isTrue(); -// } -// -// @EnableBinding(Processor.class) -// @Import(TestChannelBinderConfiguration.class) -// @EnableAutoConfiguration -// public static class GlobalErrorHandlerWithErrorMessageConfig { -// -// private boolean globalErroInvoked; -// -// @StreamListener(target = Processor.INPUT) -// public void input(final String value) { -// throw new RuntimeException("test exception"); -// } -// -// @StreamListener("errorChannel") -// public void generalError(Message message) { -// this.globalErroInvoked = true; -// } -// -// } -// -// @EnableBinding(Processor.class) -// @Import(TestChannelBinderConfiguration.class) -// @EnableAutoConfiguration -// public static class GlobalErrorHandlerWithThrowableConfig { -// -// private boolean globalErroInvoked; -// -// @StreamListener(target = Processor.INPUT) -// public void input(final String value) { -// throw new RuntimeException("test exception"); -// } -// -// @StreamListener("errorChannel") -// public void generalError(Throwable exception) { -// this.globalErroInvoked = true; -// } -// -// } -// -//} diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/test/SampleStreamApp.java.todo b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/test/SampleStreamApp.java.todo deleted file mode 100644 index 0975cad92..000000000 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/binder/test/SampleStreamApp.java.todo +++ /dev/null @@ -1,91 +0,0 @@ -///* -// * Copyright 2017-2018 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.binder.test; -// -//import java.nio.charset.StandardCharsets; -// -//import org.springframework.boot.ApplicationRunner; -//import org.springframework.boot.WebApplicationType; -//import org.springframework.boot.autoconfigure.SpringBootApplication; -//import org.springframework.boot.builder.SpringApplicationBuilder; -//import org.springframework.cloud.stream.annotation.EnableBinding; -//import org.springframework.cloud.stream.annotation.Input; -//import org.springframework.cloud.stream.annotation.StreamListener; -//import org.springframework.cloud.stream.binder.PollableMessageSource; -//import org.springframework.cloud.stream.messaging.Processor; -//import org.springframework.context.ApplicationContext; -//import org.springframework.context.annotation.Bean; -//import org.springframework.context.annotation.Import; -//import org.springframework.integration.annotation.ServiceActivator; -//import org.springframework.messaging.Message; -//import org.springframework.messaging.handler.annotation.SendTo; -//import org.springframework.messaging.support.GenericMessage; -// -//import static org.assertj.core.api.Assertions.assertThat; -// -///** -// * Sample spring cloud stream application that demonstrates the usage of -// * {@link TestChannelBinder}. -// * -// * @author Oleg Zhurakousky -// * @author Gary Russell -// * -// */ -//@SpringBootApplication -//@EnableBinding(SampleStreamApp.PolledConsumer.class) -//@Import(TestChannelBinderConfiguration.class) -//public class SampleStreamApp { -// -// public static void main(String[] args) { -// ApplicationContext context = new SpringApplicationBuilder(SampleStreamApp.class) -// .web(WebApplicationType.NONE).run("--server.port=0"); -// InputDestination source = context.getBean(InputDestination.class); -// OutputDestination target = context.getBean(OutputDestination.class); -// source.send(new GenericMessage("Hello".getBytes())); -// -// Message message = target.receive(); -// assertThat(new String((byte[]) message.getPayload(), StandardCharsets.UTF_8)) -// .isEqualTo("Hello"); -// } -// -// @Bean -// public ApplicationRunner runner(PollableMessageSource pollableSource) { -// return args -> pollableSource.poll(message -> { -// System.out.println("Polled payload: " + message.getPayload()); -// }); -// } -// -// @StreamListener(Processor.INPUT) -// @SendTo(Processor.OUTPUT) -// public String receive(String value) { -// System.out.println("Handling payload: " + value); -// return value; -// } -// -// @ServiceActivator(inputChannel = "input.anonymous.errors") -// public void error(String value) { -// System.out.println("Handling ERROR payload: " + value); -// } -// -// public interface PolledConsumer extends Processor { -// -// @Input -// PollableMessageSource pollableSource(); -// -// } -// -//} diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/config/BinderConfigurationParsingTests.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/config/BinderConfigurationParsingTests.java deleted file mode 100644 index 82c708a09..000000000 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/config/BinderConfigurationParsingTests.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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. - * 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.config; - -import java.io.ByteArrayInputStream; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - -import org.junit.Test; - -import org.springframework.cloud.stream.binder.BinderType; -import org.springframework.cloud.stream.binder.stub1.StubBinder1Configuration; -import org.springframework.cloud.stream.binder.stub2.StubBinder2ConfigurationA; -import org.springframework.cloud.stream.binder.stub2.StubBinder2ConfigurationB; -import org.springframework.core.io.InputStreamResource; -import org.springframework.core.io.Resource; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * @author Marius Bogoevici - */ -public class BinderConfigurationParsingTests { - - private static ClassLoader classLoader = BinderConfigurationParsingTests.class - .getClassLoader(); - - @Test - public void testParseOneBinderConfiguration() throws Exception { - - // this is just checking that resources are passed and classes are loaded properly - // class values used here are not binder configurations - String oneBinderConfiguration = "binder1=org.springframework.cloud.stream.binder.stub1.StubBinder1Configuration"; - Resource resource = new InputStreamResource( - new ByteArrayInputStream(oneBinderConfiguration.getBytes())); - - Collection binderConfigurations = BinderFactoryAutoConfiguration - .parseBinderConfigurations(classLoader, resource); - - assertThat(binderConfigurations).isNotNull(); - assertThat(binderConfigurations.size()).isEqualTo(1); - BinderType type = binderConfigurations.iterator().next(); - assertThat(type.getDefaultName()).isEqualTo("binder1"); - assertThat(type.getConfigurationClasses()) - .contains(StubBinder1Configuration.class); - } - - @Test - public void testParseTwoBindersConfigurations() throws Exception { - // this is just checking that resources are passed and classes are loaded properly - // class values used here are not binder configurations - String binderConfiguration = "binder1=org.springframework.cloud.stream.binder.stub1.StubBinder1Configuration\n" - + "binder2=org.springframework.cloud.stream.binder.stub2.StubBinder2ConfigurationA"; - Resource twoBinderConfigurationResource = new InputStreamResource( - new ByteArrayInputStream(binderConfiguration.getBytes())); - - Collection twoBinderConfig = BinderFactoryAutoConfiguration - .parseBinderConfigurations(classLoader, twoBinderConfigurationResource); - - assertThat(twoBinderConfig.size()).isEqualTo(2); - List stubBinder1 = stubBinders(twoBinderConfig, "binder1", - StubBinder1Configuration.class); - List stubBinder2 = stubBinders(twoBinderConfig, "binder2", - StubBinder2ConfigurationA.class); - assertThat(stubBinder1).isNotEmpty(); - assertThat(stubBinder2).isNotEmpty(); - - } - - private List stubBinders(Collection twoBinderConfigurations, - String binderName, Class... configurationNames) { - return twoBinderConfigurations.stream() - .filter(binderType -> binderName.equals(binderType.getDefaultName()) - && !Collections.disjoint( - Arrays.asList(binderType.getConfigurationClasses()), - Arrays.asList(configurationNames))) - .collect(Collectors.toList()); - } - - @Test - public void testParseTwoBindersWithMultipleClasses() throws Exception { - // this is just checking that resources are passed and classes are loaded properly - // class values used here are not binder configurations - String binderConfiguration = "binder1=org.springframework.cloud.stream.binder.stub1.StubBinder1Configuration\n" - + "binder2=org.springframework.cloud.stream.binder.stub2.StubBinder2ConfigurationA," - + "org.springframework.cloud.stream.binder.stub2.StubBinder2ConfigurationB"; - Resource binderConfigurationResource = new InputStreamResource( - new ByteArrayInputStream(binderConfiguration.getBytes())); - - Collection binderConfigurations = BinderFactoryAutoConfiguration - .parseBinderConfigurations(classLoader, binderConfigurationResource); - - assertThat(binderConfigurations.size()).isEqualTo(2); - assertThat(binderConfigurations.size()).isEqualTo(2); - List stubBinder1 = stubBinders(binderConfigurations, "binder1", - StubBinder1Configuration.class); - List stubBinder2 = stubBinders(binderConfigurations, "binder2", - StubBinder2ConfigurationA.class, StubBinder2ConfigurationB.class); - assertThat(stubBinder1).isNotEmpty(); - assertThat(stubBinder2).isNotEmpty(); - } - -} diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/pojo/Baz.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/pojo/Baz.java deleted file mode 100644 index 772941f5c..000000000 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/pojo/Baz.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018-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. - * 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.function.pojo; - -/** - * Serializable pojo with object mapper. - * - * @author Tolga Kavukcu - */ -public class Baz { - - private String baz = "baz"; - - public String getBaz() { - return this.baz; - } - - public void setBaz(String baz) { - this.baz = baz; - } - -} diff --git a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/pojo/ErrorBaz.java b/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/pojo/ErrorBaz.java deleted file mode 100644 index cb77e16fc..000000000 --- a/spring-cloud-stream/src/test/java/org/springframework/cloud/stream/function/pojo/ErrorBaz.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018-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. - * 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.function.pojo; - -/** - * Serializable pojo with object mapper. - * - * @author Tolga Kavukcu - */ -public class ErrorBaz extends Baz { - - private String baz = "bazError"; - - public String getBaz() { - return this.baz; - } - - public void setBaz(String baz) { - this.baz = baz; - } - -}