Add servlet-tomcat smoke test
See gh-70
This commit is contained in:
@@ -46,6 +46,7 @@ smoke_tests:
|
||||
- security-thymeleaf
|
||||
- security-webflux
|
||||
- security-webmvc
|
||||
- servlet-tomcat
|
||||
- session-jdbc
|
||||
- session-redis-webflux
|
||||
- spring-amqp-rabbit
|
||||
|
||||
1
servlet-tomcat/README.adoc
Normal file
1
servlet-tomcat/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
Tests if Servlets with Tomcat works
|
||||
20
servlet-tomcat/build.gradle
Normal file
20
servlet-tomcat/build.gradle
Normal file
@@ -0,0 +1,20 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot'
|
||||
id 'org.springframework.aot.smoke-test'
|
||||
id 'org.graalvm.buildtools.native'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
|
||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
|
||||
aotTestImplementation(project(":aot-smoke-test-support"))
|
||||
aotTestImplementation("org.awaitility:awaitility:4.2.0")
|
||||
}
|
||||
|
||||
aotSmokeTest {
|
||||
webApplication = true
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.example.servlet.tomcat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aot.smoketest.support.junit.AotSmokeTest;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@AotSmokeTest
|
||||
class ServletTomcatApplicationAotTests {
|
||||
|
||||
@Test
|
||||
void servletIsInvokable(WebTestClient client) {
|
||||
client.get().uri("/?name=Servlet").exchange().expectStatus().isOk().expectBody().consumeWith(
|
||||
(result) -> assertThat(new String(result.getResponseBodyContent())).isEqualTo("Hello Servlet"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.example.servlet.tomcat;
|
||||
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
class ServletConfiguration {
|
||||
|
||||
@Bean
|
||||
ServletRegistrationBean<TestServlet> testServletServletRegistrationBean() {
|
||||
return new ServletRegistrationBean<>(new TestServlet(), "/*");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.example.servlet.tomcat;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ServletTomcatApplication {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
SpringApplication.run(ServletTomcatApplication.class, args);
|
||||
Thread.currentThread().join(); // To be able to measure memory consumption
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.example.servlet.tomcat;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
class TestServlet extends HttpServlet {
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||||
String[] names = req.getParameterValues("name");
|
||||
String name;
|
||||
if (names == null || names.length == 0) {
|
||||
name = "world";
|
||||
}
|
||||
else {
|
||||
name = names[0];
|
||||
}
|
||||
resp.getWriter().printf("Hello %s", name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.example.servlet.tomcat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class ServletTomcatApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -74,6 +74,7 @@ include "security-method"
|
||||
include "security-thymeleaf"
|
||||
include "security-webflux"
|
||||
include "security-webmvc"
|
||||
include "servlet-tomcat"
|
||||
include "session-jdbc"
|
||||
include "session-redis-webflux"
|
||||
include "spring-amqp-rabbit"
|
||||
|
||||
Reference in New Issue
Block a user