diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java
index 73eadc194..fab7d96c5 100644
--- a/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java
+++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModJakartaLSTestCommon.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2023, 2024 IBM Corporation.
+ * Copyright (c) 2023, 2025 IBM Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -20,6 +20,7 @@
import java.time.Duration;
import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError;
+import static io.openliberty.tools.intellij.it.Utils.ItConstants.*;
public abstract class SingleModJakartaLSTestCommon {
public static final String REMOTEBOT_URL = "http://localhost:8082";
@@ -61,8 +62,8 @@ public void afterEach(TestInfo info) {
public static void cleanup() {
ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2));
- UIBotTestUtils.closeFileEditorTab(remoteRobot, "SystemResource.java", "5");
- UIBotTestUtils.closeFileEditorTab(remoteRobot, "SystemResource2.java", "5");
+ UIBotTestUtils.closeFileEditorTab(remoteRobot, SYSTEM_RESOURCE_JAVA, "5");
+ UIBotTestUtils.closeFileEditorTab(remoteRobot, SYSTEM_RESOURCE_2_JAVA, "5");
UIBotTestUtils.closeProjectView(remoteRobot);
UIBotTestUtils.closeProjectFrame(remoteRobot);
@@ -80,7 +81,7 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() {
String insertedCode = "public String methodname() {";
// get focus on file tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "SystemResource.java");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SYSTEM_RESOURCE_JAVA);
// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);
@@ -90,8 +91,8 @@ public void testInsertJakartaCodeSnippetIntoJavaPart() {
// Insert a code snippet into java part
try {
- UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, "SystemResource.java", snippetStr, snippetChooser);
- Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource.java");
+ UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, SYSTEM_RESOURCE_JAVA, snippetStr, snippetChooser);
+ Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SYSTEM_RESOURCE_PATH));
TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode);
}
finally {
@@ -109,28 +110,28 @@ public void testJakartaDiagnosticsInJavaPart() {
String privateString = "private Response getProperties() {";
String flaggedString = "getProperties";
String expectedHoverData = "Only public methods can be exposed as resource methods";
- Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource2.java");
+ Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SYSTEM_RESOURCE_2_PATH));
// get focus on file tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "SystemResource2.java");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SYSTEM_RESOURCE_2_JAVA);
// Modify the method signature
- UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, "SystemResource2.java", publicString, privateString);
+ UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, SYSTEM_RESOURCE_2_JAVA, publicString, privateString);
try {
// validate the method signature is no longer set to public
TestUtils.validateStringNotInFile(pathToSrc.toString(), publicString);
//there should be a diagnostic for "private" on method signature - move cursor to hover point
- UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, "SystemResource2.java", UIBotTestUtils.PopupType.DIAGNOSTIC);
+ UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, SYSTEM_RESOURCE_2_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC);
String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC);
TestUtils.validateHoverData(expectedHoverData, foundHoverData);
- UIBotTestUtils.clickOnFileTab(remoteRobot, "SystemResource2.java");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SYSTEM_RESOURCE_2_JAVA);
} finally {
// Replace modified content with the original content
- UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, "SystemResource2.java", privateString, publicString);
+ UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, SYSTEM_RESOURCE_2_JAVA, privateString, publicString);
}
}
@@ -144,24 +145,24 @@ public void testJakartaQuickFixInJavaPart() {
String privateString = "private Response getProperties() {";
String flaggedString = "getProperties";
- Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource2.java");
+ Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SYSTEM_RESOURCE_2_PATH));
String quickfixChooserString = "Make method public";
// get focus on file tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "SystemResource2.java");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SYSTEM_RESOURCE_2_JAVA);
// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);
// Modify the method signature
- UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, "SystemResource2.java", publicString, privateString);
+ UIBotTestUtils.selectAndModifyTextInJavaPart(remoteRobot, SYSTEM_RESOURCE_2_JAVA, publicString, privateString);
try {
// validate public signature no longer found in java part
TestUtils.validateStringNotInFile(pathToSrc.toString(), publicString);
//there should be a diagnostic - move cursor to hover point
- UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, "SystemResource2.java", quickfixChooserString);
+ UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, SYSTEM_RESOURCE_2_JAVA, quickfixChooserString);
// trigger and use the quickfix popup attached to the diagnostic
UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString);
@@ -198,11 +199,11 @@ public static void prepareEnv(String projectPath, String projectName) {
// expand project directories that are specific to this test app being used by these testcases
// must be expanded here before trying to open specific files
- projTree.expand(projectName, "src", "main", "java", "io.openliberty.mp.sample", "system");
-
- UIBotTestUtils.openFile(remoteRobot, projectName, "SystemResource", projectName, "src", "main", "java", "io.openliberty.mp.sample", "system");
- UIBotTestUtils.openFile(remoteRobot, projectName, "SystemResource2", projectName, "src", "main", "java", "io.openliberty.mp.sample", "system");
+ projTree.expand(TestUtils.combinePath(projectName, SYSTEM_DIR_PATH));
+ String[] systemDirPath = TestUtils.combinePath(projectName, SYSTEM_DIR_PATH);
+ UIBotTestUtils.openFile(remoteRobot, projectName, SYSTEM_RESOURCE, systemDirPath);
+ UIBotTestUtils.openFile(remoteRobot, projectName, SYSTEM_RESOURCE_2, systemDirPath);
// Removes the build tool window if it is opened. This prevents text to be hidden by it.
UIBotTestUtils.removeToolWindow(remoteRobot, "Build:");
diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java
index 9e2a0833b..8b53b7064 100644
--- a/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java
+++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModLibertyLSTestCommon.java
@@ -25,6 +25,7 @@
import static java.awt.event.KeyEvent.VK_SPACE;
import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError;
+import static io.openliberty.tools.intellij.it.Utils.ItConstants.*;
public abstract class SingleModLibertyLSTestCommon {
public static final String REMOTEBOT_URL = "http://localhost:8082";
@@ -64,11 +65,11 @@ public void afterEach(TestInfo info) {
*/
@AfterAll
public static void cleanup() {
- UIBotTestUtils.closeFileEditorTab(remoteRobot, "server.xml", "5");
- UIBotTestUtils.closeFileEditorTab(remoteRobot, "server.env", "5");
- UIBotTestUtils.closeFileEditorTab(remoteRobot, "bootstrap.properties", "5");
+ UIBotTestUtils.closeFileEditorTab(remoteRobot, SERVER_XML, "5");
+ UIBotTestUtils.closeFileEditorTab(remoteRobot, SERVER_ENV, "5");
+ UIBotTestUtils.closeFileEditorTab(remoteRobot, BOOTSTRAP_PROPERTIES, "5");
if (!remoteRobot.isMac()) {
- UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3);
+ UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3);
}
UIBotTestUtils.closeProjectView(remoteRobot);
UIBotTestUtils.closeProjectFrame(remoteRobot);
@@ -86,7 +87,7 @@ public void testServerXMLFeatureHover() {
String hoverExpectedOutcome = "This feature provides support for the MicroProfile Health specification.";
//mover cursor to hover point
- UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, "server.xml", UIBotTestUtils.PopupType.DOCUMENTATION);
+ UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, SERVER_XML, UIBotTestUtils.PopupType.DOCUMENTATION);
String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION);
// Validate that the hover action raised the expected hint text
@@ -104,7 +105,7 @@ public void testServerXMLNonFeatureHover() {
String hoverExpectedOutcome = "Configuration properties for an HTTP endpoint.";
//mover cursor to hover point
- UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, "server.xml", UIBotTestUtils.PopupType.DOCUMENTATION);
+ UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, SERVER_XML, UIBotTestUtils.PopupType.DOCUMENTATION);
String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION);
// Validate that the hover action raised the expected hint text
@@ -122,7 +123,7 @@ public void testInsertFeatureIntoServerXML() {
String insertedFeature = "el-3.0";
// get focus on server.xml tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "server.xml");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SERVER_XML);
// Save the current server.xml content.
UIBotTestUtils.copyWindowContent(remoteRobot);
@@ -130,7 +131,7 @@ public void testInsertFeatureIntoServerXML() {
// Insert a new element in server.xml.
try {
UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 18, 40, UIBotTestUtils.InsertionType.FEATURE, true);
- Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.xml");
+ Path pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVER_XML_PATH));
TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedFeature);
} finally {
// Replace server.xml content with the original content
@@ -149,7 +150,7 @@ public void testInsertLibertyConfigElementIntoServerXML() {
String insertedConfig = "";
// get focus on server.xml tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "server.xml");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SERVER_XML);
// Save the current server.xml content.
UIBotTestUtils.copyWindowContent(remoteRobot);
@@ -158,7 +159,7 @@ public void testInsertLibertyConfigElementIntoServerXML() {
try {
UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, true);
TestUtils.sleepAndIgnoreException(2); // wait for editor to update
- Path pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.xml");
+ Path pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVER_XML_PATH));
TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), insertedConfig);
} finally {
// Replace server.xml content with the original content
@@ -180,14 +181,14 @@ public void testInsertLibertyConfigIntoServerEnvForCapitalCase() {
String expectedServerEnvString = "WLP_LOGGING_CONSOLE_FORMAT=SIMPLE";
// get focus on server.env tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "server.env");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SERVER_ENV);
// Save the current server.env content.
UIBotTestUtils.copyWindowContent(remoteRobot);
try {
- UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "server.env", envCfgSnippet, envCfgNameChooserSnippet, envCfgValueSnippet, true);
- Path pathToServerEnv = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.env");
+ UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, envCfgValueSnippet, true);
+ Path pathToServerEnv = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVER_ENV_PATH));
TestUtils.validateStringInFile(pathToServerEnv.toString(), expectedServerEnvString);
} finally {
// Replace server.xml content with the original content
@@ -265,14 +266,14 @@ public void testInsertLibertyConfigIntoBootstrapPropsForLowerCase() {
String expectedBootstrapPropsString = "com.ibm.ws.logging.console.format=TBASIC";
// get focus on bootstrap.properties tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "bootstrap.properties");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, BOOTSTRAP_PROPERTIES);
// Save the current bootstrap.properties content.
UIBotTestUtils.copyWindowContent(remoteRobot);
try {
- UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "bootstrap.properties", configNameSnippet, configNameChooserSnippet, configValueSnippet, true);
- Path pathToBootstrapProps = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "bootstrap.properties");
+ UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, configValueSnippet, true);
+ Path pathToBootstrapProps = Paths.get(projectsPath, TestUtils.combinePath(projectName, BOOTSTRAP_PROPERTIES_PATH));
TestUtils.validateStringInFile(pathToBootstrapProps.toString(), expectedBootstrapPropsString);
} finally {
// Replace server.xml content with the original content
@@ -367,7 +368,7 @@ public void testServerEnvCfgHover() {
String hoverExpectedOutcome = "This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.";
//mover cursor to hover point
- UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, "server.env", UIBotTestUtils.PopupType.DOCUMENTATION);
+ UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, SERVER_ENV, UIBotTestUtils.PopupType.DOCUMENTATION);
String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION);
// Validate that the hover action raised the expected hint text
@@ -386,7 +387,7 @@ public void testBootstrapPropsCfgHover() {
String hoverExpectedOutcome = "This setting controls the granularity of messages that go to the console. The valid values are INFO, AUDIT, WARNING, ERROR, and OFF. The default is AUDIT. If using with the Eclipse developer tools this must be set to the default.";
//mover cursor to hover point
- UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, "bootstrap.properties", UIBotTestUtils.PopupType.DOCUMENTATION);
+ UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, BOOTSTRAP_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION);
String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION);
// Validate that the hover action raised the expected hint text
@@ -405,10 +406,10 @@ public void testDiagnosticInServerXML() {
String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'.";
Path pathToServerXML = null;
- pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.xml");
+ pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVER_XML_PATH));
// get focus on server.xml tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "server.xml");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SERVER_XML);
// Save the current server.xml content.
UIBotTestUtils.copyWindowContent(remoteRobot);
@@ -417,7 +418,7 @@ public void testDiagnosticInServerXML() {
UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, false);
//move cursor to hover point
- UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, "server.xml", UIBotTestUtils.PopupType.DIAGNOSTIC);
+ UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, SERVER_XML, UIBotTestUtils.PopupType.DIAGNOSTIC);
String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC);
TestUtils.validateHoverData(expectedHoverData, foundHoverData);
@@ -441,10 +442,10 @@ public void testQuickFixInServerXML() {
String expectedHoverData = "cvc-datatype-valid.1.2.3: 'wrong' is not a valid value of union type 'booleanType'.";
Path pathToServerXML = null;
- pathToServerXML = Paths.get(projectsPath, projectName, "src", "main", "liberty", "config", "server.xml");
+ pathToServerXML = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVER_XML_PATH));
// get focus on server.xml tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "server.xml");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SERVER_XML);
// Save the current server.xml content.
UIBotTestUtils.copyWindowContent(remoteRobot);
@@ -453,7 +454,7 @@ public void testQuickFixInServerXML() {
UIBotTestUtils.insertStanzaInAppServerXML(remoteRobot, stanzaSnippet, 20, 0, UIBotTestUtils.InsertionType.ELEMENT, false);
//there should be a diagnostic - move cursor to hover point
- UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, "server.xml", quickfixChooserString);
+ UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, SERVER_XML, quickfixChooserString);
UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString);
TestUtils.validateStanzaInConfigFile(pathToServerXML.toString(), correctedStanza);
@@ -476,15 +477,15 @@ public void testDiagnosticInServerEnv() {
String expectedHoverData = "The value `NONE` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.";
// get focus on server.env tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "server.env");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SERVER_ENV);
// Save the current server.env content.
UIBotTestUtils.copyWindowContent(remoteRobot);
try {
- UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "server.env", envCfgSnippet, envCfgNameChooserSnippet, incorrectValue, false);
+ UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, SERVER_ENV, envCfgSnippet, envCfgNameChooserSnippet, incorrectValue, false);
//move cursor to hover point
- UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "NONE", "server.env", UIBotTestUtils.PopupType.DIAGNOSTIC);
+ UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "NONE", SERVER_ENV, UIBotTestUtils.PopupType.DIAGNOSTIC);
String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC);
TestUtils.validateHoverData(expectedHoverData, foundHoverData);
@@ -506,16 +507,16 @@ public void testDiagnosticInBootstrapProperties() {
String expectedHoverData = "The value `none` is not valid for the property `com.ibm.ws.logging.console.format`.";
// get focus on bootstrap.properties tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "bootstrap.properties");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, BOOTSTRAP_PROPERTIES);
// Save the current bootstrap.properties content.
UIBotTestUtils.copyWindowContent(remoteRobot);
try {
- UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, "bootstrap.properties", configNameSnippet, configNameChooserSnippet, incorrectValue, false);
+ UIBotTestUtils.insertConfigIntoConfigFile(remoteRobot, BOOTSTRAP_PROPERTIES, configNameSnippet, configNameChooserSnippet, incorrectValue, false);
//move cursor to hover point
- UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "none", "bootstrap.properties", UIBotTestUtils.PopupType.DIAGNOSTIC);
+ UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, "none", BOOTSTRAP_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC);
String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC);
TestUtils.validateHoverData(expectedHoverData, foundHoverData);
} finally {
@@ -581,7 +582,7 @@ public static void prepareEnv(String projectPath, String projectName) {
UIBotTestUtils.importProject(remoteRobot, projectPath, projectName);
UIBotTestUtils.openProjectView(remoteRobot);
if (!remoteRobot.isMac()) {
- UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3);
+ UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3);
}
// IntelliJ does not start building and indexing until the Project View is open
UIBotTestUtils.waitForIndexing(remoteRobot);
@@ -591,16 +592,18 @@ public static void prepareEnv(String projectPath, String projectName) {
// get a JTreeFixture reference to the file project viewer entry
ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2));
JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName);
- projTree.expand(projectName, "src", "main", "liberty", "config");
+ projTree.expand(TestUtils.combinePath(projectName, CONFIG_DIR_PATH));
+
+ String[] configDirPath = TestUtils.combinePath(projectName, CONFIG_DIR_PATH);
// open server.xml file
- UIBotTestUtils.openFile(remoteRobot, projectName, "server.xml", projectName, "src", "main", "liberty", "config");
+ UIBotTestUtils.openFile(remoteRobot, projectName, SERVER_XML, configDirPath);
// open server.env file
- UIBotTestUtils.openFile(remoteRobot, projectName, "server.env", projectName, "src", "main", "liberty", "config");
+ UIBotTestUtils.openFile(remoteRobot, projectName, SERVER_ENV, configDirPath);
// open bootstrap.properties file
- UIBotTestUtils.openFile(remoteRobot, projectName, "bootstrap.properties", projectName, "src", "main", "liberty", "config");
+ UIBotTestUtils.openFile(remoteRobot, projectName, BOOTSTRAP_PROPERTIES, configDirPath);
// Removes the build tool window if it is opened. This prevents text to be hidden by it.
UIBotTestUtils.removeToolWindow(remoteRobot, "Build:");
diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java
index 590c9da03..14379774d 100644
--- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java
+++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPLSTestCommon.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2023, 2024 IBM Corporation.
+ * Copyright (c) 2023, 2025 IBM Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -20,6 +20,7 @@
import java.time.Duration;
import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError;
+import static io.openliberty.tools.intellij.it.Utils.ItConstants.*;
public abstract class SingleModMPLSTestCommon {
public static final String REMOTEBOT_URL = "http://localhost:8082";
@@ -64,10 +65,10 @@ public static void cleanup() {
projectFrame.findText("META-INF").doubleClick();
projectFrame.findText("resources").doubleClick();
- UIBotTestUtils.closeFileEditorTab(remoteRobot, "ServiceLiveHealthCheck.java", "5");
- UIBotTestUtils.closeFileEditorTab(remoteRobot, "microprofile-config.properties", "5");
+ UIBotTestUtils.closeFileEditorTab(remoteRobot, SERVICE_LIVE_HEALTH_CHECK_JAVA, "5");
+ UIBotTestUtils.closeFileEditorTab(remoteRobot, MPCFG_PROPERTIES, "5");
if (!remoteRobot.isMac()) {
- UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3);
+ UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3);
}
UIBotTestUtils.closeProjectView(remoteRobot);
UIBotTestUtils.closeProjectFrame(remoteRobot);
@@ -85,7 +86,7 @@ public void testInsertCodeSnippetIntoJavaPart() {
String insertedCode = "public class ServiceLiveHealthCheck implements HealthCheck {";
// get focus on file tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "ServiceLiveHealthCheck.java");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SERVICE_LIVE_HEALTH_CHECK_JAVA);
// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);
@@ -95,8 +96,8 @@ public void testInsertCodeSnippetIntoJavaPart() {
// Insert a code snippet into java part
try {
- UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, "ServiceLiveHealthCheck.java", snippetStr, snippetChooser);
- Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health","ServiceLiveHealthCheck.java");
+ UIBotTestUtils.insertCodeSnippetIntoSourceFile(remoteRobot, SERVICE_LIVE_HEALTH_CHECK_JAVA, snippetStr, snippetChooser);
+ Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVICE_LIVE_HEALTHCHECK_PATH));
TestUtils.validateCodeInJavaSrc(pathToSrc.toString(), insertedCode);
} finally {
// Replace modified content with the original content
@@ -116,14 +117,14 @@ public void testMPDiagnosticsInJavaPart() {
String expectedHoverData = "The class `io.openliberty.mp.sample.health.ServiceLiveHealthCheck` implementing the HealthCheck interface should use the @Liveness, @Readiness or @Health annotation.";
// get focus on file tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "ServiceLiveHealthCheck.java");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SERVICE_LIVE_HEALTH_CHECK_JAVA);
// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);
// Delete the liveness annotation
- UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, "ServiceLiveHealthCheck.java", livenessString);
- Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", "ServiceLiveHealthCheck.java");
+ UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot, SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString);
+ Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVICE_LIVE_HEALTHCHECK_PATH));
try {
// validate @Liveness no longer found in java part
@@ -134,7 +135,7 @@ public void testMPDiagnosticsInJavaPart() {
int maxWait = 60, delay = 5; // in some cases it can take 35s for the diagnostic to appear
for (int i = 0; i <= maxWait; i += delay) {
//there should be a diagnostic - move cursor to hover point
- UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, "ServiceLiveHealthCheck.java", UIBotTestUtils.PopupType.DIAGNOSTIC);
+ UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, flaggedString, SERVICE_LIVE_HEALTH_CHECK_JAVA, UIBotTestUtils.PopupType.DIAGNOSTIC);
foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC);
if (!foundHoverData.isBlank()) {
@@ -162,21 +163,21 @@ public void testMPQuickFixInJavaFile() {
String mainQuickFixActionStr = "Generate OpenAPI Annotations for 'ServiceLiveHealthCheck'";
// get focus on file tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "ServiceLiveHealthCheck.java");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, SERVICE_LIVE_HEALTH_CHECK_JAVA);
// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);
// Delete the liveness annotation
- UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,"ServiceLiveHealthCheck.java", livenessString);
- Path pathToSrc = Paths.get(projectsPath, projectName, "src", "main", "java", "io", "openliberty", "mp", "sample", "health", "ServiceLiveHealthCheck.java");
+ UIBotTestUtils.selectAndDeleteTextInJavaPart(remoteRobot,SERVICE_LIVE_HEALTH_CHECK_JAVA, livenessString);
+ Path pathToSrc = Paths.get(projectsPath, TestUtils.combinePath(projectName, SERVICE_LIVE_HEALTHCHECK_PATH));
try {
// validate @Liveness no longer found in java part
TestUtils.validateStringNotInFile(pathToSrc.toString(), livenessString);
//there should be a diagnostic - move cursor to hover point
- UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, "ServiceLiveHealthCheck.java", quickfixChooserString);
+ UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, flaggedString, SERVICE_LIVE_HEALTH_CHECK_JAVA, quickfixChooserString);
// trigger and use the quickfix popup attached to the diagnostic
UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString);
@@ -201,14 +202,14 @@ public void testInsertMicroProfileProperty() {
String expectedMpCfgPropertiesString = "mp.health.disable-default-procedures=true";
// get focus on file tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "microprofile-config.properties");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, MPCFG_PROPERTIES);
// Save the current microprofile-config.properties content.
UIBotTestUtils.copyWindowContent(remoteRobot);
try {
- UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, "microprofile-config.properties", cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true);
- Path pathToMpCfgProperties = Paths.get(projectsPath, projectName, "src", "main", "resources", "META-INF", "microprofile-config.properties");
+ UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, MPCFG_PROPERTIES, cfgSnippet, cfgNameChooserSnippet, cfgValueSnippet, true);
+ Path pathToMpCfgProperties = Paths.get(projectsPath, TestUtils.combinePath(projectName, MPCFG_PATH));
TestUtils.validateStringInFile(pathToMpCfgProperties.toString(), expectedMpCfgPropertiesString);
} finally {
// Replace modified microprofile-config.properties with the original content
@@ -231,7 +232,7 @@ public void testMicroProfileConfigHover() {
"java.lang.StringValue: http://localhost:9081/data/client/service";
//mover cursor to hover point
- UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, "microprofile-config.properties", UIBotTestUtils.PopupType.DOCUMENTATION);
+ UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, testHoverTarget, MPCFG_PROPERTIES, UIBotTestUtils.PopupType.DOCUMENTATION);
String hoverFoundOutcome = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DOCUMENTATION);
// if the LS has not yet poulated the popup, re-get the popup data
@@ -261,16 +262,16 @@ public void testDiagnosticInMicroProfileConfigProperties() {
String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'";
// get focus on file tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "microprofile-config.properties");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, MPCFG_PROPERTIES);
// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);
try {
- UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, "microprofile-config.properties", MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false);
+ UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, MPCFG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false);
//move cursor to hover point
- UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, incorrectValue, "microprofile-config.properties", UIBotTestUtils.PopupType.DIAGNOSTIC);
+ UIBotTestUtils.hoverInAppServerCfgFile(remoteRobot, incorrectValue, MPCFG_PROPERTIES, UIBotTestUtils.PopupType.DIAGNOSTIC);
String foundHoverData = UIBotTestUtils.getHoverStringData(remoteRobot, UIBotTestUtils.PopupType.DIAGNOSTIC);
TestUtils.validateHoverData(expectedHoverData, foundHoverData);
} finally {
@@ -294,19 +295,19 @@ public void testQuickFixInMicroProfileConfigProperties() {
String correctedValue = "mp.health.disable-default-procedures=true";
String expectedHoverData = "Type mismatch: boolean expected. By default, this value will be interpreted as 'false'";
- Path pathToMpCfgProperties = Paths.get(projectsPath, projectName,"src", "main", "resources", "META-INF", "microprofile-config.properties");
+ Path pathToMpCfgProperties = Paths.get(projectsPath, TestUtils.combinePath(projectName, MPCFG_PATH));
// get focus on file tab prior to copy
- UIBotTestUtils.clickOnFileTab(remoteRobot, "microprofile-config.properties");
+ UIBotTestUtils.clickOnFileTab(remoteRobot, MPCFG_PROPERTIES);
// Save the current content.
UIBotTestUtils.copyWindowContent(remoteRobot);
try {
- UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, "microprofile-config.properties", MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false);
+ UIBotTestUtils.insertConfigIntoMPConfigPropertiesFile(remoteRobot, MPCFG_PROPERTIES, MPCfgSnippet, MPCfgNameChooserSnippet, incorrectValue, false);
//move cursor to hover point
- UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, incorrectValue, "microprofile-config.properties", quickfixChooserString);
+ UIBotTestUtils.hoverForQuickFixInAppFile(remoteRobot, incorrectValue, MPCFG_PROPERTIES, quickfixChooserString);
UIBotTestUtils.chooseQuickFix(remoteRobot, quickfixChooserString);
TestUtils.validateStanzaInConfigFile(pathToMpCfgProperties.toString(), correctedValue);
@@ -332,7 +333,7 @@ public static void prepareEnv(String projectPath, String projectName) {
UIBotTestUtils.importProject(remoteRobot, projectPath, projectName);
UIBotTestUtils.openProjectView(remoteRobot);
if (!remoteRobot.isMac()) {
- UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3);
+ UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3);
}
// IntelliJ does not start building and indexing until the Project View is open
UIBotTestUtils.waitForIndexing(remoteRobot);
@@ -343,8 +344,8 @@ public static void prepareEnv(String projectPath, String projectName) {
ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofMinutes(2));
JTreeFixture projTree = projectFrame.getProjectViewJTree(projectName);
- UIBotTestUtils.openFile(remoteRobot, projectName, "ServiceLiveHealthCheck", projectName, "src", "main", "java", "io.openliberty.mp.sample", "health");
- UIBotTestUtils.openFile(remoteRobot, projectName, "microprofile-config.properties", projectName, "src", "main", "resources", "META-INF");
+ UIBotTestUtils.openFile(remoteRobot, projectName, SERVICE_LIVEHEALTH_CHECK, TestUtils.combinePath(projectName, HEALTH_DIR_PATH));
+ UIBotTestUtils.openFile(remoteRobot, projectName, MPCFG_PROPERTIES, TestUtils.combinePath(projectName, META_INF_DIR_PATH));
// Removes the build tool window if it is opened. This prevents text to be hidden by it.
UIBotTestUtils.removeToolWindow(remoteRobot, "Build:");
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 c794fea80..7e98335fe 100644
--- a/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java
+++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModMPProjectTestCommon.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2023, 2024 IBM Corporation.
+ * Copyright (c) 2023, 2025 IBM Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -27,6 +27,7 @@
import java.util.Map;
import static com.intellij.remoterobot.search.locators.Locators.byXpath;
+import static io.openliberty.tools.intellij.it.Utils.ItConstants.*;
import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError;
/**
@@ -294,8 +295,8 @@ public static void cleanup() {
*/
protected static void closeProjectView() {
if (!remoteRobot.isMac()) {
- UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3);
- UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3);
+ UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, CLOSE_ALL_TABS, 3);
+ UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3);
}
UIBotTestUtils.closeLibertyToolWindow(remoteRobot);
UIBotTestUtils.closeProjectView(remoteRobot);
@@ -1139,7 +1140,7 @@ public static void prepareEnv(String projectPath, String projectName) {
UIBotTestUtils.importProject(remoteRobot, projectPath, projectName);
UIBotTestUtils.openProjectView(remoteRobot);
if (!remoteRobot.isMac()) {
- UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3);
+ UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3);
}
// IntelliJ does not start building and indexing until the Project View is open
UIBotTestUtils.waitForIndexing(remoteRobot);
@@ -1157,7 +1158,7 @@ public static void prepareEnv(String projectPath, String projectName) {
UIBotTestUtils.closeAllEditorTabs(remoteRobot);
}
else {
- UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3);
+ UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, CLOSE_ALL_TABS, 3);
}
TestUtils.printTrace(TestUtils.TraceSevLevel.INFO,
diff --git a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java
index 5fb15e38c..6bdcfe201 100644
--- a/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java
+++ b/src/test/java/io/openliberty/tools/intellij/it/SingleModNLTRestProjectTestCommon.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2023, 2024 IBM Corporation.
+ * Copyright (c) 2023, 2025 IBM Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -21,6 +21,7 @@
import static com.intellij.remoterobot.utils.RepeatUtilsKt.waitForIgnoringError;
import static org.junit.jupiter.api.Assertions.fail;
+import static io.openliberty.tools.intellij.it.Utils.ItConstants.*;
/**
* Holds common tests that use a single module non Liberty Tools compliant REST project.
@@ -85,7 +86,7 @@ public void afterEach(TestInfo info) {
@AfterAll
public static void cleanup() {
if (!remoteRobot.isMac()) {
- UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3);
+ UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3);
}
UIBotTestUtils.closeLibertyToolWindow(remoteRobot);
UIBotTestUtils.closeProjectView(remoteRobot);
@@ -194,8 +195,8 @@ public void testsRefreshProjectWithServerXmlOnly() {
UIBotTestUtils.waitForLTWNoProjectDetectedMsg(remoteRobot, 10);
// Copy a valid server.xml file to this project's src/main/liberty/config directory.
- Path validServerXml = Paths.get(getHelperFilesDirPath(), "server.xml");
- Path destination = Paths.get(getProjectsDirPath(), getSmNLTRestProjectName(), "src", "main", "liberty", "config", "server.xml");
+ Path validServerXml = Paths.get(getHelperFilesDirPath(), SERVER_XML);
+ Path destination = Paths.get(getProjectsDirPath(), TestUtils.combinePath(getSmNLTRestProjectName(), SERVER_XML_PATH));
try {
Files.copy(validServerXml, destination, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
@@ -302,7 +303,7 @@ public static void prepareEnv(String projectPath, String projectName) {
UIBotTestUtils.importProject(remoteRobot, projectPath, projectName);
UIBotTestUtils.openProjectView(remoteRobot);
if (!remoteRobot.isMac()) {
- UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Compact Mode", 3);
+ UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, COMPACT_MODE, 3);
}
// IntelliJ does not start building and indexing until the Project View is open
UIBotTestUtils.waitForIndexing(remoteRobot);
diff --git a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java
index 4aba7ee90..0c271a47a 100644
--- a/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java
+++ b/src/test/java/io/openliberty/tools/intellij/it/TestUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2023, 2024 IBM Corporation.
+ * Copyright (c) 2023, 2025 IBM Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -17,17 +17,17 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Arrays;
import java.util.List;
+import java.util.stream.Stream;
+
+import static io.openliberty.tools.intellij.it.Utils.ItConstants.*;
/**
* Test utilities.
*/
public class TestUtils {
- /**
- * WLP messages.log path.
- */
- public static final Path WLP_MSGLOG_PATH = Paths.get("wlp", "usr", "servers", "defaultServer", "logs", "messages.log");
/**
* Liberty server stopped message:
@@ -60,7 +60,7 @@ public static void validateLibertyServerStopped(String testName, String wlpInsta
public static void validateLibertyServerStopped(String testName, String wlpInstallPath, int maxAttempts, boolean failOnNoStop) {
printTrace(TraceSevLevel.INFO, testName + ":validateLibertyServerStopped: Entry.");
- String wlpMsgLogPath = Paths.get(wlpInstallPath, WLP_MSGLOG_PATH.toString()).toString();
+ String wlpMsgLogPath = Paths.get(wlpInstallPath, MESSAGES_LOG_PATH).toString();
int retryIntervalSecs = 5;
boolean foundStoppedMsg = false;
Exception error = null;
@@ -168,7 +168,7 @@ public static void validateProjectStarted(String testName, String resourceURI, i
// If we are here, the expected outcome was not found. Print the Liberty server's messages.log and fail.
String msg = testName + ":validateProjectStarted: Timed out while waiting for project with resource URI " + resourceURI + "and port " + port + " to become available.";
printTrace(TraceSevLevel.ERROR, msg);
- String wlpMsgLogPath = Paths.get(wlpInstallPath, WLP_MSGLOG_PATH.toString()).toString();
+ String wlpMsgLogPath = Paths.get(wlpInstallPath, MESSAGES_LOG_PATH).toString();
String msgHeader = "Message log for failed test: " + testName + ":validateProjectStarted";
printLibertyMessagesLogFile(msgHeader, wlpMsgLogPath);
Assertions.fail(msg);
@@ -274,7 +274,7 @@ public static void validateProjectStopped(String testName, String projUrl, Strin
// If we are here, the expected outcome was not found. Print the Liberty server's messages.log and fail.
String msg = testName + ":validateProjectStopped: Timed out while waiting for project under URL: " + projUrl + " to stop.";
printTrace(TraceSevLevel.ERROR, msg);
- String wlpMsgLogPath = Paths.get(wlpInstallPath, WLP_MSGLOG_PATH.toString()).toString();
+ String wlpMsgLogPath = Paths.get(wlpInstallPath, MESSAGES_LOG_PATH).toString();
String msgHeader = "Message log for failed test: " + testName + ":validateProjectStopped";
printLibertyMessagesLogFile(msgHeader, wlpMsgLogPath);
Assertions.fail(msg);
@@ -516,7 +516,7 @@ public static void sleepAndIgnoreException(int seconds) {
*/
public static boolean isServerStopNeeded(String wlpInstallPath) {
boolean stopServer = false;
- Path msgLogPath = Paths.get(wlpInstallPath, WLP_MSGLOG_PATH.toString());
+ Path msgLogPath = Paths.get(wlpInstallPath, MESSAGES_LOG_PATH);
if (fileExists(msgLogPath)) {
try {
// The file maybe an old log. For now, check for the message indicating
@@ -541,7 +541,7 @@ public static boolean isServerStopNeeded(String wlpInstallPath) {
*/
public static void checkDebugPort(String absoluteWLPPath, int debugPort) throws IOException {
// Retrieve the WLP server.env file path
- Path serverEnvPath = Paths.get(absoluteWLPPath, "wlp", "usr", "servers", "defaultServer", "server.env");
+ Path serverEnvPath = Paths.get(absoluteWLPPath, DEFAULT_SERVER_ENV_PATH);
// Read all lines from server.env
List lines = Files.readAllLines(serverEnvPath);
// Check if Debug Port is set to the specified port
@@ -598,4 +598,17 @@ public static void detectFatalError() {
throw new RuntimeException(e);
}
}
+
+
+ /**
+ * Combines the project name with a given array of paths.
+ *
+ * @param projectName the name of the project to prepend
+ * @param pathArray an array of paths to append to the project name
+ * @return a new array with the project name as the first element followed by the original paths
+ */
+ public static String[] combinePath(String projectName, String[] pathArray) {
+ return Stream.concat(Stream.of(projectName), Arrays.stream(pathArray))
+ .toArray(String[]::new);
+ }
}
diff --git a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java
index 1ba7103b2..c9b4a84fc 100644
--- a/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java
+++ b/src/test/java/io/openliberty/tools/intellij/it/UIBotTestUtils.java
@@ -42,6 +42,7 @@
import static com.intellij.remoterobot.search.locators.Locators.byXpath;
import static java.awt.event.KeyEvent.*;
import static org.junit.jupiter.api.Assertions.fail;
+import static io.openliberty.tools.intellij.it.Utils.ItConstants.*;
/**
* UI helper function.
@@ -761,7 +762,7 @@ public static void closeFileEditorTab(RemoteRobot remoteRobot, String editorTabN
*/
public static void closeAllEditorTabs(RemoteRobot remoteRobot) {
ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(10));
- projectFrame.clickOnMainMenuWithActions(remoteRobot, "Window", "Editor Tabs", "Close All Tabs");
+ projectFrame.clickOnMainMenuWithActions(remoteRobot, "Window", "Editor Tabs", CLOSE_ALL_TABS);
}
/**
@@ -829,7 +830,7 @@ public static void hoverInAppServerCfgFile(RemoteRobot remoteRobot, String hover
// Find the target text on the editor and move the move to it.
editorNew.findText(contains(hoverTarget)).moveMouse();
// clear and "lightbulb" icons?
- if (!hoverFile.equals("server.xml")) {
+ if (!hoverFile.equals(SERVER_XML)) {
keyboard.hotKey(VK_ESCAPE);
}
@@ -1207,7 +1208,7 @@ else if (fileName.equals("bootstrap.properties")) {
public static void insertStanzaInAppServerXML(RemoteRobot remoteRobot, String stanzaSnippet, int line, int col, InsertionType type, boolean completeWithPopup) {
ProjectFrameFixture projectFrame = remoteRobot.find(ProjectFrameFixture.class, Duration.ofSeconds(30));
- clickOnFileTab(remoteRobot, "server.xml");
+ clickOnFileTab(remoteRobot, SERVER_XML);
Locator locator = byXpath("//div[@class='EditorCompositePanel']//div[@class='EditorComponentImpl']");
EditorFixture editorNew = remoteRobot.find(EditorFixture.class, locator, Duration.ofSeconds(20));
editorNew.click();
@@ -1747,7 +1748,7 @@ public static void runActionFromSearchEverywherePanel(RemoteRobot remoteRobot, S
* If we are not specify a condition check for "Close All Tabs" action when no file tabs are open, the runActionFromSearchEverywherePanel method
* will throw a RuntimeException, causing the test to fail.
*/
- if (error != null && !action.equals("Close All Tabs")) {
+ if (error != null && !action.equals(CLOSE_ALL_TABS)) {
throw new RuntimeException("Failed to run the " + action + " action using the search everywhere option", error);
}
}
@@ -2677,7 +2678,7 @@ public static void findWelcomeFrame(RemoteRobot remoteRobot) {
UIBotTestUtils.closeAllEditorTabs(remoteRobot);
}
else {
- UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, "Close All Tabs", 3);
+ UIBotTestUtils.runActionFromSearchEverywherePanel(remoteRobot, CLOSE_ALL_TABS, 3);
}
UIBotTestUtils.closeProjectView(remoteRobot);
UIBotTestUtils.closeProjectFrame(remoteRobot);
diff --git a/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java
new file mode 100644
index 000000000..369470172
--- /dev/null
+++ b/src/test/java/io/openliberty/tools/intellij/it/Utils/ItConstants.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2025 IBM Corporation.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *******************************************************************************/
+package io.openliberty.tools.intellij.it.Utils;
+
+public class ItConstants {
+
+ /**
+ * Constants for Integration testing
+ */
+ public static final String SYSTEM_RESOURCE_JAVA = "SystemResource.java";
+ public static final String SYSTEM_RESOURCE_2_JAVA = "SystemResource2.java";
+ public static final String SYSTEM_RESOURCE = "SystemResource";
+ public static final String SYSTEM_RESOURCE_2 = "SystemResource2";
+ public static final String SERVICE_LIVEHEALTH_CHECK = "ServiceLiveHealthCheck";
+ public static final String SERVICE_LIVE_HEALTH_CHECK_JAVA = "ServiceLiveHealthCheck.java";
+ public static final String MPCFG_PROPERTIES = "microprofile-config.properties";
+
+ public static final String[] CONFIG_DIR_PATH = {"src", "main", "liberty", "config"};
+ public static final String[] SERVER_XML_PATH = {"src", "main", "liberty", "config", "server.xml"};
+ public static final String[] SERVER_ENV_PATH = {"src", "main", "liberty", "config", "server.env"};
+ public static final String[] BOOTSTRAP_PROPERTIES_PATH = {"src", "main", "liberty", "config", "bootstrap.properties"};
+ public static final String[] SYSTEM_RESOURCE_PATH = {"src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource.java"};
+ public static final String[] SYSTEM_RESOURCE_2_PATH = {"src", "main", "java", "io", "openliberty", "mp", "sample", "system", "SystemResource2.java"};
+ public static final String[] SYSTEM_DIR_PATH = {"src", "main", "java", "io.openliberty.mp.sample", "system"};
+ public static final String[] SERVICE_LIVE_HEALTHCHECK_PATH = {"src", "main", "java", "io", "openliberty", "mp", "sample", "health", "ServiceLiveHealthCheck.java"};
+ public static final String[] HEALTH_DIR_PATH = {"src", "main", "java", "io.openliberty.mp.sample", "health"};
+ public static final String[] MPCFG_PATH = {"src", "main", "resources", "META-INF", "microprofile-config.properties"};
+ public static final String[] META_INF_DIR_PATH = {"src", "main", "resources", "META-INF"};
+ public static final String[] DEFAULT_SERVER_ENV_PATH = {"wlp", "usr", "servers", "defaultServer", "server.env"};
+ public static final String[] MESSAGES_LOG_PATH = {"wlp", "usr", "servers", "defaultServer", "logs", "messages.log"};
+
+ public static final String SERVER_XML = "server.xml";
+ public static final String SERVER_ENV = "server.env";
+ public static final String BOOTSTRAP_PROPERTIES = "bootstrap.properties";
+ public static final String COMPACT_MODE = "Compact Mode";
+
+ public static final String CLOSE_ALL_TABS = "Close All Tabs";
+}