Add jakarta-ee-11 module: Jakarta EE 10 vs 11 API comparison against Spring Boot 4.1.1
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Gth99spB1CzQmBFofXmU4Z
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package com.ankurm.jee11;
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Jee11Application {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ankurm.jee11;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/** Asks the servlet container which Servlet specification level it implements. */
|
||||
@RestController
|
||||
class ServletLevelController {
|
||||
|
||||
@GetMapping("/servlet-level")
|
||||
String level(HttpServletRequest request) {
|
||||
var ctx = request.getServletContext();
|
||||
return ctx.getMajorVersion() + "." + ctx.getMinorVersion() + " (container: " + ctx.getServerInfo() + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ankurm.jee11;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.server.LocalServerPort;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
class ServletLevelTest {
|
||||
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
@Test
|
||||
void containerReportsServlet61() throws IOException {
|
||||
String body = RestClient.create("http://localhost:" + port).get().uri("/servlet-level").retrieve().body(String.class);
|
||||
Files.createDirectories(Path.of("output"));
|
||||
Files.write(Path.of("output/05-servlet-level.txt"), List.of(
|
||||
"# 05-servlet-level (Spring Boot 4.1.1, embedded Tomcat, JDK " + Runtime.version().feature() + ")",
|
||||
"GET /servlet-level -> " + body));
|
||||
assertThat(body).startsWith("6.1");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user