use of org.springframework.cloud.consul.test.ConsulTestcontainers in project spring-cloud-consul by spring-cloud.
the class ConsulConfigBootstrapConfigurationTests method testConfigPropsBeanBacksOff.
/**
* Tests that the auto-config bean backs off if a user provided their own.
*/
@Test
public void testConfigPropsBeanBacksOff() {
this.contextRunner.withUserConfiguration(TestConfig.class).withInitializer(new ConsulTestcontainers()).withUserConfiguration(ConsulConfigBootstrapConfiguration.class).run(context -> {
ConsulConfigProperties config = context.getBean(ConsulConfigProperties.class);
assertThat(config.getPrefixes().get(0)).as("Prefix did not match").isEqualTo("platform-config");
assertThat(config.getDefaultContext()).as("Default context did not match").isEqualTo("defaults");
});
}
use of org.springframework.cloud.consul.test.ConsulTestcontainers in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationDisabledTests method testAutoRegistrationDisabled.
private void testAutoRegistrationDisabled(String testName, String disableProperty) {
new WebApplicationContextRunner().withUserConfiguration(TestConfig.class).withPropertyValues("spring.application.name=" + testName, disableProperty + "=false", "server.port=0").withInitializer(new ConsulTestcontainers()).run(context -> {
assertThat(context).doesNotHaveBean(ConsulAutoServiceRegistration.class);
assertThat(context).doesNotHaveBean(ConsulAutoServiceRegistrationListener.class);
assertThat(context).doesNotHaveBean(ConsulAutoRegistration.class);
assertThat(context).doesNotHaveBean(ConsulRegistrationCustomizer.class);
ConsulClient consul = context.getBean(ConsulClient.class);
Response<Map<String, Service>> response = consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get(testName);
assertThat(service).as("service was registered").isNull();
});
}
use of org.springframework.cloud.consul.test.ConsulTestcontainers in project spring-cloud-consul by spring-cloud.
the class ConsulServiceRegistryDisabledTests method testAutoRegistrationDisabled.
private void testAutoRegistrationDisabled(String testName, String disableProperty) {
new WebApplicationContextRunner().withUserConfiguration(TestConfig.class).withPropertyValues("spring.application.name=" + testName, disableProperty + "=false", "server.port=0").withInitializer(new ConsulTestcontainers()).run(context -> {
assertThat(context).doesNotHaveBean(ConsulServiceRegistry.class);
assertThat(context).doesNotHaveBean(HeartbeatProperties.class);
ConsulClient consul = context.getBean(ConsulClient.class);
Response<Map<String, Service>> response = consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get(testName);
assertThat(service).as("service was registered").isNull();
});
}
use of org.springframework.cloud.consul.test.ConsulTestcontainers in project spring-cloud-consul by spring-cloud.
the class ConsulBinderConfigurationTests method consulDisabledDisablesBinder.
@Test
// FIXME 2.0.0 need stream fix
@Ignore
public void consulDisabledDisablesBinder() {
this.exception.expectMessage(containsString("no proper implementation found"));
new SpringApplicationBuilder(Application.class).initializers(new ConsulTestcontainers()).properties("spring.cloud.consul.enabled=false").run();
}
use of org.springframework.cloud.consul.test.ConsulTestcontainers in project spring-cloud-consul by spring-cloud.
the class ConsulBinderConfigurationTests method consulBinderDisabledWorks.
@Test
// FIXME 2.0.0 need stream fix
@Ignore
public void consulBinderDisabledWorks() {
this.exception.expectMessage(containsString("no proper implementation found"));
new SpringApplicationBuilder(Application.class).initializers(new ConsulTestcontainers()).properties("spring.cloud.consul.binder.enabled=false").run();
}
Aggregations