From 4babe2e59d03971925f8f52f13495ee348a34a04 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 22 Jul 2025 18:02:39 +0100 Subject: [PATCH] Drop Tomcat 11 samples They are no longer necessary since Tomcat 11 is now the managed version. --- settings.gradle | 2 - .../build.gradle | 37 ------ .../ssl/SampleTomcat11SslApplication.java | 29 ----- .../tomcat/ssl/web/SampleController.java | 30 ----- .../src/main/resources/application.properties | 13 -- .../src/main/resources/sample.jks | Bin 2264 -> 0 bytes .../SampleTomcat11SslApplicationTests.java | 92 -------------- .../build.gradle | 38 ------ .../tomcat/SampleTomcat11Application.java | 54 -------- .../tomcat/service/HelloWorldService.java | 32 ----- .../tomcat/service/HttpHeaderService.java | 43 ------- .../tomcat/util/RandomStringUtil.java | 33 ----- .../tomcat/web/SampleController.java | 53 -------- .../src/main/resources/application.properties | 5 - ...igurationSampleTomcatApplicationTests.java | 72 ----------- .../SampleTomcat11ApplicationTests.java | 116 ------------------ 16 files changed, 649 deletions(-) delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11-ssl/build.gradle delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/java/smoketest/tomcat/ssl/SampleTomcat11SslApplication.java delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/java/smoketest/tomcat/ssl/web/SampleController.java delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/resources/application.properties delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/resources/sample.jks delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/test/java/smoketest/tomcat/ssl/SampleTomcat11SslApplicationTests.java delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11/build.gradle delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/SampleTomcat11Application.java delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/service/HelloWorldService.java delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/service/HttpHeaderService.java delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/util/RandomStringUtil.java delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/web/SampleController.java delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11/src/main/resources/application.properties delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11/src/test/java/smoketest/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java delete mode 100644 smoke-test/spring-boot-smoke-test-tomcat11/src/test/java/smoketest/tomcat/SampleTomcat11ApplicationTests.java diff --git a/settings.gradle b/settings.gradle index e64cba20aff..058f6b9e32d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -344,8 +344,6 @@ include ":smoke-test:spring-boot-smoke-test-tomcat" include ":smoke-test:spring-boot-smoke-test-tomcat-jsp" include ":smoke-test:spring-boot-smoke-test-tomcat-multi-connectors" include ":smoke-test:spring-boot-smoke-test-tomcat-ssl" -include ":smoke-test:spring-boot-smoke-test-tomcat11" -include ":smoke-test:spring-boot-smoke-test-tomcat11-ssl" include ":smoke-test:spring-boot-smoke-test-traditional" include ":smoke-test:spring-boot-smoke-test-undertow" include ":smoke-test:spring-boot-smoke-test-undertow-ssl" diff --git a/smoke-test/spring-boot-smoke-test-tomcat11-ssl/build.gradle b/smoke-test/spring-boot-smoke-test-tomcat11-ssl/build.gradle deleted file mode 100644 index 19ae3ff565a..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11-ssl/build.gradle +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id "java" -} - -description = "Spring Boot Tomcat 11 SSL smoke test" - -configurations.all { - resolutionStrategy.eachDependency { - if (it.requested.group == 'org.apache.tomcat' || it.requested.group == 'org.apache.tomcat.embed') { - it.useVersion '11.0.4' - } - } -} - -dependencies { - implementation(project(":starter:spring-boot-starter-webmvc")) - implementation(project(":starter:spring-boot-starter-actuator")) - - testImplementation(project(":starter:spring-boot-starter-test")) - testImplementation("org.apache.httpcomponents.client5:httpclient5") -} diff --git a/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/java/smoketest/tomcat/ssl/SampleTomcat11SslApplication.java b/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/java/smoketest/tomcat/ssl/SampleTomcat11SslApplication.java deleted file mode 100644 index d35a3f0cba1..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/java/smoketest/tomcat/ssl/SampleTomcat11SslApplication.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package smoketest.tomcat.ssl; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SampleTomcat11SslApplication { - - public static void main(String[] args) { - SpringApplication.run(SampleTomcat11SslApplication.class, args); - } - -} diff --git a/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/java/smoketest/tomcat/ssl/web/SampleController.java b/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/java/smoketest/tomcat/ssl/web/SampleController.java deleted file mode 100644 index 2bd71e552b4..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/java/smoketest/tomcat/ssl/web/SampleController.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package smoketest.tomcat.ssl.web; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class SampleController { - - @GetMapping("/") - public String helloWorld() { - return "Hello, world"; - } - -} diff --git a/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/resources/application.properties b/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/resources/application.properties deleted file mode 100644 index c9f855cfcee..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/resources/application.properties +++ /dev/null @@ -1,13 +0,0 @@ -server.port=8443 - -management.endpoints.web.exposure.include=* -management.endpoint.health.show-details=always -management.health.ssl.certificate-validity-warning-threshold=7d -management.health.ssl.enabled=true -management.info.ssl.enabled=true - -server.ssl.bundle=ssldemo -spring.ssl.bundle.jks.ssldemo.keystore.location=classpath:sample.jks -spring.ssl.bundle.jks.ssldemo.keystore.password=secret -spring.ssl.bundle.jks.ssldemo.keystore.type=JKS -spring.ssl.bundle.jks.ssldemo.key.password=password diff --git a/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/resources/sample.jks b/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/main/resources/sample.jks deleted file mode 100644 index 6aa9a28053a591e41453e665e5024e8a8cb78b3d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2264 zcmchYX*3iJ7sqE|hQS!q5Mv)4GM2$i#uAFqC`%7x7baWA*i&dRX>3`uq(XS?3XSYp z%38`&ib7E$8j~$cF^}gt?|I+noW8#w?uYxk=iGD8|K9Vzd#pVc0002(2k@T|2@MMI zqxqr2AhQO*TVi`j@((S;e;g;l$#dAA{>vf0kX$R(Qn4oKgGEYjZ5zti2dw?Z6A zh%LuFCNI?9o+Z1duJL-++e#cjO`zlK?u9s030=k_*wD1#-$FbIDRDnA^vo@fm( zzjt(3VJrGOr0iHXSTM|rYN#>RZ@Dp`PwB2zrDQffLvuoR2~V3ReYa0&vU^dXd8isV zsAf*@!8s%xBvHLseXn6f?1kefe(8uAmAbaF$x{Ykzb6c6jdUwY1$y4tFzsj7 zIghr!T#ODfu@Po!a29@kXQ8kY#(LE<0o7?7PQ|eMeY@Equ?R-6*f@Na3o&stDQ=6( zQzDSQhCnS(9Bu9W_~giknP0vECqUsr4_9y_}nEU`cy z4}dApnAip92wMwgzciAFpc3i}+-#Zlq+iF7d1y}d4Qsp8=%l1N8NIs161I`HmkcpQ zY4*CUCFJJf(2!M{`&qQ}3($KeTQ=)mMrBs`DOb;%Of0tC)9he_p~w&CO#DfCgx(%s z{@|D(brX_Gb}ZDLmGej*JgEl0Et>q~kgTXuJg-PwvRjNx8sBbIShxD=xOySzw{;^X zAvrh5HTg>Xq@<{#^!Kg}B?qz@b<{ebD)yaSf&RChBIJQo-?Ahzw@qopSe^e&>^IuU zydM4Y1_C&>k7u|}=; z63R7$H6zat=hNExxEwXu1fQ*ytuEkP!{w{|#6TIEq1#*ck=6_NM*ILF65tmD-O5&R zMI!-MT<3U~t@}(CN4@RlZ~1I>C=!ywF)dNI{VvH;5Y3(Z4jY^%_c&fsm4Q`<1g|qX z&!h29jXjVE3nJnet*L)XL?-8<>qDbVGP%i^NwOZfwWO7?Mr!X7 zl}sG@9S_5}}td}$xrWIYY=e(VVBiv%A+M-{M z!3_^Tc=pV?niT!{D`!{e@W;MvrZ(OER{x7itVAtwE~spPtPtma|J=5dv&_oE!5H#` zdgXJ;+gJ4hI}*9QX9jpL`Gb)yCe%1}t!&O-^sihyZys%%5uF~WhsR_w(q7;vV5d4P zr%ZUA2}kO+L^2ePTgGT9Ua71w<+)poSyjTdLq&xbUn`<6&SpwFp(HRHUyU6J3WZ_! zfztko79+94Tq%mTYj53(RYcL&1~5`I#+w3`(Q|r+P(aT z%?r(^?IWw~19CB&uvXf(f7&BnEE{zwK4piVU`I4j1j?v5d4N<7VUJ8nM`$7S*mfKR z#9-JzPRZ?{M!@L+0N^V)IyeeP2T|^UK|m0QD+Ibs!wEoml^N!YO#vW~j~jraX(0A3 z6Kux?IRLez`O^X;{!4g%BhcRn>^H*qKZ3*|{_YGuz)KCJcu;)DSES5D2tDE`C02YR0R%Vy1T7k|RQ;3g<0icA$AuP0pOvc~jGl zz+NeKv_FT_;GWK&8XlDUv&hv9kxg?@c!bu?83i=YQ$S!K09Y)Glg3Hz?@|)ZCBlVz zP8i}#XZkMoje3I=h&I!!s_m?Qi@1MR`yv7X*yEs47qOs^t^?&=;*IQ!q&)gq_Sx5* z?fhU8Q*PSe*w7y)FH#P!9R^Xw!lTT+zI39L<&8cViaj$A(Z2Cg7!{V?uuyi#vlNCg z40i}2ivw&y&1-&Nh&WMG`&aIt>)(#tKTJ}^@696Kw1-{IzSOTnFF+0@k$o3%ZHS;Q#;t diff --git a/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/test/java/smoketest/tomcat/ssl/SampleTomcat11SslApplicationTests.java b/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/test/java/smoketest/tomcat/ssl/SampleTomcat11SslApplicationTests.java deleted file mode 100644 index 0382d36e50b..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11-ssl/src/test/java/smoketest/tomcat/ssl/SampleTomcat11SslApplicationTests.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package smoketest.tomcat.ssl; - -import org.junit.jupiter.api.Test; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.AbstractConfigurableWebServerFactory; -import org.springframework.boot.web.server.test.client.TestRestTemplate; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.json.JsonContent; - -import static org.assertj.core.api.Assertions.assertThat; - -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -class SampleTomcat11SslApplicationTests { - - @Autowired - private TestRestTemplate restTemplate; - - @Autowired - private AbstractConfigurableWebServerFactory webServerFactory; - - @Test - void testSsl() { - assertThat(this.webServerFactory.getSsl().isEnabled()).isTrue(); - } - - @Test - void testHome() { - ResponseEntity entity = this.restTemplate.getForEntity("/", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(entity.getBody()).isEqualTo("Hello, world"); - } - - @Test - void testSslInfo() { - ResponseEntity entity = this.restTemplate.getForEntity("/actuator/info", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - JsonContent body = new JsonContent(entity.getBody()); - assertThat(body).extractingPath("ssl.bundles[0].name").isEqualTo("ssldemo"); - assertThat(body).extractingPath("ssl.bundles[0].certificateChains[0].alias") - .isEqualTo("spring-boot-ssl-sample"); - assertThat(body).extractingPath("ssl.bundles[0].certificateChains[0].certificates[0].issuer") - .isEqualTo("CN=localhost,OU=Unknown,O=Unknown,L=Unknown,ST=Unknown,C=Unknown"); - assertThat(body).extractingPath("ssl.bundles[0].certificateChains[0].certificates[0].subject") - .isEqualTo("CN=localhost,OU=Unknown,O=Unknown,L=Unknown,ST=Unknown,C=Unknown"); - assertThat(body).extractingPath("ssl.bundles[0].certificateChains[0].certificates[0].validity.status") - .isEqualTo("EXPIRED"); - assertThat(body).extractingPath("ssl.bundles[0].certificateChains[0].certificates[0].validity.message") - .asString() - .startsWith("Not valid after "); - } - - @Test - void testSslHealth() { - ResponseEntity entity = this.restTemplate.getForEntity("/actuator/health", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE); - JsonContent body = new JsonContent(entity.getBody()); - assertThat(body).extractingPath("status").isEqualTo("OUT_OF_SERVICE"); - assertThat(body).extractingPath("components.ssl.status").isEqualTo("OUT_OF_SERVICE"); - assertThat(body).extractingPath("components.ssl.details.invalidChains[0].alias") - .isEqualTo("spring-boot-ssl-sample"); - assertThat(body).extractingPath("components.ssl.details.invalidChains[0].certificates[0].issuer") - .isEqualTo("CN=localhost,OU=Unknown,O=Unknown,L=Unknown,ST=Unknown,C=Unknown"); - assertThat(body).extractingPath("components.ssl.details.invalidChains[0].certificates[0].subject") - .isEqualTo("CN=localhost,OU=Unknown,O=Unknown,L=Unknown,ST=Unknown,C=Unknown"); - assertThat(body).extractingPath("components.ssl.details.invalidChains[0].certificates[0].validity.status") - .isEqualTo("EXPIRED"); - assertThat(body).extractingPath("components.ssl.details.invalidChains[0].certificates[0].validity.message") - .asString() - .startsWith("Not valid after "); - } - -} diff --git a/smoke-test/spring-boot-smoke-test-tomcat11/build.gradle b/smoke-test/spring-boot-smoke-test-tomcat11/build.gradle deleted file mode 100644 index 1841b826d15..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11/build.gradle +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -plugins { - id "java" -} - -description = "Spring Boot Tomcat 11 smoke test" - -configurations.all { - resolutionStrategy.eachDependency { - if (it.requested.group == 'org.apache.tomcat' || it.requested.group == 'org.apache.tomcat.embed') { - it.useVersion '11.0.4' - } - } -} - -dependencies { - implementation(project(":module:spring-boot-http-converter")) - implementation(project(":starter:spring-boot-starter")) - implementation(project(":starter:spring-boot-starter-tomcat")) - implementation(project(":module:spring-boot-webmvc")) - - testImplementation(project(":starter:spring-boot-starter-test")) -} diff --git a/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/SampleTomcat11Application.java b/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/SampleTomcat11Application.java deleted file mode 100644 index c9218c50c3a..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/SampleTomcat11Application.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package smoketest.tomcat; - -import jakarta.servlet.ServletContextEvent; -import jakarta.servlet.ServletContextListener; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -public class SampleTomcat11Application { - - private static final Log logger = LogFactory.getLog(SampleTomcat11Application.class); - - @Bean - protected ServletContextListener listener() { - return new ServletContextListener() { - - @Override - public void contextInitialized(ServletContextEvent sce) { - logger.info("ServletContext initialized"); - } - - @Override - public void contextDestroyed(ServletContextEvent sce) { - logger.info("ServletContext destroyed"); - } - - }; - } - - public static void main(String[] args) { - SpringApplication.run(SampleTomcat11Application.class, args); - } - -} diff --git a/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/service/HelloWorldService.java b/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/service/HelloWorldService.java deleted file mode 100644 index dc197088b94..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/service/HelloWorldService.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package smoketest.tomcat.service; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -@Component -public class HelloWorldService { - - @Value("${test.name:World}") - private String name; - - public String getHelloMessage() { - return "Hello " + this.name; - } - -} diff --git a/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/service/HttpHeaderService.java b/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/service/HttpHeaderService.java deleted file mode 100644 index a5e862c9f75..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/service/HttpHeaderService.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package smoketest.tomcat.service; - -import smoketest.tomcat.util.RandomStringUtil; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -@Component -public class HttpHeaderService { - - @Value("${server.tomcat.max-http-response-header-size}") - private int maxHttpResponseHeaderSize; - - /** - * Generates random data. The data is: - *
    - *
  1. is longer than configured - * server.tomcat.max-http-response-header-size
  2. - *
  3. is url encoded by base 64 encode the random value
  4. - *
