diff --git a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java index f00d3b477..d7fc689a3 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPProjectTest.java @@ -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"); @@ -35,7 +48,5 @@ public static void setup() { setBuildFileOpenCommand("Liberty: View Gradle config"); setStartParams("--hotTests"); setStartParamsDebugPort("--libertyDebugPort=9876"); - - prepareEnv(getProjectsDirPath(), getSmMPProjectName()); } } \ No newline at end of file diff --git a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java index 82f037a4e..1eac1376d 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/GradleSingleModMPSIDProjectTest.java @@ -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); @@ -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()); @@ -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"); + } } \ No newline at end of file diff --git a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java index e27bfa681..a19428f8c 100755 --- a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPProjectTest.java @@ -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. */ @@ -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"); @@ -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. */ diff --git a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java index e594bee40..e193b7c0e 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java +++ b/src/test/java/io/openliberty/tools/intellij/it/MavenSingleModMPSIDProjectTest.java @@ -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(); @@ -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. */ diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java index af932d9fc..eda258d06 100644 --- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java +++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java @@ -61,72 +61,72 @@ public enum BuildType { /** * Single module Microprofile project name. */ - private static String smMpProjectName = null; + private String smMpProjectName = null; /** * The path to the folder containing the test projects. */ - private static String projectsPath = null; + private String projectsPath = null; /** * Project port. */ - private static int smMpProjectPort = 0; + private int smMpProjectPort = 0; /** * Project resource URI. */ - private static String smMpProjectResUri = null; + private String smMpProjectResUri = null; /** * Project response. */ - private static String smMpProjectOutput = null; + private String smMpProjectOutput = null; /** * Relative location of the WLP installation. */ - private static String wlpInstallPath = null; + private String wlpInstallPath = null; /** * The path to the test report. */ - private static Path testReportPath = null; + private Path testReportPath = null; /** * Build file name. */ - private static String buildFileName = null; + private String buildFileName = null; /** * Action command to open the build file. */ - private static String buildFileOpenCmd = null; + private String buildFileOpenCmd = null; /** * Dev mode configuration start parameters. */ - private static String devModeStartParams = null; + private String devModeStartParams = null; /** * Dev mode configuration custom start parameters for debugging. */ - private static String devModeStartParamsDebug = null; + private String devModeStartParamsDebug = null; /** * Build Category. */ - private static BuildType buildCategory = null; + private BuildType buildCategory = null; /** * Returns the path where the Liberty server was installed. * * @return The path where the Liberty server was installed. */ - public static String getWLPInstallPath() { + public String getWLPInstallPath() { return wlpInstallPath; } - public static void setWLPInstallPath(String path) { + public void setWLPInstallPath(String path) { wlpInstallPath = path; } @@ -134,7 +134,7 @@ public static void setWLPInstallPath(String path) { * Sets the path where the Liberty server stores test reports. * */ - public static void setTestReportPath(Path path) { + public void setTestReportPath(Path path) { testReportPath = path; } @@ -143,10 +143,10 @@ public static void setTestReportPath(Path path) { * * @return The projects directory path. */ - public static String getProjectsDirPath() { + public String getProjectsDirPath() { return projectsPath; } - public static void setProjectsDirPath(String path) { + public void setProjectsDirPath(String path) { projectsPath = path; } @@ -155,10 +155,10 @@ public static void setProjectsDirPath(String path) { * * @return The name of the single module MicroProfile project. */ - public static String getSmMPProjectName() { + public String getSmMPProjectName() { return smMpProjectName; } - public static void setSmMPProjectName(String name) { + public void setSmMPProjectName(String name) { smMpProjectName = name; } @@ -169,10 +169,10 @@ public static void setSmMPProjectName(String name) { * @return The expected HTTP response payload associated with the single module * MicroProfile project. */ - public static String getSmMPProjOutput() { + public String getSmMPProjOutput() { return smMpProjectOutput; } - public static void setSmMPProjOutput(String s) { + public void setSmMPProjOutput(String s) { smMpProjectOutput = s; } @@ -181,10 +181,10 @@ public static void setSmMPProjOutput(String s) { * * @return The port number associated with the single module MicroProfile project. */ - public static int getSmMpProjPort() { + public int getSmMpProjPort() { return smMpProjectPort; } - public static void setSmMpProjPort(int port) { + public void setSmMpProjPort(int port) { smMpProjectPort = port; } @@ -193,10 +193,10 @@ public static void setSmMpProjPort(int port) { * * @return The Resource URI associated with the single module MicroProfile project. */ - public static String getSmMpProjResURI() { + public String getSmMpProjResURI() { return smMpProjectResUri; } - public static void setSmMpProjResURI(String uri) { + public void setSmMpProjResURI(String uri) { smMpProjectResUri = uri; } @@ -205,10 +205,10 @@ public static void setSmMpProjResURI(String uri) { * * @return The name of the build file used by the project. */ - public static String getBuildFileName() { + public String getBuildFileName() { return buildFileName; } - public static void setBuildFileName(String name) { + public void setBuildFileName(String name) { buildFileName = name; } @@ -217,10 +217,10 @@ public static void setBuildFileName(String name) { * * @return The name of the custom action command used to open the build file. */ - public static String getBuildFileOpenCommand() { + public String getBuildFileOpenCommand() { return buildFileOpenCmd; } - public static void setBuildFileOpenCommand(String command) { + public void setBuildFileOpenCommand(String command) { buildFileOpenCmd = command; } @@ -229,10 +229,10 @@ public static void setBuildFileOpenCommand(String command) { * * @return The custom start parameters to be used to start dev mode. */ - public static String getStartParams() { + public String getStartParams() { return devModeStartParams; } - public static void setStartParams(String params) { + public void setStartParams(String params) { devModeStartParams = params; } @@ -241,20 +241,20 @@ public static void setStartParams(String params) { * * @return The custom start parameters for debugging to start dev mode. */ - public static String getStartParamsDebugPort() { + public String getStartParamsDebugPort() { return devModeStartParamsDebug; } - public static void setStartParamsDebugPort(String params) { + public void setStartParamsDebugPort(String params) { devModeStartParamsDebug = params; } /** * Returns Build Category */ - public static BuildType getBuildCategory() { + public BuildType getBuildCategory() { return buildCategory; }; - public static void setBuildCategory(BuildType type) { + public void setBuildCategory(BuildType type) { buildCategory = type; };