Skip to content

Commit

Permalink
test: speedup integration test use sharedContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
ReaJason committed Dec 4, 2024
1 parent 9a843b7 commit 26d07f5
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 158 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.reajason.javaweb.integration.tomcat;

import com.reajason.javaweb.memsell.packer.Packer;
import com.reajason.javaweb.memsell.tomcat.TomcatShell;
import net.bytebuddy.jar.asm.Opcodes;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;

/**
* @author ReaJason
* @since 2024/12/4
*/
public class Tomcat10ContainerTest extends TomcatIntegrationTest {
public static final String tomcat10ImageName = "tomcat:10.1-jre11";
@Container
public final static GenericContainer<?> tomcat = new GenericContainer<>(tomcat10ImageName)
.withCopyToContainer(warJakartaFile, "/usr/local/tomcat/webapps/app.war")
.waitingFor(Wait.forHttp("/app"))
.withExposedPorts(8080);

@ParameterizedTest(name = tomcat10ImageName + "|{0}Godzilla|JSP")
@ValueSource(strings = {TomcatShell.JAKARTA_FILTER, TomcatShell.JAKARTA_LISTENER, TomcatShell.JAKARTA_VALVE})
void testGodzillaJSP(String shellType) {
testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V11, Packer.INSTANCE.JSP);
}

@ParameterizedTest(name = tomcat10ImageName + "|{0}Command|JSP")
@ValueSource(strings = {TomcatShell.JAKARTA_FILTER, TomcatShell.JAKARTA_LISTENER, TomcatShell.JAKARTA_VALVE})
void testCommandJSP(String shellType) {
testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V11, Packer.INSTANCE.JSP);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.reajason.javaweb.integration.tomcat;

import com.reajason.javaweb.memsell.packer.Packer;
import com.reajason.javaweb.memsell.tomcat.TomcatShell;
import net.bytebuddy.jar.asm.Opcodes;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;

/**
* @author ReaJason
* @since 2024/12/4
*/
public class Tomcat11ContainerTest extends TomcatIntegrationTest {
public static final String tomcat11ImageName = "tomcat:11.0-jre17";
@Container
public final static GenericContainer<?> tomcat = new GenericContainer<>(tomcat11ImageName)
.withCopyToContainer(warJakartaFile, "/usr/local/tomcat/webapps/app.war")
.waitingFor(Wait.forHttp("/app"))
.withExposedPorts(8080);

@ParameterizedTest(name = tomcat11ImageName + "|{0}Godzilla|JSP")
@ValueSource(strings = {TomcatShell.JAKARTA_FILTER, TomcatShell.JAKARTA_LISTENER, TomcatShell.JAKARTA_VALVE})
void testGodzillaJSP(String shellType) {
testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V17, Packer.INSTANCE.JSP);
}

@ParameterizedTest(name = tomcat11ImageName + "|{0}Command|JSP")
@ValueSource(strings = {TomcatShell.JAKARTA_FILTER, TomcatShell.JAKARTA_LISTENER, TomcatShell.JAKARTA_VALVE})
void testCommandJSP(String shellType) {
testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V17, Packer.INSTANCE.JSP);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.reajason.javaweb.integration.tomcat;

import com.reajason.javaweb.memsell.packer.Packer;
import com.reajason.javaweb.memsell.tomcat.TomcatShell;
import net.bytebuddy.jar.asm.Opcodes;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;

/**
* @author ReaJason
* @since 2024/12/4
*/
public class Tomcat6ContainerTest extends TomcatIntegrationTest {
public static final String tomcat6ImageName = "reajason/tomcat:6-jdk6";

@Container
public final static GenericContainer<?> tomcat = new GenericContainer<>(tomcat6ImageName)
.withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war")
.waitingFor(Wait.forHttp("/app"))
.withExposedPorts(8080);

@ParameterizedTest(name = tomcat6ImageName + "|{0}Godzilla|JSP")
@ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE})
void testGodzillaJSP(String shellType) {
testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V1_6, Packer.INSTANCE.JSP);
}

