Restructure embedded web server packages
Rework `org.springframework.boot.context.embedded` to relocate classes to `org.springframework.boot.web`. Packages are now organized around the following areas: Packages for shared concerns, for example the `WebServer` interface to start/stop a server and the common configuration elements: - org.springframework.boot.web.context - org.springframework.boot.web.server Servlet specific packages: - org.springframework.boot.web.servlet.server - org.springframework.boot.web.servlet.context - org.springframework.boot.web.servlet.filter Reactive specific packages: - org.springframework.boot.web.reactive.context - org.springframework.boot.web.reactive.server Embedded server implementations (both reactive and servlet): - org.springframework.boot.web.embedded In addition: - Rename `EmbeddedServletContainerFactory` to `ServletWebServerFactory` to align with the `ReactiveWebServerFactory`. - Rename `EmbeddedWebApplicationContext` to `ServletWebServerApplicationContext` and - Rename `EmbeddedReactiveWebApplicationContext` to `ReactiveWebServerApplicationContext`. - Add checkstyle rules to restrict imports. - Fixup all affected code to use the correct imports and local names. Fixes gh-8532
This commit is contained in:
parent
7b388e5865
commit
67556ba8ea
|
@ -45,17 +45,17 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
|
||||||
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration;
|
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||||
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.event.ApplicationFailedEvent;
|
import org.springframework.boot.context.event.ApplicationFailedEvent;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.web.filter.ApplicationContextHeaderFilter;
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
|
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
|
||||||
|
import org.springframework.boot.web.servlet.filter.ApplicationContextHeaderFilter;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.context.ApplicationEvent;
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
@ -95,7 +95,7 @@ import org.springframework.web.servlet.DispatcherServlet;
|
||||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||||
@EnableConfigurationProperties(ManagementServerProperties.class)
|
@EnableConfigurationProperties(ManagementServerProperties.class)
|
||||||
@AutoConfigureAfter({ PropertyPlaceholderAutoConfiguration.class,
|
@AutoConfigureAfter({ PropertyPlaceholderAutoConfiguration.class,
|
||||||
EmbeddedServletContainerAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
ServletWebServerFactoryAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
RepositoryRestMvcAutoConfiguration.class, HypermediaAutoConfiguration.class,
|
RepositoryRestMvcAutoConfiguration.class, HypermediaAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class })
|
HttpMessageConvertersAutoConfiguration.class })
|
||||||
public class EndpointWebMvcAutoConfiguration
|
public class EndpointWebMvcAutoConfiguration
|
||||||
|
@ -138,13 +138,13 @@ public class EndpointWebMvcAutoConfiguration
|
||||||
.get(this.applicationContext.getEnvironment());
|
.get(this.applicationContext.getEnvironment());
|
||||||
}
|
}
|
||||||
if (managementPort == ManagementServerPort.DIFFERENT) {
|
if (managementPort == ManagementServerPort.DIFFERENT) {
|
||||||
if (this.applicationContext instanceof EmbeddedWebApplicationContext
|
if (this.applicationContext instanceof ServletWebServerApplicationContext
|
||||||
&& ((EmbeddedWebApplicationContext) this.applicationContext)
|
&& ((ServletWebServerApplicationContext) this.applicationContext)
|
||||||
.getEmbeddedWebServer() != null) {
|
.getWebServer() != null) {
|
||||||
createChildManagementContext();
|
createChildManagementContext();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.warn("Could not start embedded management container on "
|
logger.warn("Could not start management web server on "
|
||||||
+ "different port (management endpoints are still available "
|
+ "different port (management endpoints are still available "
|
||||||
+ "through JMX)");
|
+ "through JMX)");
|
||||||
}
|
}
|
||||||
|
@ -166,31 +166,30 @@ public class EndpointWebMvcAutoConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createChildManagementContext() {
|
private void createChildManagementContext() {
|
||||||
AnnotationConfigEmbeddedWebApplicationContext childContext = new AnnotationConfigEmbeddedWebApplicationContext();
|
AnnotationConfigServletWebServerApplicationContext childContext = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
childContext.setParent(this.applicationContext);
|
childContext.setParent(this.applicationContext);
|
||||||
childContext.setNamespace("management");
|
childContext.setNamespace("management");
|
||||||
childContext.setId(this.applicationContext.getId() + ":management");
|
childContext.setId(this.applicationContext.getId() + ":management");
|
||||||
childContext.setClassLoader(this.applicationContext.getClassLoader());
|
childContext.setClassLoader(this.applicationContext.getClassLoader());
|
||||||
childContext.register(EndpointWebMvcChildContextConfiguration.class,
|
childContext.register(EndpointWebMvcChildContextConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class,
|
PropertyPlaceholderAutoConfiguration.class,
|
||||||
EmbeddedServletContainerAutoConfiguration.class,
|
ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class);
|
DispatcherServletAutoConfiguration.class);
|
||||||
registerEmbeddedServletContainerFactory(childContext);
|
registerServletWebServerFactory(childContext);
|
||||||
CloseManagementContextListener.addIfPossible(this.applicationContext,
|
CloseManagementContextListener.addIfPossible(this.applicationContext,
|
||||||
childContext);
|
childContext);
|
||||||
childContext.refresh();
|
childContext.refresh();
|
||||||
managementContextResolver().setApplicationContext(childContext);
|
managementContextResolver().setApplicationContext(childContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEmbeddedServletContainerFactory(
|
private void registerServletWebServerFactory(
|
||||||
AnnotationConfigEmbeddedWebApplicationContext childContext) {
|
AnnotationConfigServletWebServerApplicationContext childContext) {
|
||||||
try {
|
try {
|
||||||
ConfigurableListableBeanFactory beanFactory = childContext.getBeanFactory();
|
ConfigurableListableBeanFactory beanFactory = childContext.getBeanFactory();
|
||||||
if (beanFactory instanceof BeanDefinitionRegistry) {
|
if (beanFactory instanceof BeanDefinitionRegistry) {
|
||||||
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
|
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
|
||||||
registry.registerBeanDefinition("embeddedServletContainerFactory",
|
registry.registerBeanDefinition("ServletWebServerFactory",
|
||||||
new RootBeanDefinition(
|
new RootBeanDefinition(determineServletWebServerFactoryClass()));
|
||||||
determineEmbeddedServletContainerFactoryClass()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NoSuchBeanDefinitionException ex) {
|
catch (NoSuchBeanDefinitionException ex) {
|
||||||
|
@ -198,17 +197,17 @@ public class EndpointWebMvcAutoConfiguration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Class<?> determineEmbeddedServletContainerFactoryClass()
|
private Class<?> determineServletWebServerFactoryClass()
|
||||||
throws NoSuchBeanDefinitionException {
|
throws NoSuchBeanDefinitionException {
|
||||||
Class<?> servletContainerFactoryClass = this.applicationContext
|
Class<?> factoryClass = this.applicationContext
|
||||||
.getBean(EmbeddedServletContainerFactory.class).getClass();
|
.getBean(ServletWebServerFactory.class).getClass();
|
||||||
if (cannotBeInstantiated(servletContainerFactoryClass)) {
|
if (cannotBeInstantiated(factoryClass)) {
|
||||||
throw new FatalBeanException("EmbeddedServletContainerFactory implementation "
|
throw new FatalBeanException("ServletWebServerFactory implementation "
|
||||||
+ servletContainerFactoryClass.getName() + " cannot be instantiated. "
|
+ factoryClass.getName() + " cannot be instantiated. "
|
||||||
+ "To allow a separate management port to be used, a top-level class "
|
+ "To allow a separate management port to be used, a top-level class "
|
||||||
+ "or static inner class should be used instead");
|
+ "or static inner class should be used instead");
|
||||||
}
|
}
|
||||||
return servletContainerFactoryClass;
|
return factoryClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean cannotBeInstantiated(Class<?> clazz) {
|
private boolean cannotBeInstantiated(Class<?> clazz) {
|
||||||
|
|
|
@ -40,17 +40,17 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
||||||
import org.springframework.boot.autoconfigure.hateoas.HypermediaHttpMessageConverterConfiguration;
|
import org.springframework.boot.autoconfigure.hateoas.HypermediaHttpMessageConverterConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.DefaultServletContainerCustomizer;
|
import org.springframework.boot.autoconfigure.web.DefaultServletWebServerFactoryCustomizer;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
|
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||||
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
import org.springframework.boot.web.server.ErrorPage;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebServer;
|
import org.springframework.boot.web.server.WebServer;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
import org.springframework.boot.web.servlet.ErrorPage;
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
@ -69,7 +69,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration triggered from {@link EndpointWebMvcAutoConfiguration} when a new
|
* Configuration triggered from {@link EndpointWebMvcAutoConfiguration} when a new
|
||||||
* {@link EmbeddedWebServer} running on a different port is required.
|
* {@link WebServer} running on a different port is required.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
|
@ -109,8 +109,8 @@ public class EndpointWebMvcChildContextConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ServerCustomization serverCustomization() {
|
public ServerFactoryCustomization serverCustomization() {
|
||||||
return new ServerCustomization();
|
return new ServerFactoryCustomization();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -171,19 +171,19 @@ public class EndpointWebMvcChildContextConfiguration {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ServerCustomization
|
static class ServerFactoryCustomization
|
||||||
implements EmbeddedServletContainerCustomizer, Ordered {
|
implements ServletWebServerFactoryCustomizer, Ordered {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ListableBeanFactory beanFactory;
|
private ListableBeanFactory beanFactory;
|
||||||
|
|
||||||
// This needs to be lazily initialized because EmbeddedServletContainerCustomizer
|
// This needs to be lazily initialized because web server customizer
|
||||||
// instances get their callback very early in the context lifecycle.
|
// instances get their callback very early in the context lifecycle.
|
||||||
private ManagementServerProperties managementServerProperties;
|
private ManagementServerProperties managementServerProperties;
|
||||||
|
|
||||||
private ServerProperties server;
|
private ServerProperties server;
|
||||||
|
|
||||||
private DefaultServletContainerCustomizer serverCustomizer;
|
private DefaultServletWebServerFactoryCustomizer serverCustomizer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
|
@ -191,7 +191,7 @@ public class EndpointWebMvcChildContextConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(ConfigurableEmbeddedServletContainer container) {
|
public void customize(ConfigurableServletWebServerFactory webServerFactory) {
|
||||||
if (this.managementServerProperties == null) {
|
if (this.managementServerProperties == null) {
|
||||||
this.managementServerProperties = BeanFactoryUtils
|
this.managementServerProperties = BeanFactoryUtils
|
||||||
.beanOfTypeIncludingAncestors(this.beanFactory,
|
.beanOfTypeIncludingAncestors(this.beanFactory,
|
||||||
|
@ -199,23 +199,23 @@ public class EndpointWebMvcChildContextConfiguration {
|
||||||
this.server = BeanFactoryUtils.beanOfTypeIncludingAncestors(
|
this.server = BeanFactoryUtils.beanOfTypeIncludingAncestors(
|
||||||
this.beanFactory, ServerProperties.class);
|
this.beanFactory, ServerProperties.class);
|
||||||
this.serverCustomizer = BeanFactoryUtils.beanOfTypeIncludingAncestors(
|
this.serverCustomizer = BeanFactoryUtils.beanOfTypeIncludingAncestors(
|
||||||
this.beanFactory, DefaultServletContainerCustomizer.class);
|
this.beanFactory, DefaultServletWebServerFactoryCustomizer.class);
|
||||||
}
|
}
|
||||||
// Customize as per the parent context first (so e.g. the access logs go to
|
// Customize as per the parent context first (so e.g. the access logs go to
|
||||||
// the same place)
|
// the same place)
|
||||||
this.serverCustomizer.customize(container);
|
this.serverCustomizer.customize(webServerFactory);
|
||||||
// Then reset the error pages
|
// Then reset the error pages
|
||||||
container.setErrorPages(Collections.<ErrorPage>emptySet());
|
webServerFactory.setErrorPages(Collections.<ErrorPage>emptySet());
|
||||||
// and the context path
|
// and the context path
|
||||||
container.setContextPath("");
|
webServerFactory.setContextPath("");
|
||||||
// and add the management-specific bits
|
// and add the management-specific bits
|
||||||
container.setPort(this.managementServerProperties.getPort());
|
webServerFactory.setPort(this.managementServerProperties.getPort());
|
||||||
if (this.managementServerProperties.getSsl() != null) {
|
if (this.managementServerProperties.getSsl() != null) {
|
||||||
container.setSsl(this.managementServerProperties.getSsl());
|
webServerFactory.setSsl(this.managementServerProperties.getSsl());
|
||||||
}
|
}
|
||||||
container.setServerHeader(this.server.getServerHeader());
|
webServerFactory.setServerHeader(this.server.getServerHeader());
|
||||||
container.setAddress(this.managementServerProperties.getAddress());
|
webServerFactory.setAddress(this.managementServerProperties.getAddress());
|
||||||
container.addErrorPages(new ErrorPage(this.server.getError().getPath()));
|
webServerFactory.addErrorPages(new ErrorPage(this.server.getError().getPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -343,8 +343,8 @@ public class EndpointWebMvcChildContextConfiguration {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static abstract class AccessLogCustomizer<T extends EmbeddedServletContainerFactory>
|
static abstract class AccessLogCustomizer<T extends ServletWebServerFactory>
|
||||||
implements EmbeddedServletContainerCustomizer, Ordered {
|
implements ServletWebServerFactoryCustomizer, Ordered {
|
||||||
|
|
||||||
private final Class<T> factoryClass;
|
private final Class<T> factoryClass;
|
||||||
|
|
||||||
|
@ -362,26 +362,26 @@ public class EndpointWebMvcChildContextConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(ConfigurableEmbeddedServletContainer container) {
|
public void customize(ConfigurableServletWebServerFactory serverFactory) {
|
||||||
if (this.factoryClass.isInstance(container)) {
|
if (this.factoryClass.isInstance(serverFactory)) {
|
||||||
customize(this.factoryClass.cast(container));
|
customize(this.factoryClass.cast(serverFactory));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void customize(T container);
|
abstract void customize(T webServerFactory);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TomcatAccessLogCustomizer
|
static class TomcatAccessLogCustomizer
|
||||||
extends AccessLogCustomizer<TomcatEmbeddedServletContainerFactory> {
|
extends AccessLogCustomizer<TomcatServletWebServerFactory> {
|
||||||
|
|
||||||
TomcatAccessLogCustomizer() {
|
TomcatAccessLogCustomizer() {
|
||||||
super(TomcatEmbeddedServletContainerFactory.class);
|
super(TomcatServletWebServerFactory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(TomcatEmbeddedServletContainerFactory container) {
|
public void customize(TomcatServletWebServerFactory serverFactory) {
|
||||||
AccessLogValve accessLogValve = findAccessLogValve(container);
|
AccessLogValve accessLogValve = findAccessLogValve(serverFactory);
|
||||||
if (accessLogValve == null) {
|
if (accessLogValve == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -389,8 +389,8 @@ public class EndpointWebMvcChildContextConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
private AccessLogValve findAccessLogValve(
|
private AccessLogValve findAccessLogValve(
|
||||||
TomcatEmbeddedServletContainerFactory container) {
|
TomcatServletWebServerFactory serverFactory) {
|
||||||
for (Valve engineValve : container.getEngineValves()) {
|
for (Valve engineValve : serverFactory.getEngineValves()) {
|
||||||
if (engineValve instanceof AccessLogValve) {
|
if (engineValve instanceof AccessLogValve) {
|
||||||
return (AccessLogValve) engineValve;
|
return (AccessLogValve) engineValve;
|
||||||
}
|
}
|
||||||
|
@ -401,15 +401,15 @@ public class EndpointWebMvcChildContextConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class UndertowAccessLogCustomizer
|
static class UndertowAccessLogCustomizer
|
||||||
extends AccessLogCustomizer<UndertowEmbeddedServletContainerFactory> {
|
extends AccessLogCustomizer<UndertowServletWebServerFactory> {
|
||||||
|
|
||||||
UndertowAccessLogCustomizer() {
|
UndertowAccessLogCustomizer() {
|
||||||
super(UndertowEmbeddedServletContainerFactory.class);
|
super(UndertowServletWebServerFactory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(UndertowEmbeddedServletContainerFactory container) {
|
public void customize(UndertowServletWebServerFactory serverFactory) {
|
||||||
container.setAccessLogPrefix(customizePrefix(container.getAccessLogPrefix()));
|
serverFactory.setAccessLogPrefix(customizePrefix(serverFactory.getAccessLogPrefix()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
import org.springframework.boot.bind.RelaxedPropertyResolver;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
@ -66,7 +66,7 @@ import org.springframework.web.servlet.mvc.ServletWrappingController;
|
||||||
@ConditionalOnClass({ AgentServlet.class, ServletWrappingController.class })
|
@ConditionalOnClass({ AgentServlet.class, ServletWrappingController.class })
|
||||||
@Conditional(JolokiaCondition.class)
|
@Conditional(JolokiaCondition.class)
|
||||||
@AutoConfigureBefore(ManagementWebSecurityAutoConfiguration.class)
|
@AutoConfigureBefore(ManagementWebSecurityAutoConfiguration.class)
|
||||||
@AutoConfigureAfter(EmbeddedServletContainerAutoConfiguration.class)
|
@AutoConfigureAfter(ServletWebServerFactoryAutoConfiguration.class)
|
||||||
@EnableConfigurationProperties(JolokiaProperties.class)
|
@EnableConfigurationProperties(JolokiaProperties.class)
|
||||||
public class JolokiaAutoConfiguration {
|
public class JolokiaAutoConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ import javax.servlet.http.HttpSession;
|
||||||
import org.springframework.boot.autoconfigure.security.SecurityPrerequisite;
|
import org.springframework.boot.autoconfigure.security.SecurityPrerequisite;
|
||||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||||
import org.springframework.boot.context.embedded.Ssl;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||||
|
import org.springframework.boot.web.server.Ssl;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,9 @@ import org.apache.catalina.session.ManagerBase;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.boot.actuate.metrics.Metric;
|
import org.springframework.boot.actuate.metrics.Metric;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
|
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebServer;
|
import org.springframework.boot.web.server.WebServer;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
|
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
|
||||||
|
@ -47,9 +47,9 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Metric<?>> metrics() {
|
public Collection<Metric<?>> metrics() {
|
||||||
if (this.applicationContext instanceof EmbeddedWebApplicationContext) {
|
if (this.applicationContext instanceof ServletWebServerApplicationContext) {
|
||||||
Manager manager = getManager(
|
Manager manager = getManager(
|
||||||
(EmbeddedWebApplicationContext) this.applicationContext);
|
(ServletWebServerApplicationContext) this.applicationContext);
|
||||||
if (manager != null) {
|
if (manager != null) {
|
||||||
return metrics(manager);
|
return metrics(manager);
|
||||||
}
|
}
|
||||||
|
@ -57,16 +57,16 @@ public class TomcatPublicMetrics implements PublicMetrics, ApplicationContextAwa
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Manager getManager(EmbeddedWebApplicationContext applicationContext) {
|
private Manager getManager(ServletWebServerApplicationContext applicationContext) {
|
||||||
EmbeddedWebServer embeddedWebServer = applicationContext.getEmbeddedWebServer();
|
WebServer webServer = applicationContext.getWebServer();
|
||||||
if (embeddedWebServer instanceof TomcatEmbeddedServletContainer) {
|
if (webServer instanceof TomcatWebServer) {
|
||||||
return getManager((TomcatEmbeddedServletContainer) embeddedWebServer);
|
return getManager((TomcatWebServer) webServer);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Manager getManager(TomcatEmbeddedServletContainer servletContainer) {
|
private Manager getManager(TomcatWebServer webServer) {
|
||||||
for (Container container : servletContainer.getTomcat().getHost()
|
for (Container container : webServer.getTomcat().getHost()
|
||||||
.findChildren()) {
|
.findChildren()) {
|
||||||
if (container instanceof Context) {
|
if (container instanceof Context) {
|
||||||
return ((Context) container).getManager();
|
return ((Context) container).getManager();
|
||||||
|
|
|
@ -23,10 +23,10 @@ import net.minidev.json.JSONArray;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.ServerPortInfoApplicationContextInitializer;
|
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
|
||||||
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*/
|
*/
|
||||||
public class BootCuriesHrefIntegrationTests {
|
public class BootCuriesHrefIntegrationTests {
|
||||||
|
|
||||||
private AnnotationConfigEmbeddedWebApplicationContext context;
|
private AnnotationConfigServletWebServerApplicationContext context;
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void closeContext() {
|
public void closeContext() {
|
||||||
|
@ -110,7 +110,7 @@ public class BootCuriesHrefIntegrationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int load(String... properties) {
|
private int load(String... properties) {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.setClassLoader(new ClassLoader(getClass().getClassLoader()) {
|
this.context.setClassLoader(new ClassLoader(getClass().getClassLoader()) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -42,14 +42,14 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
|
||||||
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
@ -152,7 +152,7 @@ public class EndpointMvcIntegrationTests {
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
JacksonAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
JacksonAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class })
|
PropertyPlaceholderAutoConfiguration.class })
|
||||||
|
|
|
@ -56,23 +56,23 @@ import org.springframework.boot.actuate.endpoint.mvc.ShutdownMvcEndpoint;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||||
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebServer;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebServerException;
|
|
||||||
import org.springframework.boot.context.embedded.ServerPortInfoApplicationContextInitializer;
|
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.event.ApplicationFailedEvent;
|
import org.springframework.boot.context.event.ApplicationFailedEvent;
|
||||||
import org.springframework.boot.logging.LoggingSystem;
|
import org.springframework.boot.logging.LoggingSystem;
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
import org.springframework.boot.testutil.Matched;
|
import org.springframework.boot.testutil.Matched;
|
||||||
|
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.server.WebServer;
|
||||||
|
import org.springframework.boot.web.server.WebServerException;
|
||||||
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
|
import org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
@ -115,7 +115,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
public ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
private final AnnotationConfigEmbeddedWebApplicationContext applicationContext = new AnnotationConfigEmbeddedWebApplicationContext();
|
private final AnnotationConfigServletWebServerApplicationContext applicationContext = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
|
|
||||||
private static ThreadLocal<Ports> ports = new ThreadLocal<>();
|
private static ThreadLocal<Ports> ports = new ThreadLocal<>();
|
||||||
|
|
||||||
|
@ -185,10 +185,10 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onDifferentPortWithSpecificContainer() throws Exception {
|
public void onDifferentPortWithSpecificServer() throws Exception {
|
||||||
EnvironmentTestUtils.addEnvironment(this.applicationContext,
|
EnvironmentTestUtils.addEnvironment(this.applicationContext,
|
||||||
"management.port=" + ports.get().management);
|
"management.port=" + ports.get().management);
|
||||||
this.applicationContext.register(SpecificContainerConfig.class, RootConfig.class,
|
this.applicationContext.register(SpecificWebServerConfig.class, RootConfig.class,
|
||||||
DifferentPortConfig.class, EndpointConfig.class, BaseConfiguration.class,
|
DifferentPortConfig.class, EndpointConfig.class, BaseConfiguration.class,
|
||||||
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||||
this.applicationContext.refresh();
|
this.applicationContext.refresh();
|
||||||
|
@ -202,15 +202,13 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
List<?> interceptors = (List<?>) ReflectionTestUtils.getField(
|
List<?> interceptors = (List<?>) ReflectionTestUtils.getField(
|
||||||
managementContext.getBean(EndpointHandlerMapping.class), "interceptors");
|
managementContext.getBean(EndpointHandlerMapping.class), "interceptors");
|
||||||
assertThat(interceptors).hasSize(1);
|
assertThat(interceptors).hasSize(1);
|
||||||
EmbeddedServletContainerFactory parentContainerFactory = this.applicationContext
|
ServletWebServerFactory parentFactory = this.applicationContext
|
||||||
.getBean(EmbeddedServletContainerFactory.class);
|
.getBean(ServletWebServerFactory.class);
|
||||||
EmbeddedServletContainerFactory managementContainerFactory = managementContext
|
ServletWebServerFactory managementFactory = managementContext
|
||||||
.getBean(EmbeddedServletContainerFactory.class);
|
.getBean(ServletWebServerFactory.class);
|
||||||
assertThat(parentContainerFactory)
|
assertThat(parentFactory).isInstanceOf(SpecificServletWebServerFactory.class);
|
||||||
.isInstanceOf(SpecificEmbeddedServletContainerFactory.class);
|
assertThat(managementFactory).isInstanceOf(SpecificServletWebServerFactory.class);
|
||||||
assertThat(managementContainerFactory)
|
assertThat(managementFactory).isNotSameAs(parentFactory);
|
||||||
.isInstanceOf(SpecificEmbeddedServletContainerFactory.class);
|
|
||||||
assertThat(managementContainerFactory).isNotSameAs(parentContainerFactory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -254,7 +252,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onDifferentPortInServletContainer() throws Exception {
|
public void onDifferentPortInWebServer() throws Exception {
|
||||||
EnvironmentTestUtils.addEnvironment(this.applicationContext,
|
EnvironmentTestUtils.addEnvironment(this.applicationContext,
|
||||||
"management.port=" + ports.get().management);
|
"management.port=" + ports.get().management);
|
||||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||||
|
@ -282,7 +280,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
this.applicationContext);
|
this.applicationContext);
|
||||||
this.applicationContext.addApplicationListener(grabManagementPort);
|
this.applicationContext.addApplicationListener(grabManagementPort);
|
||||||
this.applicationContext.refresh();
|
this.applicationContext.refresh();
|
||||||
int managementPort = grabManagementPort.getServletContainer().getPort();
|
int managementPort = grabManagementPort.getWebServer().getPort();
|
||||||
assertThat(managementPort).isNotEqualTo(ports.get().server);
|
assertThat(managementPort).isNotEqualTo(ports.get().server);
|
||||||
assertContent("/controller", ports.get().server, "controlleroutput");
|
assertContent("/controller", ports.get().server, "controlleroutput");
|
||||||
assertContent("/endpoint", ports.get().server, null);
|
assertContent("/endpoint", ports.get().server, null);
|
||||||
|
@ -348,7 +346,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||||
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
|
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
|
||||||
ErrorMvcAutoConfiguration.class);
|
ErrorMvcAutoConfiguration.class);
|
||||||
this.thrown.expect(EmbeddedWebServerException.class);
|
this.thrown.expect(WebServerException.class);
|
||||||
this.applicationContext.refresh();
|
this.applicationContext.refresh();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -363,7 +361,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class,
|
PropertyPlaceholderAutoConfiguration.class,
|
||||||
JacksonAutoConfiguration.class,
|
JacksonAutoConfiguration.class,
|
||||||
EmbeddedServletContainerAutoConfiguration.class,
|
ServletWebServerFactoryAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class,
|
HttpMessageConvertersAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
EndpointWebMvcAutoConfiguration.class, AuditAutoConfiguration.class);
|
EndpointWebMvcAutoConfiguration.class, AuditAutoConfiguration.class);
|
||||||
|
@ -379,7 +377,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class,
|
PropertyPlaceholderAutoConfiguration.class,
|
||||||
JacksonAutoConfiguration.class,
|
JacksonAutoConfiguration.class,
|
||||||
EmbeddedServletContainerAutoConfiguration.class,
|
ServletWebServerFactoryAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class,
|
HttpMessageConvertersAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
EndpointWebMvcAutoConfiguration.class, AuditAutoConfiguration.class);
|
EndpointWebMvcAutoConfiguration.class, AuditAutoConfiguration.class);
|
||||||
|
@ -590,7 +588,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
public void tomcatManagementAccessLogUsesCustomPrefix() throws Exception {
|
public void tomcatManagementAccessLogUsesCustomPrefix() throws Exception {
|
||||||
EnvironmentTestUtils.addEnvironment(this.applicationContext,
|
EnvironmentTestUtils.addEnvironment(this.applicationContext,
|
||||||
"management.port=" + ports.get().management);
|
"management.port=" + ports.get().management);
|
||||||
this.applicationContext.register(TomcatContainerConfig.class, RootConfig.class,
|
this.applicationContext.register(TomcatWebServerConfig.class, RootConfig.class,
|
||||||
EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class,
|
EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class,
|
||||||
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||||
EnvironmentTestUtils.addEnvironment(this.applicationContext,
|
EnvironmentTestUtils.addEnvironment(this.applicationContext,
|
||||||
|
@ -598,12 +596,11 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
this.applicationContext.refresh();
|
this.applicationContext.refresh();
|
||||||
ApplicationContext managementContext = this.applicationContext
|
ApplicationContext managementContext = this.applicationContext
|
||||||
.getBean(ManagementContextResolver.class).getApplicationContext();
|
.getBean(ManagementContextResolver.class).getApplicationContext();
|
||||||
EmbeddedServletContainerFactory servletContainerFactory = managementContext
|
ServletWebServerFactory factory = managementContext
|
||||||
.getBean(EmbeddedServletContainerFactory.class);
|
.getBean(ServletWebServerFactory.class);
|
||||||
assertThat(servletContainerFactory)
|
assertThat(factory).isInstanceOf(TomcatServletWebServerFactory.class);
|
||||||
.isInstanceOf(TomcatEmbeddedServletContainerFactory.class);
|
|
||||||
AccessLogValve accessLogValve = findAccessLogValve(
|
AccessLogValve accessLogValve = findAccessLogValve(
|
||||||
((TomcatEmbeddedServletContainerFactory) servletContainerFactory));
|
((TomcatServletWebServerFactory) factory));
|
||||||
assertThat(accessLogValve).isNotNull();
|
assertThat(accessLogValve).isNotNull();
|
||||||
assertThat(accessLogValve.getPrefix()).isEqualTo("management_access_log");
|
assertThat(accessLogValve.getPrefix()).isEqualTo("management_access_log");
|
||||||
}
|
}
|
||||||
|
@ -613,23 +610,22 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
EnvironmentTestUtils.addEnvironment(this.applicationContext,
|
EnvironmentTestUtils.addEnvironment(this.applicationContext,
|
||||||
"management.port=" + ports.get().management,
|
"management.port=" + ports.get().management,
|
||||||
"server.undertow.accesslog.enabled: true");
|
"server.undertow.accesslog.enabled: true");
|
||||||
this.applicationContext.register(UndertowContainerConfig.class, RootConfig.class,
|
this.applicationContext.register(UndertowWebServerConfig.class, RootConfig.class,
|
||||||
EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class,
|
EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class,
|
||||||
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
|
||||||
this.applicationContext.refresh();
|
this.applicationContext.refresh();
|
||||||
ApplicationContext managementContext = this.applicationContext
|
ApplicationContext managementContext = this.applicationContext
|
||||||
.getBean(ManagementContextResolver.class).getApplicationContext();
|
.getBean(ManagementContextResolver.class).getApplicationContext();
|
||||||
EmbeddedServletContainerFactory servletContainerFactory = managementContext
|
ServletWebServerFactory factory = managementContext
|
||||||
.getBean(EmbeddedServletContainerFactory.class);
|
.getBean(ServletWebServerFactory.class);
|
||||||
assertThat(servletContainerFactory)
|
assertThat(factory).isInstanceOf(UndertowServletWebServerFactory.class);
|
||||||
.isInstanceOf(UndertowEmbeddedServletContainerFactory.class);
|
assertThat(((UndertowServletWebServerFactory) factory).getAccessLogPrefix())
|
||||||
assertThat(((UndertowEmbeddedServletContainerFactory) servletContainerFactory)
|
.isEqualTo("management_access_log.");
|
||||||
.getAccessLogPrefix()).isEqualTo("management_access_log.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private AccessLogValve findAccessLogValve(
|
private AccessLogValve findAccessLogValve(
|
||||||
TomcatEmbeddedServletContainerFactory container) {
|
TomcatServletWebServerFactory webServerFactory) {
|
||||||
for (Valve engineValve : container.getEngineValves()) {
|
for (Valve engineValve : webServerFactory.getEngineValves()) {
|
||||||
if (engineValve instanceof AccessLogValve) {
|
if (engineValve instanceof AccessLogValve) {
|
||||||
return (AccessLogValve) engineValve;
|
return (AccessLogValve) engineValve;
|
||||||
}
|
}
|
||||||
|
@ -733,7 +729,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ PropertyPlaceholderAutoConfiguration.class,
|
@Import({ PropertyPlaceholderAutoConfiguration.class,
|
||||||
EmbeddedServletContainerAutoConfiguration.class,
|
ServletWebServerFactoryAutoConfiguration.class,
|
||||||
JacksonAutoConfiguration.class, EndpointAutoConfiguration.class,
|
JacksonAutoConfiguration.class, EndpointAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class,
|
HttpMessageConvertersAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
|
@ -784,31 +780,31 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public static class SpecificContainerConfig {
|
public static class SpecificWebServerConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SpecificEmbeddedServletContainerFactory embeddedServletContainerFactory() {
|
public SpecificServletWebServerFactory webServerFactory() {
|
||||||
return new SpecificEmbeddedServletContainerFactory();
|
return new SpecificServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public static class TomcatContainerConfig {
|
public static class TomcatWebServerConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TomcatEmbeddedServletContainerFactory embeddedServletContainerFactory() {
|
public TomcatServletWebServerFactory webServerFactory() {
|
||||||
return new TomcatEmbeddedServletContainerFactory();
|
return new TomcatServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public static class UndertowContainerConfig {
|
public static class UndertowWebServerConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
|
public UndertowServletWebServerFactory webServerFactory() {
|
||||||
return new UndertowEmbeddedServletContainerFactory();
|
return new UndertowServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -879,31 +875,31 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class GrabManagementPort
|
private static class GrabManagementPort
|
||||||
implements ApplicationListener<EmbeddedServletContainerInitializedEvent> {
|
implements ApplicationListener<ServletWebServerInitializedEvent> {
|
||||||
|
|
||||||
private ApplicationContext rootContext;
|
private ApplicationContext rootContext;
|
||||||
|
|
||||||
private EmbeddedWebServer servletContainer;
|
private WebServer webServer;
|
||||||
|
|
||||||
GrabManagementPort(ApplicationContext rootContext) {
|
GrabManagementPort(ApplicationContext rootContext) {
|
||||||
this.rootContext = rootContext;
|
this.rootContext = rootContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
|
public void onApplicationEvent(ServletWebServerInitializedEvent event) {
|
||||||
if (event.getApplicationContext() != this.rootContext) {
|
if (event.getApplicationContext() != this.rootContext) {
|
||||||
this.servletContainer = event.getEmbeddedWebServer();
|
this.webServer = event.getWebServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmbeddedWebServer getServletContainer() {
|
public WebServer getWebServer() {
|
||||||
return this.servletContainer;
|
return this.webServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SpecificEmbeddedServletContainerFactory
|
private static class SpecificServletWebServerFactory
|
||||||
extends TomcatEmbeddedServletContainerFactory {
|
extends TomcatServletWebServerFactory {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,12 @@ import org.springframework.boot.actuate.endpoint.mvc.MvcEndpointSecurityIntercep
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
|
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
@ -53,21 +53,21 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*/
|
*/
|
||||||
public class JolokiaAutoConfigurationTests {
|
public class JolokiaAutoConfigurationTests {
|
||||||
|
|
||||||
private AnnotationConfigEmbeddedWebApplicationContext context;
|
private AnnotationConfigServletWebServerApplicationContext context;
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void close() {
|
public void close() {
|
||||||
if (this.context != null) {
|
if (this.context != null) {
|
||||||
this.context.close();
|
this.context.close();
|
||||||
}
|
}
|
||||||
if (Config.containerFactory != null) {
|
if (Config.webServerFactory != null) {
|
||||||
Config.containerFactory = null;
|
Config.webServerFactory = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void agentServletRegisteredWithAppContext() throws Exception {
|
public void agentServletRegisteredWithAppContext() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context, "jolokia.config[key1]:value1",
|
EnvironmentTestUtils.addEnvironment(this.context, "jolokia.config[key1]:value1",
|
||||||
"jolokia.config[key2]:value2");
|
"jolokia.config[key2]:value2");
|
||||||
this.context.register(Config.class, WebMvcAutoConfiguration.class,
|
this.context.register(Config.class, WebMvcAutoConfiguration.class,
|
||||||
|
@ -80,7 +80,7 @@ public class JolokiaAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void agentServletWithCustomPath() throws Exception {
|
public void agentServletWithCustomPath() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"endpoints.jolokia.path=/foo/bar");
|
"endpoints.jolokia.path=/foo/bar");
|
||||||
this.context.register(EndpointsConfig.class, WebMvcAutoConfiguration.class,
|
this.context.register(EndpointsConfig.class, WebMvcAutoConfiguration.class,
|
||||||
|
@ -112,7 +112,7 @@ public class JolokiaAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertEndpointDisabled(String... pairs) {
|
private void assertEndpointDisabled(String... pairs) {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context, pairs);
|
EnvironmentTestUtils.addEnvironment(this.context, pairs);
|
||||||
this.context.register(Config.class, WebMvcAutoConfiguration.class,
|
this.context.register(Config.class, WebMvcAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class,
|
PropertyPlaceholderAutoConfiguration.class,
|
||||||
|
@ -123,7 +123,7 @@ public class JolokiaAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertEndpointEnabled(String... pairs) {
|
private void assertEndpointEnabled(String... pairs) {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context, pairs);
|
EnvironmentTestUtils.addEnvironment(this.context, pairs);
|
||||||
this.context.register(Config.class, WebMvcAutoConfiguration.class,
|
this.context.register(Config.class, WebMvcAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class,
|
PropertyPlaceholderAutoConfiguration.class,
|
||||||
|
@ -151,19 +151,19 @@ public class JolokiaAutoConfigurationTests {
|
||||||
@EnableConfigurationProperties
|
@EnableConfigurationProperties
|
||||||
protected static class Config {
|
protected static class Config {
|
||||||
|
|
||||||
protected static MockEmbeddedServletContainerFactory containerFactory = null;
|
protected static MockServletWebServerFactory webServerFactory = null;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory containerFactory() {
|
public ServletWebServerFactory webServerFactory() {
|
||||||
if (containerFactory == null) {
|
if (webServerFactory == null) {
|
||||||
containerFactory = new MockEmbeddedServletContainerFactory();
|
webServerFactory = new MockServletWebServerFactory();
|
||||||
}
|
}
|
||||||
return containerFactory;
|
return webServerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
|
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
|
||||||
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
|
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,9 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
|
||||||
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration;
|
import org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Configuration
|
@Configuration
|
||||||
@ImportAutoConfiguration({ EmbeddedServletContainerAutoConfiguration.class,
|
@ImportAutoConfiguration({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, JacksonAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class, JacksonAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
HttpMessageConvertersAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
HypermediaAutoConfiguration.class, EndpointAutoConfiguration.class,
|
HypermediaAutoConfiguration.class, EndpointAutoConfiguration.class,
|
||||||
|
|
|
@ -43,9 +43,9 @@ import org.springframework.boot.actuate.metrics.rich.RichGaugeReader;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
||||||
import org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProvidersConfiguration;
|
import org.springframework.boot.autoconfigure.jdbc.metadata.DataSourcePoolMetadataProvidersConfiguration;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
|
||||||
import org.springframework.cache.CacheManager;
|
import org.springframework.cache.CacheManager;
|
||||||
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
|
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
@ -237,14 +237,13 @@ public class PublicMetricsAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadWeb(Class<?>... config) {
|
private void loadWeb(Class<?>... config) {
|
||||||
AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext();
|
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
if (config.length > 0) {
|
if (config.length > 0) {
|
||||||
context.register(config);
|
context.register(config);
|
||||||
}
|
}
|
||||||
context.register(DataSourcePoolMetadataProvidersConfiguration.class,
|
context.register(DataSourcePoolMetadataProvidersConfiguration.class,
|
||||||
CacheStatisticsAutoConfiguration.class,
|
CacheStatisticsAutoConfiguration.class,
|
||||||
PublicMetricsAutoConfiguration.class,
|
PublicMetricsAutoConfiguration.class, MockServletWebServerFactory.class);
|
||||||
MockEmbeddedServletContainerFactory.class);
|
|
||||||
context.refresh();
|
context.refresh();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
@ -346,8 +345,8 @@ public class PublicMetricsAutoConfigurationTests {
|
||||||
static class TomcatConfiguration {
|
static class TomcatConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TomcatEmbeddedServletContainerFactory containerFactory() {
|
public TomcatServletWebServerFactory webServerFactory() {
|
||||||
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
factory.setPort(SocketUtils.findAvailableTcpPort(40000));
|
factory.setPort(SocketUtils.findAvailableTcpPort(40000));
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,11 @@ import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebServer;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.ExampleServlet;
|
import org.springframework.boot.web.server.Ssl;
|
||||||
import org.springframework.boot.context.embedded.Ssl;
|
import org.springframework.boot.web.server.WebServer;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||||
|
import org.springframework.boot.web.servlet.server.ExampleServlet;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.client.ResourceAccessException;
|
import org.springframework.web.client.ResourceAccessException;
|
||||||
|
@ -63,13 +63,12 @@ public class SkipSslVerificationHttpRequestFactoryTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHttpsUrl() {
|
private String getHttpsUrl() {
|
||||||
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory(
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
||||||
0);
|
|
||||||
factory.setSsl(getSsl("password", "classpath:test.jks"));
|
factory.setSsl(getSsl("password", "classpath:test.jks"));
|
||||||
EmbeddedWebServer container = factory.getEmbeddedServletContainer(
|
WebServer webServer = factory.getWebServer(
|
||||||
new ServletRegistrationBean<>(new ExampleServlet(), "/hello"));
|
new ServletRegistrationBean<>(new ExampleServlet(), "/hello"));
|
||||||
container.start();
|
webServer.start();
|
||||||
return "https://localhost:" + container.getPort() + "/hello";
|
return "https://localhost:" + webServer.getPort() + "/hello";
|
||||||
}
|
}
|
||||||
|
|
||||||
private Ssl getSsl(String keyPassword, String keyStore) {
|
private Ssl getSsl(String keyPassword, String keyStore) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -21,8 +21,8 @@ import java.util.Iterator;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.metrics.Metric;
|
import org.springframework.boot.actuate.metrics.Metric;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.util.SocketUtils;
|
import org.springframework.util.SocketUtils;
|
||||||
|
@ -39,7 +39,7 @@ public class TomcatPublicMetricsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void tomcatMetrics() throws Exception {
|
public void tomcatMetrics() throws Exception {
|
||||||
AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext(
|
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
Config.class);
|
Config.class);
|
||||||
try {
|
try {
|
||||||
TomcatPublicMetrics tomcatMetrics = context
|
TomcatPublicMetrics tomcatMetrics = context
|
||||||
|
@ -58,8 +58,8 @@ public class TomcatPublicMetricsTests {
|
||||||
static class Config {
|
static class Config {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TomcatEmbeddedServletContainerFactory containerFactory() {
|
public TomcatServletWebServerFactory webServerFactory() {
|
||||||
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
factory.setPort(SocketUtils.findAvailableTcpPort(40000));
|
factory.setPort(SocketUtils.findAvailableTcpPort(40000));
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,10 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication;
|
import org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication;
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
|
|
@ -23,10 +23,10 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication;
|
import org.springframework.boot.actuate.autoconfigure.MinimalActuatorHypermediaApplication;
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.hateoas.ResourceSupport;
|
import org.springframework.hateoas.ResourceSupport;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
|
|
@ -26,8 +26,8 @@ import java.lang.annotation.Target;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
import org.springframework.context.annotation.Conditional;
|
import org.springframework.context.annotation.Conditional;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
@ -38,8 +38,8 @@ import org.springframework.core.io.support.SpringFactoriesLoader;
|
||||||
* configure beans that you are likely to need. Auto-configuration classes are usually
|
* configure beans that you are likely to need. Auto-configuration classes are usually
|
||||||
* applied based on your classpath and what beans you have defined. For example, If you
|
* applied based on your classpath and what beans you have defined. For example, If you
|
||||||
* have {@code tomcat-embedded.jar} on your classpath you are likely to want a
|
* have {@code tomcat-embedded.jar} on your classpath you are likely to want a
|
||||||
* {@link TomcatEmbeddedServletContainerFactory} (unless you have defined your own
|
* {@link TomcatServletWebServerFactory} (unless you have defined your own
|
||||||
* {@link EmbeddedServletContainerFactory} bean).
|
* {@link ServletWebServerFactory} bean).
|
||||||
* <p>
|
* <p>
|
||||||
* Auto-configuration tries to be as intelligent as possible and will back-away as you
|
* Auto-configuration tries to be as intelligent as possible and will back-away as you
|
||||||
* define more of your own configuration. You can always manually {@link #exclude()} any
|
* define more of your own configuration. You can always manually {@link #exclude()} any
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.condition;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||||
import org.springframework.boot.context.ReactiveWebApplicationContext;
|
import org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext;
|
||||||
import org.springframework.context.annotation.Condition;
|
import org.springframework.context.annotation.Condition;
|
||||||
import org.springframework.context.annotation.ConditionContext;
|
import org.springframework.context.annotation.ConditionContext;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
|
|
|
@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.web.ErrorProperties.IncludeStacktrace;
|
import org.springframework.boot.autoconfigure.web.ErrorProperties.IncludeStacktrace;
|
||||||
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -38,7 +38,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||||
* Basic global error {@link Controller}, rendering {@link ErrorAttributes}. More specific
|
* Basic global error {@link Controller}, rendering {@link ErrorAttributes}. More specific
|
||||||
* errors can be handled either using Spring MVC abstractions (e.g.
|
* errors can be handled either using Spring MVC abstractions (e.g.
|
||||||
* {@code @ExceptionHandler}) or by adding servlet
|
* {@code @ExceptionHandler}) or by adding servlet
|
||||||
* {@link AbstractEmbeddedServletContainerFactory#setErrorPages container error pages}.
|
* {@link AbstractServletWebServerFactory#setErrorPages server error pages}.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
|
|
@ -43,19 +43,19 @@ import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.web.ServerProperties.Session;
|
import org.springframework.boot.autoconfigure.web.ServerProperties.Session;
|
||||||
import org.springframework.boot.cloud.CloudPlatform;
|
import org.springframework.boot.cloud.CloudPlatform;
|
||||||
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
|
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
|
||||||
import org.springframework.boot.context.embedded.InitParameterConfiguringServletContextInitializer;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer;
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyServerCustomizer;
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer;
|
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer;
|
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowBuilderCustomizer;
|
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
||||||
|
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.InitParameterConfiguringServletContextInitializer;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
|
||||||
import org.springframework.context.EnvironmentAware;
|
import org.springframework.context.EnvironmentAware;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
@ -63,26 +63,26 @@ import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customizer used by an {@link EmbeddedServletContainerFactory} when an
|
* Customizer used by an {@link ServletWebServerFactory} when an
|
||||||
* {@link EmbeddedServletContainerCustomizerBeanPostProcessor} is active.
|
* {@link ServletWebServerFactoryCustomizerBeanPostProcessor} is active.
|
||||||
*
|
*
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
public class DefaultServletContainerCustomizer
|
public class DefaultServletWebServerFactoryCustomizer
|
||||||
implements EmbeddedServletContainerCustomizer, EnvironmentAware, Ordered {
|
implements ServletWebServerFactoryCustomizer, EnvironmentAware, Ordered {
|
||||||
|
|
||||||
private final ServerProperties serverProperties;
|
private final ServerProperties serverProperties;
|
||||||
|
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
|
|
||||||
public DefaultServletContainerCustomizer(ServerProperties serverProperties) {
|
public DefaultServletWebServerFactoryCustomizer(ServerProperties serverProperties) {
|
||||||
this.serverProperties = serverProperties;
|
this.serverProperties = serverProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoader(String value) {
|
public void setLoader(String value) {
|
||||||
// no op to support Tomcat running as a traditional container (not embedded)
|
// no op to support Tomcat running as a traditional server (not embedded)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,50 +96,50 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(ConfigurableEmbeddedServletContainer container) {
|
public void customize(ConfigurableServletWebServerFactory factory) {
|
||||||
if (this.serverProperties.getPort() != null) {
|
if (this.serverProperties.getPort() != null) {
|
||||||
container.setPort(this.serverProperties.getPort());
|
factory.setPort(this.serverProperties.getPort());
|
||||||
}
|
}
|
||||||
if (this.serverProperties.getAddress() != null) {
|
if (this.serverProperties.getAddress() != null) {
|
||||||
container.setAddress(this.serverProperties.getAddress());
|
factory.setAddress(this.serverProperties.getAddress());
|
||||||
}
|
}
|
||||||
if (this.serverProperties.getServlet().getContextPath() != null) {
|
if (this.serverProperties.getServlet().getContextPath() != null) {
|
||||||
container.setContextPath(this.serverProperties.getServlet().getContextPath());
|
factory.setContextPath(this.serverProperties.getServlet().getContextPath());
|
||||||
}
|
}
|
||||||
if (this.serverProperties.getDisplayName() != null) {
|
if (this.serverProperties.getDisplayName() != null) {
|
||||||
container.setDisplayName(this.serverProperties.getDisplayName());
|
factory.setDisplayName(this.serverProperties.getDisplayName());
|
||||||
}
|
}
|
||||||
if (this.serverProperties.getSession().getTimeout() != null) {
|
if (this.serverProperties.getSession().getTimeout() != null) {
|
||||||
container.setSessionTimeout(this.serverProperties.getSession().getTimeout());
|
factory.setSessionTimeout(this.serverProperties.getSession().getTimeout());
|
||||||
}
|
}
|
||||||
container.setPersistSession(this.serverProperties.getSession().isPersistent());
|
factory.setPersistSession(this.serverProperties.getSession().isPersistent());
|
||||||
container.setSessionStoreDir(this.serverProperties.getSession().getStoreDir());
|
factory.setSessionStoreDir(this.serverProperties.getSession().getStoreDir());
|
||||||
if (this.serverProperties.getSsl() != null) {
|
if (this.serverProperties.getSsl() != null) {
|
||||||
container.setSsl(this.serverProperties.getSsl());
|
factory.setSsl(this.serverProperties.getSsl());
|
||||||
}
|
}
|
||||||
if (this.serverProperties.getServlet() != null) {
|
if (this.serverProperties.getServlet() != null) {
|
||||||
container.setJsp(this.serverProperties.getServlet().getJsp());
|
factory.setJsp(this.serverProperties.getServlet().getJsp());
|
||||||
}
|
}
|
||||||
if (this.serverProperties.getCompression() != null) {
|
if (this.serverProperties.getCompression() != null) {
|
||||||
container.setCompression(this.serverProperties.getCompression());
|
factory.setCompression(this.serverProperties.getCompression());
|
||||||
}
|
}
|
||||||
container.setServerHeader(this.serverProperties.getServerHeader());
|
factory.setServerHeader(this.serverProperties.getServerHeader());
|
||||||
if (container instanceof TomcatEmbeddedServletContainerFactory) {
|
if (factory instanceof TomcatServletWebServerFactory) {
|
||||||
TomcatCustomizer.customizeTomcat(this.serverProperties, this.environment,
|
TomcatCustomizer.customizeTomcat(this.serverProperties, this.environment,
|
||||||
(TomcatEmbeddedServletContainerFactory) container);
|
(TomcatServletWebServerFactory) factory);
|
||||||
}
|
}
|
||||||
if (container instanceof JettyEmbeddedServletContainerFactory) {
|
if (factory instanceof JettyServletWebServerFactory) {
|
||||||
JettyCustomizer.customizeJetty(this.serverProperties, this.environment,
|
JettyCustomizer.customizeJetty(this.serverProperties, this.environment,
|
||||||
(JettyEmbeddedServletContainerFactory) container);
|
(JettyServletWebServerFactory) factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container instanceof UndertowEmbeddedServletContainerFactory) {
|
if (factory instanceof UndertowServletWebServerFactory) {
|
||||||
UndertowCustomizer.customizeUndertow(this.serverProperties, this.environment,
|
UndertowCustomizer.customizeUndertow(this.serverProperties, this.environment,
|
||||||
(UndertowEmbeddedServletContainerFactory) container);
|
(UndertowServletWebServerFactory) factory);
|
||||||
}
|
}
|
||||||
container.addInitializers(
|
factory.addInitializers(
|
||||||
new SessionConfiguringInitializer(this.serverProperties.getSession()));
|
new SessionConfiguringInitializer(this.serverProperties.getSession()));
|
||||||
container.addInitializers(new InitParameterConfiguringServletContextInitializer(
|
factory.addInitializers(new InitParameterConfiguringServletContextInitializer(
|
||||||
this.serverProperties.getServlet().getContextParameters()));
|
this.serverProperties.getServlet().getContextParameters()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ public class DefaultServletContainerCustomizer
|
||||||
private static class TomcatCustomizer {
|
private static class TomcatCustomizer {
|
||||||
|
|
||||||
public static void customizeTomcat(ServerProperties serverProperties,
|
public static void customizeTomcat(ServerProperties serverProperties,
|
||||||
Environment environment, TomcatEmbeddedServletContainerFactory factory) {
|
Environment environment, TomcatServletWebServerFactory factory) {
|
||||||
|
|
||||||
ServerProperties.Tomcat tomcatProperties = serverProperties.getTomcat();
|
ServerProperties.Tomcat tomcatProperties = serverProperties.getTomcat();
|
||||||
if (tomcatProperties.getBasedir() != null) {
|
if (tomcatProperties.getBasedir() != null) {
|
||||||
|
@ -266,8 +266,8 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeAcceptCount(
|
private static void customizeAcceptCount(TomcatServletWebServerFactory factory,
|
||||||
TomcatEmbeddedServletContainerFactory factory, final int acceptCount) {
|
final int acceptCount) {
|
||||||
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -282,8 +282,8 @@ public class DefaultServletContainerCustomizer
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeMaxConnections(
|
private static void customizeMaxConnections(TomcatServletWebServerFactory factory,
|
||||||
TomcatEmbeddedServletContainerFactory factory, final int maxConnections) {
|
final int maxConnections) {
|
||||||
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -299,8 +299,7 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeConnectionTimeout(
|
private static void customizeConnectionTimeout(
|
||||||
TomcatEmbeddedServletContainerFactory factory,
|
TomcatServletWebServerFactory factory, final int connectionTimeout) {
|
||||||
final int connectionTimeout) {
|
|
||||||
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -316,7 +315,7 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeRemoteIpValve(ServerProperties properties,
|
private static void customizeRemoteIpValve(ServerProperties properties,
|
||||||
Environment environment, TomcatEmbeddedServletContainerFactory factory) {
|
Environment environment, TomcatServletWebServerFactory factory) {
|
||||||
String protocolHeader = properties.getTomcat().getProtocolHeader();
|
String protocolHeader = properties.getTomcat().getProtocolHeader();
|
||||||
String remoteIpHeader = properties.getTomcat().getRemoteIpHeader();
|
String remoteIpHeader = properties.getTomcat().getRemoteIpHeader();
|
||||||
// For back compatibility the valve is also enabled if protocol-header is set
|
// For back compatibility the valve is also enabled if protocol-header is set
|
||||||
|
@ -340,8 +339,8 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private static void customizeMaxThreads(
|
private static void customizeMaxThreads(TomcatServletWebServerFactory factory,
|
||||||
TomcatEmbeddedServletContainerFactory factory, final int maxThreads) {
|
final int maxThreads) {
|
||||||
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
||||||
@Override
|
@Override
|
||||||
public void customize(Connector connector) {
|
public void customize(Connector connector) {
|
||||||
|
@ -357,8 +356,7 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private static void customizeMinThreads(
|
private static void customizeMinThreads(TomcatServletWebServerFactory factory,
|
||||||
TomcatEmbeddedServletContainerFactory factory,
|
|
||||||
final int minSpareThreads) {
|
final int minSpareThreads) {
|
||||||
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -376,8 +374,7 @@ public class DefaultServletContainerCustomizer
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private static void customizeMaxHttpHeaderSize(
|
private static void customizeMaxHttpHeaderSize(
|
||||||
TomcatEmbeddedServletContainerFactory factory,
|
TomcatServletWebServerFactory factory, final int maxHttpHeaderSize) {
|
||||||
final int maxHttpHeaderSize) {
|
|
||||||
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -393,8 +390,7 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeMaxHttpPostSize(
|
private static void customizeMaxHttpPostSize(
|
||||||
TomcatEmbeddedServletContainerFactory factory,
|
TomcatServletWebServerFactory factory, final int maxHttpPostSize) {
|
||||||
final int maxHttpPostSize) {
|
|
||||||
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -406,7 +402,7 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeAccessLog(ServerProperties.Tomcat tomcatProperties,
|
private static void customizeAccessLog(ServerProperties.Tomcat tomcatProperties,
|
||||||
TomcatEmbeddedServletContainerFactory factory) {
|
TomcatServletWebServerFactory factory) {
|
||||||
|
|
||||||
AccessLogValve valve = new AccessLogValve();
|
AccessLogValve valve = new AccessLogValve();
|
||||||
valve.setPattern(tomcatProperties.getAccesslog().getPattern());
|
valve.setPattern(tomcatProperties.getAccesslog().getPattern());
|
||||||
|
@ -423,7 +419,7 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeRedirectContextRoot(
|
private static void customizeRedirectContextRoot(
|
||||||
TomcatEmbeddedServletContainerFactory factory,
|
TomcatServletWebServerFactory factory,
|
||||||
final boolean redirectContextRoot) {
|
final boolean redirectContextRoot) {
|
||||||
factory.addContextCustomizers(new TomcatContextCustomizer() {
|
factory.addContextCustomizers(new TomcatContextCustomizer() {
|
||||||
|
|
||||||
|
@ -440,8 +436,7 @@ public class DefaultServletContainerCustomizer
|
||||||
private static class UndertowCustomizer {
|
private static class UndertowCustomizer {
|
||||||
|
|
||||||
protected static void customizeUndertow(final ServerProperties serverProperties,
|
protected static void customizeUndertow(final ServerProperties serverProperties,
|
||||||
Environment environment,
|
Environment environment, UndertowServletWebServerFactory factory) {
|
||||||
UndertowEmbeddedServletContainerFactory factory) {
|
|
||||||
|
|
||||||
ServerProperties.Undertow undertowProperties = serverProperties.getUndertow();
|
ServerProperties.Undertow undertowProperties = serverProperties.getUndertow();
|
||||||
ServerProperties.Undertow.Accesslog accesslogProperties = undertowProperties
|
ServerProperties.Undertow.Accesslog accesslogProperties = undertowProperties
|
||||||
|
@ -484,8 +479,7 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeConnectionTimeout(
|
private static void customizeConnectionTimeout(
|
||||||
UndertowEmbeddedServletContainerFactory factory,
|
UndertowServletWebServerFactory factory, final int connectionTimeout) {
|
||||||
final int connectionTimeout) {
|
|
||||||
factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
|
factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
|
||||||
@Override
|
@Override
|
||||||
public void customize(Undertow.Builder builder) {
|
public void customize(Undertow.Builder builder) {
|
||||||
|
@ -496,8 +490,7 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeMaxHttpHeaderSize(
|
private static void customizeMaxHttpHeaderSize(
|
||||||
UndertowEmbeddedServletContainerFactory factory,
|
UndertowServletWebServerFactory factory, final int maxHttpHeaderSize) {
|
||||||
final int maxHttpHeaderSize) {
|
|
||||||
factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
|
factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -510,8 +503,7 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeMaxHttpPostSize(
|
private static void customizeMaxHttpPostSize(
|
||||||
UndertowEmbeddedServletContainerFactory factory,
|
UndertowServletWebServerFactory factory, final long maxHttpPostSize) {
|
||||||
final long maxHttpPostSize) {
|
|
||||||
factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
|
factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -528,7 +520,7 @@ public class DefaultServletContainerCustomizer
|
||||||
private static class JettyCustomizer {
|
private static class JettyCustomizer {
|
||||||
|
|
||||||
public static void customizeJetty(final ServerProperties serverProperties,
|
public static void customizeJetty(final ServerProperties serverProperties,
|
||||||
Environment environment, JettyEmbeddedServletContainerFactory factory) {
|
Environment environment, JettyServletWebServerFactory factory) {
|
||||||
ServerProperties.Jetty jettyProperties = serverProperties.getJetty();
|
ServerProperties.Jetty jettyProperties = serverProperties.getJetty();
|
||||||
factory.setUseForwardHeaders(
|
factory.setUseForwardHeaders(
|
||||||
getOrDeduceUseForwardHeaders(serverProperties, environment));
|
getOrDeduceUseForwardHeaders(serverProperties, environment));
|
||||||
|
@ -553,8 +545,7 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeConnectionTimeout(
|
private static void customizeConnectionTimeout(
|
||||||
JettyEmbeddedServletContainerFactory factory,
|
JettyServletWebServerFactory factory, final int connectionTimeout) {
|
||||||
final int connectionTimeout) {
|
|
||||||
factory.addServerCustomizers(new JettyServerCustomizer() {
|
factory.addServerCustomizers(new JettyServerCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -572,8 +563,7 @@ public class DefaultServletContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeMaxHttpHeaderSize(
|
private static void customizeMaxHttpHeaderSize(
|
||||||
JettyEmbeddedServletContainerFactory factory,
|
JettyServletWebServerFactory factory, final int maxHttpHeaderSize) {
|
||||||
final int maxHttpHeaderSize) {
|
|
||||||
factory.addServerCustomizers(new JettyServerCustomizer() {
|
factory.addServerCustomizers(new JettyServerCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -619,8 +609,8 @@ public class DefaultServletContainerCustomizer
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void customizeMaxHttpPostSize(
|
private static void customizeMaxHttpPostSize(JettyServletWebServerFactory factory,
|
||||||
JettyEmbeddedServletContainerFactory factory, final int maxHttpPostSize) {
|
final int maxHttpPostSize) {
|
||||||
factory.addServerCustomizers(new JettyServerCustomizer() {
|
factory.addServerCustomizers(new JettyServerCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -53,7 +53,7 @@ import org.springframework.web.servlet.DispatcherServlet;
|
||||||
/**
|
/**
|
||||||
* {@link EnableAutoConfiguration Auto-configuration} for the Spring
|
* {@link EnableAutoConfiguration Auto-configuration} for the Spring
|
||||||
* {@link DispatcherServlet}. Should work for a standalone application where an embedded
|
* {@link DispatcherServlet}. Should work for a standalone application where an embedded
|
||||||
* servlet container is already present and also for a deployable application using
|
* web server is already present and also for a deployable application using
|
||||||
* {@link SpringBootServletInitializer}.
|
* {@link SpringBootServletInitializer}.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
@ -65,7 +65,7 @@ import org.springframework.web.servlet.DispatcherServlet;
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||||
@ConditionalOnClass(DispatcherServlet.class)
|
@ConditionalOnClass(DispatcherServlet.class)
|
||||||
@AutoConfigureAfter(EmbeddedServletContainerAutoConfiguration.class)
|
@AutoConfigureAfter(ServletWebServerFactoryAutoConfiguration.class)
|
||||||
@EnableConfigurationProperties(ServerProperties.class)
|
@EnableConfigurationProperties(ServerProperties.class)
|
||||||
public class DispatcherServletAutoConfiguration {
|
public class DispatcherServletAutoConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,11 @@ import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
||||||
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
|
||||||
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
|
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
|
||||||
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProviders;
|
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProviders;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.web.servlet.ErrorPage;
|
import org.springframework.boot.web.server.ErrorPage;
|
||||||
import org.springframework.boot.web.servlet.ErrorPageRegistrar;
|
import org.springframework.boot.web.server.ErrorPageRegistrar;
|
||||||
import org.springframework.boot.web.servlet.ErrorPageRegistry;
|
import org.springframework.boot.web.server.ErrorPageRegistry;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ConditionContext;
|
import org.springframework.context.annotation.ConditionContext;
|
||||||
|
@ -296,8 +296,7 @@ public class ErrorMvcAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EmbeddedServletContainerCustomizer} that configures the container's error
|
* {@link ServletWebServerFactoryCustomizer} that configures the server's error pages.
|
||||||
* pages.
|
|
||||||
*/
|
*/
|
||||||
private static class ErrorPageCustomizer implements ErrorPageRegistrar, Ordered {
|
private static class ErrorPageCustomizer implements ErrorPageRegistrar, Ordered {
|
||||||
|
|
||||||
|
|
|
@ -22,10 +22,10 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||||
import org.springframework.boot.autoconfigure.web.HttpEncodingProperties.Type;
|
import org.springframework.boot.autoconfigure.web.HttpEncodingProperties.Type;
|
||||||
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.web.filter.OrderedCharacterEncodingFilter;
|
import org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter;
|
||||||
|
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
|
@ -68,7 +68,7 @@ public class HttpEncodingAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class LocaleCharsetMappingsCustomizer
|
private static class LocaleCharsetMappingsCustomizer
|
||||||
implements EmbeddedServletContainerCustomizer, Ordered {
|
implements ServletWebServerFactoryCustomizer, Ordered {
|
||||||
|
|
||||||
private final HttpEncodingProperties properties;
|
private final HttpEncodingProperties properties;
|
||||||
|
|
||||||
|
@ -77,9 +77,9 @@ public class HttpEncodingAutoConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(ConfigurableEmbeddedServletContainer container) {
|
public void customize(ConfigurableServletWebServerFactory webServerFactory) {
|
||||||
if (this.properties.getMapping() != null) {
|
if (this.properties.getMapping() != null) {
|
||||||
container.setLocaleCharsetMappings(this.properties.getMapping());
|
webServerFactory.setLocaleCharsetMappings(this.properties.getMapping());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -23,8 +23,8 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.multipart.MultipartResolver;
|
import org.springframework.web.multipart.MultipartResolver;
|
||||||
|
@ -35,11 +35,11 @@ import org.springframework.web.servlet.DispatcherServlet;
|
||||||
* {@link EnableAutoConfiguration Auto-configuration} for multi-part uploads. Adds a
|
* {@link EnableAutoConfiguration Auto-configuration} for multi-part uploads. Adds a
|
||||||
* {@link StandardServletMultipartResolver} if none is present, and adds a
|
* {@link StandardServletMultipartResolver} if none is present, and adds a
|
||||||
* {@link javax.servlet.MultipartConfigElement multipartConfigElement} if none is
|
* {@link javax.servlet.MultipartConfigElement multipartConfigElement} if none is
|
||||||
* otherwise defined. The {@link EmbeddedWebApplicationContext} will associate the
|
* otherwise defined. The {@link ServletWebServerApplicationContext} will associate the
|
||||||
* {@link MultipartConfigElement} bean to any {@link Servlet} beans.
|
* {@link MultipartConfigElement} bean to any {@link Servlet} beans.
|
||||||
* <p>
|
* <p>
|
||||||
* The {@link javax.servlet.MultipartConfigElement} is a Servlet API that's used to
|
* The {@link javax.servlet.MultipartConfigElement} is a Servlet API that's used to
|
||||||
* configure how the container handles file uploads. By default
|
* configure how the server handles file uploads. By default
|
||||||
*
|
*
|
||||||
* @author Greg Turnquist
|
* @author Greg Turnquist
|
||||||
* @author Josh Long
|
* @author Josh Long
|
||||||
|
|
|
@ -20,15 +20,20 @@ import java.io.File;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.Compression;
|
|
||||||
import org.springframework.boot.context.embedded.Servlet;
|
|
||||||
import org.springframework.boot.context.embedded.Ssl;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
||||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||||
|
import org.springframework.boot.web.server.Compression;
|
||||||
|
import org.springframework.boot.web.server.Ssl;
|
||||||
|
import org.springframework.boot.web.servlet.server.Jsp;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link ConfigurationProperties} for a web server (e.g. port and path settings).
|
* {@link ConfigurationProperties} for a web server (e.g. port and path settings).
|
||||||
|
@ -82,8 +87,8 @@ public class ServerProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Time in milliseconds that connectors will wait for another HTTP request before
|
* Time in milliseconds that connectors will wait for another HTTP request before
|
||||||
* closing the connection. When not set, the connector's container-specific default
|
* closing the connection. When not set, the connector's server-specific default will
|
||||||
* will be used. Use a value of -1 to indicate no (i.e. infinite) timeout.
|
* be used. Use a value of -1 to indicate no (i.e. infinite) timeout.
|
||||||
*/
|
*/
|
||||||
private Integer connectionTimeout;
|
private Integer connectionTimeout;
|
||||||
|
|
||||||
|
@ -95,7 +100,6 @@ public class ServerProperties {
|
||||||
@NestedConfigurationProperty
|
@NestedConfigurationProperty
|
||||||
private Compression compression = new Compression();
|
private Compression compression = new Compression();
|
||||||
|
|
||||||
@NestedConfigurationProperty
|
|
||||||
private Servlet servlet = new Servlet();
|
private Servlet servlet = new Servlet();
|
||||||
|
|
||||||
private final Tomcat tomcat = new Tomcat();
|
private final Tomcat tomcat = new Tomcat();
|
||||||
|
@ -204,6 +208,120 @@ public class ServerProperties {
|
||||||
return this.undertow;
|
return this.undertow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Servlet properties.
|
||||||
|
*/
|
||||||
|
public class Servlet {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ServletContext parameters.
|
||||||
|
*/
|
||||||
|
private final Map<String, String> contextParameters = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context path of the application.
|
||||||
|
*/
|
||||||
|
private String contextPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path of the main dispatcher servlet.
|
||||||
|
*/
|
||||||
|
private String path = "/";
|
||||||
|
|
||||||
|
@NestedConfigurationProperty
|
||||||
|
private Jsp jsp = new Jsp();
|
||||||
|
|
||||||
|
public String getContextPath() {
|
||||||
|
return this.contextPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContextPath(String contextPath) {
|
||||||
|
this.contextPath = cleanContextPath(contextPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String cleanContextPath(String contextPath) {
|
||||||
|
if (StringUtils.hasText(contextPath) && contextPath.endsWith("/")) {
|
||||||
|
return contextPath.substring(0, contextPath.length() - 1);
|
||||||
|
}
|
||||||
|
return contextPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return this.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(String path) {
|
||||||
|
Assert.notNull(path, "Path must not be null");
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getContextParameters() {
|
||||||
|
return this.contextParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Jsp getJsp() {
|
||||||
|
return this.jsp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJsp(Jsp jsp) {
|
||||||
|
this.jsp = jsp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServletMapping() {
|
||||||
|
if (this.path.equals("") || this.path.equals("/")) {
|
||||||
|
return "/";
|
||||||
|
}
|
||||||
|
if (this.path.contains("*")) {
|
||||||
|
return this.path;
|
||||||
|
}
|
||||||
|
if (this.path.endsWith("/")) {
|
||||||
|
return this.path + "*";
|
||||||
|
}
|
||||||
|
return this.path + "/*";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath(String path) {
|
||||||
|
String prefix = getServletPrefix();
|
||||||
|
if (!path.startsWith("/")) {
|
||||||
|
path = "/" + path;
|
||||||
|
}
|
||||||
|
return prefix + path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServletPrefix() {
|
||||||
|
String result = this.path;
|
||||||
|
if (result.contains("*")) {
|
||||||
|
result = result.substring(0, result.indexOf("*"));
|
||||||
|
}
|
||||||
|
if (result.endsWith("/")) {
|
||||||
|
result = result.substring(0, result.length() - 1);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getPathsArray(Collection<String> paths) {
|
||||||
|
String[] result = new String[paths.size()];
|
||||||
|
int i = 0;
|
||||||
|
for (String path : paths) {
|
||||||
|
result[i++] = getPath(path);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getPathsArray(String[] paths) {
|
||||||
|
String[] result = new String[paths.length];
|
||||||
|
int i = 0;
|
||||||
|
for (String path : paths) {
|
||||||
|
result[i++] = getPath(path);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Session properties.
|
||||||
|
*/
|
||||||
public static class Session {
|
public static class Session {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,6 +382,9 @@ public class ServerProperties {
|
||||||
this.storeDir = storeDir;
|
this.storeDir = storeDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cookie properties.
|
||||||
|
*/
|
||||||
public static class Cookie {
|
public static class Cookie {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -384,6 +505,9 @@ public class ServerProperties {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tomcat properties.
|
||||||
|
*/
|
||||||
public static class Tomcat {
|
public static class Tomcat {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -615,6 +739,9 @@ public class ServerProperties {
|
||||||
this.additionalTldSkipPatterns = additionalTldSkipPatterns;
|
this.additionalTldSkipPatterns = additionalTldSkipPatterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tomcat access log properties.
|
||||||
|
*/
|
||||||
public static class Accesslog {
|
public static class Accesslog {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -753,6 +880,9 @@ public class ServerProperties {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Jetty properties.
|
||||||
|
*/
|
||||||
public static class Jetty {
|
public static class Jetty {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -796,6 +926,9 @@ public class ServerProperties {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undertow properties.
|
||||||
|
*/
|
||||||
public static class Undertow {
|
public static class Undertow {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -884,6 +1017,9 @@ public class ServerProperties {
|
||||||
return this.accesslog;
|
return this.accesslog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undertow access log properties.
|
||||||
|
*/
|
||||||
public static class Accesslog {
|
public static class Accesslog {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -38,14 +38,14 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||||
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration.BeanPostProcessorsRegistrar;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration.BeanPostProcessorsRegistrar;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.web.servlet.ErrorPageRegistrarBeanPostProcessor;
|
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.server.ErrorPageRegistrarBeanPostProcessor;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
@ -55,7 +55,7 @@ import org.springframework.core.type.AnnotationMetadata;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EnableAutoConfiguration Auto-configuration} for an embedded servlet containers.
|
* {@link EnableAutoConfiguration Auto-configuration} for servlet web servers.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
|
@ -68,13 +68,13 @@ import org.springframework.util.ObjectUtils;
|
||||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||||
@EnableConfigurationProperties(ServerProperties.class)
|
@EnableConfigurationProperties(ServerProperties.class)
|
||||||
@Import(BeanPostProcessorsRegistrar.class)
|
@Import(BeanPostProcessorsRegistrar.class)
|
||||||
public class EmbeddedServletContainerAutoConfiguration {
|
public class ServletWebServerFactoryAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public DefaultServletContainerCustomizer serverPropertiesServletContainerCustomizer(
|
public DefaultServletWebServerFactoryCustomizer serverPropertiesWebServerFactoryCustomizer(
|
||||||
ServerProperties serverProperties) {
|
ServerProperties serverProperties) {
|
||||||
return new DefaultServletContainerCustomizer(serverProperties);
|
return new DefaultServletWebServerFactoryCustomizer(serverProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,12 +82,12 @@ public class EmbeddedServletContainerAutoConfiguration {
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnClass({ Servlet.class, Tomcat.class })
|
@ConditionalOnClass({ Servlet.class, Tomcat.class })
|
||||||
@ConditionalOnMissingBean(value = EmbeddedServletContainerFactory.class, search = SearchStrategy.CURRENT)
|
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
|
||||||
public static class EmbeddedTomcat {
|
public static class EmbeddedTomcat {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() {
|
public TomcatServletWebServerFactory tomcatServletWebServerFactory() {
|
||||||
return new TomcatEmbeddedServletContainerFactory();
|
return new TomcatServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,12 +98,12 @@ public class EmbeddedServletContainerAutoConfiguration {
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnClass({ Servlet.class, Server.class, Loader.class,
|
@ConditionalOnClass({ Servlet.class, Server.class, Loader.class,
|
||||||
WebAppContext.class })
|
WebAppContext.class })
|
||||||
@ConditionalOnMissingBean(value = EmbeddedServletContainerFactory.class, search = SearchStrategy.CURRENT)
|
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
|
||||||
public static class EmbeddedJetty {
|
public static class EmbeddedJetty {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory() {
|
public JettyServletWebServerFactory JettyServletWebServerFactory() {
|
||||||
return new JettyEmbeddedServletContainerFactory();
|
return new JettyServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -113,18 +113,18 @@ public class EmbeddedServletContainerAutoConfiguration {
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnClass({ Servlet.class, Undertow.class, SslClientAuthMode.class })
|
@ConditionalOnClass({ Servlet.class, Undertow.class, SslClientAuthMode.class })
|
||||||
@ConditionalOnMissingBean(value = EmbeddedServletContainerFactory.class, search = SearchStrategy.CURRENT)
|
@ConditionalOnMissingBean(value = ServletWebServerFactory.class, search = SearchStrategy.CURRENT)
|
||||||
public static class EmbeddedUndertow {
|
public static class EmbeddedUndertow {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public UndertowEmbeddedServletContainerFactory undertowEmbeddedServletContainerFactory() {
|
public UndertowServletWebServerFactory undertowServletWebServerFactory() {
|
||||||
return new UndertowEmbeddedServletContainerFactory();
|
return new UndertowServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a {@link EmbeddedServletContainerCustomizerBeanPostProcessor}. Registered
|
* Registers a {@link ServletWebServerFactoryCustomizerBeanPostProcessor}. Registered
|
||||||
* via {@link ImportBeanDefinitionRegistrar} for early registration.
|
* via {@link ImportBeanDefinitionRegistrar} for early registration.
|
||||||
*/
|
*/
|
||||||
public static class BeanPostProcessorsRegistrar
|
public static class BeanPostProcessorsRegistrar
|
||||||
|
@ -146,8 +146,8 @@ public class EmbeddedServletContainerAutoConfiguration {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
registerSyntheticBeanIfMissing(registry,
|
registerSyntheticBeanIfMissing(registry,
|
||||||
"embeddedServletContainerCustomizerBeanPostProcessor",
|
"ServletWebServerCustomizerBeanPostProcessor",
|
||||||
EmbeddedServletContainerCustomizerBeanPostProcessor.class);
|
ServletWebServerFactoryCustomizerBeanPostProcessor.class);
|
||||||
registerSyntheticBeanIfMissing(registry,
|
registerSyntheticBeanIfMissing(registry,
|
||||||
"errorPageRegistrarBeanPostProcessor",
|
"errorPageRegistrarBeanPostProcessor",
|
||||||
ErrorPageRegistrarBeanPostProcessor.class);
|
ErrorPageRegistrarBeanPostProcessor.class);
|
|
@ -47,9 +47,9 @@ import org.springframework.boot.autoconfigure.validation.SpringValidator;
|
||||||
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
|
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.ResourceProperties.Strategy;
|
import org.springframework.boot.autoconfigure.web.ResourceProperties.Strategy;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.web.filter.OrderedHiddenHttpMethodFilter;
|
import org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter;
|
||||||
import org.springframework.boot.web.filter.OrderedHttpPutFormContentFilter;
|
import org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter;
|
||||||
import org.springframework.boot.web.filter.OrderedRequestContextFilter;
|
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -15,6 +15,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auto-configuration for embedded servlet containers and Spring MVC.
|
* Auto-configuration for embedded web servers and Spring MVC.
|
||||||
*/
|
*/
|
||||||
package org.springframework.boot.autoconfigure.web;
|
package org.springframework.boot.autoconfigure.web;
|
||||||
|
|
|
@ -17,15 +17,15 @@
|
||||||
package org.springframework.boot.autoconfigure.webflux;
|
package org.springframework.boot.autoconfigure.webflux;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||||
import org.springframework.boot.context.embedded.ConfigurableReactiveWebServer;
|
import org.springframework.boot.web.reactive.server.ConfigurableReactiveWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
|
import org.springframework.boot.web.reactive.server.ReactiveWebServerCustomizer;
|
||||||
import org.springframework.boot.context.embedded.ReactiveWebServerCustomizer;
|
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.ReactiveWebServerFactory;
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customizer used by an {@link ReactiveWebServerFactory} when an
|
* Customizer used by an {@link ReactiveWebServerFactory} when an
|
||||||
* {@link EmbeddedServletContainerCustomizerBeanPostProcessor} is active.
|
* {@link ServletWebServerFactoryCustomizerBeanPostProcessor} is active.
|
||||||
*
|
*
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
|
@ -45,7 +45,7 @@ public class DefaultReactiveWebServerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(ConfigurableReactiveWebServer server) {
|
public void customize(ConfigurableReactiveWebServerFactory server) {
|
||||||
if (this.serverProperties.getPort() != null) {
|
if (this.serverProperties.getPort() != null) {
|
||||||
server.setPort(this.serverProperties.getPort());
|
server.setPort(this.serverProperties.getPort());
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||||
import org.springframework.boot.context.embedded.ReactiveWebServerCustomizerBeanPostProcessor;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.boot.web.reactive.server.ReactiveWebServerCustomizerBeanPostProcessor;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
|
@ -21,11 +21,11 @@ import reactor.ipc.netty.http.server.HttpServer;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.context.embedded.ReactiveWebServerFactory;
|
import org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyReactiveWebServerFactory;
|
import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.reactor.ReactorNettyReactiveWebServerFactory;
|
import org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatReactiveWebServerFactory;
|
import org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowReactiveWebServerFactory;
|
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,8 +43,8 @@ abstract class ReactiveWebServerConfiguration {
|
||||||
static class ReactorNettyAutoConfiguration {
|
static class ReactorNettyAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ReactorNettyReactiveWebServerFactory reactorNettyReactiveWebServerFactory() {
|
public NettyReactiveWebServerFactory NettyReactiveWebServerFactory() {
|
||||||
return new ReactorNettyReactiveWebServerFactory();
|
return new NettyReactiveWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
@ -46,7 +46,7 @@ import org.springframework.ws.transport.http.MessageDispatcherServlet;
|
||||||
@ConditionalOnClass(MessageDispatcherServlet.class)
|
@ConditionalOnClass(MessageDispatcherServlet.class)
|
||||||
@ConditionalOnMissingBean(WsConfigurationSupport.class)
|
@ConditionalOnMissingBean(WsConfigurationSupport.class)
|
||||||
@EnableConfigurationProperties(WebServicesProperties.class)
|
@EnableConfigurationProperties(WebServicesProperties.class)
|
||||||
@AutoConfigureAfter(EmbeddedServletContainerAutoConfiguration.class)
|
@AutoConfigureAfter(ServletWebServerFactoryAutoConfiguration.class)
|
||||||
public class WebServicesAutoConfiguration {
|
public class WebServicesAutoConfiguration {
|
||||||
|
|
||||||
private final WebServicesProperties properties;
|
private final WebServicesProperties properties;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -22,10 +22,10 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
||||||
import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
|
import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
|
||||||
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
|
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link WebSocketContainerCustomizer} for {@link JettyEmbeddedServletContainerFactory}.
|
* {@link WebSocketContainerCustomizer} for {@link JettyServletWebServerFactory}.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
@ -33,11 +33,11 @@ import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletConta
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
public class JettyWebSocketContainerCustomizer
|
public class JettyWebSocketContainerCustomizer
|
||||||
extends WebSocketContainerCustomizer<JettyEmbeddedServletContainerFactory> {
|
extends WebSocketContainerCustomizer<JettyServletWebServerFactory> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doCustomize(JettyEmbeddedServletContainerFactory container) {
|
protected void doCustomize(JettyServletWebServerFactory factory) {
|
||||||
container.addConfigurations(new AbstractConfiguration() {
|
factory.addConfigurations(new AbstractConfiguration() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(WebAppContext context) throws Exception {
|
public void configure(WebAppContext context) throws Exception {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -21,13 +21,13 @@ import java.lang.reflect.Constructor;
|
||||||
import org.apache.catalina.Context;
|
import org.apache.catalina.Context;
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer;
|
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link WebSocketContainerCustomizer} for {@link TomcatEmbeddedServletContainerFactory}.
|
* {@link WebSocketContainerCustomizer} for {@link TomcatServletWebServerFactory}.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
@ -35,7 +35,7 @@ import org.springframework.util.ReflectionUtils;
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
public class TomcatWebSocketContainerCustomizer
|
public class TomcatWebSocketContainerCustomizer
|
||||||
extends WebSocketContainerCustomizer<TomcatEmbeddedServletContainerFactory> {
|
extends WebSocketContainerCustomizer<TomcatServletWebServerFactory> {
|
||||||
|
|
||||||
private static final String TOMCAT_7_LISTENER_TYPE = "org.apache.catalina.deploy.ApplicationListener";
|
private static final String TOMCAT_7_LISTENER_TYPE = "org.apache.catalina.deploy.ApplicationListener";
|
||||||
|
|
||||||
|
@ -44,12 +44,14 @@ public class TomcatWebSocketContainerCustomizer
|
||||||
private static final String WS_LISTENER = "org.apache.tomcat.websocket.server.WsContextListener";
|
private static final String WS_LISTENER = "org.apache.tomcat.websocket.server.WsContextListener";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doCustomize(TomcatEmbeddedServletContainerFactory tomcatContainer) {
|
public void doCustomize(TomcatServletWebServerFactory factory) {
|
||||||
tomcatContainer.addContextCustomizers(new TomcatContextCustomizer() {
|
factory.addContextCustomizers(new TomcatContextCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(Context context) {
|
public void customize(Context context) {
|
||||||
addListener(context, findListenerType());
|
addListener(context, findListenerType());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,10 +67,9 @@ public class TomcatWebSocketContainerCustomizer
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instead of registering the WsSci directly as a ServletContainerInitializer, we use
|
* Instead of registering directly as a ServletContainerInitializer, we use the
|
||||||
* the ApplicationListener provided by Tomcat. Unfortunately the ApplicationListener
|
* ApplicationListener provided by Tomcat. Unfortunately the ApplicationListener class
|
||||||
* class moved packages in Tomcat 8 and been deleted in 8.0.8 so we have to use
|
* moved packages in Tomcat 8 and been deleted in 8.0.8 so we have to use reflection.
|
||||||
* reflection.
|
|
||||||
* @param context the current context
|
* @param context the current context
|
||||||
* @param listenerType the type of listener to add
|
* @param listenerType the type of listener to add
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -19,23 +19,22 @@ package org.springframework.boot.autoconfigure.websocket;
|
||||||
import io.undertow.servlet.api.DeploymentInfo;
|
import io.undertow.servlet.api.DeploymentInfo;
|
||||||
import io.undertow.websockets.jsr.WebSocketDeploymentInfo;
|
import io.undertow.websockets.jsr.WebSocketDeploymentInfo;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowDeploymentInfoCustomizer;
|
import org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer;
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link WebSocketContainerCustomizer} for
|
* {@link WebSocketContainerCustomizer} for {@link UndertowServletWebServerFactory}.
|
||||||
* {@link UndertowEmbeddedServletContainerFactory}.
|
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
public class UndertowWebSocketContainerCustomizer
|
public class UndertowWebSocketContainerCustomizer
|
||||||
extends WebSocketContainerCustomizer<UndertowEmbeddedServletContainerFactory> {
|
extends WebSocketContainerCustomizer<UndertowServletWebServerFactory> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doCustomize(UndertowEmbeddedServletContainerFactory container) {
|
protected void doCustomize(UndertowServletWebServerFactory factory) {
|
||||||
WebsocketDeploymentInfoCustomizer customizer = new WebsocketDeploymentInfoCustomizer();
|
WebsocketDeploymentInfoCustomizer customizer = new WebsocketDeploymentInfoCustomizer();
|
||||||
container.addDeploymentInfoCustomizers(customizer);
|
factory.addDeploymentInfoCustomizers(customizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class WebsocketDeploymentInfoCustomizer
|
private static class WebsocketDeploymentInfoCustomizer
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@ -36,16 +36,16 @@ import org.springframework.context.annotation.Configuration;
|
||||||
* the appropriate WebSocket modules to be on the classpath.
|
* the appropriate WebSocket modules to be on the classpath.
|
||||||
* <p>
|
* <p>
|
||||||
* If Tomcat's WebSocket support is detected on the classpath we add a customizer that
|
* If Tomcat's WebSocket support is detected on the classpath we add a customizer that
|
||||||
* installs the Tomcat Websocket initializer. In a non-embedded container it should
|
* installs the Tomcat Websocket initializer. In a non-embedded server it should already
|
||||||
* already be there.
|
* be there.
|
||||||
* <p>
|
* <p>
|
||||||
* If Jetty's WebSocket support is detected on the classpath we add a configuration that
|
* If Jetty's WebSocket support is detected on the classpath we add a configuration that
|
||||||
* configures the context with WebSocket support. In a non-embedded container it should
|
* configures the context with WebSocket support. In a non-embedded server it should
|
||||||
* already be there.
|
* already be there.
|
||||||
* <p>
|
* <p>
|
||||||
* If Undertow's WebSocket support is detected on the classpath we add a customizer that
|
* If Undertow's WebSocket support is detected on the classpath we add a customizer that
|
||||||
* installs the Undertow Websocket DeploymentInfo Customizer. In a non-embedded container
|
* installs the Undertow Websocket DeploymentInfo Customizer. In a non-embedded server it
|
||||||
* it should already be there.
|
* should already be there.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
@ -54,7 +54,7 @@ import org.springframework.context.annotation.Configuration;
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnClass({ Servlet.class, ServerContainer.class })
|
@ConditionalOnClass({ Servlet.class, ServerContainer.class })
|
||||||
@ConditionalOnWebApplication(type = Type.SERVLET)
|
@ConditionalOnWebApplication(type = Type.SERVLET)
|
||||||
@AutoConfigureBefore(EmbeddedServletContainerAutoConfiguration.class)
|
@AutoConfigureBefore(ServletWebServerFactoryAutoConfiguration.class)
|
||||||
public class WebSocketAutoConfiguration {
|
public class WebSocketAutoConfiguration {
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,24 +16,24 @@
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.websocket;
|
package org.springframework.boot.autoconfigure.websocket;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EmbeddedServletContainerCustomizer} to configure websockets for a given
|
* {@link ServletWebServerFactoryCustomizer} to configure websockets for a given
|
||||||
* {@link EmbeddedServletContainerFactory}.
|
* {@link ServletWebServerFactory}.
|
||||||
*
|
*
|
||||||
* @param <T> the embedded servlet container factory
|
* @param <T> the {@link ServletWebServerFactory}
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
public abstract class WebSocketContainerCustomizer<T extends EmbeddedServletContainerFactory>
|
public abstract class WebSocketContainerCustomizer<T extends ServletWebServerFactory>
|
||||||
implements EmbeddedServletContainerCustomizer, Ordered {
|
implements ServletWebServerFactoryCustomizer, Ordered {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
|
@ -42,17 +42,17 @@ public abstract class WebSocketContainerCustomizer<T extends EmbeddedServletCont
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void customize(ConfigurableEmbeddedServletContainer container) {
|
public void customize(ConfigurableServletWebServerFactory factory) {
|
||||||
if (getContainerType().isAssignableFrom(container.getClass())) {
|
if (getWebServerFactoryType().isAssignableFrom(factory.getClass())) {
|
||||||
doCustomize((T) container);
|
doCustomize((T) factory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Class<?> getContainerType() {
|
protected Class<?> getWebServerFactoryType() {
|
||||||
return ResolvableType.forClass(WebSocketContainerCustomizer.class, getClass())
|
return ResolvableType.forClass(WebSocketContainerCustomizer.class, getClass())
|
||||||
.resolveGeneric();
|
.resolveGeneric();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void doCustomize(T container);
|
protected abstract void doCustomize(T factory);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,
|
||||||
org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\
|
org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\
|
||||||
org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\
|
org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\
|
||||||
org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration,\
|
org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration,\
|
||||||
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration,\
|
org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration,\
|
||||||
org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration,\
|
org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration,\
|
||||||
org.springframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration,\
|
org.springframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration,\
|
||||||
org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration,\
|
org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration,\
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.junit.After;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.ImportResource;
|
import org.springframework.context.annotation.ImportResource;
|
||||||
|
@ -48,7 +48,7 @@ public class AutoConfigurationReproTests {
|
||||||
public void doesNotEarlyInitializeFactoryBeans() throws Exception {
|
public void doesNotEarlyInitializeFactoryBeans() throws Exception {
|
||||||
SpringApplication application = new SpringApplication(EarlyInitConfig.class,
|
SpringApplication application = new SpringApplication(EarlyInitConfig.class,
|
||||||
PropertySourcesPlaceholderConfigurer.class,
|
PropertySourcesPlaceholderConfigurer.class,
|
||||||
EmbeddedServletContainerAutoConfiguration.class);
|
ServletWebServerFactoryAutoConfiguration.class);
|
||||||
this.context = application.run("--server.port=0");
|
this.context = application.run("--server.port=0");
|
||||||
String bean = (String) this.context.getBean("earlyInit");
|
String bean = (String) this.context.getBean("earlyInit");
|
||||||
assertThat(bean).isEqualTo("bucket");
|
assertThat(bean).isEqualTo("bucket");
|
||||||
|
|
|
@ -36,10 +36,10 @@ import org.springframework.boot.WebApplicationType;
|
||||||
import org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar;
|
import org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar;
|
||||||
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
|
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
|
|
||||||
|
@ -119,16 +119,16 @@ public class SpringApplicationAdminJmxAutoConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void registerWithSimpleWebApp() throws Exception {
|
public void registerWithSimpleWebApp() throws Exception {
|
||||||
this.context = new SpringApplicationBuilder()
|
this.context = new SpringApplicationBuilder()
|
||||||
.sources(EmbeddedServletContainerAutoConfiguration.class,
|
.sources(ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class,
|
||||||
JmxAutoConfiguration.class,
|
JmxAutoConfiguration.class,
|
||||||
SpringApplicationAdminJmxAutoConfiguration.class)
|
SpringApplicationAdminJmxAutoConfiguration.class)
|
||||||
.run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
|
.run("--" + ENABLE_ADMIN_PROP, "--server.port=0");
|
||||||
assertThat(this.context).isInstanceOf(EmbeddedWebApplicationContext.class);
|
assertThat(this.context).isInstanceOf(ServletWebServerApplicationContext.class);
|
||||||
assertThat(this.mBeanServer.getAttribute(createDefaultObjectName(),
|
assertThat(this.mBeanServer.getAttribute(createDefaultObjectName(),
|
||||||
"EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
|
"EmbeddedWebApplication")).isEqualTo(Boolean.TRUE);
|
||||||
int expected = ((EmbeddedWebApplicationContext) this.context)
|
int expected = ((ServletWebServerApplicationContext) this.context)
|
||||||
.getEmbeddedWebServer().getPort();
|
.getWebServer().getPort();
|
||||||
String actual = getProperty(createDefaultObjectName(), "local.server.port");
|
String actual = getProperty(createDefaultObjectName(), "local.server.port");
|
||||||
assertThat(actual).isEqualTo(String.valueOf(expected));
|
assertThat(actual).isEqualTo(String.valueOf(expected));
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ import org.junit.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.webflux.MockReactiveWebServerFactory;
|
import org.springframework.boot.autoconfigure.webflux.MockReactiveWebServerFactory;
|
||||||
import org.springframework.boot.context.GenericReactiveWebApplicationContext;
|
import org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext;
|
||||||
import org.springframework.boot.context.embedded.ReactiveWebServerFactory;
|
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
|
@ -22,8 +22,8 @@ import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
|
||||||
import org.springframework.boot.autoconfigure.webflux.MockReactiveWebServerFactory;
|
import org.springframework.boot.autoconfigure.webflux.MockReactiveWebServerFactory;
|
||||||
import org.springframework.boot.context.GenericReactiveWebApplicationContext;
|
import org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext;
|
||||||
import org.springframework.boot.context.embedded.ReactiveWebServerFactory;
|
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
@ -95,7 +95,7 @@ public class JerseyAutoConfigurationCustomFilterContextPathTests {
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
||||||
protected @interface MinimalWebConfiguration {
|
protected @interface MinimalWebConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
@ -94,7 +94,7 @@ public class JerseyAutoConfigurationCustomFilterPathTests {
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
||||||
protected @interface MinimalWebConfiguration {
|
protected @interface MinimalWebConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.DirectFieldAccessor;
|
import org.springframework.beans.DirectFieldAccessor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
@ -73,7 +73,7 @@ public class JerseyAutoConfigurationCustomLoadOnStartupTests {
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
||||||
protected @interface MinimalWebConfiguration {
|
protected @interface MinimalWebConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
@ -121,7 +121,7 @@ public class JerseyAutoConfigurationCustomObjectMapperProviderTests {
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
JacksonAutoConfiguration.class, JerseyAutoConfiguration.class,
|
JacksonAutoConfiguration.class, JerseyAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class })
|
PropertyPlaceholderAutoConfiguration.class })
|
||||||
protected @interface MinimalWebConfiguration {
|
protected @interface MinimalWebConfiguration {
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
@ -95,7 +95,7 @@ public class JerseyAutoConfigurationCustomServletContextPathTests {
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
||||||
protected @interface MinimalWebConfiguration {
|
protected @interface MinimalWebConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
@ -95,7 +95,7 @@ public class JerseyAutoConfigurationCustomServletPathTests {
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
||||||
protected @interface MinimalWebConfiguration {
|
protected @interface MinimalWebConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
@ -92,7 +92,7 @@ public class JerseyAutoConfigurationDefaultFilterPathTests {
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
||||||
protected @interface MinimalWebConfiguration {
|
protected @interface MinimalWebConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
@ -93,7 +93,7 @@ public class JerseyAutoConfigurationDefaultServletPathTests {
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
||||||
protected @interface MinimalWebConfiguration {
|
protected @interface MinimalWebConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
@ -132,7 +132,7 @@ public class JerseyAutoConfigurationObjectMapperProviderTests {
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
JacksonAutoConfiguration.class, JerseyAutoConfiguration.class,
|
JacksonAutoConfiguration.class, JerseyAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class })
|
PropertyPlaceholderAutoConfiguration.class })
|
||||||
protected @interface MinimalWebConfiguration {
|
protected @interface MinimalWebConfiguration {
|
||||||
|
|
|
@ -32,11 +32,11 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationServletContainerTests.Application;
|
import org.springframework.boot.autoconfigure.jersey.JerseyAutoConfigurationServletContainerTests.Application;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.rule.OutputCapture;
|
import org.springframework.boot.test.rule.OutputCapture;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
@ -67,7 +67,7 @@ public class JerseyAutoConfigurationServletContainerTests {
|
||||||
"Servlet " + Application.class.getName() + " was not registered");
|
"Servlet " + Application.class.getName() + " was not registered");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ImportAutoConfiguration({ EmbeddedServletContainerAutoConfiguration.class,
|
@ImportAutoConfiguration({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
||||||
@Import(ContainerConfiguration.class)
|
@Import(ContainerConfiguration.class)
|
||||||
@Path("/hello")
|
@Path("/hello")
|
||||||
|
@ -91,8 +91,8 @@ public class JerseyAutoConfigurationServletContainerTests {
|
||||||
public static class ContainerConfiguration {
|
public static class ContainerConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TomcatEmbeddedServletContainerFactory tomcat() {
|
public TomcatServletWebServerFactory tomcat() {
|
||||||
return new TomcatEmbeddedServletContainerFactory() {
|
return new TomcatServletWebServerFactory() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void postProcessContext(Context context) {
|
protected void postProcessContext(Context context) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
@ -92,7 +92,7 @@ public class JerseyAutoConfigurationWithoutApplicationPathTests {
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
JerseyAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class })
|
||||||
protected @interface MinimalWebConfiguration {
|
protected @interface MinimalWebConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
@ -58,13 +58,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
public class MustacheAutoConfigurationIntegrationTests {
|
public class MustacheAutoConfigurationIntegrationTests {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmbeddedWebApplicationContext context;
|
private ServletWebServerApplicationContext context;
|
||||||
|
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
this.port = this.context.getEmbeddedWebServer().getPort();
|
this.port = this.context.getWebServer().getPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -112,7 +112,7 @@ public class MustacheAutoConfigurationIntegrationTests {
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Import({ MustacheAutoConfiguration.class,
|
@Import({ MustacheAutoConfiguration.class,
|
||||||
EmbeddedServletContainerAutoConfiguration.class,
|
ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class })
|
PropertyPlaceholderAutoConfiguration.class })
|
||||||
protected @interface MinimalWebConfiguration {
|
protected @interface MinimalWebConfiguration {
|
||||||
|
|
|
@ -37,11 +37,11 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
|
||||||
import org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration;
|
import org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.mustache.MustacheResourceTemplateLoader;
|
import org.springframework.boot.autoconfigure.mustache.MustacheResourceTemplateLoader;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
@ -64,13 +64,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
public class MustacheWebIntegrationTests {
|
public class MustacheWebIntegrationTests {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmbeddedWebApplicationContext context;
|
private ServletWebServerApplicationContext context;
|
||||||
|
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
this.port = this.context.getEmbeddedWebServer().getPort();
|
this.port = this.context.getWebServer().getPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -138,7 +138,7 @@ public class MustacheWebIntegrationTests {
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class })
|
PropertyPlaceholderAutoConfiguration.class })
|
||||||
protected @interface MinimalWebConfiguration {
|
protected @interface MinimalWebConfiguration {
|
||||||
|
|
|
@ -33,10 +33,10 @@ import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
@ -58,13 +58,13 @@ public class SecurityFilterAutoConfigurationEarlyInitializationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSecurityFilterDoesNotCauseEarlyInitialization() throws Exception {
|
public void testSecurityFilterDoesNotCauseEarlyInitialization() throws Exception {
|
||||||
AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext();
|
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
try {
|
try {
|
||||||
EnvironmentTestUtils.addEnvironment(context, "server.port:0",
|
EnvironmentTestUtils.addEnvironment(context, "server.port:0",
|
||||||
"security.user.password:password");
|
"security.user.password:password");
|
||||||
context.register(Config.class);
|
context.register(Config.class);
|
||||||
context.refresh();
|
context.refresh();
|
||||||
int port = context.getEmbeddedWebServer().getPort();
|
int port = context.getWebServer().getPort();
|
||||||
new TestRestTemplate("user", "password")
|
new TestRestTemplate("user", "password")
|
||||||
.getForEntity("http://localhost:" + port, Object.class);
|
.getForEntity("http://localhost:" + port, Object.class);
|
||||||
// If early initialization occurred a ConverterNotFoundException is thrown
|
// If early initialization occurred a ConverterNotFoundException is thrown
|
||||||
|
@ -87,8 +87,8 @@ public class SecurityFilterAutoConfigurationEarlyInitializationTests {
|
||||||
static class Config {
|
static class Config {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TomcatEmbeddedServletContainerFactory containerFactory() {
|
public TomcatServletWebServerFactory webServerFactory() {
|
||||||
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
factory.setPort(0);
|
factory.setPort(0);
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
@ -321,7 +321,7 @@ public class SpringBootWebSecurityConfigurationTests {
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class })
|
PropertyPlaceholderAutoConfiguration.class })
|
||||||
|
|
|
@ -34,10 +34,10 @@ import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceS
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
@ -116,11 +116,11 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
private static final Class<?> AUTHORIZATION_SERVER_CONFIG = OAuth2AuthorizationServerConfiguration.class;
|
private static final Class<?> AUTHORIZATION_SERVER_CONFIG = OAuth2AuthorizationServerConfiguration.class;
|
||||||
|
|
||||||
private AnnotationConfigEmbeddedWebApplicationContext context;
|
private AnnotationConfigServletWebServerApplicationContext context;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultConfiguration() {
|
public void testDefaultConfiguration() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(AuthorizationAndResourceServerConfiguration.class,
|
this.context.register(AuthorizationAndResourceServerConfiguration.class,
|
||||||
MinimalSecureWebApplication.class);
|
MinimalSecureWebApplication.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
|
@ -148,7 +148,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void methodSecurityExpressionHandlerIsConfiguredWithRoleHierarchyFromTheContext() {
|
public void methodSecurityExpressionHandlerIsConfiguredWithRoleHierarchyFromTheContext() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(RoleHierarchyConfiguration.class,
|
this.context.register(RoleHierarchyConfiguration.class,
|
||||||
AuthorizationAndResourceServerConfiguration.class,
|
AuthorizationAndResourceServerConfiguration.class,
|
||||||
MinimalSecureWebApplication.class);
|
MinimalSecureWebApplication.class);
|
||||||
|
@ -164,7 +164,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void methodSecurityExpressionHandlerIsConfiguredWithPermissionEvaluatorFromTheContext() {
|
public void methodSecurityExpressionHandlerIsConfiguredWithPermissionEvaluatorFromTheContext() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(PermissionEvaluatorConfiguration.class,
|
this.context.register(PermissionEvaluatorConfiguration.class,
|
||||||
AuthorizationAndResourceServerConfiguration.class,
|
AuthorizationAndResourceServerConfiguration.class,
|
||||||
MinimalSecureWebApplication.class);
|
MinimalSecureWebApplication.class);
|
||||||
|
@ -181,7 +181,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEnvironmentalOverrides() {
|
public void testEnvironmentalOverrides() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"security.oauth2.client.clientId:myclientid",
|
"security.oauth2.client.clientId:myclientid",
|
||||||
"security.oauth2.client.clientSecret:mysecret",
|
"security.oauth2.client.clientSecret:mysecret",
|
||||||
|
@ -204,7 +204,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDisablingResourceServer() {
|
public void testDisablingResourceServer() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(AuthorizationServerConfiguration.class,
|
this.context.register(AuthorizationServerConfiguration.class,
|
||||||
MinimalSecureWebApplication.class);
|
MinimalSecureWebApplication.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
|
@ -214,7 +214,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClientIsNotResourceServer() {
|
public void testClientIsNotResourceServer() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(ClientConfiguration.class,
|
this.context.register(ClientConfiguration.class,
|
||||||
MinimalSecureWebApplication.class);
|
MinimalSecureWebApplication.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
|
@ -226,7 +226,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCanUseClientCredentials() {
|
public void testCanUseClientCredentials() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(TestSecurityConfiguration.class,
|
this.context.register(TestSecurityConfiguration.class,
|
||||||
MinimalSecureWebApplication.class);
|
MinimalSecureWebApplication.class);
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
|
@ -241,7 +241,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCanUseClientCredentialsWithEnableOAuth2Client() {
|
public void testCanUseClientCredentialsWithEnableOAuth2Client() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(ClientConfiguration.class,
|
this.context.register(ClientConfiguration.class,
|
||||||
MinimalSecureWebApplication.class);
|
MinimalSecureWebApplication.class);
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
|
@ -274,7 +274,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDisablingAuthorizationServer() {
|
public void testDisablingAuthorizationServer() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(ResourceServerConfiguration.class,
|
this.context.register(ResourceServerConfiguration.class,
|
||||||
MinimalSecureWebApplication.class);
|
MinimalSecureWebApplication.class);
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
|
@ -288,7 +288,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testResourceServerOverride() {
|
public void testResourceServerOverride() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(AuthorizationAndResourceServerConfiguration.class,
|
this.context.register(AuthorizationAndResourceServerConfiguration.class,
|
||||||
CustomResourceServer.class, MinimalSecureWebApplication.class);
|
CustomResourceServer.class, MinimalSecureWebApplication.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
|
@ -301,7 +301,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAuthorizationServerOverride() {
|
public void testAuthorizationServerOverride() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"security.oauth2.resourceId:resource-id");
|
"security.oauth2.resourceId:resource-id");
|
||||||
this.context.register(AuthorizationAndResourceServerConfiguration.class,
|
this.context.register(AuthorizationAndResourceServerConfiguration.class,
|
||||||
|
@ -321,7 +321,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultPrePostSecurityAnnotations() {
|
public void testDefaultPrePostSecurityAnnotations() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(AuthorizationAndResourceServerConfiguration.class,
|
this.context.register(AuthorizationAndResourceServerConfiguration.class,
|
||||||
MinimalSecureWebApplication.class);
|
MinimalSecureWebApplication.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
|
@ -339,7 +339,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClassicSecurityAnnotationOverride() {
|
public void testClassicSecurityAnnotationOverride() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(SecuredEnabledConfiguration.class,
|
this.context.register(SecuredEnabledConfiguration.class,
|
||||||
MinimalSecureWebApplication.class);
|
MinimalSecureWebApplication.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
|
@ -357,7 +357,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testJsr250SecurityAnnotationOverride() {
|
public void testJsr250SecurityAnnotationOverride() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(Jsr250EnabledConfiguration.class,
|
this.context.register(Jsr250EnabledConfiguration.class,
|
||||||
MinimalSecureWebApplication.class);
|
MinimalSecureWebApplication.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
|
@ -375,7 +375,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMethodSecurityBackingOff() {
|
public void testMethodSecurityBackingOff() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(CustomMethodSecurity.class, TestSecurityConfiguration.class,
|
this.context.register(CustomMethodSecurity.class, TestSecurityConfiguration.class,
|
||||||
MinimalSecureWebApplication.class);
|
MinimalSecureWebApplication.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
|
@ -391,7 +391,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void resourceServerConditionWhenJwkConfigurationPresentShouldMatch()
|
public void resourceServerConditionWhenJwkConfigurationPresentShouldMatch()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"security.oauth2.resource.jwk.key-set-uri:http://my-auth-server/token_keys");
|
"security.oauth2.resource.jwk.key-set-uri:http://my-auth-server/token_keys");
|
||||||
this.context.register(ResourceServerConfiguration.class,
|
this.context.register(ResourceServerConfiguration.class,
|
||||||
|
@ -411,7 +411,7 @@ public class OAuth2AutoConfigurationTests {
|
||||||
|
|
||||||
private void verifyAuthentication(ClientDetails config, HttpStatus finalStatus) {
|
private void verifyAuthentication(ClientDetails config, HttpStatus finalStatus) {
|
||||||
String baseUrl = "http://localhost:"
|
String baseUrl = "http://localhost:"
|
||||||
+ this.context.getEmbeddedWebServer().getPort();
|
+ this.context.getWebServer().getPort();
|
||||||
TestRestTemplate rest = new TestRestTemplate();
|
TestRestTemplate rest = new TestRestTemplate();
|
||||||
// First, verify the web endpoint can't be reached
|
// First, verify the web endpoint can't be reached
|
||||||
assertEndpointUnauthorized(baseUrl, rest);
|
assertEndpointUnauthorized(baseUrl, rest);
|
||||||
|
@ -573,8 +573,8 @@ public class OAuth2AutoConfigurationTests {
|
||||||
protected static class UseFreePortEmbeddedContainerConfiguration {
|
protected static class UseFreePortEmbeddedContainerConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
TomcatEmbeddedServletContainerFactory containerFactory() {
|
TomcatServletWebServerFactory webServerFactory() {
|
||||||
return new TomcatEmbeddedServletContainerFactory(0);
|
return new TomcatServletWebServerFactory(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,10 +35,10 @@ import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2RestO
|
||||||
import org.springframework.boot.autoconfigure.social.FacebookAutoConfiguration;
|
import org.springframework.boot.autoconfigure.social.FacebookAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.social.SocialWebAutoConfiguration;
|
import org.springframework.boot.autoconfigure.social.SocialWebAutoConfiguration;
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
|
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
@ -317,8 +317,8 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||||
protected static class ResourceNoClientConfiguration extends ResourceConfiguration {
|
protected static class ResourceNoClientConfiguration extends ResourceConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MockEmbeddedServletContainerFactory embeddedServletContainerFactory() {
|
public MockServletWebServerFactory webServerFactory() {
|
||||||
return new MockEmbeddedServletContainerFactory();
|
return new MockServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -344,8 +344,8 @@ public class ResourceServerTokenServicesConfigurationTests {
|
||||||
protected static class SocialResourceConfiguration extends ResourceConfiguration {
|
protected static class SocialResourceConfiguration extends ResourceConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory embeddedServletContainerFactory() {
|
public ServletWebServerFactory webServerFactory() {
|
||||||
return mock(EmbeddedServletContainerFactory.class);
|
return mock(ServletWebServerFactory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,12 @@ import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -110,7 +110,7 @@ public class UserInfoTokenServicesRefreshTokenTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class,
|
HttpMessageConvertersAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class })
|
PropertyPlaceholderAutoConfiguration.class })
|
||||||
|
|
|
@ -25,9 +25,9 @@ import java.lang.annotation.Target;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
@ -36,7 +36,7 @@ import org.springframework.context.annotation.Import;
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class, SecurityAutoConfiguration.class })
|
PropertyPlaceholderAutoConfiguration.class, SecurityAutoConfiguration.class })
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class BasicErrorControllerDirectMockMvcTests {
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class })
|
PropertyPlaceholderAutoConfiguration.class })
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class BasicErrorControllerMockMvcTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBindingExceptionForMachineClient() throws Exception {
|
public void testBindingExceptionForMachineClient() throws Exception {
|
||||||
// In a real container the response is carried over into the error dispatcher, but
|
// In a real server the response is carried over into the error dispatcher, but
|
||||||
// in the mock a new one is created so we have to assert the status at this
|
// in the mock a new one is created so we have to assert the status at this
|
||||||
// intermediate point
|
// intermediate point
|
||||||
MvcResult result = this.mockMvc.perform(get("/bind"))
|
MvcResult result = this.mockMvc.perform(get("/bind"))
|
||||||
|
@ -125,8 +125,8 @@ public class BasicErrorControllerMockMvcTests {
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.EmbeddedTomcat.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.EmbeddedTomcat.class,
|
||||||
EmbeddedServletContainerAutoConfiguration.class,
|
ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class })
|
PropertyPlaceholderAutoConfiguration.class })
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class DefaultErrorViewIntegrationTests {
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
DispatcherServletAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
HttpMessageConvertersAutoConfiguration.class, ErrorMvcAutoConfiguration.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class })
|
PropertyPlaceholderAutoConfiguration.class })
|
||||||
|
|
|
@ -29,17 +29,17 @@ import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
|
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
|
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.test.util.ReflectionTestUtils;
|
import org.springframework.test.util.ReflectionTestUtils;
|
||||||
|
@ -49,23 +49,23 @@ import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests for {@link DefaultServletContainerCustomizer}.
|
* Integration tests for {@link DefaultServletWebServerFactoryCustomizer}.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
* @author Ivan Sopov
|
* @author Ivan Sopov
|
||||||
*/
|
*/
|
||||||
public class DefaultServletContainerCustomizerIntegrationTests {
|
public class DefaultServletWebServerFactoryCustomizerTests {
|
||||||
|
|
||||||
private static AbstractEmbeddedServletContainerFactory containerFactory;
|
private static AbstractServletWebServerFactory webServerFactory;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
public ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
private AnnotationConfigEmbeddedWebApplicationContext context;
|
private AnnotationConfigServletWebServerApplicationContext context;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
containerFactory = mock(AbstractEmbeddedServletContainerFactory.class);
|
webServerFactory = mock(AbstractServletWebServerFactory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -85,20 +85,20 @@ public class DefaultServletContainerCustomizerIntegrationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createFromConfigClass() throws Exception {
|
public void createFromConfigClass() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(Config.class, PropertyPlaceholderAutoConfiguration.class);
|
this.context.register(Config.class, PropertyPlaceholderAutoConfiguration.class);
|
||||||
EnvironmentTestUtils.addEnvironment(this.context, "server.port:9000");
|
EnvironmentTestUtils.addEnvironment(this.context, "server.port:9000");
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
ServerProperties server = this.context.getBean(ServerProperties.class);
|
ServerProperties server = this.context.getBean(ServerProperties.class);
|
||||||
assertThat(server).isNotNull();
|
assertThat(server).isNotNull();
|
||||||
assertThat(server.getPort().intValue()).isEqualTo(9000);
|
assertThat(server.getPort().intValue()).isEqualTo(9000);
|
||||||
verify(containerFactory).setPort(9000);
|
verify(webServerFactory).setPort(9000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void tomcatProperties() throws Exception {
|
public void tomcatProperties() throws Exception {
|
||||||
containerFactory = mock(TomcatEmbeddedServletContainerFactory.class);
|
webServerFactory = mock(TomcatServletWebServerFactory.class);
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(Config.class, PropertyPlaceholderAutoConfiguration.class);
|
this.context.register(Config.class, PropertyPlaceholderAutoConfiguration.class);
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"server.tomcat.basedir:target/foo", "server.port:9000");
|
"server.tomcat.basedir:target/foo", "server.port:9000");
|
||||||
|
@ -106,49 +106,47 @@ public class DefaultServletContainerCustomizerIntegrationTests {
|
||||||
ServerProperties server = this.context.getBean(ServerProperties.class);
|
ServerProperties server = this.context.getBean(ServerProperties.class);
|
||||||
assertThat(server).isNotNull();
|
assertThat(server).isNotNull();
|
||||||
assertThat(server.getTomcat().getBasedir()).isEqualTo(new File("target/foo"));
|
assertThat(server.getTomcat().getBasedir()).isEqualTo(new File("target/foo"));
|
||||||
verify(containerFactory).setPort(9000);
|
verify(webServerFactory).setPort(9000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void customizeWithJettyContainerFactory() throws Exception {
|
public void customizeWithJettyWebServerFactory() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(CustomJettyContainerConfig.class,
|
this.context.register(CustomJettyWebServerConfig.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class);
|
PropertyPlaceholderAutoConfiguration.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
containerFactory = this.context
|
webServerFactory = this.context.getBean(AbstractServletWebServerFactory.class);
|
||||||
.getBean(AbstractEmbeddedServletContainerFactory.class);
|
|
||||||
ServerProperties server = this.context.getBean(ServerProperties.class);
|
ServerProperties server = this.context.getBean(ServerProperties.class);
|
||||||
assertThat(server).isNotNull();
|
assertThat(server).isNotNull();
|
||||||
// The server.port environment property was not explicitly set so the container
|
// The server.port environment property was not explicitly set so the server
|
||||||
// factory should take precedence...
|
// factory should take precedence...
|
||||||
assertThat(containerFactory.getPort()).isEqualTo(3000);
|
assertThat(webServerFactory.getPort()).isEqualTo(3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void customizeWithUndertowContainerFactory() throws Exception {
|
public void customizeWithUndertowWebServerFactory() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(CustomUndertowContainerConfig.class,
|
this.context.register(CustomUndertowWebServerConfig.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class);
|
PropertyPlaceholderAutoConfiguration.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
containerFactory = this.context
|
webServerFactory = this.context.getBean(AbstractServletWebServerFactory.class);
|
||||||
.getBean(AbstractEmbeddedServletContainerFactory.class);
|
|
||||||
ServerProperties server = this.context.getBean(ServerProperties.class);
|
ServerProperties server = this.context.getBean(ServerProperties.class);
|
||||||
assertThat(server).isNotNull();
|
assertThat(server).isNotNull();
|
||||||
assertThat(containerFactory.getPort()).isEqualTo(3000);
|
assertThat(webServerFactory.getPort()).isEqualTo(3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void customizeTomcatWithCustomizer() throws Exception {
|
public void customizeTomcatWithCustomizer() throws Exception {
|
||||||
containerFactory = mock(TomcatEmbeddedServletContainerFactory.class);
|
webServerFactory = mock(TomcatServletWebServerFactory.class);
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
this.context.register(Config.class, CustomizeConfig.class,
|
this.context.register(Config.class, CustomizeConfig.class,
|
||||||
PropertyPlaceholderAutoConfiguration.class);
|
PropertyPlaceholderAutoConfiguration.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
ServerProperties server = this.context.getBean(ServerProperties.class);
|
ServerProperties server = this.context.getBean(ServerProperties.class);
|
||||||
assertThat(server).isNotNull();
|
assertThat(server).isNotNull();
|
||||||
// The server.port environment property was not explicitly set so the container
|
// The server.port environment property was not explicitly set so the server
|
||||||
// customizer should take precedence...
|
// customizer should take precedence...
|
||||||
verify(containerFactory).setPort(3000);
|
verify(webServerFactory).setPort(3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ -156,55 +154,55 @@ public class DefaultServletContainerCustomizerIntegrationTests {
|
||||||
protected static class Config {
|
protected static class Config {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public DefaultServletContainerCustomizer defaultServletContainerCustomizer(
|
public DefaultServletWebServerFactoryCustomizer defaultServletWebServerFactoryCustomizer(
|
||||||
ServerProperties properties) {
|
ServerProperties properties) {
|
||||||
return new DefaultServletContainerCustomizer(properties);
|
return new DefaultServletWebServerFactoryCustomizer(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory containerFactory() {
|
public ServletWebServerFactory webServerFactory() {
|
||||||
return DefaultServletContainerCustomizerIntegrationTests.containerFactory;
|
return DefaultServletWebServerFactoryCustomizerTests.webServerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
|
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
|
||||||
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
|
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableConfigurationProperties(ServerProperties.class)
|
@EnableConfigurationProperties(ServerProperties.class)
|
||||||
protected static class CustomJettyContainerConfig {
|
protected static class CustomJettyWebServerConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory containerFactory() {
|
public ServletWebServerFactory webServerFactory() {
|
||||||
JettyEmbeddedServletContainerFactory factory = new JettyEmbeddedServletContainerFactory();
|
JettyServletWebServerFactory factory = new JettyServletWebServerFactory();
|
||||||
factory.setPort(3000);
|
factory.setPort(3000);
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
|
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
|
||||||
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
|
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableConfigurationProperties(ServerProperties.class)
|
@EnableConfigurationProperties(ServerProperties.class)
|
||||||
protected static class CustomUndertowContainerConfig {
|
protected static class CustomUndertowWebServerConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory containerFactory() {
|
public ServletWebServerFactory webServerFactory() {
|
||||||
UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
|
UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory();
|
||||||
factory.setPort(3000);
|
factory.setPort(3000);
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
|
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
|
||||||
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
|
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -213,12 +211,12 @@ public class DefaultServletContainerCustomizerIntegrationTests {
|
||||||
protected static class CustomizeConfig {
|
protected static class CustomizeConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerCustomizer containerCustomizer() {
|
public ServletWebServerFactoryCustomizer webServerFactoryCustomizer() {
|
||||||
return new EmbeddedServletContainerCustomizer() {
|
return new ServletWebServerFactoryCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(ConfigurableEmbeddedServletContainer container) {
|
public void customize(ConfigurableServletWebServerFactory serverFactory) {
|
||||||
container.setPort(3000);
|
serverFactory.setPort(3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
|
@ -28,13 +28,13 @@ import org.junit.Test;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.session.SessionAutoConfiguration;
|
import org.springframework.boot.autoconfigure.session.SessionAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
|
|
||||||
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory.RegisteredFilter;
|
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
import org.springframework.boot.web.filter.OrderedCharacterEncodingFilter;
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
import org.springframework.boot.web.filter.OrderedRequestContextFilter;
|
import org.springframework.boot.web.servlet.filter.OrderedCharacterEncodingFilter;
|
||||||
|
import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter;
|
||||||
|
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory.RegisteredFilter;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.redis.connection.RedisConnection;
|
import org.springframework.data.redis.connection.RedisConnection;
|
||||||
|
@ -54,7 +54,7 @@ import static org.mockito.Mockito.mock;
|
||||||
*/
|
*/
|
||||||
public class FilterOrderingIntegrationTests {
|
public class FilterOrderingIntegrationTests {
|
||||||
|
|
||||||
private AnnotationConfigEmbeddedWebApplicationContext context;
|
private AnnotationConfigServletWebServerApplicationContext context;
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
|
@ -67,7 +67,7 @@ public class FilterOrderingIntegrationTests {
|
||||||
public void testFilterOrdering() {
|
public void testFilterOrdering() {
|
||||||
load();
|
load();
|
||||||
List<RegisteredFilter> registeredFilters = this.context
|
List<RegisteredFilter> registeredFilters = this.context
|
||||||
.getBean(MockEmbeddedServletContainerFactory.class).getContainer()
|
.getBean(MockServletWebServerFactory.class).getWebServer()
|
||||||
.getRegisteredFilters();
|
.getRegisteredFilters();
|
||||||
List<Filter> filters = new ArrayList<>(registeredFilters.size());
|
List<Filter> filters = new ArrayList<>(registeredFilters.size());
|
||||||
for (RegisteredFilter registeredFilter : registeredFilters) {
|
for (RegisteredFilter registeredFilter : registeredFilters) {
|
||||||
|
@ -83,10 +83,10 @@ public class FilterOrderingIntegrationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void load() {
|
private void load() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"spring.session.store-type=hash-map");
|
"spring.session.store-type=hash-map");
|
||||||
this.context.register(MockEmbeddedServletContainerConfiguration.class,
|
this.context.register(MockWebServerConfiguration.class,
|
||||||
TestRedisConfiguration.class, WebMvcAutoConfiguration.class,
|
TestRedisConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
SecurityAutoConfiguration.class, SessionAutoConfiguration.class,
|
SecurityAutoConfiguration.class, SessionAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class,
|
HttpMessageConvertersAutoConfiguration.class,
|
||||||
|
@ -96,16 +96,16 @@ public class FilterOrderingIntegrationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
static class MockEmbeddedServletContainerConfiguration {
|
static class MockWebServerConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MockEmbeddedServletContainerFactory containerFactory() {
|
public MockServletWebServerFactory webServerFactory() {
|
||||||
return new MockEmbeddedServletContainerFactory();
|
return new MockServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
|
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
|
||||||
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
|
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,12 +30,12 @@ import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
|
|
||||||
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
import org.springframework.boot.web.filter.OrderedHiddenHttpMethodFilter;
|
import org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter;
|
||||||
import org.springframework.boot.web.filter.OrderedHttpPutFormContentFilter;
|
import org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter;
|
||||||
|
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||||
|
@ -145,10 +145,10 @@ public class HttpEncodingAutoConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void noLocaleCharsetMapping() {
|
public void noLocaleCharsetMapping() {
|
||||||
load(EmptyConfiguration.class);
|
load(EmptyConfiguration.class);
|
||||||
Map<String, EmbeddedServletContainerCustomizer> beans = this.context
|
Map<String, ServletWebServerFactoryCustomizer> beans = this.context
|
||||||
.getBeansOfType(EmbeddedServletContainerCustomizer.class);
|
.getBeansOfType(ServletWebServerFactoryCustomizer.class);
|
||||||
assertThat(beans.size()).isEqualTo(1);
|
assertThat(beans.size()).isEqualTo(1);
|
||||||
assertThat(this.context.getBean(MockEmbeddedServletContainerFactory.class)
|
assertThat(this.context.getBean(MockServletWebServerFactory.class)
|
||||||
.getLocaleCharsetMappings().size()).isEqualTo(0);
|
.getLocaleCharsetMappings().size()).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,15 +156,15 @@ public class HttpEncodingAutoConfigurationTests {
|
||||||
public void customLocaleCharsetMappings() {
|
public void customLocaleCharsetMappings() {
|
||||||
load(EmptyConfiguration.class, "spring.http.encoding.mapping.en:UTF-8",
|
load(EmptyConfiguration.class, "spring.http.encoding.mapping.en:UTF-8",
|
||||||
"spring.http.encoding.mapping.fr_FR:UTF-8");
|
"spring.http.encoding.mapping.fr_FR:UTF-8");
|
||||||
Map<String, EmbeddedServletContainerCustomizer> beans = this.context
|
Map<String, ServletWebServerFactoryCustomizer> beans = this.context
|
||||||
.getBeansOfType(EmbeddedServletContainerCustomizer.class);
|
.getBeansOfType(ServletWebServerFactoryCustomizer.class);
|
||||||
assertThat(beans.size()).isEqualTo(1);
|
assertThat(beans.size()).isEqualTo(1);
|
||||||
assertThat(this.context.getBean(MockEmbeddedServletContainerFactory.class)
|
assertThat(this.context.getBean(MockServletWebServerFactory.class)
|
||||||
.getLocaleCharsetMappings().size()).isEqualTo(2);
|
.getLocaleCharsetMappings().size()).isEqualTo(2);
|
||||||
assertThat(this.context.getBean(MockEmbeddedServletContainerFactory.class)
|
assertThat(this.context.getBean(MockServletWebServerFactory.class)
|
||||||
.getLocaleCharsetMappings().get(Locale.ENGLISH))
|
.getLocaleCharsetMappings().get(Locale.ENGLISH))
|
||||||
.isEqualTo(Charset.forName("UTF-8"));
|
.isEqualTo(Charset.forName("UTF-8"));
|
||||||
assertThat(this.context.getBean(MockEmbeddedServletContainerFactory.class)
|
assertThat(this.context.getBean(MockServletWebServerFactory.class)
|
||||||
.getLocaleCharsetMappings().get(Locale.FRANCE))
|
.getLocaleCharsetMappings().get(Locale.FRANCE))
|
||||||
.isEqualTo(Charset.forName("UTF-8"));
|
.isEqualTo(Charset.forName("UTF-8"));
|
||||||
}
|
}
|
||||||
|
@ -230,13 +230,13 @@ public class HttpEncodingAutoConfigurationTests {
|
||||||
static class MinimalWebAutoConfiguration {
|
static class MinimalWebAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MockEmbeddedServletContainerFactory mockEmbeddedServletContainerFactory() {
|
public MockServletWebServerFactory MockServletWebServerFactory() {
|
||||||
return new MockEmbeddedServletContainerFactory();
|
return new MockServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
|
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
|
||||||
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
|
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,18 +23,17 @@ import javax.servlet.MultipartConfigElement;
|
||||||
|
|
||||||
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
|
import org.apache.catalina.webresources.TomcatURLStreamHandlerFactory;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
|
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
@ -68,7 +67,7 @@ import static org.mockito.Mockito.mock;
|
||||||
*/
|
*/
|
||||||
public class MultipartAutoConfigurationTests {
|
public class MultipartAutoConfigurationTests {
|
||||||
|
|
||||||
private AnnotationConfigEmbeddedWebApplicationContext context;
|
private AnnotationConfigServletWebServerApplicationContext context;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
public ExpectedException thrown = ExpectedException.none();
|
||||||
|
@ -80,18 +79,18 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@Before
|
||||||
@AfterClass
|
@After
|
||||||
public static void uninstallUrlStreamHandlerFactory() {
|
public void uninstallUrlStreamHandlerFactory() {
|
||||||
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
|
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
|
||||||
null);
|
null);
|
||||||
ReflectionTestUtils.setField(URL.class, "factory", null);
|
ReflectionTestUtils.setField(URL.class, "factory", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containerWithNothing() throws Exception {
|
public void webServerWithNothing() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
ContainerWithNothing.class, BaseConfiguration.class);
|
WebServerWithNothing.class, BaseConfiguration.class);
|
||||||
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
|
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
|
||||||
verify404();
|
verify404();
|
||||||
assertThat(servlet.getMultipartResolver()).isNotNull();
|
assertThat(servlet.getMultipartResolver()).isNotNull();
|
||||||
|
@ -101,9 +100,9 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containerWithNoMultipartJettyConfiguration() {
|
public void webServerWithNoMultipartJettyConfiguration() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
ContainerWithNoMultipartJetty.class, BaseConfiguration.class);
|
WebServerWithNoMultipartJetty.class, BaseConfiguration.class);
|
||||||
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
|
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
|
||||||
assertThat(servlet.getMultipartResolver()).isNotNull();
|
assertThat(servlet.getMultipartResolver()).isNotNull();
|
||||||
assertThat(this.context.getBeansOfType(StandardServletMultipartResolver.class))
|
assertThat(this.context.getBeansOfType(StandardServletMultipartResolver.class))
|
||||||
|
@ -113,9 +112,9 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containerWithNoMultipartUndertowConfiguration() {
|
public void webServerWithNoMultipartUndertowConfiguration() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
ContainerWithNoMultipartUndertow.class, BaseConfiguration.class);
|
WebServerWithNoMultipartUndertow.class, BaseConfiguration.class);
|
||||||
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
|
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
|
||||||
verifyServletWorks();
|
verifyServletWorks();
|
||||||
assertThat(servlet.getMultipartResolver()).isNotNull();
|
assertThat(servlet.getMultipartResolver()).isNotNull();
|
||||||
|
@ -125,9 +124,9 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containerWithNoMultipartTomcatConfiguration() {
|
public void webServerWithNoMultipartTomcatConfiguration() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
ContainerWithNoMultipartTomcat.class, BaseConfiguration.class);
|
WebServerWithNoMultipartTomcat.class, BaseConfiguration.class);
|
||||||
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
|
DispatcherServlet servlet = this.context.getBean(DispatcherServlet.class);
|
||||||
assertThat(servlet.getMultipartResolver()).isNull();
|
assertThat(servlet.getMultipartResolver()).isNull();
|
||||||
assertThat(this.context.getBeansOfType(StandardServletMultipartResolver.class))
|
assertThat(this.context.getBeansOfType(StandardServletMultipartResolver.class))
|
||||||
|
@ -137,9 +136,9 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containerWithAutomatedMultipartJettyConfiguration() {
|
public void webServerWithAutomatedMultipartJettyConfiguration() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
ContainerWithEverythingJetty.class, BaseConfiguration.class);
|
WebServerWithEverythingJetty.class, BaseConfiguration.class);
|
||||||
this.context.getBean(MultipartConfigElement.class);
|
this.context.getBean(MultipartConfigElement.class);
|
||||||
assertThat(this.context.getBean(StandardServletMultipartResolver.class)).isSameAs(
|
assertThat(this.context.getBean(StandardServletMultipartResolver.class)).isSameAs(
|
||||||
this.context.getBean(DispatcherServlet.class).getMultipartResolver());
|
this.context.getBean(DispatcherServlet.class).getMultipartResolver());
|
||||||
|
@ -147,11 +146,11 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containerWithAutomatedMultipartTomcatConfiguration() throws Exception {
|
public void webServerWithAutomatedMultipartTomcatConfiguration() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
ContainerWithEverythingTomcat.class, BaseConfiguration.class);
|
WebServerWithEverythingTomcat.class, BaseConfiguration.class);
|
||||||
new RestTemplate().getForObject(
|
new RestTemplate().getForObject(
|
||||||
"http://localhost:" + this.context.getEmbeddedWebServer().getPort() + "/",
|
"http://localhost:" + this.context.getWebServer().getPort() + "/",
|
||||||
String.class);
|
String.class);
|
||||||
this.context.getBean(MultipartConfigElement.class);
|
this.context.getBean(MultipartConfigElement.class);
|
||||||
assertThat(this.context.getBean(StandardServletMultipartResolver.class)).isSameAs(
|
assertThat(this.context.getBean(StandardServletMultipartResolver.class)).isSameAs(
|
||||||
|
@ -160,9 +159,9 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containerWithAutomatedMultipartUndertowConfiguration() {
|
public void webServerWithAutomatedMultipartUndertowConfiguration() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
ContainerWithEverythingUndertow.class, BaseConfiguration.class);
|
WebServerWithEverythingUndertow.class, BaseConfiguration.class);
|
||||||
this.context.getBean(MultipartConfigElement.class);
|
this.context.getBean(MultipartConfigElement.class);
|
||||||
verifyServletWorks();
|
verifyServletWorks();
|
||||||
assertThat(this.context.getBean(StandardServletMultipartResolver.class)).isSameAs(
|
assertThat(this.context.getBean(StandardServletMultipartResolver.class)).isSameAs(
|
||||||
|
@ -170,21 +169,21 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containerWithMultipartConfigDisabled() {
|
public void webServerWithMultipartConfigDisabled() {
|
||||||
testContainerWithCustomMultipartConfigEnabledSetting("false", 0);
|
testWebServerWithCustomMultipartConfigEnabledSetting("false", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containerWithMultipartConfigEnabled() {
|
public void webServerWithMultipartConfigEnabled() {
|
||||||
testContainerWithCustomMultipartConfigEnabledSetting("true", 1);
|
testWebServerWithCustomMultipartConfigEnabledSetting("true", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testContainerWithCustomMultipartConfigEnabledSetting(
|
private void testWebServerWithCustomMultipartConfigEnabledSetting(
|
||||||
final String propertyValue, int expectedNumberOfMultipartConfigElementBeans) {
|
final String propertyValue, int expectedNumberOfMultipartConfigElementBeans) {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"spring.http.multipart.enabled=" + propertyValue);
|
"spring.http.multipart.enabled=" + propertyValue);
|
||||||
this.context.register(ContainerWithNoMultipartTomcat.class,
|
this.context.register(WebServerWithNoMultipartTomcat.class,
|
||||||
BaseConfiguration.class);
|
BaseConfiguration.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
this.context.getBean(MultipartProperties.class);
|
this.context.getBean(MultipartProperties.class);
|
||||||
|
@ -193,9 +192,9 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containerWithCustomMultipartResolver() throws Exception {
|
public void webServerWithCustomMultipartResolver() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
ContainerWithCustomMultipartResolver.class, BaseConfiguration.class);
|
WebServerWithCustomMultipartResolver.class, BaseConfiguration.class);
|
||||||
MultipartResolver multipartResolver = this.context
|
MultipartResolver multipartResolver = this.context
|
||||||
.getBean(MultipartResolver.class);
|
.getBean(MultipartResolver.class);
|
||||||
assertThat(multipartResolver)
|
assertThat(multipartResolver)
|
||||||
|
@ -204,10 +203,10 @@ public class MultipartAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void configureResolveLazily() {
|
public void configureResolveLazily() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"spring.http.multipart.resolve-lazily=true");
|
"spring.http.multipart.resolve-lazily=true");
|
||||||
this.context.register(ContainerWithNothing.class, BaseConfiguration.class);
|
this.context.register(WebServerWithNothing.class, BaseConfiguration.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
StandardServletMultipartResolver multipartResolver = this.context
|
StandardServletMultipartResolver multipartResolver = this.context
|
||||||
.getBean(StandardServletMultipartResolver.class);
|
.getBean(StandardServletMultipartResolver.class);
|
||||||
|
@ -218,32 +217,32 @@ public class MultipartAutoConfigurationTests {
|
||||||
|
|
||||||
private void verify404() throws Exception {
|
private void verify404() throws Exception {
|
||||||
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
|
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
|
||||||
ClientHttpRequest request = requestFactory.createRequest(
|
ClientHttpRequest request = requestFactory
|
||||||
new URI("http://localhost:"
|
.createRequest(
|
||||||
+ this.context.getEmbeddedWebServer().getPort() + "/"),
|
new URI("http://localhost:"
|
||||||
HttpMethod.GET);
|
+ this.context.getWebServer().getPort() + "/"),
|
||||||
|
HttpMethod.GET);
|
||||||
ClientHttpResponse response = request.execute();
|
ClientHttpResponse response = request.execute();
|
||||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyServletWorks() {
|
private void verifyServletWorks() {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
String url = "http://localhost:" + this.context.getEmbeddedWebServer().getPort()
|
String url = "http://localhost:" + this.context.getWebServer().getPort() + "/";
|
||||||
+ "/";
|
|
||||||
assertThat(restTemplate.getForObject(url, String.class)).isEqualTo("Hello");
|
assertThat(restTemplate.getForObject(url, String.class)).isEqualTo("Hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public static class ContainerWithNothing {
|
public static class WebServerWithNothing {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public static class ContainerWithNoMultipartJetty {
|
public static class WebServerWithNoMultipartJetty {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
JettyEmbeddedServletContainerFactory containerFactory() {
|
JettyServletWebServerFactory webServerFactory() {
|
||||||
return new JettyEmbeddedServletContainerFactory();
|
return new JettyServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -254,11 +253,11 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public static class ContainerWithNoMultipartUndertow {
|
public static class WebServerWithNoMultipartUndertow {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
UndertowEmbeddedServletContainerFactory containerFactory() {
|
UndertowServletWebServerFactory webServerFactory() {
|
||||||
return new UndertowEmbeddedServletContainerFactory();
|
return new UndertowServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -269,7 +268,7 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, MultipartAutoConfiguration.class })
|
DispatcherServletAutoConfiguration.class, MultipartAutoConfiguration.class })
|
||||||
@EnableConfigurationProperties(MultipartProperties.class)
|
@EnableConfigurationProperties(MultipartProperties.class)
|
||||||
protected static class BaseConfiguration {
|
protected static class BaseConfiguration {
|
||||||
|
@ -284,11 +283,11 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public static class ContainerWithNoMultipartTomcat {
|
public static class WebServerWithNoMultipartTomcat {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
TomcatEmbeddedServletContainerFactory containerFactory() {
|
TomcatServletWebServerFactory webServerFactory() {
|
||||||
return new TomcatEmbeddedServletContainerFactory();
|
return new TomcatServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -299,7 +298,7 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public static class ContainerWithEverythingJetty {
|
public static class WebServerWithEverythingJetty {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
MultipartConfigElement multipartConfigElement() {
|
MultipartConfigElement multipartConfigElement() {
|
||||||
|
@ -307,8 +306,8 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
JettyEmbeddedServletContainerFactory containerFactory() {
|
JettyServletWebServerFactory webServerFactory() {
|
||||||
return new JettyEmbeddedServletContainerFactory();
|
return new JettyServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -320,7 +319,7 @@ public class MultipartAutoConfigurationTests {
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
public static class ContainerWithEverythingTomcat {
|
public static class WebServerWithEverythingTomcat {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
MultipartConfigElement multipartConfigElement() {
|
MultipartConfigElement multipartConfigElement() {
|
||||||
|
@ -328,8 +327,8 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
TomcatEmbeddedServletContainerFactory containerFactory() {
|
TomcatServletWebServerFactory webServerFactory() {
|
||||||
return new TomcatEmbeddedServletContainerFactory();
|
return new TomcatServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -341,7 +340,7 @@ public class MultipartAutoConfigurationTests {
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
public static class ContainerWithEverythingUndertow {
|
public static class WebServerWithEverythingUndertow {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
MultipartConfigElement multipartConfigElement() {
|
MultipartConfigElement multipartConfigElement() {
|
||||||
|
@ -349,8 +348,8 @@ public class MultipartAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
UndertowEmbeddedServletContainerFactory containerFactory() {
|
UndertowServletWebServerFactory webServerFactory() {
|
||||||
return new UndertowEmbeddedServletContainerFactory();
|
return new UndertowServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -360,7 +359,7 @@ public class MultipartAutoConfigurationTests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ContainerWithCustomMultipartResolver {
|
public static class WebServerWithCustomMultipartResolver {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
MultipartResolver multipartResolver() {
|
MultipartResolver multipartResolver() {
|
||||||
|
|
|
@ -21,13 +21,13 @@ import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
import org.springframework.boot.web.servlet.ErrorPage;
|
import org.springframework.boot.web.server.ErrorPage;
|
||||||
import org.springframework.boot.web.servlet.ErrorPageRegistrar;
|
import org.springframework.boot.web.server.ErrorPageRegistrar;
|
||||||
import org.springframework.boot.web.servlet.ErrorPageRegistry;
|
import org.springframework.boot.web.server.ErrorPageRegistry;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
@ -71,7 +71,7 @@ public class RemappedErrorViewIntegrationTests {
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ PropertyPlaceholderAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
@Import({ PropertyPlaceholderAutoConfiguration.class, WebMvcAutoConfiguration.class,
|
||||||
HttpMessageConvertersAutoConfiguration.class,
|
HttpMessageConvertersAutoConfiguration.class,
|
||||||
EmbeddedServletContainerAutoConfiguration.class,
|
ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class, ErrorMvcAutoConfiguration.class })
|
DispatcherServletAutoConfiguration.class, ErrorMvcAutoConfiguration.class })
|
||||||
@Controller
|
@Controller
|
||||||
public static class TestConfiguration implements ErrorPageRegistrar {
|
public static class TestConfiguration implements ErrorPageRegistrar {
|
||||||
|
|
|
@ -39,13 +39,14 @@ import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
import org.springframework.beans.MutablePropertyValues;
|
import org.springframework.beans.MutablePropertyValues;
|
||||||
import org.springframework.boot.bind.RelaxedDataBinder;
|
import org.springframework.boot.bind.RelaxedDataBinder;
|
||||||
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
|
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
||||||
|
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
|
||||||
import org.springframework.mock.env.MockEnvironment;
|
import org.springframework.mock.env.MockEnvironment;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
@ -58,84 +59,83 @@ import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link DefaultServletContainerCustomizer}.
|
* Tests for {@link ServerProperties} {@link ServletWebServerFactoryCustomizer}.
|
||||||
*
|
*
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
*/
|
*/
|
||||||
public class DefaultServletContainerCustomizerTests {
|
public class ServerPropertiesServletWebServerFactoryCustomizerTests {
|
||||||
|
|
||||||
private final ServerProperties properties = new ServerProperties();
|
private final ServerProperties properties = new ServerProperties();
|
||||||
|
|
||||||
private DefaultServletContainerCustomizer customizer;
|
private DefaultServletWebServerFactoryCustomizer customizer;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
this.customizer = new DefaultServletContainerCustomizer(this.properties);
|
this.customizer = new DefaultServletWebServerFactoryCustomizer(this.properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void tomcatAccessLogIsDisabledByDefault() {
|
public void tomcatAccessLogIsDisabledByDefault() {
|
||||||
TomcatEmbeddedServletContainerFactory tomcatContainer = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
this.customizer.customize(tomcatContainer);
|
this.customizer.customize(factory);
|
||||||
assertThat(tomcatContainer.getEngineValves()).isEmpty();
|
assertThat(factory.getEngineValves()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void tomcatAccessLogCanBeEnabled() {
|
public void tomcatAccessLogCanBeEnabled() {
|
||||||
TomcatEmbeddedServletContainerFactory tomcatContainer = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("server.tomcat.accesslog.enabled", "true");
|
map.put("server.tomcat.accesslog.enabled", "true");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
this.customizer.customize(tomcatContainer);
|
this.customizer.customize(factory);
|
||||||
assertThat(tomcatContainer.getEngineValves()).hasSize(1);
|
assertThat(factory.getEngineValves()).hasSize(1);
|
||||||
assertThat(tomcatContainer.getEngineValves()).first()
|
assertThat(factory.getEngineValves()).first().isInstanceOf(AccessLogValve.class);
|
||||||
.isInstanceOf(AccessLogValve.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void tomcatAccessLogFileDateFormatByDefault() {
|
public void tomcatAccessLogFileDateFormatByDefault() {
|
||||||
TomcatEmbeddedServletContainerFactory tomcatContainer = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
map.put("server.tomcat.accesslog.enabled", "true");
|
map.put("server.tomcat.accesslog.enabled", "true");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
this.customizer.customize(tomcatContainer);
|
this.customizer.customize(factory);
|
||||||
assertThat(((AccessLogValve) tomcatContainer.getEngineValves().iterator().next())
|
assertThat(((AccessLogValve) factory.getEngineValves().iterator().next())
|
||||||
.getFileDateFormat()).isEqualTo(".yyyy-MM-dd");
|
.getFileDateFormat()).isEqualTo(".yyyy-MM-dd");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void tomcatAccessLogFileDateFormatCanBeRedefined() {
|
public void tomcatAccessLogFileDateFormatCanBeRedefined() {
|
||||||
TomcatEmbeddedServletContainerFactory tomcatContainer = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
map.put("server.tomcat.accesslog.enabled", "true");
|
map.put("server.tomcat.accesslog.enabled", "true");
|
||||||
map.put("server.tomcat.accesslog.file-date-format", "yyyy-MM-dd.HH");
|
map.put("server.tomcat.accesslog.file-date-format", "yyyy-MM-dd.HH");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
this.customizer.customize(tomcatContainer);
|
this.customizer.customize(factory);
|
||||||
assertThat(((AccessLogValve) tomcatContainer.getEngineValves().iterator().next())
|
assertThat(((AccessLogValve) factory.getEngineValves().iterator().next())
|
||||||
.getFileDateFormat()).isEqualTo("yyyy-MM-dd.HH");
|
.getFileDateFormat()).isEqualTo("yyyy-MM-dd.HH");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void tomcatAccessLogIsBufferedByDefault() {
|
public void tomcatAccessLogIsBufferedByDefault() {
|
||||||
TomcatEmbeddedServletContainerFactory tomcatContainer = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("server.tomcat.accesslog.enabled", "true");
|
map.put("server.tomcat.accesslog.enabled", "true");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
this.customizer.customize(tomcatContainer);
|
this.customizer.customize(factory);
|
||||||
assertThat(((AccessLogValve) tomcatContainer.getEngineValves().iterator().next())
|
assertThat(((AccessLogValve) factory.getEngineValves().iterator().next())
|
||||||
.isBuffered()).isTrue();
|
.isBuffered()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void tomcatAccessLogBufferingCanBeDisabled() {
|
public void tomcatAccessLogBufferingCanBeDisabled() {
|
||||||
TomcatEmbeddedServletContainerFactory tomcatContainer = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("server.tomcat.accesslog.enabled", "true");
|
map.put("server.tomcat.accesslog.enabled", "true");
|
||||||
map.put("server.tomcat.accesslog.buffered", "false");
|
map.put("server.tomcat.accesslog.buffered", "false");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
this.customizer.customize(tomcatContainer);
|
this.customizer.customize(factory);
|
||||||
assertThat(((AccessLogValve) tomcatContainer.getEngineValves().iterator().next())
|
assertThat(((AccessLogValve) factory.getEngineValves().iterator().next())
|
||||||
.isBuffered()).isFalse();
|
.isBuffered()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,11 +146,10 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
ServerProperties.Tomcat tomcat = this.properties.getTomcat();
|
ServerProperties.Tomcat tomcat = this.properties.getTomcat();
|
||||||
assertThat(tomcat.getRedirectContextRoot()).isEqualTo(false);
|
assertThat(tomcat.getRedirectContextRoot()).isEqualTo(false);
|
||||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
Context context = mock(Context.class);
|
Context context = mock(Context.class);
|
||||||
for (TomcatContextCustomizer customizer : container
|
for (TomcatContextCustomizer customizer : factory.getTomcatContextCustomizers()) {
|
||||||
.getTomcatContextCustomizers()) {
|
|
||||||
customizer.customize(context);
|
customizer.customize(context);
|
||||||
}
|
}
|
||||||
verify(context).setMapperContextRootRedirectEnabled(false);
|
verify(context).setMapperContextRootRedirectEnabled(false);
|
||||||
|
@ -158,24 +157,24 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCustomizeTomcat() throws Exception {
|
public void testCustomizeTomcat() throws Exception {
|
||||||
ConfigurableEmbeddedServletContainer factory = mock(
|
ConfigurableServletWebServerFactory factory = mock(
|
||||||
ConfigurableEmbeddedServletContainer.class);
|
ConfigurableServletWebServerFactory.class);
|
||||||
this.customizer.customize(factory);
|
this.customizer.customize(factory);
|
||||||
verify(factory, never()).setContextPath("");
|
verify(factory, never()).setContextPath("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultDisplayName() throws Exception {
|
public void testDefaultDisplayName() throws Exception {
|
||||||
ConfigurableEmbeddedServletContainer factory = mock(
|
ConfigurableServletWebServerFactory factory = mock(
|
||||||
ConfigurableEmbeddedServletContainer.class);
|
ConfigurableServletWebServerFactory.class);
|
||||||
this.customizer.customize(factory);
|
this.customizer.customize(factory);
|
||||||
verify(factory).setDisplayName("application");
|
verify(factory).setDisplayName("application");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCustomizeDisplayName() throws Exception {
|
public void testCustomizeDisplayName() throws Exception {
|
||||||
ConfigurableEmbeddedServletContainer factory = mock(
|
ConfigurableServletWebServerFactory factory = mock(
|
||||||
ConfigurableEmbeddedServletContainer.class);
|
ConfigurableServletWebServerFactory.class);
|
||||||
this.properties.setDisplayName("TestName");
|
this.properties.setDisplayName("TestName");
|
||||||
this.customizer.customize(factory);
|
this.customizer.customize(factory);
|
||||||
verify(factory).setDisplayName("TestName");
|
verify(factory).setDisplayName("TestName");
|
||||||
|
@ -194,8 +193,8 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
map.put("server.session.cookie.secure", "true");
|
map.put("server.session.cookie.secure", "true");
|
||||||
map.put("server.session.cookie.max-age", "60");
|
map.put("server.session.cookie.max-age", "60");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
ConfigurableEmbeddedServletContainer factory = mock(
|
ConfigurableServletWebServerFactory factory = mock(
|
||||||
ConfigurableEmbeddedServletContainer.class);
|
ConfigurableServletWebServerFactory.class);
|
||||||
ServletContext servletContext = mock(ServletContext.class);
|
ServletContext servletContext = mock(ServletContext.class);
|
||||||
SessionCookieConfig sessionCookieConfig = mock(SessionCookieConfig.class);
|
SessionCookieConfig sessionCookieConfig = mock(SessionCookieConfig.class);
|
||||||
given(servletContext.getSessionCookieConfig()).willReturn(sessionCookieConfig);
|
given(servletContext.getSessionCookieConfig()).willReturn(sessionCookieConfig);
|
||||||
|
@ -215,8 +214,8 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCustomizeTomcatPort() throws Exception {
|
public void testCustomizeTomcatPort() throws Exception {
|
||||||
ConfigurableEmbeddedServletContainer factory = mock(
|
ConfigurableServletWebServerFactory factory = mock(
|
||||||
ConfigurableEmbeddedServletContainer.class);
|
ConfigurableServletWebServerFactory.class);
|
||||||
this.properties.setPort(8080);
|
this.properties.setPort(8080);
|
||||||
this.customizer.customize(factory);
|
this.customizer.customize(factory);
|
||||||
verify(factory).setPort(8080);
|
verify(factory).setPort(8080);
|
||||||
|
@ -227,9 +226,9 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("server.display-name", "MyBootApp");
|
map.put("server.display-name", "MyBootApp");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
assertThat(container.getDisplayName()).isEqualTo("MyBootApp");
|
assertThat(factory.getDisplayName()).isEqualTo("MyBootApp");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -238,19 +237,17 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
map.put("server.tomcat.remote_ip_header", "");
|
map.put("server.tomcat.remote_ip_header", "");
|
||||||
map.put("server.tomcat.protocol_header", "");
|
map.put("server.tomcat.protocol_header", "");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
assertThat(container.getEngineValves()).isEmpty();
|
assertThat(factory.getEngineValves()).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void defaultTomcatBackgroundProcessorDelay() throws Exception {
|
public void defaultTomcatBackgroundProcessorDelay() throws Exception {
|
||||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
assertThat(
|
assertThat(((TomcatWebServer) factory.getWebServer()).getTomcat().getEngine()
|
||||||
((TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer())
|
.getBackgroundProcessorDelay()).isEqualTo(30);
|
||||||
.getTomcat().getEngine().getBackgroundProcessorDelay())
|
|
||||||
.isEqualTo(30);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -258,12 +255,10 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("server.tomcat.background-processor-delay", "5");
|
map.put("server.tomcat.background-processor-delay", "5");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
assertThat(
|
assertThat(((TomcatWebServer) factory.getWebServer()).getTomcat().getEngine()
|
||||||
((TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer())
|
.getBackgroundProcessorDelay()).isEqualTo(5);
|
||||||
.getTomcat().getEngine().getBackgroundProcessorDelay())
|
|
||||||
.isEqualTo(5);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -290,10 +285,10 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testRemoteIpValveConfigured() {
|
private void testRemoteIpValveConfigured() {
|
||||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
assertThat(container.getEngineValves()).hasSize(1);
|
assertThat(factory.getEngineValves()).hasSize(1);
|
||||||
Valve valve = container.getEngineValves().iterator().next();
|
Valve valve = factory.getEngineValves().iterator().next();
|
||||||
assertThat(valve).isInstanceOf(RemoteIpValve.class);
|
assertThat(valve).isInstanceOf(RemoteIpValve.class);
|
||||||
RemoteIpValve remoteIpValve = (RemoteIpValve) valve;
|
RemoteIpValve remoteIpValve = (RemoteIpValve) valve;
|
||||||
assertThat(remoteIpValve.getProtocolHeader()).isEqualTo("X-Forwarded-Proto");
|
assertThat(remoteIpValve.getProtocolHeader()).isEqualTo("X-Forwarded-Proto");
|
||||||
|
@ -318,10 +313,10 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
map.put("server.tomcat.port-header", "x-my-forward-port");
|
map.put("server.tomcat.port-header", "x-my-forward-port");
|
||||||
map.put("server.tomcat.protocol-header-https-value", "On");
|
map.put("server.tomcat.protocol-header-https-value", "On");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
assertThat(container.getEngineValves()).hasSize(1);
|
assertThat(factory.getEngineValves()).hasSize(1);
|
||||||
Valve valve = container.getEngineValves().iterator().next();
|
Valve valve = factory.getEngineValves().iterator().next();
|
||||||
assertThat(valve).isInstanceOf(RemoteIpValve.class);
|
assertThat(valve).isInstanceOf(RemoteIpValve.class);
|
||||||
RemoteIpValve remoteIpValve = (RemoteIpValve) valve;
|
RemoteIpValve remoteIpValve = (RemoteIpValve) valve;
|
||||||
assertThat(remoteIpValve.getProtocolHeader()).isEqualTo("x-my-protocol-header");
|
assertThat(remoteIpValve.getProtocolHeader()).isEqualTo("x-my-protocol-header");
|
||||||
|
@ -336,18 +331,16 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("server.tomcat.accept-count", "10");
|
map.put("server.tomcat.accept-count", "10");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
||||||
0);
|
this.customizer.customize(factory);
|
||||||
this.customizer.customize(container);
|
TomcatWebServer embeddedfactory = (TomcatWebServer) factory.getWebServer();
|
||||||
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
|
embeddedfactory.start();
|
||||||
.getEmbeddedServletContainer();
|
|
||||||
embeddedContainer.start();
|
|
||||||
try {
|
try {
|
||||||
assertThat(((AbstractProtocol<?>) embeddedContainer.getTomcat().getConnector()
|
assertThat(((AbstractProtocol<?>) embeddedfactory.getTomcat().getConnector()
|
||||||
.getProtocolHandler()).getBacklog()).isEqualTo(10);
|
.getProtocolHandler()).getBacklog()).isEqualTo(10);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
embeddedContainer.stop();
|
embeddedfactory.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,18 +349,16 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("server.tomcat.max-connections", "5");
|
map.put("server.tomcat.max-connections", "5");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
||||||
0);
|
this.customizer.customize(factory);
|
||||||
this.customizer.customize(container);
|
TomcatWebServer embeddedfactory = (TomcatWebServer) factory.getWebServer();
|
||||||
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
|
embeddedfactory.start();
|
||||||
.getEmbeddedServletContainer();
|
|
||||||
embeddedContainer.start();
|
|
||||||
try {
|
try {
|
||||||
assertThat(((AbstractProtocol<?>) embeddedContainer.getTomcat().getConnector()
|
assertThat(((AbstractProtocol<?>) embeddedfactory.getTomcat().getConnector()
|
||||||
.getProtocolHandler()).getMaxConnections()).isEqualTo(5);
|
.getProtocolHandler()).getMaxConnections()).isEqualTo(5);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
embeddedContainer.stop();
|
embeddedfactory.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,18 +367,16 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("server.tomcat.max-http-post-size", "10000");
|
map.put("server.tomcat.max-http-post-size", "10000");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
|
||||||
0);
|
this.customizer.customize(factory);
|
||||||
this.customizer.customize(container);
|
TomcatWebServer embeddedfactory = (TomcatWebServer) factory.getWebServer();
|
||||||
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
|
embeddedfactory.start();
|
||||||
.getEmbeddedServletContainer();
|
|
||||||
embeddedContainer.start();
|
|
||||||
try {
|
try {
|
||||||
assertThat(embeddedContainer.getTomcat().getConnector().getMaxPostSize())
|
assertThat(embeddedfactory.getTomcat().getConnector().getMaxPostSize())
|
||||||
.isEqualTo(10000);
|
.isEqualTo(10000);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
embeddedContainer.stop();
|
embeddedfactory.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,15 +390,15 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
map.put("server.undertow.accesslog.dir", "test-logs");
|
map.put("server.undertow.accesslog.dir", "test-logs");
|
||||||
map.put("server.undertow.accesslog.rotate", "false");
|
map.put("server.undertow.accesslog.rotate", "false");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
UndertowEmbeddedServletContainerFactory container = spy(
|
UndertowServletWebServerFactory factory = spy(
|
||||||
new UndertowEmbeddedServletContainerFactory());
|
new UndertowServletWebServerFactory());
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
verify(container).setAccessLogEnabled(true);
|
verify(factory).setAccessLogEnabled(true);
|
||||||
verify(container).setAccessLogPattern("foo");
|
verify(factory).setAccessLogPattern("foo");
|
||||||
verify(container).setAccessLogPrefix("test_log");
|
verify(factory).setAccessLogPrefix("test_log");
|
||||||
verify(container).setAccessLogSuffix("txt");
|
verify(factory).setAccessLogSuffix("txt");
|
||||||
verify(container).setAccessLogDirectory(new File("test-logs"));
|
verify(factory).setAccessLogDirectory(new File("test-logs"));
|
||||||
verify(container).setAccessLogRotate(false);
|
verify(factory).setAccessLogRotate(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -438,63 +427,60 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testCustomTomcatTldSkip(String... expectedJars) {
|
private void testCustomTomcatTldSkip(String... expectedJars) {
|
||||||
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
assertThat(container.getTldSkipPatterns()).contains(expectedJars);
|
assertThat(factory.getTldSkipPatterns()).contains(expectedJars);
|
||||||
assertThat(container.getTldSkipPatterns()).contains("junit-*.jar",
|
assertThat(factory.getTldSkipPatterns()).contains("junit-*.jar",
|
||||||
"spring-boot-*.jar");
|
"spring-boot-*.jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void defaultUseForwardHeadersUndertow() throws Exception {
|
public void defaultUseForwardHeadersUndertow() throws Exception {
|
||||||
UndertowEmbeddedServletContainerFactory container = spy(
|
UndertowServletWebServerFactory factory = spy(
|
||||||
new UndertowEmbeddedServletContainerFactory());
|
new UndertowServletWebServerFactory());
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
verify(container).setUseForwardHeaders(false);
|
verify(factory).setUseForwardHeaders(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setUseForwardHeadersUndertow() throws Exception {
|
public void setUseForwardHeadersUndertow() throws Exception {
|
||||||
this.properties.setUseForwardHeaders(true);
|
this.properties.setUseForwardHeaders(true);
|
||||||
UndertowEmbeddedServletContainerFactory container = spy(
|
UndertowServletWebServerFactory factory = spy(
|
||||||
new UndertowEmbeddedServletContainerFactory());
|
new UndertowServletWebServerFactory());
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
verify(container).setUseForwardHeaders(true);
|
verify(factory).setUseForwardHeaders(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deduceUseForwardHeadersUndertow() throws Exception {
|
public void deduceUseForwardHeadersUndertow() throws Exception {
|
||||||
this.customizer.setEnvironment(new MockEnvironment().withProperty("DYNO", "-"));
|
this.customizer.setEnvironment(new MockEnvironment().withProperty("DYNO", "-"));
|
||||||
UndertowEmbeddedServletContainerFactory container = spy(
|
UndertowServletWebServerFactory factory = spy(
|
||||||
new UndertowEmbeddedServletContainerFactory());
|
new UndertowServletWebServerFactory());
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
verify(container).setUseForwardHeaders(true);
|
verify(factory).setUseForwardHeaders(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void defaultUseForwardHeadersJetty() throws Exception {
|
public void defaultUseForwardHeadersJetty() throws Exception {
|
||||||
JettyEmbeddedServletContainerFactory container = spy(
|
JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
|
||||||
new JettyEmbeddedServletContainerFactory());
|
this.customizer.customize(factory);
|
||||||
this.customizer.customize(container);
|
verify(factory).setUseForwardHeaders(false);
|
||||||
verify(container).setUseForwardHeaders(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setUseForwardHeadersJetty() throws Exception {
|
public void setUseForwardHeadersJetty() throws Exception {
|
||||||
this.properties.setUseForwardHeaders(true);
|
this.properties.setUseForwardHeaders(true);
|
||||||
JettyEmbeddedServletContainerFactory container = spy(
|
JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
|
||||||
new JettyEmbeddedServletContainerFactory());
|
this.customizer.customize(factory);
|
||||||
this.customizer.customize(container);
|
verify(factory).setUseForwardHeaders(true);
|
||||||
verify(container).setUseForwardHeaders(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deduceUseForwardHeadersJetty() throws Exception {
|
public void deduceUseForwardHeadersJetty() throws Exception {
|
||||||
this.customizer.setEnvironment(new MockEnvironment().withProperty("DYNO", "-"));
|
this.customizer.setEnvironment(new MockEnvironment().withProperty("DYNO", "-"));
|
||||||
JettyEmbeddedServletContainerFactory container = spy(
|
JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
|
||||||
new JettyEmbeddedServletContainerFactory());
|
this.customizer.customize(factory);
|
||||||
this.customizer.customize(container);
|
verify(factory).setUseForwardHeaders(true);
|
||||||
verify(container).setUseForwardHeaders(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -502,24 +488,22 @@ public class DefaultServletContainerCustomizerTests {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
map.put("server.session.store-dir", "myfolder");
|
map.put("server.session.store-dir", "myfolder");
|
||||||
bindProperties(map);
|
bindProperties(map);
|
||||||
JettyEmbeddedServletContainerFactory container = spy(
|
JettyServletWebServerFactory factory = spy(new JettyServletWebServerFactory());
|
||||||
new JettyEmbeddedServletContainerFactory());
|
this.customizer.customize(factory);
|
||||||
this.customizer.customize(container);
|
verify(factory).setSessionStoreDir(new File("myfolder"));
|
||||||
verify(container).setSessionStoreDir(new File("myfolder"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void skipNullElementsForUndertow() throws Exception {
|
public void skipNullElementsForUndertow() throws Exception {
|
||||||
UndertowEmbeddedServletContainerFactory container = mock(
|
UndertowServletWebServerFactory factory = mock(
|
||||||
UndertowEmbeddedServletContainerFactory.class);
|
UndertowServletWebServerFactory.class);
|
||||||
this.customizer.customize(container);
|
this.customizer.customize(factory);
|
||||||
verify(container, never()).setAccessLogEnabled(anyBoolean());
|
verify(factory, never()).setAccessLogEnabled(anyBoolean());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void triggerInitializers(ConfigurableEmbeddedServletContainer container,
|
private void triggerInitializers(ConfigurableServletWebServerFactory factory,
|
||||||
ServletContext servletContext) throws ServletException {
|
ServletContext servletContext) throws ServletException {
|
||||||
verify(container, atLeastOnce())
|
verify(factory, atLeastOnce()).addInitializers(this.initializersCaptor.capture());
|
||||||
.addInitializers(this.initializersCaptor.capture());
|
|
||||||
for (Object initializers : this.initializersCaptor.getAllValues()) {
|
for (Object initializers : this.initializersCaptor.getAllValues()) {
|
||||||
if (initializers instanceof ServletContextInitializer) {
|
if (initializers instanceof ServletContextInitializer) {
|
||||||
((ServletContextInitializer) initializers).onStartup(servletContext);
|
((ServletContextInitializer) initializers).onStartup(servletContext);
|
|
@ -26,13 +26,13 @@ import org.junit.Test;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||||
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
|
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
@ -44,31 +44,32 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link EmbeddedServletContainerAutoConfiguration}.
|
* Tests for {@link ServletWebServerFactoryAutoConfiguration}.
|
||||||
*
|
*
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
|
* @author Phillip Webb
|
||||||
*/
|
*/
|
||||||
public class EmbeddedServletContainerAutoConfigurationTests {
|
public class ServletWebServerFactoryAutoConfigurationTests {
|
||||||
|
|
||||||
private AnnotationConfigEmbeddedWebApplicationContext context;
|
private AnnotationConfigServletWebServerApplicationContext context;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createFromConfigClass() throws Exception {
|
public void createFromConfigClass() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
BaseConfiguration.class);
|
BaseConfiguration.class);
|
||||||
verifyContext();
|
verifyContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextAlreadyHasDispatcherServletWithDefaultName() throws Exception {
|
public void contextAlreadyHasDispatcherServletWithDefaultName() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
DispatcherServletConfiguration.class, BaseConfiguration.class);
|
DispatcherServletConfiguration.class, BaseConfiguration.class);
|
||||||
verifyContext();
|
verifyContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextAlreadyHasDispatcherServlet() throws Exception {
|
public void contextAlreadyHasDispatcherServlet() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
SpringServletConfiguration.class, BaseConfiguration.class);
|
SpringServletConfiguration.class, BaseConfiguration.class);
|
||||||
verifyContext();
|
verifyContext();
|
||||||
assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length)
|
assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length)
|
||||||
|
@ -77,7 +78,7 @@ public class EmbeddedServletContainerAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextAlreadyHasNonDispatcherServlet() throws Exception {
|
public void contextAlreadyHasNonDispatcherServlet() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
NonSpringServletConfiguration.class, BaseConfiguration.class);
|
NonSpringServletConfiguration.class, BaseConfiguration.class);
|
||||||
verifyContext(); // the non default servlet is still registered
|
verifyContext(); // the non default servlet is still registered
|
||||||
assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length)
|
assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length)
|
||||||
|
@ -86,7 +87,7 @@ public class EmbeddedServletContainerAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextAlreadyHasNonServlet() throws Exception {
|
public void contextAlreadyHasNonServlet() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
NonServletConfiguration.class, BaseConfiguration.class);
|
NonServletConfiguration.class, BaseConfiguration.class);
|
||||||
assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length)
|
assertThat(this.context.getBeanNamesForType(DispatcherServlet.class).length)
|
||||||
.isEqualTo(0);
|
.isEqualTo(0);
|
||||||
|
@ -95,7 +96,7 @@ public class EmbeddedServletContainerAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextAlreadyHasDispatcherServletAndRegistration() throws Exception {
|
public void contextAlreadyHasDispatcherServletAndRegistration() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
DispatcherServletWithRegistrationConfiguration.class,
|
DispatcherServletWithRegistrationConfiguration.class,
|
||||||
BaseConfiguration.class);
|
BaseConfiguration.class);
|
||||||
verifyContext();
|
verifyContext();
|
||||||
|
@ -104,23 +105,23 @@ public class EmbeddedServletContainerAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void containerHasNoServletContext() throws Exception {
|
public void webServerHasNoServletContext() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
EnsureContainerHasNoServletContext.class, BaseConfiguration.class);
|
EnsureWebServerHasNoServletContext.class, BaseConfiguration.class);
|
||||||
verifyContext();
|
verifyContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void customizeContainerThroughCallback() throws Exception {
|
public void customizeWebServerFactoryThroughCallback() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext(
|
this.context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
CallbackEmbeddedContainerCustomizer.class, BaseConfiguration.class);
|
CallbackEmbeddedServerFactoryCustomizer.class, BaseConfiguration.class);
|
||||||
verifyContext();
|
verifyContext();
|
||||||
assertThat(getContainerFactory().getPort()).isEqualTo(9000);
|
assertThat(getWebServerFactory().getPort()).isEqualTo(9000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void initParametersAreConfiguredOnTheServletContext() {
|
public void initParametersAreConfiguredOnTheServletContext() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"server.servlet.context-parameters.a:alpha",
|
"server.servlet.context-parameters.a:alpha",
|
||||||
"server.servlet.context-parameters.b:bravo");
|
"server.servlet.context-parameters.b:bravo");
|
||||||
|
@ -133,21 +134,20 @@ public class EmbeddedServletContainerAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyContext() {
|
private void verifyContext() {
|
||||||
MockEmbeddedServletContainerFactory containerFactory = getContainerFactory();
|
MockServletWebServerFactory factory = getWebServerFactory();
|
||||||
Servlet servlet = this.context.getBean(
|
Servlet servlet = this.context.getBean(
|
||||||
DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME,
|
DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_BEAN_NAME,
|
||||||
Servlet.class);
|
Servlet.class);
|
||||||
verify(containerFactory.getServletContext()).addServlet("dispatcherServlet",
|
verify(factory.getServletContext()).addServlet("dispatcherServlet", servlet);
|
||||||
servlet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private MockEmbeddedServletContainerFactory getContainerFactory() {
|
private MockServletWebServerFactory getWebServerFactory() {
|
||||||
return this.context.getBean(MockEmbeddedServletContainerFactory.class);
|
return this.context.getBean(MockServletWebServerFactory.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedContainerConfiguration.class,
|
@Import({ WebServerConfiguration.class,
|
||||||
EmbeddedServletContainerAutoConfiguration.class,
|
ServletWebServerFactoryAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class })
|
DispatcherServletAutoConfiguration.class })
|
||||||
protected static class BaseConfiguration {
|
protected static class BaseConfiguration {
|
||||||
|
|
||||||
|
@ -155,11 +155,11 @@ public class EmbeddedServletContainerAutoConfigurationTests {
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnExpression("true")
|
@ConditionalOnExpression("true")
|
||||||
public static class EmbeddedContainerConfiguration {
|
public static class WebServerConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory containerFactory() {
|
public ServletWebServerFactory webServerFactory() {
|
||||||
return new MockEmbeddedServletContainerFactory();
|
return new MockServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -225,14 +225,14 @@ public class EmbeddedServletContainerAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public static class EnsureContainerHasNoServletContext implements BeanPostProcessor {
|
public static class EnsureWebServerHasNoServletContext implements BeanPostProcessor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object postProcessBeforeInitialization(Object bean, String beanName)
|
public Object postProcessBeforeInitialization(Object bean, String beanName)
|
||||||
throws BeansException {
|
throws BeansException {
|
||||||
if (bean instanceof ConfigurableEmbeddedServletContainer) {
|
if (bean instanceof ConfigurableServletWebServerFactory) {
|
||||||
MockEmbeddedServletContainerFactory containerFactory = (MockEmbeddedServletContainerFactory) bean;
|
MockServletWebServerFactory webServerFactory = (MockServletWebServerFactory) bean;
|
||||||
assertThat(containerFactory.getServletContext()).isNull();
|
assertThat(webServerFactory.getServletContext()).isNull();
|
||||||
}
|
}
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
@ -245,12 +245,12 @@ public class EmbeddedServletContainerAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public static class CallbackEmbeddedContainerCustomizer
|
public static class CallbackEmbeddedServerFactoryCustomizer
|
||||||
implements EmbeddedServletContainerCustomizer {
|
implements ServletWebServerFactoryCustomizer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(ConfigurableEmbeddedServletContainer container) {
|
public void customize(ConfigurableServletWebServerFactory serverFactory) {
|
||||||
container.setPort(9000);
|
serverFactory.setPort(9000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,13 +21,13 @@ import javax.servlet.ServletContextListener;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebServer;
|
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.server.WebServer;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
|
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
|
||||||
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@ -36,11 +36,11 @@ import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link EmbeddedWebServer}s driving {@link ServletContextListener}s correctly
|
* Tests for {@link WebServer}s driving {@link ServletContextListener}s correctly
|
||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
public class EmbeddedServletContainerServletContextListenerTests {
|
public class ServletWebServerServletContextListenerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void registeredServletContextListenerBeanIsCalledByJetty() {
|
public void registeredServletContextListenerBeanIsCalledByJetty() {
|
||||||
|
@ -73,7 +73,7 @@ public class EmbeddedServletContainerServletContextListenerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void servletContextListenerBeanIsCalled(Class<?> configuration) {
|
private void servletContextListenerBeanIsCalled(Class<?> configuration) {
|
||||||
AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext(
|
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
ServletContextListenerBeanConfiguration.class, configuration);
|
ServletContextListenerBeanConfiguration.class, configuration);
|
||||||
ServletContextListener servletContextListener = context
|
ServletContextListener servletContextListener = context
|
||||||
.getBean("servletContextListener", ServletContextListener.class);
|
.getBean("servletContextListener", ServletContextListener.class);
|
||||||
|
@ -82,7 +82,7 @@ public class EmbeddedServletContainerServletContextListenerTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registeredServletContextListenerBeanIsCalled(Class<?> configuration) {
|
private void registeredServletContextListenerBeanIsCalled(Class<?> configuration) {
|
||||||
AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext(
|
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(
|
||||||
ServletListenerRegistrationBeanConfiguration.class, configuration);
|
ServletListenerRegistrationBeanConfiguration.class, configuration);
|
||||||
ServletContextListener servletContextListener = (ServletContextListener) context
|
ServletContextListener servletContextListener = (ServletContextListener) context
|
||||||
.getBean("registration", ServletListenerRegistrationBean.class)
|
.getBean("registration", ServletListenerRegistrationBean.class)
|
||||||
|
@ -95,8 +95,8 @@ public class EmbeddedServletContainerServletContextListenerTests {
|
||||||
static class TomcatConfiguration {
|
static class TomcatConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory servletContainerFactory() {
|
public ServletWebServerFactory webServerFactory() {
|
||||||
return new TomcatEmbeddedServletContainerFactory(0);
|
return new TomcatServletWebServerFactory(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -105,8 +105,8 @@ public class EmbeddedServletContainerServletContextListenerTests {
|
||||||
static class JettyConfiguration {
|
static class JettyConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory servletContainerFactory() {
|
public ServletWebServerFactory webServerFactory() {
|
||||||
return new JettyEmbeddedServletContainerFactory(0);
|
return new JettyServletWebServerFactory(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -115,8 +115,8 @@ public class EmbeddedServletContainerServletContextListenerTests {
|
||||||
static class UndertowConfiguration {
|
static class UndertowConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory servletContainerFactory() {
|
public ServletWebServerFactory webServerFactory() {
|
||||||
return new UndertowEmbeddedServletContainerFactory(0);
|
return new UndertowServletWebServerFactory(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -42,12 +42,12 @@ import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoCon
|
||||||
import org.springframework.boot.autoconfigure.validation.SpringValidator;
|
import org.springframework.boot.autoconfigure.validation.SpringValidator;
|
||||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter;
|
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter;
|
||||||
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration.WelcomePageHandlerMapping;
|
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration.WelcomePageHandlerMapping;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
import org.springframework.boot.web.filter.OrderedHttpPutFormContentFilter;
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
|
import org.springframework.boot.web.servlet.filter.OrderedHttpPutFormContentFilter;
|
||||||
|
import org.springframework.boot.web.servlet.server.MockServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
@ -116,12 +116,12 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||||
*/
|
*/
|
||||||
public class WebMvcAutoConfigurationTests {
|
public class WebMvcAutoConfigurationTests {
|
||||||
|
|
||||||
private static final MockEmbeddedServletContainerFactory containerFactory = new MockEmbeddedServletContainerFactory();
|
private static final MockServletWebServerFactory webServerFactory = new MockServletWebServerFactory();
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
public ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
private AnnotationConfigEmbeddedWebApplicationContext context;
|
private AnnotationConfigServletWebServerApplicationContext context;
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void close() {
|
public void close() {
|
||||||
|
@ -411,7 +411,7 @@ public class WebMvcAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void overrideIgnoreDefaultModelOnRedirect() throws Exception {
|
public void overrideIgnoreDefaultModelOnRedirect() throws Exception {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"spring.mvc.ignore-default-model-on-redirect:false");
|
"spring.mvc.ignore-default-model-on-redirect:false");
|
||||||
this.context.register(Config.class, WebMvcAutoConfiguration.class,
|
this.context.register(Config.class, WebMvcAutoConfiguration.class,
|
||||||
|
@ -708,7 +708,7 @@ public class WebMvcAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void load(Class<?> config, String... environment) {
|
private void load(Class<?> config, String... environment) {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
EnvironmentTestUtils.addEnvironment(this.context, environment);
|
EnvironmentTestUtils.addEnvironment(this.context, environment);
|
||||||
List<Class<?>> configClasses = new ArrayList<>();
|
List<Class<?>> configClasses = new ArrayList<>();
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
|
@ -768,13 +768,13 @@ public class WebMvcAutoConfigurationTests {
|
||||||
public static class Config {
|
public static class Config {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory containerFactory() {
|
public ServletWebServerFactory webServerFactory() {
|
||||||
return containerFactory;
|
return webServerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
|
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
|
||||||
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
|
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||||
import org.springframework.boot.context.embedded.ConfigurableReactiveWebServer;
|
import org.springframework.boot.web.reactive.server.ConfigurableReactiveWebServerFactory;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
@ -45,7 +45,7 @@ public class DefaultReactiveWebServerCustomizerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCustomizeServerPort() throws Exception {
|
public void testCustomizeServerPort() throws Exception {
|
||||||
ConfigurableReactiveWebServer factory = mock(ConfigurableReactiveWebServer.class);
|
ConfigurableReactiveWebServerFactory factory = mock(ConfigurableReactiveWebServerFactory.class);
|
||||||
this.properties.setPort(9000);
|
this.properties.setPort(9000);
|
||||||
this.customizer.customize(factory);
|
this.customizer.customize(factory);
|
||||||
verify(factory).setPort(9000);
|
verify(factory).setPort(9000);
|
||||||
|
@ -53,7 +53,7 @@ public class DefaultReactiveWebServerCustomizerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCustomizeServerAddress() throws Exception {
|
public void testCustomizeServerAddress() throws Exception {
|
||||||
ConfigurableReactiveWebServer factory = mock(ConfigurableReactiveWebServer.class);
|
ConfigurableReactiveWebServerFactory factory = mock(ConfigurableReactiveWebServerFactory.class);
|
||||||
InetAddress address = mock(InetAddress.class);
|
InetAddress address = mock(InetAddress.class);
|
||||||
this.properties.setAddress(address);
|
this.properties.setAddress(address);
|
||||||
this.customizer.customize(factory);
|
this.customizer.customize(factory);
|
||||||
|
|
|
@ -20,8 +20,8 @@ import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
import org.springframework.boot.context.GenericReactiveWebApplicationContext;
|
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
|
import org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
|
@ -18,10 +18,10 @@ package org.springframework.boot.autoconfigure.webflux;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.AbstractReactiveWebServerFactory;
|
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebServer;
|
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebServerException;
|
import org.springframework.boot.web.server.WebServer;
|
||||||
import org.springframework.boot.context.embedded.ReactiveWebServerFactory;
|
import org.springframework.boot.web.server.WebServerException;
|
||||||
import org.springframework.http.server.reactive.HttpHandler;
|
import org.springframework.http.server.reactive.HttpHandler;
|
||||||
|
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
@ -36,13 +36,13 @@ public class MockReactiveWebServerFactory extends AbstractReactiveWebServerFacto
|
||||||
private MockReactiveWebServer webServer;
|
private MockReactiveWebServer webServer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EmbeddedWebServer getReactiveHttpServer(HttpHandler httpHandler) {
|
public WebServer getWebServer(HttpHandler httpHandler) {
|
||||||
this.webServer = spy(new MockReactiveWebServer(httpHandler, getPort()));
|
this.webServer = spy(new MockReactiveWebServer(httpHandler, getPort()));
|
||||||
return this.webServer;
|
return this.webServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EmbeddedWebServer getReactiveHttpServer(Map<String, HttpHandler> handlerMap) {
|
public WebServer getWebServer(Map<String, HttpHandler> handlerMap) {
|
||||||
this.webServer = spy(new MockReactiveWebServer(handlerMap, getPort()));
|
this.webServer = spy(new MockReactiveWebServer(handlerMap, getPort()));
|
||||||
return this.webServer;
|
return this.webServer;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class MockReactiveWebServerFactory extends AbstractReactiveWebServerFacto
|
||||||
return this.webServer;
|
return this.webServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MockReactiveWebServer implements EmbeddedWebServer {
|
public static class MockReactiveWebServer implements WebServer {
|
||||||
|
|
||||||
private final int port;
|
private final int port;
|
||||||
|
|
||||||
|
@ -78,12 +78,12 @@ public class MockReactiveWebServerFactory extends AbstractReactiveWebServerFacto
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() throws EmbeddedWebServerException {
|
public void start() throws WebServerException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() throws EmbeddedWebServerException {
|
public void stop() throws WebServerException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@ import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.EmbeddedReactiveWebApplicationContext;
|
import org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext;
|
||||||
import org.springframework.boot.context.embedded.ReactiveWebServerCustomizer;
|
import org.springframework.boot.web.reactive.server.ReactiveWebServerCustomizer;
|
||||||
import org.springframework.boot.context.embedded.ReactiveWebServerFactory;
|
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
|
||||||
import org.springframework.context.ApplicationContextException;
|
import org.springframework.context.ApplicationContextException;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
@ -40,14 +40,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*/
|
*/
|
||||||
public class ReactiveWebServerAutoConfigurationTests {
|
public class ReactiveWebServerAutoConfigurationTests {
|
||||||
|
|
||||||
private EmbeddedReactiveWebApplicationContext context;
|
private ReactiveWebServerApplicationContext context;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
public ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createFromConfigClass() {
|
public void createFromConfigClass() {
|
||||||
this.context = new EmbeddedReactiveWebApplicationContext(BaseConfiguration.class);
|
this.context = new ReactiveWebServerApplicationContext(BaseConfiguration.class);
|
||||||
assertThat(this.context.getBeansOfType(ReactiveWebServerFactory.class))
|
assertThat(this.context.getBeansOfType(ReactiveWebServerFactory.class))
|
||||||
.hasSize(1);
|
.hasSize(1);
|
||||||
assertThat(this.context.getBeansOfType(ReactiveWebServerCustomizer.class))
|
assertThat(this.context.getBeansOfType(ReactiveWebServerCustomizer.class))
|
||||||
|
@ -60,7 +60,7 @@ public class ReactiveWebServerAutoConfigurationTests {
|
||||||
public void missingHttpHandler() {
|
public void missingHttpHandler() {
|
||||||
this.thrown.expect(ApplicationContextException.class);
|
this.thrown.expect(ApplicationContextException.class);
|
||||||
this.thrown.expectMessage(Matchers.containsString("missing HttpHandler bean"));
|
this.thrown.expectMessage(Matchers.containsString("missing HttpHandler bean"));
|
||||||
this.context = new EmbeddedReactiveWebApplicationContext(
|
this.context = new ReactiveWebServerApplicationContext(
|
||||||
MissingHttpHandlerConfiguration.class);
|
MissingHttpHandlerConfiguration.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,13 +69,13 @@ public class ReactiveWebServerAutoConfigurationTests {
|
||||||
this.thrown.expect(ApplicationContextException.class);
|
this.thrown.expect(ApplicationContextException.class);
|
||||||
this.thrown.expectMessage(Matchers.containsString(
|
this.thrown.expectMessage(Matchers.containsString(
|
||||||
"multiple HttpHandler beans : httpHandler,additionalHttpHandler"));
|
"multiple HttpHandler beans : httpHandler,additionalHttpHandler"));
|
||||||
this.context = new EmbeddedReactiveWebApplicationContext(BaseConfiguration.class,
|
this.context = new ReactiveWebServerApplicationContext(BaseConfiguration.class,
|
||||||
TooManyHttpHandlers.class);
|
TooManyHttpHandlers.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void customizeReactiveWebServer() {
|
public void customizeReactiveWebServer() {
|
||||||
this.context = new EmbeddedReactiveWebApplicationContext(BaseConfiguration.class,
|
this.context = new ReactiveWebServerApplicationContext(BaseConfiguration.class,
|
||||||
ReactiveWebServerCustomization.class);
|
ReactiveWebServerCustomization.class);
|
||||||
MockReactiveWebServerFactory factory = this.context
|
MockReactiveWebServerFactory factory = this.context
|
||||||
.getBean(MockReactiveWebServerFactory.class);
|
.getBean(MockReactiveWebServerFactory.class);
|
||||||
|
|
|
@ -24,9 +24,9 @@ import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.beans.DirectFieldAccessor;
|
import org.springframework.beans.DirectFieldAccessor;
|
||||||
import org.springframework.boot.autoconfigure.validation.SpringValidator;
|
import org.springframework.boot.autoconfigure.validation.SpringValidator;
|
||||||
import org.springframework.boot.context.GenericReactiveWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
|
import org.springframework.boot.web.reactive.context.GenericReactiveWebApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
|
@ -27,11 +27,11 @@ import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.test.util.ReflectionTestUtils;
|
import org.springframework.test.util.ReflectionTestUtils;
|
||||||
|
@ -45,11 +45,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*/
|
*/
|
||||||
public class WebSocketAutoConfigurationTests {
|
public class WebSocketAutoConfigurationTests {
|
||||||
|
|
||||||
private AnnotationConfigEmbeddedWebApplicationContext context;
|
private AnnotationConfigServletWebServerApplicationContext context;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void createContext() {
|
public void createContext() {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -92,8 +92,8 @@ public class WebSocketAutoConfigurationTests {
|
||||||
static class CommonConfiguration {
|
static class CommonConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerCustomizerBeanPostProcessor embeddedServletContainerCustomizerBeanPostProcessor() {
|
public ServletWebServerFactoryCustomizerBeanPostProcessor ServletWebServerCustomizerBeanPostProcessor() {
|
||||||
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
|
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -102,10 +102,10 @@ public class WebSocketAutoConfigurationTests {
|
||||||
static class TomcatConfiguration extends CommonConfiguration {
|
static class TomcatConfiguration extends CommonConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory servletContainerFactory() {
|
public ServletWebServerFactory webServerFactory() {
|
||||||
TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
|
||||||
tomcatEmbeddedServletContainerFactory.setPort(0);
|
factory.setPort(0);
|
||||||
return tomcatEmbeddedServletContainerFactory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -114,10 +114,10 @@ public class WebSocketAutoConfigurationTests {
|
||||||
static class JettyConfiguration extends CommonConfiguration {
|
static class JettyConfiguration extends CommonConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory servletContainerFactory() {
|
public ServletWebServerFactory webServerFactory() {
|
||||||
JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory = new JettyEmbeddedServletContainerFactory();
|
JettyServletWebServerFactory JettyServletWebServerFactory = new JettyServletWebServerFactory();
|
||||||
jettyEmbeddedServletContainerFactory.setPort(0);
|
JettyServletWebServerFactory.setPort(0);
|
||||||
return jettyEmbeddedServletContainerFactory;
|
return JettyServletWebServerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,12 +34,12 @@ import org.junit.Test;
|
||||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.ServerPortInfoApplicationContextInitializer;
|
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
|
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.messaging.converter.CompositeMessageConverter;
|
import org.springframework.messaging.converter.CompositeMessageConverter;
|
||||||
|
@ -78,7 +78,7 @@ import static org.junit.Assert.fail;
|
||||||
*/
|
*/
|
||||||
public class WebSocketMessagingAutoConfigurationTests {
|
public class WebSocketMessagingAutoConfigurationTests {
|
||||||
|
|
||||||
private AnnotationConfigEmbeddedWebApplicationContext context = new AnnotationConfigEmbeddedWebApplicationContext();
|
private AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
|
|
||||||
private SockJsClient sockJsClient;
|
private SockJsClient sockJsClient;
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ public class WebSocketMessagingAutoConfigurationTests {
|
||||||
@EnableConfigurationProperties
|
@EnableConfigurationProperties
|
||||||
@EnableWebSocketMessageBroker
|
@EnableWebSocketMessageBroker
|
||||||
@ImportAutoConfiguration({ JacksonAutoConfiguration.class,
|
@ImportAutoConfiguration({ JacksonAutoConfiguration.class,
|
||||||
EmbeddedServletContainerAutoConfiguration.class,
|
ServletWebServerFactoryAutoConfiguration.class,
|
||||||
WebSocketMessagingAutoConfiguration.class,
|
WebSocketMessagingAutoConfiguration.class,
|
||||||
DispatcherServletAutoConfiguration.class })
|
DispatcherServletAutoConfiguration.class })
|
||||||
static class WebSocketMessagingConfiguration
|
static class WebSocketMessagingConfiguration
|
||||||
|
@ -230,8 +230,8 @@ public class WebSocketMessagingAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TomcatEmbeddedServletContainerFactory tomcat() {
|
public TomcatServletWebServerFactory tomcat() {
|
||||||
return new TomcatEmbeddedServletContainerFactory(0);
|
return new TomcatServletWebServerFactory(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Example implements CommandLineRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(String... args) {
|
void run(String... args) {
|
||||||
def port = context.embeddedWebServer.port;
|
def port = context.webServer.port;
|
||||||
def world = new RESTClient("http://localhost:" + port).get(path:"/").data.text
|
def world = new RESTClient("http://localhost:" + port).get(path:"/").data.text
|
||||||
print "Hello " + world
|
print "Hello " + world
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,8 @@ import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
|
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
|
|
||||||
import org.springframework.boot.autoconfigure.web.ResourceProperties;
|
import org.springframework.boot.autoconfigure.web.ResourceProperties;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedWebApplicationContext;
|
import org.springframework.boot.autoconfigure.web.ServletWebServerFactoryAutoConfiguration;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
|
|
||||||
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
|
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
|
||||||
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
|
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
|
||||||
import org.springframework.boot.devtools.filewatch.ChangedFiles;
|
import org.springframework.boot.devtools.filewatch.ChangedFiles;
|
||||||
|
@ -45,6 +43,8 @@ import org.springframework.boot.devtools.restart.FailureHandler;
|
||||||
import org.springframework.boot.devtools.restart.MockRestartInitializer;
|
import org.springframework.boot.devtools.restart.MockRestartInitializer;
|
||||||
import org.springframework.boot.devtools.restart.MockRestarter;
|
import org.springframework.boot.devtools.restart.MockRestarter;
|
||||||
import org.springframework.boot.devtools.restart.Restarter;
|
import org.springframework.boot.devtools.restart.Restarter;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
|
||||||
|
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
@ -243,8 +243,8 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void devToolsSwitchesJspServletToDevelopmentMode() {
|
public void devToolsSwitchesJspServletToDevelopmentMode() {
|
||||||
this.context = initializeAndRun(Config.class);
|
this.context = initializeAndRun(Config.class);
|
||||||
TomcatEmbeddedServletContainer tomcatContainer = (TomcatEmbeddedServletContainer) ((EmbeddedWebApplicationContext) this.context)
|
TomcatWebServer tomcatContainer = (TomcatWebServer) ((ServletWebServerApplicationContext) this.context)
|
||||||
.getEmbeddedWebServer();
|
.getWebServer();
|
||||||
Container context = tomcatContainer.getTomcat().getHost().findChildren()[0];
|
Container context = tomcatContainer.getTomcat().getHost().findChildren()[0];
|
||||||
StandardWrapper jspServletWrapper = (StandardWrapper) context.findChild("jsp");
|
StandardWrapper jspServletWrapper = (StandardWrapper) context.findChild("jsp");
|
||||||
EmbeddedServletOptions options = (EmbeddedServletOptions) ReflectionTestUtils
|
EmbeddedServletOptions options = (EmbeddedServletOptions) ReflectionTestUtils
|
||||||
|
@ -277,14 +277,14 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class })
|
LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class })
|
||||||
public static class Config {
|
public static class Config {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class })
|
LocalDevToolsAutoConfiguration.class, ThymeleafAutoConfiguration.class })
|
||||||
public static class ConfigWithMockLiveReload {
|
public static class ConfigWithMockLiveReload {
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@Import({ EmbeddedServletContainerAutoConfiguration.class,
|
@Import({ ServletWebServerFactoryAutoConfiguration.class,
|
||||||
LocalDevToolsAutoConfiguration.class, ResourceProperties.class })
|
LocalDevToolsAutoConfiguration.class, ResourceProperties.class })
|
||||||
public static class WebResourcesConfig {
|
public static class WebResourcesConfig {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -23,8 +23,6 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.devtools.remote.server.AccessManager;
|
import org.springframework.boot.devtools.remote.server.AccessManager;
|
||||||
import org.springframework.boot.devtools.remote.server.Dispatcher;
|
import org.springframework.boot.devtools.remote.server.Dispatcher;
|
||||||
import org.springframework.boot.devtools.remote.server.DispatcherFilter;
|
import org.springframework.boot.devtools.remote.server.DispatcherFilter;
|
||||||
|
@ -42,6 +40,8 @@ import org.springframework.boot.devtools.tunnel.server.TargetServerConnection;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -95,8 +95,8 @@ public class HttpTunnelIntegrationTests {
|
||||||
private int httpServerPort = SocketUtils.findAvailableTcpPort();
|
private int httpServerPort = SocketUtils.findAvailableTcpPort();
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory container() {
|
public ServletWebServerFactory container() {
|
||||||
return new TomcatEmbeddedServletContainerFactory(this.httpServerPort);
|
return new TomcatServletWebServerFactory(this.httpServerPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -28,8 +28,6 @@ import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
import org.springframework.beans.factory.BeanCreationException;
|
import org.springframework.beans.factory.BeanCreationException;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
|
||||||
import org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer;
|
import org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer;
|
||||||
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
|
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
|
||||||
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
|
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
|
||||||
|
@ -43,6 +41,8 @@ import org.springframework.boot.devtools.restart.RestartScopeInitializer;
|
||||||
import org.springframework.boot.devtools.tunnel.client.TunnelClient;
|
import org.springframework.boot.devtools.tunnel.client.TunnelClient;
|
||||||
import org.springframework.boot.test.rule.OutputCapture;
|
import org.springframework.boot.test.rule.OutputCapture;
|
||||||
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
import org.springframework.boot.test.util.EnvironmentTestUtils;
|
||||||
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.server.ServerHttpRequest;
|
import org.springframework.http.server.ServerHttpRequest;
|
||||||
|
@ -71,7 +71,7 @@ public class RemoteClientConfigurationTests {
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
public ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
private AnnotationConfigEmbeddedWebApplicationContext context;
|
private AnnotationConfigServletWebServerApplicationContext context;
|
||||||
|
|
||||||
private static int remotePort = SocketUtils.findAvailableTcpPort();
|
private static int remotePort = SocketUtils.findAvailableTcpPort();
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ public class RemoteClientConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configure(String remoteUrl, boolean setSecret, String... pairs) {
|
private void configure(String remoteUrl, boolean setSecret, String... pairs) {
|
||||||
this.context = new AnnotationConfigEmbeddedWebApplicationContext();
|
this.context = new AnnotationConfigServletWebServerApplicationContext();
|
||||||
new RestartScopeInitializer().initialize(this.context);
|
new RestartScopeInitializer().initialize(this.context);
|
||||||
this.context.register(Config.class, RemoteClientConfiguration.class);
|
this.context.register(Config.class, RemoteClientConfiguration.class);
|
||||||
String remoteUrlProperty = "remoteUrl:" + remoteUrl + ":"
|
String remoteUrlProperty = "remoteUrl:" + remoteUrl + ":"
|
||||||
|
@ -167,8 +167,8 @@ public class RemoteClientConfigurationTests {
|
||||||
static class Config {
|
static class Config {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TomcatEmbeddedServletContainerFactory tomcat() {
|
public TomcatServletWebServerFactory tomcat() {
|
||||||
return new TomcatEmbeddedServletContainerFactory(remotePort);
|
return new TomcatServletWebServerFactory(remotePort);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -19,8 +19,10 @@ package org.springframework.boot.context.embedded;
|
||||||
import org.apache.catalina.Context;
|
import org.apache.catalina.Context;
|
||||||
import org.apache.tomcat.util.http.LegacyCookieProcessor;
|
import org.apache.tomcat.util.http.LegacyCookieProcessor;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatContextCustomizer;
|
import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizer;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@ -33,20 +35,20 @@ public class TomcatLegacyCookieProcessorExample {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration class that declares the required
|
* Configuration class that declares the required
|
||||||
* {@link EmbeddedServletContainerCustomizer}.
|
* {@link ServletWebServerFactoryCustomizer}.
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
static class LegacyCookieProcessorConfiguration {
|
static class LegacyCookieProcessorConfiguration {
|
||||||
|
|
||||||
// tag::customizer[]
|
// tag::customizer[]
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerCustomizer cookieProcessorCustomizer() {
|
public ServletWebServerFactoryCustomizer cookieProcessorCustomizer() {
|
||||||
return new EmbeddedServletContainerCustomizer() {
|
return new ServletWebServerFactoryCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void customize(ConfigurableEmbeddedServletContainer container) {
|
public void customize(ConfigurableServletWebServerFactory serverFactory) {
|
||||||
if (container instanceof TomcatEmbeddedServletContainerFactory) {
|
if (serverFactory instanceof TomcatServletWebServerFactory) {
|
||||||
((TomcatEmbeddedServletContainerFactory) container)
|
((TomcatServletWebServerFactory) serverFactory)
|
||||||
.addContextCustomizers(new TomcatContextCustomizer() {
|
.addContextCustomizers(new TomcatContextCustomizer() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,8 +22,10 @@ import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.context.embedded.TomcatLegacyCookieProcessorExample.LegacyCookieProcessorConfiguration;
|
import org.springframework.boot.context.embedded.TomcatLegacyCookieProcessorExample.LegacyCookieProcessorConfiguration;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
|
||||||
|
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
|
||||||
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactoryCustomizerBeanPostProcessor;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@ -38,10 +40,10 @@ public class TomcatLegacyCookieProcessorExampleTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void cookieProcessorIsCustomized() {
|
public void cookieProcessorIsCustomized() {
|
||||||
EmbeddedWebApplicationContext applicationContext = (EmbeddedWebApplicationContext) new SpringApplication(
|
ServletWebServerApplicationContext applicationContext = (ServletWebServerApplicationContext) new SpringApplication(
|
||||||
TestConfiguration.class, LegacyCookieProcessorConfiguration.class).run();
|
TestConfiguration.class, LegacyCookieProcessorConfiguration.class).run();
|
||||||
Context context = (Context) ((TomcatEmbeddedServletContainer) applicationContext
|
Context context = (Context) ((TomcatWebServer) applicationContext
|
||||||
.getEmbeddedWebServer()).getTomcat().getHost().findChildren()[0];
|
.getWebServer()).getTomcat().getHost().findChildren()[0];
|
||||||
assertThat(context.getCookieProcessor())
|
assertThat(context.getCookieProcessor())
|
||||||
.isInstanceOf(LegacyCookieProcessor.class);
|
.isInstanceOf(LegacyCookieProcessor.class);
|
||||||
}
|
}
|
||||||
|
@ -50,13 +52,13 @@ public class TomcatLegacyCookieProcessorExampleTests {
|
||||||
static class TestConfiguration {
|
static class TestConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TomcatEmbeddedServletContainerFactory tomcatFactory() {
|
public TomcatServletWebServerFactory tomcatFactory() {
|
||||||
return new TomcatEmbeddedServletContainerFactory(0);
|
return new TomcatServletWebServerFactory(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerCustomizerBeanPostProcessor postProcessor() {
|
public ServletWebServerFactoryCustomizerBeanPostProcessor postProcessor() {
|
||||||
return new EmbeddedServletContainerCustomizerBeanPostProcessor();
|
return new ServletWebServerFactoryCustomizerBeanPostProcessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,21 +70,21 @@ public class WarPackagingTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onlyTomcatIsPackagedInWebInfLibProvided() throws IOException {
|
public void onlyTomcatIsPackagedInWebInfLibProvided() throws IOException {
|
||||||
checkWebInfEntriesForServletContainer("tomcat",
|
checkWebInfEntriesForWebServer("tomcat",
|
||||||
TOMCAT_EXPECTED_IN_WEB_INF_LIB_PROVIDED);
|
TOMCAT_EXPECTED_IN_WEB_INF_LIB_PROVIDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onlyJettyIsPackagedInWebInfLibProvided() throws IOException {
|
public void onlyJettyIsPackagedInWebInfLibProvided() throws IOException {
|
||||||
checkWebInfEntriesForServletContainer("jetty",
|
checkWebInfEntriesForWebServer("jetty",
|
||||||
JETTY_EXPECTED_IN_WEB_INF_LIB_PROVIDED);
|
JETTY_EXPECTED_IN_WEB_INF_LIB_PROVIDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkWebInfEntriesForServletContainer(String servletContainer,
|
private void checkWebInfEntriesForWebServer(String webServer,
|
||||||
Set<String> expectedLibProvidedEntries) throws IOException {
|
Set<String> expectedLibProvidedEntries) throws IOException {
|
||||||
project.newBuild().forTasks("clean", "build")
|
project.newBuild().forTasks("clean", "build")
|
||||||
.withArguments("-PbootVersion=" + BOOT_VERSION,
|
.withArguments("-PbootVersion=" + BOOT_VERSION,
|
||||||
"-PservletContainer=" + servletContainer)
|
"-PservletContainer=" + webServer)
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
JarFile war = new JarFile("target/war-packaging/build/libs/war-packaging.war");
|
JarFile war = new JarFile("target/war-packaging/build/libs/war-packaging.war");
|
||||||
|
|
|
@ -301,7 +301,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.puppycrawl.tools</groupId>
|
<groupId>com.puppycrawl.tools</groupId>
|
||||||
<artifactId>checkstyle</artifactId>
|
<artifactId>checkstyle</artifactId>
|
||||||
<version>7.1.1</version>
|
<version>7.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -77,6 +77,10 @@
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck">
|
<module name="com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck">
|
||||||
<property name="processJavadoc" value="true" />
|
<property name="processJavadoc" value="true" />
|
||||||
</module>
|
</module>
|
||||||
|
<module name="com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck">
|
||||||
|
<property name="file" value="spring-boot-parent/src/checkstyle/import-control.xml" />
|
||||||
|
<property name="path" value="^.*[\\/]src[\\/]main[\\/].*$" />
|
||||||
|
</module>
|
||||||
<module name="com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck">
|
<module name="com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck">
|
||||||
<property name="groups" value="java,/^javax?\./,*,org.springframework" />
|
<property name="groups" value="java,/^javax?\./,*,org.springframework" />
|
||||||
<property name="ordered" value="true" />
|
<property name="ordered" value="true" />
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE import-control PUBLIC "-//Puppy Crawl//DTD Import Control 1.1//EN" "http://www.puppycrawl.com/dtds/import_control_1_1.dtd">
|
||||||
|
<import-control pkg="org.springframework.boot">
|
||||||
|
<allow pkg=".*" regex="true" />
|
||||||
|
|
||||||
|
<!-- Web related concerns -->
|
||||||
|
<subpackage name="web">
|
||||||
|
|
||||||
|
<!-- Lock things down -->
|
||||||
|
<disallow pkg="org.springframework.boot.web" />
|
||||||
|
<disallow pkg="org.springframework.web.servlet" />
|
||||||
|
<disallow pkg="javax.servlet" />
|
||||||
|
|
||||||
|
<!-- Common -->
|
||||||
|
<subpackage name="client">
|
||||||
|
</subpackage>
|
||||||
|
<subpackage name="server">
|
||||||
|
<disallow pkg="org.springframework.context" />
|
||||||
|
</subpackage>
|
||||||
|
<subpackage name="context">
|
||||||
|
<allow pkg="org.springframework.boot.web.server" />
|
||||||
|
</subpackage>
|
||||||
|
|
||||||
|
<!-- Servlet -->
|
||||||
|
<subpackage name="servlet">
|
||||||
|
<allow pkg="javax.servlet" />
|
||||||
|
<subpackage name="context">
|
||||||
|
<allow pkg="org.springframework.boot.web.context" />
|
||||||
|
<allow pkg="org.springframework.boot.web.server" />
|
||||||
|
<allow pkg="org.springframework.boot.web.servlet.server" />
|
||||||
|
<allow pkg="org.springframework.boot.web.servlet" />
|
||||||
|
</subpackage>
|
||||||
|
<subpackage name="filter">
|
||||||
|
<allow pkg="javax.servlet" />
|
||||||
|
<allow pkg="org.springframework.boot.web.servlet" />
|
||||||
|
</subpackage>
|
||||||
|
<subpackage name="server">
|
||||||
|
<disallow pkg="org.springframework.context" />
|
||||||
|
<allow pkg="org.springframework.boot.web.server" />
|
||||||
|
<allow pkg="org.springframework.boot.web.servlet" />
|
||||||
|
</subpackage>
|
||||||
|
</subpackage>
|
||||||
|
<subpackage name="support">
|
||||||
|
<allow pkg="javax.servlet" />
|
||||||
|
<allow pkg="org.springframework.boot.web.servlet" />
|
||||||
|
<allow pkg="org.springframework.boot.web.server" />
|
||||||
|
</subpackage>
|
||||||
|
|
||||||
|
<!-- Reactive -->
|
||||||
|
<subpackage name="reactive">
|
||||||
|
<subpackage name="context">
|
||||||
|
<allow pkg="org.springframework.boot.web.context" />
|
||||||
|
<allow pkg="org.springframework.boot.web.server" />
|
||||||
|
<allow pkg="org.springframework.boot.web.reactive.server" />
|
||||||
|
</subpackage>
|
||||||
|
<subpackage name="server">
|
||||||
|
<allow pkg="org.springframework.boot.web.server" />
|
||||||
|
<disallow pkg="org.springframework.context" />
|
||||||
|
</subpackage>
|
||||||
|
</subpackage>
|
||||||
|
|
||||||
|
<!-- Embedded Servers -->
|
||||||
|
<subpackage name="embedded">
|
||||||
|
<allow pkg="javax.servlet" />
|
||||||
|
<allow pkg="org.springframework.boot.web.server" />
|
||||||
|
<allow pkg="org.springframework.boot.web.servlet" />
|
||||||
|
<allow pkg="org.springframework.boot.web.servlet.server" />
|
||||||
|
<allow pkg="org.springframework.boot.web.reactive.server" />
|
||||||
|
</subpackage>
|
||||||
|
|
||||||
|
</subpackage>
|
||||||
|
</import-control>
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -22,10 +22,10 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
|
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -24,10 +24,10 @@ import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
|
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
|
||||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -22,10 +22,10 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
|
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -24,10 +24,10 @@ import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
|
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
|
||||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -24,10 +24,10 @@ import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
|
import org.springframework.boot.actuate.autoconfigure.LocalManagementPort;
|
||||||
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
import org.springframework.boot.autoconfigure.security.SecurityProperties;
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
|
|
@ -29,9 +29,9 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.CommandLineRunner;
|
import org.springframework.boot.CommandLineRunner;
|
||||||
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
|
@ -25,7 +25,7 @@ import com.sun.jersey.spi.container.servlet.ServletContainer;
|
||||||
import org.springframework.boot.WebApplicationType;
|
import org.springframework.boot.WebApplicationType;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ public class SampleJersey1Application {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
// Not needed if Spring Web MVC is also present on classpath
|
// Not needed if Spring Web MVC is also present on classpath
|
||||||
public TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory() {
|
public TomcatServletWebServerFactory webServerFactory() {
|
||||||
return new TomcatEmbeddedServletContainerFactory();
|
return new TomcatServletWebServerFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -19,11 +19,11 @@ package sample.jetty.ssl;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
import org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption;
|
import org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.test.annotation.DirtiesContext;
|
import org.springframework.test.annotation.DirtiesContext;
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.net.URI;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.context.embedded.ServerPortInfoApplicationContextInitializer;
|
import org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.data.redis.RedisConnectionFailureException;
|
import org.springframework.data.redis.RedisConnectionFailureException;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -20,8 +20,8 @@ import org.apache.catalina.connector.Connector;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
|
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||||||
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
|
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.util.SocketUtils;
|
import org.springframework.util.SocketUtils;
|
||||||
|
|
||||||
|
@ -40,8 +40,8 @@ public class SampleTomcatTwoConnectorsApplication {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public EmbeddedServletContainerFactory servletContainer() {
|
public ServletWebServerFactory servletContainer() {
|
||||||
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
|
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
|
||||||
tomcat.addAdditionalTomcatConnectors(createStandardConnector());
|
tomcat.addAdditionalTomcatConnectors(createStandardConnector());
|
||||||
return tomcat;
|
return tomcat;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -31,9 +31,9 @@ import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.context.embedded.LocalServerPort;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||||
|
import org.springframework.boot.web.server.LocalServerPort;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue