Unify WebServerFactory implementations

Unify common for from the abstract `ServletWebServerFactory` and
`ReactiveWebServerFactory` classes. Common code is now located in
`AbstractConfigurableWebServerFactory`.

Fixes gh-8631
This commit is contained in:
Phillip Webb
2017-03-14 17:08:00 -07:00
parent 099e188f9f
commit b1c689b9b2
10 changed files with 329 additions and 496 deletions

View File

@@ -26,7 +26,7 @@ import org.springframework.boot.test.web.client.LocalHostUriTemplateHandler;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.web.servlet.server.AbstractConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
@@ -106,8 +106,8 @@ class SpringBootTestContextCustomizer implements ContextCustomizer {
private boolean isSslEnabled(ApplicationContext context) {
try {
AbstractConfigurableServletWebServerFactory webServerFactory = context
.getBean(AbstractConfigurableServletWebServerFactory.class);
AbstractServletWebServerFactory webServerFactory = context
.getBean(AbstractServletWebServerFactory.class);
return webServerFactory.getSsl() != null
&& webServerFactory.getSsl().isEnabled();
}

View File

@@ -23,7 +23,7 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.reactive.server.AbstractConfigurableReactiveWebServerFactory;
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
@@ -120,9 +120,10 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
private boolean isSslEnabled(ApplicationContext context) {
try {
AbstractConfigurableReactiveWebServerFactory webServerFactory = context
.getBean(AbstractConfigurableReactiveWebServerFactory.class);
return webServerFactory.getSsl() != null && webServerFactory.getSsl().isEnabled();
AbstractReactiveWebServerFactory webServerFactory = context
.getBean(AbstractReactiveWebServerFactory.class);
return webServerFactory.getSsl() != null
&& webServerFactory.getSsl().isEnabled();
}
catch (NoSuchBeanDefinitionException ex) {
return false;