use of org.springframework.boot.test.context.runner.ApplicationContextRunner in project spring-cloud-netflix by spring-cloud.
the class ConditionalOnRefreshScopeTests method refreshScopeIncluded.
@Test
public void refreshScopeIncluded() {
new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(RefreshAutoConfiguration.class)).withUserConfiguration(Beans.class).run(c -> {
assertThat(c).hasSingleBean(org.springframework.cloud.context.scope.refresh.RefreshScope.class);
assertThat(c.getBean("foo")).isEqualTo("foo");
});
}
use of org.springframework.boot.test.context.runner.ApplicationContextRunner in project spring-cloud-netflix by spring-cloud.
the class EurekaClientConfigServerAutoConfigurationTests method onWhenRequested.
@Test
public void onWhenRequested() {
new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(EurekaClientConfigServerAutoConfiguration.class, ConfigServerProperties.class, EurekaInstanceConfigBean.class)).withPropertyValues("spring.cloud.config.server.prefix=/config").run(c -> {
assertEquals(1, c.getBeanNamesForType(EurekaInstanceConfig.class).length);
EurekaInstanceConfig instance = c.getBean(EurekaInstanceConfig.class);
assertEquals("/config", instance.getMetadataMap().get("configPath"));
});
}
use of org.springframework.boot.test.context.runner.ApplicationContextRunner in project spring-boot-admin by codecentric.
the class SpringBootAdminClientAutoConfigurationTest method nonWebEnvironment.
@Test
public void nonWebEnvironment() {
ApplicationContextRunner nonWebcontextRunner = new ApplicationContextRunner().withConfiguration(AutoConfigurations.of(SpringBootAdminClientAutoConfiguration.class));
nonWebcontextRunner.withPropertyValues("spring.boot.admin.client.url:http://localhost:8081").run((context) -> assertThat(context).doesNotHaveBean(ApplicationRegistrator.class));
}
use of org.springframework.boot.test.context.runner.ApplicationContextRunner in project spring-boot by spring-projects.
the class MetricsAutoConfigurationIntegrationTests method emptyCompositeIsCreatedWhenNoMeterRegistriesAreAutoConfigured.
@Test
void emptyCompositeIsCreatedWhenNoMeterRegistriesAreAutoConfigured() {
new ApplicationContextRunner().with(MetricsRun.limitedTo()).run((context) -> {
MeterRegistry registry = context.getBean(MeterRegistry.class);
assertThat(registry).isInstanceOf(CompositeMeterRegistry.class);
assertThat(((CompositeMeterRegistry) registry).getRegistries()).isEmpty();
});
}
use of org.springframework.boot.test.context.runner.ApplicationContextRunner in project spring-boot by spring-projects.
the class ConditionsReportEndpointTests method invoke.
@Test
void invoke() {
new ApplicationContextRunner().withUserConfiguration(Config.class).run((context) -> {
ContextConditionEvaluation report = context.getBean(ConditionsReportEndpoint.class).applicationConditionEvaluation().getContexts().get(context.getId());
assertThat(report.getPositiveMatches()).isEmpty();
assertThat(report.getNegativeMatches()).containsKey("a");
assertThat(report.getUnconditionalClasses()).contains("b");
assertThat(report.getExclusions()).contains("com.foo.Bar");
});
}
Aggregations