- * @return a base64 encoded string of random bytes - */ - public String getHeaderValue() { - return RandomStringUtil.getRandomBase64EncodedString(this.maxHttpResponseHeaderSize + 1); - } - -} diff --git a/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/util/RandomStringUtil.java b/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/util/RandomStringUtil.java deleted file mode 100644 index 217f3d3da05..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/util/RandomStringUtil.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package smoketest.tomcat.util; - -import java.util.Base64; -import java.util.Random; - -public final class RandomStringUtil { - - private RandomStringUtil() { - } - - public static String getRandomBase64EncodedString(int length) { - byte[] responseHeader = new byte[length]; - new Random().nextBytes(responseHeader); - return Base64.getEncoder().encodeToString(responseHeader); - } - -} diff --git a/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/web/SampleController.java b/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/web/SampleController.java deleted file mode 100644 index 5caa5f25d1d..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11/src/main/java/smoketest/tomcat/web/SampleController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package smoketest.tomcat.web; - -import jakarta.servlet.http.HttpServletResponse; -import smoketest.tomcat.service.HelloWorldService; -import smoketest.tomcat.service.HttpHeaderService; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -@Controller -public class SampleController { - - private final HelloWorldService helloWorldService; - - private final HttpHeaderService httpHeaderService; - - public SampleController(HelloWorldService helloWorldService, HttpHeaderService httpHeaderService) { - this.helloWorldService = helloWorldService; - this.httpHeaderService = httpHeaderService; - } - - @GetMapping("/") - @ResponseBody - public String helloWorld() { - return this.helloWorldService.getHelloMessage(); - } - - @GetMapping("/max-http-response-header") - @ResponseBody - public String maxHttpResponseHeader(HttpServletResponse response) { - String headerValue = this.httpHeaderService.getHeaderValue(); - response.addHeader("x-max-header", headerValue); - return this.helloWorldService.getHelloMessage(); - } - -} diff --git a/smoke-test/spring-boot-smoke-test-tomcat11/src/main/resources/application.properties b/smoke-test/spring-boot-smoke-test-tomcat11/src/main/resources/application.properties deleted file mode 100644 index 2a19059833c..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11/src/main/resources/application.properties +++ /dev/null @@ -1,5 +0,0 @@ -server.compression.enabled: true -server.compression.min-response-size: 1 -server.max-http-request-header-size=1000 -server.tomcat.connection-timeout=5s -server.tomcat.max-http-response-header-size=1000 diff --git a/smoke-test/spring-boot-smoke-test-tomcat11/src/test/java/smoketest/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java b/smoke-test/spring-boot-smoke-test-tomcat11/src/test/java/smoketest/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java deleted file mode 100644 index 2ee9253d033..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11/src/test/java/smoketest/tomcat/NonAutoConfigurationSampleTomcatApplicationTests.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package smoketest.tomcat; - -import org.junit.jupiter.api.Test; -import smoketest.tomcat.service.HelloWorldService; -import smoketest.tomcat.web.SampleController; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; -import org.springframework.boot.http.converter.autoconfigure.HttpMessageConvertersAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration; -import org.springframework.boot.web.server.test.client.TestRestTemplate; -import org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfiguration; -import org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfiguration; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Basic integration tests for demo application. - * - * @author Dave Syer - */ -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -class NonAutoConfigurationSampleTomcatApplicationTests { - - @Autowired - private TestRestTemplate restTemplate; - - @Test - void testHome() { - ResponseEntity entity = this.restTemplate.getForEntity("/", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(entity.getBody()).isEqualTo("Hello World"); - } - - @Configuration(proxyBeanMethods = false) - @Import({ TomcatServletWebServerAutoConfiguration.class, DispatcherServletAutoConfiguration.class, - WebMvcAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class, - PropertyPlaceholderAutoConfiguration.class }) - @ComponentScan(basePackageClasses = { SampleController.class, HelloWorldService.class }) - public static class NonAutoConfigurationSampleTomcatApplication { - - public static void main(String[] args) { - SpringApplication.run(SampleTomcat11Application.class, args); - } - - } - -} diff --git a/smoke-test/spring-boot-smoke-test-tomcat11/src/test/java/smoketest/tomcat/SampleTomcat11ApplicationTests.java b/smoke-test/spring-boot-smoke-test-tomcat11/src/test/java/smoketest/tomcat/SampleTomcat11ApplicationTests.java deleted file mode 100644 index f3547778354..00000000000 --- a/smoke-test/spring-boot-smoke-test-tomcat11/src/test/java/smoketest/tomcat/SampleTomcat11ApplicationTests.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2012-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package smoketest.tomcat; - -import java.io.ByteArrayInputStream; -import java.nio.charset.StandardCharsets; -import java.util.zip.GZIPInputStream; - -import org.apache.coyote.AbstractProtocol; -import org.apache.coyote.ProtocolHandler; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import smoketest.tomcat.util.RandomStringUtil; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.system.CapturedOutput; -import org.springframework.boot.test.system.OutputCaptureExtension; -import org.springframework.boot.tomcat.TomcatWebServer; -import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext; -import org.springframework.boot.web.server.test.client.TestRestTemplate; -import org.springframework.context.ApplicationContext; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.util.StreamUtils; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Basic integration tests for demo application. - * - * @author Dave Syer - * @author Andy Wilkinson - * @author Florian Storz - * @author Michael Weidmann - */ -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@ExtendWith(OutputCaptureExtension.class) -class SampleTomcat11ApplicationTests { - - @Autowired - private TestRestTemplate restTemplate; - - @Autowired - private ApplicationContext applicationContext; - - @Value("${server.max-http-request-header-size}") - private int maxHttpRequestHeaderSize; - - @Test - void testHome() { - ResponseEntity entity = this.restTemplate.getForEntity("/", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(entity.getBody()).isEqualTo("Hello World"); - } - - @Test - void testCompression() throws Exception { - HttpHeaders requestHeaders = new HttpHeaders(); - requestHeaders.set("Accept-Encoding", "gzip"); - HttpEntity requestEntity = new HttpEntity<>(requestHeaders); - ResponseEntity entity = this.restTemplate.exchange("/", HttpMethod.GET, requestEntity, byte[].class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - try (GZIPInputStream inflater = new GZIPInputStream(new ByteArrayInputStream(entity.getBody()))) { - assertThat(StreamUtils.copyToString(inflater, StandardCharsets.UTF_8)).isEqualTo("Hello World"); - } - } - - @Test - void testTimeout() { - ServletWebServerApplicationContext context = (ServletWebServerApplicationContext) this.applicationContext; - TomcatWebServer embeddedServletContainer = (TomcatWebServer) context.getWebServer(); - ProtocolHandler protocolHandler = embeddedServletContainer.getTomcat().getConnector().getProtocolHandler(); - int timeout = ((AbstractProtocol) protocolHandler).getConnectionTimeout(); - assertThat(timeout).isEqualTo(5000); - } - - @Test - void testMaxHttpResponseHeaderSize(CapturedOutput output) { - ResponseEntity entity = this.restTemplate.getForEntity("/max-http-response-header", String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); - assertThat(output).contains( - "threw exception [Request processing failed: org.apache.coyote.http11.HeadersTooLargeException: An attempt was made to write more data to the response headers than there was room available in the buffer. Increase maxHttpHeaderSize on the connector or write less data into the response headers.]"); - } - - @Test - void testMaxHttpRequestHeaderSize(CapturedOutput output) { - String headerValue = RandomStringUtil.getRandomBase64EncodedString(this.maxHttpRequestHeaderSize + 1); - HttpHeaders headers = new HttpHeaders(); - headers.add("x-max-request-header", headerValue); - HttpEntity httpEntity = new HttpEntity<>(headers); - ResponseEntity entity = this.restTemplate.exchange("/", HttpMethod.GET, httpEntity, String.class); - assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); - assertThat(output).contains("java.lang.IllegalArgumentException: Request header is too large"); - } - -}