use of org.springframework.cloud.stream.binding.BindingsLifecycleController in project spring-cloud-stream by spring-cloud.
the class ImplicitFunctionBindingTests method testBindingControl.
@SuppressWarnings({ "rawtypes" })
@Test
public void testBindingControl() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration(SendToDestinationConfiguration.class)).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false")) {
BindingsLifecycleController ctrl = context.getBean(BindingsLifecycleController.class);
Binding input = ctrl.queryState("echo-in-0");
Binding output = ctrl.queryState("echo-out-0");
assertThat(input.isRunning()).isTrue();
ctrl.changeState("echo-in-0", State.STOPPED);
assertThat(input.isRunning()).isFalse();
}
}
use of org.springframework.cloud.stream.binding.BindingsLifecycleController in project spring-cloud-stream by spring-cloud.
the class ActuatorBindingsTest method test_2253.
/*
* Even though this test performs some simple assertions, the main purpose for it is to validate that
* it does not result in recursive exception described in https://github.com/spring-cloud/spring-cloud-stream/issues/2253
*/
@Test
public void test_2253() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration(Bindings.class)).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false", "--spring.cloud.function.definition=consume", // see https://github.com/spring-cloud/spring-cloud-stream/issues/2253
"--spring.jackson.visibility.field=ANY")) {
BindingsLifecycleController controller = context.getBean(BindingsLifecycleController.class);
List<Map<?, ?>> bindings = controller.queryStates();
assertThat(bindings.size()).isEqualTo(1);
assertThat(bindings.get(0).get("bindingName")).isEqualTo("consume-in-0");
}
}
use of org.springframework.cloud.stream.binding.BindingsLifecycleController in project spring-cloud-stream by spring-cloud.
the class ImplicitFunctionBindingTests method testDisableAutodetect.
@SuppressWarnings({ "rawtypes" })
@Test
public void testDisableAutodetect() {
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(TestChannelBinderConfiguration.getCompleteConfiguration(SendToDestinationConfiguration.class)).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false", "--spring.cloud.stream.function.autodetect=false")) {
BindingsLifecycleController ctrl = context.getBean(BindingsLifecycleController.class);
Binding input = ctrl.queryState("echo-in-0");
Binding output = ctrl.queryState("echo-out-0");
assertThat(input).isNull();
assertThat(output).isNull();
}
}
Aggregations