use of org.springframework.boot.test.context.runner.WebApplicationContextRunner in project spring-cloud-config by spring-cloud.
the class CompositUtilsTests method getCompositeTypeListWorks.
@Test
public void getCompositeTypeListWorks() {
new WebApplicationContextRunner().withUserConfiguration(ConfigServerApplication.class).withPropertyValues("spring.profiles.active:test,composite", "spring.config.name:compositeconfigserver", "spring.cloud.config.server.composite[0].uri:file:./target/repos/config-repo", "spring.cloud.config.server.composite[0].type:git", "spring.cloud.config.server.composite[1].uri:file:///./target/repos/svn-config-repo", "spring.cloud.config.server.composite[1].type:svn").run(context -> {
List<String> types = CompositeUtils.getCompositeTypeList(context.getEnvironment());
assertThat(types).containsExactly("git", "svn");
});
}
use of org.springframework.boot.test.context.runner.WebApplicationContextRunner in project spring-boot by spring-projects.
the class TomcatMetricsAutoConfigurationTests method autoConfiguresTomcatMetricsWithEmbeddedServletTomcat.
@Test
void autoConfiguresTomcatMetricsWithEmbeddedServletTomcat() {
resetTomcatState();
new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(TomcatMetricsAutoConfiguration.class, ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(ServletWebServerConfiguration.class, MeterRegistryConfiguration.class).withPropertyValues("server.tomcat.mbeanregistry.enabled=true").run((context) -> {
context.publishEvent(createApplicationStartedEvent(context.getSourceApplicationContext()));
assertThat(context).hasSingleBean(TomcatMetricsBinder.class);
SimpleMeterRegistry registry = context.getBean(SimpleMeterRegistry.class);
assertThat(registry.find("tomcat.sessions.active.max").meter()).isNotNull();
assertThat(registry.find("tomcat.threads.current").meter()).isNotNull();
});
}
use of org.springframework.boot.test.context.runner.WebApplicationContextRunner in project spring-boot by spring-projects.
the class ManagementContextAutoConfigurationTests method childManagementContextShouldStartForEmbeddedServer.
@Test
void childManagementContextShouldStartForEmbeddedServer(CapturedOutput output) {
WebApplicationContextRunner contextRunner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ManagementContextAutoConfiguration.class, ServletWebServerFactoryAutoConfiguration.class, ServletManagementContextAutoConfiguration.class, WebEndpointAutoConfiguration.class, EndpointAutoConfiguration.class));
contextRunner.withPropertyValues("server.port=0", "management.server.port=0").run((context) -> assertThat(output).satisfies(numberOfOccurrences("Tomcat started on port", 2)));
}
use of org.springframework.boot.test.context.runner.WebApplicationContextRunner in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method undertowBuilderCustomizerBeanIsAddedToFactory.
@Test
void undertowBuilderCustomizerBeanIsAddedToFactory() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class)).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(UndertowBuilderCustomizerConfiguration.class).withPropertyValues("server.port:0");
runner.run((context) -> {
UndertowServletWebServerFactory factory = context.getBean(UndertowServletWebServerFactory.class);
assertThat(factory.getBuilderCustomizers()).hasSize(1);
});
}
use of org.springframework.boot.test.context.runner.WebApplicationContextRunner in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method undertowBuilderCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce.
@Test
void undertowBuilderCustomizerRegisteredAsBeanAndViaFactoryIsOnlyCalledOnce() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class)).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(DoubleRegistrationUndertowBuilderCustomizerConfiguration.class).withPropertyValues("server.port: 0");
runner.run((context) -> {
UndertowServletWebServerFactory factory = context.getBean(UndertowServletWebServerFactory.class);
UndertowBuilderCustomizer customizer = context.getBean("builderCustomizer", UndertowBuilderCustomizer.class);
assertThat(factory.getBuilderCustomizers()).contains(customizer);
then(customizer).should().customize(any(Builder.class));
});
}
Aggregations