From a30fe9d9ff882db3e4bcbea93d5c54030da0c741 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 20 Jan 2017 16:39:00 +0000 Subject: [PATCH] Update ServerPropertiesTests to tolerate changes in Tomcat 8.5.11 Closes gh-7360 --- .../web/ServerPropertiesTests.java | 52 ++++++++++++++----- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java index b8e5fa9b1d..c8e4ede3b8 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java @@ -496,12 +496,19 @@ public class ServerPropertiesTests { Map map = new HashMap(); map.put("server.tomcat.accept-count", "10"); bindProperties(map); - TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); + TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory( + 0); this.properties.customize(container); TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container .getEmbeddedServletContainer(); - assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector() - .getProtocolHandler()).getBacklog()).isEqualTo(10); + embeddedContainer.start(); + try { + assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector() + .getProtocolHandler()).getBacklog()).isEqualTo(10); + } + finally { + embeddedContainer.stop(); + } } @Test @@ -509,12 +516,19 @@ public class ServerPropertiesTests { Map map = new HashMap(); map.put("server.tomcat.max-connections", "5"); bindProperties(map); - TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); + TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory( + 0); this.properties.customize(container); TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container .getEmbeddedServletContainer(); - assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector() - .getProtocolHandler()).getMaxConnections()).isEqualTo(5); + embeddedContainer.start(); + try { + assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector() + .getProtocolHandler()).getMaxConnections()).isEqualTo(5); + } + finally { + embeddedContainer.stop(); + } } @Test @@ -522,12 +536,19 @@ public class ServerPropertiesTests { Map map = new HashMap(); map.put("server.tomcat.max-http-post-size", "10000"); bindProperties(map); - TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); + TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory( + 0); this.properties.customize(container); TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container .getEmbeddedServletContainer(); - assertThat(embeddedContainer.getTomcat().getConnector().getMaxPostSize()) - .isEqualTo(10000); + embeddedContainer.start(); + try { + assertThat(embeddedContainer.getTomcat().getConnector().getMaxPostSize()) + .isEqualTo(10000); + } + finally { + embeddedContainer.stop(); + } } @Test @@ -536,12 +557,19 @@ public class ServerPropertiesTests { Map map = new HashMap(); map.put("server.max-http-post-size", "2000"); bindProperties(map); - TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); + TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory( + 0); this.properties.customize(container); TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container .getEmbeddedServletContainer(); - assertThat(embeddedContainer.getTomcat().getConnector().getMaxPostSize()) - .isEqualTo(2000); + embeddedContainer.start(); + try { + assertThat(embeddedContainer.getTomcat().getConnector().getMaxPostSize()) + .isEqualTo(2000); + } + finally { + embeddedContainer.stop(); + } } @Test