Address .todo tests commented as a result of removal of annotation configuration
Fix ErrorHandlingTests Remove stub binders from tests remove dead test classes
This commit is contained in:
9
pom.xml
9
pom.xml
@@ -153,17 +153,16 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<compilerArgument>-parameters</compilerArgument>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
</plugin>
|
||||
<!-- <plugin> -->
|
||||
<!-- <groupId>org.apache.maven.plugins</groupId> -->
|
||||
<!-- <artifactId>maven-checkstyle-plugin</artifactId> -->
|
||||
<!-- </plugin> -->
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -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<Object, ConsumerProperties, ProducerProperties> {
|
||||
|
||||
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<Object> bindConsumer(String name, String group,
|
||||
Object inboundBindTarget, ConsumerProperties properties) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Binding<Object> bindProducer(String name, Object outboundBindTarget,
|
||||
ProducerProperties properties) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getFromCustomization() {
|
||||
return fromCustomization;
|
||||
}
|
||||
|
||||
public void setFromCustomization(String fromCustomization) {
|
||||
this.fromCustomization = fromCustomization;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<Object, ConsumerProperties, ProducerProperties> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final StubBinder2Dependency stubBinder2Dependency;
|
||||
|
||||
private String fromCustomization;
|
||||
|
||||
public StubBinder2(StubBinder2Dependency stubBinder2Dependency) {
|
||||
this.stubBinder2Dependency = stubBinder2Dependency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Binding<Object> bindConsumer(String name, String group,
|
||||
Object inboundBindTarget, ConsumerProperties properties) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Binding<Object> bindProducer(String name, Object outboundBindTarget,
|
||||
ProducerProperties properties) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getFromCustomization() {
|
||||
return fromCustomization;
|
||||
}
|
||||
|
||||
public void setFromCustomization(String fromCustomization) {
|
||||
this.fromCustomization = fromCustomization;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
@@ -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<String, String> 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<String, String> func() {
|
||||
return v -> {
|
||||
throw new RuntimeException("test exception");
|
||||
};
|
||||
}
|
||||
|
||||
@ServiceActivator(inputChannel="errorChannel")
|
||||
public void generalError(Throwable exception) {
|
||||
this.globalErroInvoked = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -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<byte[]>("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();
|
||||
//
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -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<BinderType> 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<BinderType> twoBinderConfig = BinderFactoryAutoConfiguration
|
||||
.parseBinderConfigurations(classLoader, twoBinderConfigurationResource);
|
||||
|
||||
assertThat(twoBinderConfig.size()).isEqualTo(2);
|
||||
List<BinderType> stubBinder1 = stubBinders(twoBinderConfig, "binder1",
|
||||
StubBinder1Configuration.class);
|
||||
List<BinderType> stubBinder2 = stubBinders(twoBinderConfig, "binder2",
|
||||
StubBinder2ConfigurationA.class);
|
||||
assertThat(stubBinder1).isNotEmpty();
|
||||
assertThat(stubBinder2).isNotEmpty();
|
||||
|
||||
}
|
||||
|
||||
private List<BinderType> stubBinders(Collection<BinderType> 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<BinderType> binderConfigurations = BinderFactoryAutoConfiguration
|
||||
.parseBinderConfigurations(classLoader, binderConfigurationResource);
|
||||
|
||||
assertThat(binderConfigurations.size()).isEqualTo(2);
|
||||
assertThat(binderConfigurations.size()).isEqualTo(2);
|
||||
List<BinderType> stubBinder1 = stubBinders(binderConfigurations, "binder1",
|
||||
StubBinder1Configuration.class);
|
||||
List<BinderType> stubBinder2 = stubBinders(binderConfigurations, "binder2",
|
||||
StubBinder2ConfigurationA.class, StubBinder2ConfigurationB.class);
|
||||
assertThat(stubBinder1).isNotEmpty();
|
||||
assertThat(stubBinder2).isNotEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user