Skip to content

Commit

Permalink
Rework the single mod mp tests not to be static
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Gooderham <[email protected]>
  • Loading branch information
turkeylurkey committed Nov 7, 2024
1 parent ba9bf01 commit 3e2de83
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,28 @@
* Tests Liberty Tools actions using a single module MicroProfile Gradle project.
*/
public class GradleSingleModMPProjectTest extends SingleModMPProjectTestCommon {
/**
* Single module Microprofile project name.
*/
private static final String SM_MP_PROJECT_NAME = "singleModGradleMP";

/**
* The path to the folder containing the test projects.
*/
private static final String PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "gradle").toAbsolutePath().toString();

/**
* Prepares the environment for test execution.
*/
@BeforeAll
public static void setup() {
setSmMPProjectName("singleModGradleMP");
prepareEnv(PROJECTS_PATH, SM_MP_PROJECT_NAME);
}

GradleSingleModMPProjectTest() {
setSmMPProjectName(SM_MP_PROJECT_NAME);
setProjectsDirPath(PROJECTS_PATH);
setBuildCategory(BuildType.GRADLE_TYPE);
setProjectsDirPath(Paths.get("src", "test", "resources", "projects", "gradle").toAbsolutePath().toString());
setSmMpProjPort(9080);
setSmMpProjResURI("api/resource");
setSmMPProjOutput("Hello! Welcome to Open Liberty");
Expand All @@ -35,7 +48,5 @@ public static void setup() {
setBuildFileOpenCommand("Liberty: View Gradle config");
setStartParams("--hotTests");
setStartParamsDebugPort("--libertyDebugPort=9876");

prepareEnv(getProjectsDirPath(), getSmMPProjectName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ public class GradleSingleModMPSIDProjectTest extends SingleModMPProjectTestCommo
@BeforeAll
public static void setup() {
try {
setBuildCategory(BuildType.GRADLE_TYPE);
setSmMpProjPort(9080);
setSmMpProjResURI("api/resource");
setSmMPProjOutput("Hello! Welcome to Open Liberty");
setWLPInstallPath("build");
setBuildFileName("build.gradle");
setBuildFileOpenCommand("Liberty: View Gradle config");
setStartParams("--hotTests");
setStartParamsDebugPort("--libertyDebugPort=9876");

// Copy the directory to allow renaming.
TestUtils.copyDirectory(PROJECTS_PATH, PROJECTS_PATH_NEW);

Expand All @@ -80,13 +70,8 @@ public static void setup() {
// Rename the project directory to a new name, replacing it if it already exists
Files.move(projectDirPath, projectDirNewPath, StandardCopyOption.REPLACE_EXISTING);

// set the new locations
setSmMPProjectName(SM_MP_PROJECT_NAME_NEW);
setProjectsDirPath(PROJECTS_PATH_NEW);
setTestReportPath(Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME_NEW, "build", "reports", "tests", "test", "index.html"));

// Prepare the environment with the new project path and name
prepareEnv(getProjectsDirPath(), getSmMPProjectName());
prepareEnv(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME_NEW);

} catch (IOException e) {
System.err.println("Setup failed: " + e.getMessage());
Expand All @@ -106,4 +91,20 @@ public static void cleanup() {
deleteDirectoryIfExists(PROJECTS_PATH_NEW);
}
}

GradleSingleModMPSIDProjectTest() {
// set the new locations for the test, not the original locations
setSmMPProjectName(SM_MP_PROJECT_NAME_NEW);
setProjectsDirPath(PROJECTS_PATH_NEW);
setTestReportPath(Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME_NEW, "build", "reports", "tests", "test", "index.html"));
setBuildCategory(BuildType.GRADLE_TYPE);
setSmMpProjPort(9080);
setSmMpProjResURI("api/resource");
setSmMPProjOutput("Hello! Welcome to Open Liberty");
setWLPInstallPath("build");
setBuildFileName("build.gradle");
setBuildFileOpenCommand("Liberty: View Gradle config");
setStartParams("--hotTests");
setStartParamsDebugPort("--libertyDebugPort=9876");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
*/
public class MavenSingleModMPProjectTest extends SingleModMPProjectTestCommon {

/**
* Single module Microprofile project name.
*/
private static final String SM_MP_PROJECT_NAME = "singleModMavenMP";

/**
* The path to the folder containing the test projects.
*/
private static final String PROJECTS_PATH = Paths.get("src", "test", "resources", "projects", "maven").toAbsolutePath().toString();

/**
* The paths to the integration test reports. The first is used when maven-surefire-report-plugin 3.4 is used and the second when version 3.5 is used.
*/
Expand All @@ -39,9 +49,14 @@ public class MavenSingleModMPProjectTest extends SingleModMPProjectTestCommon {
*/
@BeforeAll
public static void setup() {
setSmMPProjectName("singleModMavenMP");
StepWorker.registerProcessor(new StepLogger());
prepareEnv(PROJECTS_PATH, SM_MP_PROJECT_NAME);
}

MavenSingleModMPProjectTest() {
setSmMPProjectName(SM_MP_PROJECT_NAME);
setBuildCategory(BuildType.MAVEN_TYPE);
setProjectsDirPath(Paths.get("src", "test", "resources", "projects", "maven").toAbsolutePath().toString());
setProjectsDirPath(PROJECTS_PATH);
setSmMpProjPort(9080);
setSmMpProjResURI("api/resource");
setSmMPProjOutput("Hello! Welcome to Open Liberty");
Expand All @@ -51,11 +66,7 @@ public static void setup() {
setBuildFileOpenCommand("Liberty: View pom.xml");
setStartParams("-DhotTests=true");
setStartParamsDebugPort("-DdebugPort=9876");

StepWorker.registerProcessor(new StepLogger());
prepareEnv(getProjectsDirPath(), getSmMPProjectName());
}

/**
* Deletes test reports.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,11 @@ public class MavenSingleModMPSIDProjectTest extends SingleModMPProjectTestCommon
@BeforeAll
public static void setup() {
try {
setSmMPProjectName(SM_MP_PROJECT_NAME);
setBuildCategory(BuildType.MAVEN_TYPE);
setSmMpProjPort(9080);
setSmMpProjResURI("api/resource");
setSmMPProjOutput("Hello! Welcome to Open Liberty");
setWLPInstallPath(Paths.get("target", "liberty").toString());
setBuildFileName("pom.xml");
setBuildFileOpenCommand("Liberty: View pom.xml");
setStartParams("-DhotTests=true");
setStartParamsDebugPort("-DdebugPort=9876");

StepWorker.registerProcessor(new StepLogger());
// Copy the directory from PROJECTS_PATH to PROJECTS_PATH_NEW
TestUtils.copyDirectory(PROJECTS_PATH, PROJECTS_PATH_NEW);

// set the new locations
setProjectsDirPath(PROJECTS_PATH_NEW);
setTestReportPath(Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME, "build", "reports", "tests", "test", "index.html"));

prepareEnv(getProjectsDirPath(), getSmMPProjectName());
prepareEnv(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME);
} catch (IOException e) {
System.err.println("Setup failed: " + e.getMessage());
e.printStackTrace();
Expand All @@ -96,6 +81,22 @@ public static void cleanup() {
}
}

MavenSingleModMPSIDProjectTest() {
setSmMPProjectName(SM_MP_PROJECT_NAME);
// set the new locations for the test, not the original locations
setProjectsDirPath(PROJECTS_PATH_NEW);
setTestReportPath(Paths.get(PROJECTS_PATH_NEW, SM_MP_PROJECT_NAME, "build", "reports", "tests", "test", "index.html"));
setBuildCategory(BuildType.MAVEN_TYPE);
setSmMpProjPort(9080);
setSmMpProjResURI("api/resource");
setSmMPProjOutput("Hello! Welcome to Open Liberty");
setWLPInstallPath(Paths.get("target", "liberty").toString());
setBuildFileName("pom.xml");
setBuildFileOpenCommand("Liberty: View pom.xml");
setStartParams("-DhotTests=true");
setStartParamsDebugPort("-DdebugPort=9876");
}

/**
* Deletes test reports.
*/
Expand Down
Loading

0 comments on commit 3e2de83

Please sign in to comment.