@ParameterizedTest(name = tomcat6ImageName + "|{0}Command|JSP")
@ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE})
void testCommandJSP(String shellType) {
testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V1_6, Packer.INSTANCE.JSP);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.reajason.javaweb.integration.tomcat;

import com.reajason.javaweb.memsell.packer.Packer;
import com.reajason.javaweb.memsell.tomcat.TomcatShell;
import net.bytebuddy.jar.asm.Opcodes;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;

/**
* @author ReaJason
* @since 2024/12/4
*/
public class Tomcat7ContainerTest extends TomcatIntegrationTest {
public static final String tomcat7ImageName = "tomcat:7.0.85-jre7";
@Container
public final static GenericContainer<?> tomcat = new GenericContainer<>(tomcat7ImageName)
.withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war")
.waitingFor(Wait.forHttp("/app"))
.withExposedPorts(8080);


@ParameterizedTest(name = tomcat7ImageName + "|{0}Godzilla|JSP")
@ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE})
void testGodzillaJSP(String shellType) {
testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V1_7, Packer.INSTANCE.JSP);
}


@ParameterizedTest(name = tomcat7ImageName + "|{0}Command|JSP")
@ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE})
void testCommandJSP(String shellType) {
testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V1_7, Packer.INSTANCE.JSP);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.reajason.javaweb.integration.tomcat;

import com.reajason.javaweb.memsell.packer.Packer;
import com.reajason.javaweb.memsell.tomcat.TomcatShell;
import net.bytebuddy.jar.asm.Opcodes;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;

/**
* @author ReaJason
* @since 2024/12/4
*/
public class Tomcat8ContainerTest extends TomcatIntegrationTest {
public static final String tomcat8ImageName = "tomcat:8-jre8";
@Container
public final static GenericContainer<?> tomcat = new GenericContainer<>(tomcat8ImageName)
.withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war")
.waitingFor(Wait.forHttp("/app"))
.withExposedPorts(8080);

@ParameterizedTest(name = tomcat8ImageName + "|{0}Godzilla|JSP")
@ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE})
void testGodzillaJSP(String shellType) {
testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V1_8, Packer.INSTANCE.JSP);
}

@ParameterizedTest(name = tomcat8ImageName + "|{0}Godzilla|JS")
@ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE})
void testGodzillaJS(String shellType) {
testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V1_8, Packer.INSTANCE.ScriptEngine);
}

@ParameterizedTest(name = tomcat8ImageName + "|{0}Command|JSP")
@ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE})
void testCommandJSP(String shellType) {
testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V1_8, Packer.INSTANCE.JSP);
}

@ParameterizedTest(name = tomcat8ImageName + "|{0}Command|JS")
@ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE})
void testCommandJS(String shellType) {
testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V1_8, Packer.INSTANCE.ScriptEngine);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.reajason.javaweb.integration.tomcat;

import com.reajason.javaweb.memsell.packer.Packer;
import com.reajason.javaweb.memsell.tomcat.TomcatShell;
import net.bytebuddy.jar.asm.Opcodes;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;

/**
* @author ReaJason
* @since 2024/12/4
*/
public class Tomcat9ContainerTest extends TomcatIntegrationTest {
public static final String tomcat9ImageName = "tomcat:9-jre9";
@Container
public final static GenericContainer<?> tomcat = new GenericContainer<>(tomcat9ImageName)
.withCopyToContainer(warFile, "/usr/local/tomcat/webapps/app.war")
.waitingFor(Wait.forHttp("/app"))
.withExposedPorts(8080);

@ParameterizedTest(name = tomcat9ImageName + "|{0}Godzilla|JSP")
@ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE})
void testGodzillaJSP(String shellType) {
testGodzillaAssertOk(getUrl(tomcat), shellType, Opcodes.V9, Packer.INSTANCE.JSP);
}

@ParameterizedTest(name = tomcat9ImageName + "|{0}Command|JSP")
@ValueSource(strings = {TomcatShell.FILTER, TomcatShell.LISTENER, TomcatShell.VALVE})
void testCommandJSP(String shellType) {
testCommandAssertOk(getUrl(tomcat), shellType, Opcodes.V9, Packer.INSTANCE.JSP);
}
}
Loading

0 comments on commit 26d07f5

Please sign in to comment.