-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
75 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...tion-test/src/test/java/com/reajason/javaweb/integration/tomcat/Tomcat5ContainerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.reajason.javaweb.integration.tomcat; | ||
|
||
import com.reajason.javaweb.config.Constants; | ||
import com.reajason.javaweb.config.Server; | ||
import com.reajason.javaweb.config.ShellTool; | ||
import com.reajason.javaweb.memsell.packer.Packer; | ||
import lombok.extern.slf4j.Slf4j; | ||
import net.bytebuddy.jar.asm.Opcodes; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.containers.wait.strategy.Wait; | ||
import org.testcontainers.junit.jupiter.Container; | ||
import org.testcontainers.junit.jupiter.Testcontainers; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static com.reajason.javaweb.integration.ContainerTool.getUrl; | ||
import static com.reajason.javaweb.integration.ContainerTool.warFile; | ||
import static com.reajason.javaweb.integration.ShellAssertionTool.testShellInjectAssertOk; | ||
import static org.junit.jupiter.params.provider.Arguments.arguments; | ||
|
||
/** | ||
* @author ReaJason | ||
* @since 2024/12/4 | ||
*/ | ||
@Slf4j | ||
@Testcontainers | ||
public class Tomcat5ContainerTest { | ||
public static final String imageName = "reajason/tomcat:5-jdk6"; | ||
|
||
static Stream<Arguments> casesProvider() { | ||
return Stream.of( | ||
// arguments(imageName, Constants.FILTER, ShellTool.Godzilla, Packer.INSTANCE.JSP), // 不支持,初始化 Filter 时 jdk6 下会抛 Caused by: java.lang.NoClassDefFoundError: java/lang/ReflectiveOperationException | ||
arguments(imageName, Constants.FILTER, ShellTool.Command, Packer.INSTANCE.JSP), | ||
arguments(imageName, Constants.LISTENER, ShellTool.Godzilla, Packer.INSTANCE.JSP), | ||
arguments(imageName, Constants.LISTENER, ShellTool.Command, Packer.INSTANCE.JSP) | ||
// arguments(imageName, TomcatShell.VALVE, ShellTool.Godzilla, Packer.INSTANCE.JSP), // 不支持,Caused by: java.lang.NoClassDefFoundError: org/apache/catalina/Valve | ||
// arguments(imageName, TomcatShell.VALVE, ShellTool.Command, Packer.INSTANCE.JSP) | ||
); | ||
} | ||
|
||
@Container | ||
public final static GenericContainer<?> container = new GenericContainer<>(imageName) | ||
.withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war") | ||
.waitingFor(Wait.forHttp("/app")) | ||
.withExposedPorts(8080); | ||
|
||
|
||
@ParameterizedTest(name = "{0}|{1}{2}|{3}") | ||
@MethodSource("casesProvider") | ||
void test(String imageName, String shellType, ShellTool shellTool, Packer.INSTANCE packer) { | ||
testShellInjectAssertOk(getUrl(container), Server.TOMCAT, shellType, shellTool, Opcodes.V1_6, packer); | ||
} | ||
|
||
// @AfterAll | ||
// static void tearDown() { | ||
// log.info(container.getLogs()); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters