|
| 1 | +package com.reajason.javaweb.integration.memshell.springwebmvc; |
| 2 | + |
| 3 | +import com.reajason.javaweb.Server; |
| 4 | +import com.reajason.javaweb.integration.AbstractContainerTest; |
| 5 | +import com.reajason.javaweb.integration.ContainerTestConfig; |
| 6 | +import com.reajason.javaweb.integration.ContainerTool; |
| 7 | +import com.reajason.javaweb.memshell.ShellTool; |
| 8 | +import com.reajason.javaweb.memshell.ShellType; |
| 9 | +import com.reajason.javaweb.packer.Packers; |
| 10 | +import net.bytebuddy.jar.asm.Opcodes; |
| 11 | +import org.junit.jupiter.params.ParameterizedTest; |
| 12 | +import org.junit.jupiter.params.provider.Arguments; |
| 13 | +import org.junit.jupiter.params.provider.MethodSource; |
| 14 | +import org.testcontainers.containers.GenericContainer; |
| 15 | +import org.testcontainers.containers.Network; |
| 16 | +import org.testcontainers.junit.jupiter.Container; |
| 17 | +import org.testcontainers.junit.jupiter.Testcontainers; |
| 18 | + |
| 19 | +import java.util.List; |
| 20 | +import java.util.stream.Stream; |
| 21 | + |
| 22 | +/** |
| 23 | + * @author ReaJason |
| 24 | + * @since 2024/12/22 |
| 25 | + */ |
| 26 | +@Testcontainers |
| 27 | +public class SpringBoot359ContainerTest extends AbstractContainerTest { |
| 28 | + private static final ContainerTestConfig CONFIG = ContainerTestConfig.builder() |
| 29 | + .imageName("eclipse-temurin:17.0.17_10-jdk") |
| 30 | + .jarFile(ContainerTool.springBoot359JarFile) |
| 31 | + .jakarta(true) |
| 32 | + .jarDeployPath("/app/app.jar") |
| 33 | + .command("java -jar /app/app.jar") |
| 34 | + .server(Server.SpringWebMvc) |
| 35 | + .pidScript(ContainerTool.springbootPid) |
| 36 | + .targetJdkVersion(Opcodes.V17) |
| 37 | + .enableJspPackerTest(false) |
| 38 | + .contextPath("") |
| 39 | + .healthCheckPath("/test") |
| 40 | + .supportedShellTypes(List.of( |
| 41 | + ShellType.SPRING_WEBMVC_JAKARTA_INTERCEPTOR, |
| 42 | + ShellType.SPRING_WEBMVC_JAKARTA_CONTROLLER_HANDLER, |
| 43 | + ShellType.SPRING_WEBMVC_AGENT_FRAMEWORK_SERVLET |
| 44 | + )) |
| 45 | + .testPackers(List.of(Packers.H2)) |
| 46 | + .unSupportedShellTools(List.of(ShellTool.AntSword)) |
| 47 | + .probeShellTypes(List.of( |
| 48 | + ShellType.SPRING_WEBMVC_JAKARTA_INTERCEPTOR, |
| 49 | + ShellType.SPRING_WEBMVC_JAKARTA_CONTROLLER_HANDLER |
| 50 | + )) |
| 51 | + .build(); |
| 52 | + |
| 53 | + private static final ContainerTestConfig TOMCAT_CONFIG = ContainerTestConfig.builder() |
| 54 | + .imageName("springboot3") |
| 55 | + .server(Server.Tomcat) |
| 56 | + .targetJdkVersion(Opcodes.V17) |
| 57 | + .supportedShellTypes(List.of( |
| 58 | + ShellType.JAKARTA_FILTER, |
| 59 | +// ShellType.LISTENER, |
| 60 | + ShellType.JAKARTA_VALVE, |
| 61 | + ShellType.JAKARTA_WEBSOCKET, |
| 62 | + ShellType.AGENT_FILTER_CHAIN, |
| 63 | + ShellType.CATALINA_AGENT_CONTEXT_VALVE |
| 64 | + )) |
| 65 | + .testPackers(List.of(Packers.H2)) |
| 66 | + .unSupportedShellTools(List.of(ShellTool.AntSword)) |
| 67 | + .build(); |
| 68 | + |
| 69 | + static Network network = newNetwork(); |
| 70 | + @Container |
| 71 | + public static final GenericContainer<?> python = buildPythonContainer(network); |
| 72 | + |
| 73 | + @Container |
| 74 | + public static final GenericContainer<?> container = buildContainer(CONFIG, network); |
| 75 | + |
| 76 | + static Stream<Arguments> tomcatCasesProvider() { |
| 77 | + return generateTestCases(TOMCAT_CONFIG); |
| 78 | + } |
| 79 | + |
| 80 | + @ParameterizedTest(name = "{0}|{1}{2}|{3}") |
| 81 | + @MethodSource("tomcatCasesProvider") |
| 82 | + void testTomcat(String imageName, String shellType, String shellTool, Packers packer) { |
| 83 | + runShellInject(TOMCAT_CONFIG, shellType, shellTool, packer); |
| 84 | + } |
| 85 | + |
| 86 | + @Override |
| 87 | + protected ContainerTestConfig getConfig() { |
| 88 | + return CONFIG; |
| 89 | + } |
| 90 | +} |
0 commit comments