diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertySourcePathComputer.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertySourcePathComputer.java index 20c9907e..8bdb1d0f 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertySourcePathComputer.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertySourcePathComputer.java @@ -193,7 +193,7 @@ private void addRuntimeDependencies(IProject project) throws CoreException { // If the project is a java project, get classpath entries for runtime dependencies if (project.isNatureEnabled(JavaCore.NATURE_ID)) { List runtimeDependencies = Arrays - .asList(JavaRuntime.computeUnresolvedRuntimeDependencies(JavaCore.create(project))); + .asList(JavaRuntime.computeUnresolvedRuntimeClasspath(JavaCore.create(project))); for (IRuntimeClasspathEntry runtimeDependency : runtimeDependencies) { if (!unresolvedClasspathEntries.contains(runtimeDependency)) { unresolvedClasspathEntries.add(runtimeDependency); diff --git a/tests/resources/applications/gradle/liberty-gradle-test-app/build.gradle b/tests/resources/applications/gradle/liberty-gradle-test-app/build.gradle index 690a61ae..6bb55d97 100644 --- a/tests/resources/applications/gradle/liberty-gradle-test-app/build.gradle +++ b/tests/resources/applications/gradle/liberty-gradle-test-app/build.gradle @@ -13,6 +13,7 @@ tasks.withType(JavaCompile) { buildscript { repositories { mavenCentral() + mavenLocal() } dependencies { classpath 'io.openliberty.tools:liberty-gradle-plugin:3.6.2' @@ -21,6 +22,7 @@ buildscript { repositories { mavenCentral() + mavenLocal() } dependencies { diff --git a/tests/resources/applications/maven/test-shared-lib-jar/pom.xml b/tests/resources/applications/maven/test-shared-lib-jar/pom.xml index bb0303af..6078669e 100644 --- a/tests/resources/applications/maven/test-shared-lib-jar/pom.xml +++ b/tests/resources/applications/maven/test-shared-lib-jar/pom.xml @@ -9,6 +9,7 @@ test shared-lib 1.0-SNAPSHOT + jar UTF-8 diff --git a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotGradleTest.java b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotGradleTest.java index c7d27926..7ea59ae6 100644 --- a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotGradleTest.java +++ b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotGradleTest.java @@ -45,9 +45,12 @@ import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.refreshProjectUsingExplorerView; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.setBuildCmdPathInPreferences; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.unsetBuildCmdPathInPreferences; +import static org.junit.jupiter.api.Assertions.assertEquals; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; +import java.io.InputStreamReader; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -105,7 +108,7 @@ public class LibertyPluginSWTBotGradleTest extends AbstractLibertyPluginSWTBotTe /** * Shared lib jar project name. */ - static final String MVN_SHARED_LIB_NAME = "test-shared-lib-jar"; + static final String MVN_SHARED_LIB_NAME = "shared-lib"; static String testAppPath; static String testWrapperAppPath; @@ -142,6 +145,7 @@ public class LibertyPluginSWTBotGradleTest extends AbstractLibertyPluginSWTBotTe /** * Setup. * + * @throws IOException * @throws CoreException * @throws InterruptedException */ @@ -171,6 +175,19 @@ public static void setup() throws Exception { } importMavenProjects(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(), mavenProjectToInstall); + // Build shared lib project + Process process = new ProcessBuilder("mvn", "clean", "install").directory(sharedLibProjectPath.toFile()).start(); + + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + + String line; + while ((line = reader.readLine()) != null) { + System.out.println(line); + } + + int exitCode = process.waitFor(); + assertEquals(0, exitCode, "Building of shared lib jar project failed with RC " + exitCode); + // Check basic plugin artifacts are functioning before running tests. validateBeforeTestRun(); @@ -828,6 +845,8 @@ public void testDefaultJRECompliance() { @Test public void testDebugSourceLookupContent() { + deleteLibertyToolsRunConfigEntriesFromAppRunAs(GRADLE_APP_NAME); + Shell configShell = launchDebugConfigurationsDialogFromAppRunAs(GRADLE_APP_NAME); boolean jarEntryFound = false; diff --git a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMavenTest.java b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMavenTest.java index 2b849ae7..a2ac92f4 100644 --- a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMavenTest.java +++ b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMavenTest.java @@ -17,65 +17,43 @@ import static io.openliberty.tools.eclipse.test.it.utils.MagicWidgetFinder.goGlobal; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.checkRunInContainerCheckBox; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.deleteLibertyToolsRunConfigEntriesFromAppRunAs; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.enableLibertyTools; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.getAppDebugAsMenu; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.getAppRunAsMenu; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.getComboTextBoxWithTextPrefix; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.getDashboardContent; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.getDashboardItemMenuActions; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.getDefaultSourceLookupTreeItemNoBot; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.getLibertyTreeItem; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.getLibertyTreeItemNoBot; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.getRunConfigurationsShell; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchCustomDebugFromDashboard; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchCustomRunFromDashboard; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchDashboardAction; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchDebugConfigurationsDialogFromAppRunAs; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchRunConfigurationsDialogFromAppRunAs; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchRunTestsWithRunAsShortcut; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchStartWithDebugAsShortcut; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchStartWithDefaultRunConfigFromAppRunAs; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchStartWithNewCustomDebugConfig; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchStartWithNewCustomRunConfig; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchStartWithRunAsShortcut; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchStopWithRunAsShortcut; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchViewITReportWithRunDebugAsShortcut; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchViewUTReportWithRunDebugAsShortcut; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.openJRETab; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.openJavaPerspectiveViaMenu; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.openSourceTab; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.pressWorkspaceErrorDialogProceedButton; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.setBuildCmdPathInPreferences; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.unsetBuildCmdPathInPreferences; +import static org.junit.jupiter.api.Assertions.assertEquals; +import java.io.BufferedReader; import java.io.File; -import java.io.IOException; +import java.io.InputStreamReader; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.TimeUnit; -import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import io.openliberty.tools.eclipse.CommandBuilder; -import io.openliberty.tools.eclipse.CommandBuilder.CommandNotFoundException; -import io.openliberty.tools.eclipse.test.it.utils.DisabledOnMac; import io.openliberty.tools.eclipse.test.it.utils.LibertyPluginTestUtils; import io.openliberty.tools.eclipse.ui.dashboard.DashboardView; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher; @@ -103,7 +81,7 @@ public class LibertyPluginSWTBotMavenTest extends AbstractLibertyPluginSWTBotTes /** * Shared lib jar project name. */ - static final String MVN_SHARED_LIB_NAME = "test-shared-lib-jar"; + static final String MVN_SHARED_LIB_NAME = "shared-lib"; /** * Test app relative path. @@ -155,6 +133,8 @@ public class LibertyPluginSWTBotMavenTest extends AbstractLibertyPluginSWTBotTes /** * Setup. + * + * @throws Exception */ @BeforeAll public static void setup() throws Exception { @@ -168,14 +148,26 @@ public static void setup() throws Exception { projectPaths.add(sharedLibProjectPath.toString()); // Maybe redundant but we really want to cleanup. We really want to - // avoid wasting time debugging tricky differences in behavior because of a dirty re-run + // avoid wasting time debugging tricky sdifferences in behavior because of a dirty re-run for (String p : projectPaths) { cleanupProject(p); } importMavenProjects(workspaceRoot, projectPaths); - // set the preferences + // Build shared lib project + Process process = new ProcessBuilder("mvn", "clean", "install").directory(sharedLibProjectPath.toFile()).start(); + BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); + + String line; + while ((line = reader.readLine()) != null) { + System.out.println(line); + } + + int exitCode = process.waitFor(); + assertEquals(0, exitCode, "Building of shared lib jar project failed with RC " + exitCode); + + // Set the preferences setBuildCmdPathInPreferences(bot, "Maven"); LibertyPluginTestUtils.validateLibertyToolsPreferencesSet(); @@ -296,630 +288,646 @@ public static final void validateBeforeTestRun() { } } - /** - * Tests the start with parameters menu action on a dashboard listed application. - */ - @Test - public void testLibertyConfigurationTabsExist() { - - Shell configShell = launchRunConfigurationsDialogFromAppRunAs(MVN_APP_NAME); - - try { - TreeItem libertyConfigTree = getLibertyTreeItemNoBot(configShell); - context(libertyConfigTree, "New Configuration"); - - Assertions.assertTrue(bot.cTabItem("Start").isVisible(), "Liberty Start tab not visible."); - Assertions.assertTrue(bot.cTabItem("JRE").isVisible(), "Liberty JRE tab not visible."); - } finally { - go("Close", configShell); - } - } - - @Test - @DisabledOnMac - public void testMavenCommandAssembly() throws IOException, InterruptedException, CommandNotFoundException { - - IProject iProject = LibertyPluginTestUtils.getProject(MVN_APP_NAME); - String projPath = iProject.getLocation().toOSString(); - - String localMvnCmd = LibertyPluginTestUtils.onWindows() ? "mvn.cmd" : "mvn"; - String opaqueMvnCmd = CommandBuilder.getMavenCommandLine(projPath, "io.openliberty.tools:liberty-maven-plugin:dev -f " + projPath, - System.getenv("PATH"), true); - Assertions.assertTrue(opaqueMvnCmd.contains(localMvnCmd + " io.openliberty.tools:liberty-maven-plugin:dev"), - "Expected cmd to contain 'mvn io.openliberty.tools...' but cmd = " + opaqueMvnCmd); - } - - @Test - public void testMavenWrapperCommandAssembly() throws IOException, InterruptedException, CommandNotFoundException { - IProject iProject = LibertyPluginTestUtils.getProject(MVN_WRAPPER_APP_NAME); - String projPath = iProject.getLocation().toOSString(); - - String opaqueMvnwCmd = CommandBuilder.getMavenCommandLine(projPath, "io.openliberty.tools:liberty-maven-plugin:dev -f " + projPath, - System.getenv("PATH"), true); - Assertions.assertTrue(opaqueMvnwCmd.contains("mvnw"), "Expected cmd to contain 'mvnw' but cmd = " + opaqueMvnwCmd); - } - - /** - * Tests the start menu action on a dashboard listed application. - */ - @Test - public void testDashboardStartActionWithWrapper() { - - // Start dev mode. - launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_START); - - goGlobal("Terminal"); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_WRAPPER_APP_NAME, true, - wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); - - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); - - // Stop dev mode. - launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); - } - - /** - * Tests the start menu action on a dashboard listed application. - */ - @Test - public void testDashboardStartAction() { - // Start dev mode. - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START); - goGlobal("Terminal"); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); - - // Stop dev mode. - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); - } - - /** - * Tests stop of a server started outside of the current Liberty Tools Eclipse session - * - * @throws CommandNotFoundException - * @throws IOException - * @throws InterruptedException - */ - @Test - public void testDashboardStopExternalServer() throws CommandNotFoundException, IOException, InterruptedException { - - Path projAbsolutePath = wrapperProjectPath.toAbsolutePath(); - - // Doing a 'clean' first in case server was started previously and terminated abruptly. App tests may fail, - // making it look like an "outer", actual test is failing, so we skip the tests. - String cmd = CommandBuilder.getMavenCommandLine(projAbsolutePath.toString(), - "clean io.openliberty.tools:liberty-maven-plugin:dev -DskipITs=true", null, false); - String[] cmdParts = cmd.split(" "); - ProcessBuilder pb = new ProcessBuilder(cmdParts).inheritIO().directory(projAbsolutePath.toFile()).redirectErrorStream(true); - pb.environment().put("JAVA_HOME", JavaRuntime.getDefaultVMInstall().getInstallLocation().getAbsolutePath()); - - Process p = pb.start(); - p.waitFor(3, TimeUnit.SECONDS); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_WRAPPER_APP_NAME, true, - wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); - - // Stop dev mode. - launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); - - bot.button("Yes").click(); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); - } - - /** - * Tests the start menu action on a dashboard listed application. - */ - @Test - public void testDashboardDebugAction() { - // Start dev mode. - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_DEBUG); - goGlobal("Terminal"); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); - - // Stop dev mode. - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); - } - - /** - * Tests the start with parameters menu action on a dashboard listed application. - */ - @Test - public void testDashboardStartWithCustomConfigAction() { - - // Delete any previously created configs. - deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); - - // Delete the test report files before we start this test. - Path pathToITReport = Paths.get(projectPath.toString(), "target", "site", "failsafe-report.html"); - boolean testReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); - Assertions.assertTrue(testReportDeleted, () -> "File: " + pathToITReport + " was not be deleted."); - - launchCustomRunFromDashboard(MVN_APP_NAME, "-DhotTests=true"); - - goGlobal("Terminal"); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); - - try { - // Validate that the test reports were generated. - LibertyPluginTestUtils.validateTestReportExists(pathToITReport); - } finally { - // Stop dev mode. - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); - } - } - - /** - * Tests the start with parameters menu action on a dashboard listed application. - */ - @Test - public void testDashboardDebugWithCustomConfigAction() { - - // Delete any previously created configs. - deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); - - // Delete the test report files before we start this test. - Path pathToITReport = Paths.get(projectPath.toString(), "target", "site", "failsafe-report.html"); - boolean testReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); - Assertions.assertTrue(testReportDeleted, () -> "File: " + pathToITReport + " was not be deleted."); - - launchCustomDebugFromDashboard(MVN_APP_NAME, "-DhotTests=true"); - - goGlobal("Terminal"); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); - - try { - // Validate that the test reports were generated. - LibertyPluginTestUtils.validateTestReportExists(pathToITReport); - } catch (Exception e) { - System.out.println("Caught exception: " + e); - throw new RuntimeException(e); - } finally { - // Stop dev mode. - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); - } - } - - /** - * Tests the start, run tests, view test report, and stop dashboard actions. - */ - @Test - public void testDashboardActions() { - - // Delete the test report files before we start this test. - Path pathToITReport = Paths.get(projectPath.toString(), "target", "site", "failsafe-report.html"); - boolean itReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); - Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport + " was not be deleted."); - - Path pathToUTReport = Paths.get(projectPath.toString(), "target", "site", "surefire-report.html"); - boolean utReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); - Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToITReport + " was not be deleted."); - - // Start dev mode. - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START); - goGlobal("Terminal"); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); - - try { - // Run Tests. - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_RUN_TESTS); - - // Validate that the reports were generated and the the browser editor was launched. - LibertyPluginTestUtils.validateTestReportExists(pathToITReport); - if (LibertyPluginTestUtils.isInternalBrowserSupportAvailable()) { - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_VIEW_MVN_IT_REPORT); - } - - LibertyPluginTestUtils.validateTestReportExists(pathToUTReport); - if (LibertyPluginTestUtils.isInternalBrowserSupportAvailable()) { - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_VIEW_MVN_UT_REPORT); - } - } finally { - // Stop dev mode. - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); - } - } - - /** - * Tests the start action initiated through: project -> Run As -> Run Configurations -> Liberty -> New configuration (default) -> - * Run. - */ - @Test - public void testStartWithDefaultRunAsConfig() { - - deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); - - // Start dev mode. - launchStartWithDefaultRunConfigFromAppRunAs(MVN_APP_NAME); - - goGlobal("Terminal"); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); - - // Stop dev mode. - launchStopWithRunAsShortcut(MVN_APP_NAME); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); - } - - /** - * Tests the start action initiated through: project -> Run As -> Run Configurations -> Liberty -> New configuration (customized) - * -> Run. - */ - @Test - public void testStartWithCustomRunAsConfig() { - // Delete any previously created configs. - deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); - - // Delete the test report files before we start this test. - Path pathToITReport = Paths.get(projectPath.toString(), "target", "site", "failsafe-report.html"); - boolean testReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); - Assertions.assertTrue(testReportDeleted, () -> "File: " + pathToITReport + " was not be deleted."); - - // Start dev mode with parms. - launchStartWithNewCustomRunConfig(MVN_APP_NAME, "-DhotTests=true"); - goGlobal("Terminal"); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty"); - - try { - // Validate that the test reports were generated. - LibertyPluginTestUtils.validateTestReportExists(pathToITReport); - } finally { - // Stop dev mode. - launchStopWithRunAsShortcut(MVN_APP_NAME); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); - } - } - - /** - * Tests the start, run tests, view IT report, view UT report, and stop run as shortcut actions. - */ - @Test - public void testRunAsShortcutActions() { - - // Delete any previously created configs. - deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); - - // Delete the test report files before we start this test. - Path pathToITReport = Paths.get(projectPath.toString(), "target", "site", "failsafe-report.html"); - boolean itReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); - Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport + " was not be deleted."); - - Path pathToUTReport = Paths.get(projectPath.toString(), "target", "site", "surefire-report.html"); - boolean utReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); - Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToITReport + " was not be deleted."); - - // Start dev mode. - launchStartWithRunAsShortcut(MVN_APP_NAME); - goGlobal("Terminal"); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); - - try { - // Run Tests. - launchRunTestsWithRunAsShortcut(MVN_APP_NAME); - - // Validate that the reports were generated and the the browser editor was launched. - LibertyPluginTestUtils.validateTestReportExists(pathToITReport); - if (LibertyPluginTestUtils.isInternalBrowserSupportAvailable()) { - launchViewITReportWithRunDebugAsShortcut(bot, MVN_APP_NAME); - } - - LibertyPluginTestUtils.validateTestReportExists(pathToUTReport); - if (LibertyPluginTestUtils.isInternalBrowserSupportAvailable()) { - launchViewUTReportWithRunDebugAsShortcut(bot, MVN_APP_NAME); - } - } finally { - // Stop dev mode. - launchStopWithRunAsShortcut(MVN_APP_NAME); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); - } - } - - /** - * Tests the start action initiated through: project -> Debug As -> Debug Configurations -> Liberty -> New configuration - * (customized) -> Run. - */ - @Test - public void testStartWithCustomDebugAsConfig() { - - deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); - - // Delete the test report files before we start this test. - Path pathToITReport = Paths.get(projectPath.toString(), "target", "site", "failsafe-report.html"); - boolean testReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); - Assertions.assertTrue(testReportDeleted, () -> "File: " + pathToITReport + " was not be deleted."); - - // Start dev mode with parms. - launchStartWithNewCustomDebugConfig(MVN_APP_NAME, "-DhotTests=true"); - goGlobal("Terminal"); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); - - try { - // Validate that the test reports were generated. - LibertyPluginTestUtils.validateTestReportExists(pathToITReport); - - // Validate that a remote java application configuration was created and is named after the application. - validateRemoteJavaAppCreation(MVN_APP_NAME); - } catch (Exception e) { - System.out.println("Caught exception: " + e); - throw new RuntimeException(e); - } finally { - - openJavaPerspectiveViaMenu(); - - // Stop dev mode using the Run As stop command. - launchStopWithRunAsShortcut(MVN_APP_NAME); - // terminal.show(); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // Close the terminal. - // terminal.close(); - } - } - - /** - * Tests the start/stop debug as shortcut actions. - */ - @Test - public void testStartWithDebugAsShortcut() { - - // Delete any previously created configs. - deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); - - // Start dev mode. - launchStartWithDebugAsShortcut(MVN_APP_NAME); - - goGlobal("Terminal"); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); - - // Validate that a remote java application configuration was created and is named after the application. - validateRemoteJavaAppCreation(MVN_APP_NAME); - - // Switch back to Java so we can find Pkg Explorer - openJavaPerspectiveViaMenu(); - - // Stop dev mode using the Run As stop command. - launchStopWithRunAsShortcut(MVN_APP_NAME); - - // terminal.show(); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // Close the terminal. - // terminal.close(); - } - - @Test - @Disabled - public void testStartWithNoWrapperAndNoPreferencesSet() { - - // verify no wrapper present - String localMvnwCmd = LibertyPluginTestUtils.onWindows() ? "mvnw.cmd" : "mvnw"; - String absoluteMvnwCmd = projectPath.toAbsolutePath().toString() + localMvnwCmd; - LibertyPluginTestUtils.validateWrapperInProject(false, absoluteMvnwCmd); - - // Start dev mode. - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START); - - // Validate application is not up and not running. - LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); - } - - @Test - @DisabledOnMac - public void testStartWithWrapperAndNoPreferencesSet() { - - unsetBuildCmdPathInPreferences(bot, "Maven"); - - // verify wrapper present - String localMvnwCmd = LibertyPluginTestUtils.onWindows() ? "mvnw.cmd" : "mvnw"; - String absoluteMvnwCmd = wrapperProjectPath + File.separator + localMvnwCmd; - LibertyPluginTestUtils.validateWrapperInProject(true, absoluteMvnwCmd); - - // Start dev mode. - launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_START); - SWTBotView terminal = bot.viewByTitle("Terminal"); - terminal.show(); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_WRAPPER_APP_NAME, true, - wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); - - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); - - // Stop dev mode. - launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); - terminal.show(); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); - - // Close the terminal. - terminal.close(); - - setBuildCmdPathInPreferences(bot, "Maven"); - } - - @Test - @DisabledOnMac - public void testStartWithNoWrapperAndPreferencesSet() { - - // verify no wrapper present - String localMvnwCmd = LibertyPluginTestUtils.onWindows() ? "mvnw.cmd" : "mvnw"; - String absoluteMvnwCmd = projectPath.toAbsolutePath().toString() + localMvnwCmd; - LibertyPluginTestUtils.validateWrapperInProject(false, absoluteMvnwCmd); - - // Start dev mode. - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START); - SWTBotView terminal = bot.viewByTitle("Terminal"); - terminal.show(); - - // Validate application is up and running. - LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); - - // Stop dev mode. - launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); - terminal.show(); - - // Validate application stopped. - LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); - - // Close the terminal. - terminal.close(); - } - - /** - * Tests that the default JRE set in the project's java build path matches what is marked as default in the Liberty Tools - * configuration JRE tab. - */ - @Test - public void testDefaultJRECompliance() { - // Delete any previously created configs. - deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); - - Shell configShell = launchRunConfigurationsDialogFromAppRunAs(MVN_APP_NAME); - try { - TreeItem libertyConfigTree = getLibertyTreeItemNoBot(configShell); - - context(libertyConfigTree, "New Configuration"); - openJRETab(bot); - String buildPathJRE = LibertyPluginTestUtils.getJREFromBuildpath(projectPath.toString()); - - Assertions.assertTrue(buildPathJRE != null, - () -> "Unable to find the JRE configured in the project's build path (.classpath)."); - - SWTBotCombo comboJREBox = getComboTextBoxWithTextPrefix(bot, buildPathJRE); - - Assertions.assertTrue(comboJREBox != null, - () -> "The java installation shown on the Liberty run configurations JRE tab does not contain the Java installation configured on project's the build path (claspath):" - + buildPathJRE); - Assertions.assertTrue(comboJREBox.isEnabled(), - () -> "The JRE tab box showing Java installation \" + buildPathJRE + \" is not selected."); - } finally { - go("Apply", configShell); - go("Close", configShell); - } - } - - /** - * Tests that a non-Liberty project can be manually be categorized to be Liberty project. This test also tests the refresh - * function. - * - * @throws Exception - */ - @Test - public void testAddingProjectToDashboardManually() throws Exception { - - IProject iProject = LibertyPluginTestUtils.getProject(NON_DFLT_NAME); - String projectName = iProject.getName(); - - // Make sure the application is no longer listed in the dashboard. - List projectList = getDashboardContent(); - boolean mavenAppFound = false; - for (String project : projectList) { - if (NON_DFLT_NAME.equals(project)) { - mavenAppFound = true; - break; - } - } - - Assertions.assertTrue(!mavenAppFound, () -> "Project " + projectName + " should not be listed in the dashboard."); - - // Add the project nature manually. - enableLibertyTools(NON_DFLT_NAME); - - // Make sure the application is listed in the dashboard. - List newProjectList = getDashboardContent(); - boolean newMavenAppFound = false; - for (String project : newProjectList) { - if (NON_DFLT_NAME.equals(project)) { - newMavenAppFound = true; - break; - } - } - - Assertions.assertTrue(newMavenAppFound, () -> "The Maven project should be listed in the dashboard."); - } + // /** + // * Tests the start with parameters menu action on a dashboard listed application. + // */ + // @Test + // public void testLibertyConfigurationTabsExist() { + // + // Shell configShell = launchRunConfigurationsDialogFromAppRunAs(MVN_APP_NAME); + // + // try { + // TreeItem libertyConfigTree = getLibertyTreeItemNoBot(configShell); + // context(libertyConfigTree, "New Configuration"); + // + // Assertions.assertTrue(bot.cTabItem("Start").isVisible(), "Liberty Start tab not visible."); + // Assertions.assertTrue(bot.cTabItem("JRE").isVisible(), "Liberty JRE tab not visible."); + // } finally { + // go("Close", configShell); + // } + // } + // + // @Test + // @DisabledOnMac + // public void testMavenCommandAssembly() throws IOException, InterruptedException, CommandNotFoundException { + // + // IProject iProject = LibertyPluginTestUtils.getProject(MVN_APP_NAME); + // String projPath = iProject.getLocation().toOSString(); + // + // String localMvnCmd = LibertyPluginTestUtils.onWindows() ? "mvn.cmd" : "mvn"; + // String opaqueMvnCmd = CommandBuilder.getMavenCommandLine(projPath, "io.openliberty.tools:liberty-maven-plugin:dev -f " + + // projPath, + // System.getenv("PATH"), true); + // Assertions.assertTrue(opaqueMvnCmd.contains(localMvnCmd + " io.openliberty.tools:liberty-maven-plugin:dev"), + // "Expected cmd to contain 'mvn io.openliberty.tools...' but cmd = " + opaqueMvnCmd); + // } + // + // @Test + // public void testMavenWrapperCommandAssembly() throws IOException, InterruptedException, CommandNotFoundException { + // IProject iProject = LibertyPluginTestUtils.getProject(MVN_WRAPPER_APP_NAME); + // String projPath = iProject.getLocation().toOSString(); + // + // String opaqueMvnwCmd = CommandBuilder.getMavenCommandLine(projPath, "io.openliberty.tools:liberty-maven-plugin:dev -f " + + // projPath, + // System.getenv("PATH"), true); + // Assertions.assertTrue(opaqueMvnwCmd.contains("mvnw"), "Expected cmd to contain 'mvnw' but cmd = " + opaqueMvnwCmd); + // } + // + // /** + // * Tests the start menu action on a dashboard listed application. + // */ + // @Test + // public void testDashboardStartActionWithWrapper() { + // + // // Start dev mode. + // launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_START); + // + // goGlobal("Terminal"); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_WRAPPER_APP_NAME, true, + // wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); + // + // // If there are issues with the workspace, close the error dialog. + // pressWorkspaceErrorDialogProceedButton(bot); + // + // // Stop dev mode. + // launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); + // } + // + // /** + // * Tests the start menu action on a dashboard listed application. + // */ + // @Test + // public void testDashboardStartAction() { + // // Start dev mode. + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START); + // goGlobal("Terminal"); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + + // "/target/liberty"); + // + // // If there are issues with the workspace, close the error dialog. + // pressWorkspaceErrorDialogProceedButton(bot); + // + // // Stop dev mode. + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); + // } + // + // /** + // * Tests stop of a server started outside of the current Liberty Tools Eclipse session + // * + // * @throws CommandNotFoundException + // * @throws IOException + // * @throws InterruptedException + // */ + // @Test + // public void testDashboardStopExternalServer() throws CommandNotFoundException, IOException, InterruptedException { + // + // Path projAbsolutePath = wrapperProjectPath.toAbsolutePath(); + // + // // Doing a 'clean' first in case server was started previously and terminated abruptly. App tests may fail, + // // making it look like an "outer", actual test is failing, so we skip the tests. + // String cmd = CommandBuilder.getMavenCommandLine(projAbsolutePath.toString(), + // "clean io.openliberty.tools:liberty-maven-plugin:dev -DskipITs=true", null, false); + // String[] cmdParts = cmd.split(" "); + // ProcessBuilder pb = new ProcessBuilder(cmdParts).inheritIO().directory(projAbsolutePath.toFile()).redirectErrorStream(true); + // pb.environment().put("JAVA_HOME", JavaRuntime.getDefaultVMInstall().getInstallLocation().getAbsolutePath()); + // + // Process p = pb.start(); + // p.waitFor(3, TimeUnit.SECONDS); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_WRAPPER_APP_NAME, true, + // wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); + // + // // Stop dev mode. + // launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); + // + // bot.button("Yes").click(); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); + // } + // + // /** + // * Tests the start menu action on a dashboard listed application. + // */ + // @Test + // public void testDashboardDebugAction() { + // // Start dev mode. + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_DEBUG); + // goGlobal("Terminal"); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + + // "/target/liberty"); + // + // // If there are issues with the workspace, close the error dialog. + // pressWorkspaceErrorDialogProceedButton(bot); + // + // // Stop dev mode. + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); + // } + // + // /** + // * Tests the start with parameters menu action on a dashboard listed application. + // */ + // @Test + // public void testDashboardStartWithCustomConfigAction() { + // + // // Delete any previously created configs. + // deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); + // + // // Delete the test report files before we start this test. + // Path pathToITReport = Paths.get(projectPath.toString(), "target", "site", "failsafe-report.html"); + // boolean testReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); + // Assertions.assertTrue(testReportDeleted, () -> "File: " + pathToITReport + " was not be deleted."); + // + // launchCustomRunFromDashboard(MVN_APP_NAME, "-DhotTests=true"); + // + // goGlobal("Terminal"); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + + // "/target/liberty"); + // + // // If there are issues with the workspace, close the error dialog. + // pressWorkspaceErrorDialogProceedButton(bot); + // + // try { + // // Validate that the test reports were generated. + // LibertyPluginTestUtils.validateTestReportExists(pathToITReport); + // } finally { + // // Stop dev mode. + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); + // } + // } + // + // /** + // * Tests the start with parameters menu action on a dashboard listed application. + // */ + // @Test + // public void testDashboardDebugWithCustomConfigAction() { + // + // // Delete any previously created configs. + // deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); + // + // // Delete the test report files before we start this test. + // Path pathToITReport = Paths.get(projectPath.toString(), "target", "site", "failsafe-report.html"); + // boolean testReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); + // Assertions.assertTrue(testReportDeleted, () -> "File: " + pathToITReport + " was not be deleted."); + // + // launchCustomDebugFromDashboard(MVN_APP_NAME, "-DhotTests=true"); + // + // goGlobal("Terminal"); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + + // "/target/liberty"); + // + // // If there are issues with the workspace, close the error dialog. + // pressWorkspaceErrorDialogProceedButton(bot); + // + // try { + // // Validate that the test reports were generated. + // LibertyPluginTestUtils.validateTestReportExists(pathToITReport); + // } catch (Exception e) { + // System.out.println("Caught exception: " + e); + // throw new RuntimeException(e); + // } finally { + // // Stop dev mode. + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); + // } + // } + // + // /** + // * Tests the start, run tests, view test report, and stop dashboard actions. + // */ + // @Test + // public void testDashboardActions() { + // + // // Delete the test report files before we start this test. + // Path pathToITReport = Paths.get(projectPath.toString(), "target", "site", "failsafe-report.html"); + // boolean itReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); + // Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport + " was not be deleted."); + // + // Path pathToUTReport = Paths.get(projectPath.toString(), "target", "site", "surefire-report.html"); + // boolean utReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); + // Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToITReport + " was not be deleted."); + // + // // Start dev mode. + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START); + // goGlobal("Terminal"); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + + // "/target/liberty"); + // + // // If there are issues with the workspace, close the error dialog. + // pressWorkspaceErrorDialogProceedButton(bot); + // + // try { + // // Run Tests. + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_RUN_TESTS); + // + // // Validate that the reports were generated and the the browser editor was launched. + // LibertyPluginTestUtils.validateTestReportExists(pathToITReport); + // if (LibertyPluginTestUtils.isInternalBrowserSupportAvailable()) { + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_VIEW_MVN_IT_REPORT); + // } + // + // LibertyPluginTestUtils.validateTestReportExists(pathToUTReport); + // if (LibertyPluginTestUtils.isInternalBrowserSupportAvailable()) { + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_VIEW_MVN_UT_REPORT); + // } + // } finally { + // // Stop dev mode. + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); + // } + // } + // + // /** + // * Tests the start action initiated through: project -> Run As -> Run Configurations -> Liberty -> New configuration (default) + // -> + // * Run. + // */ + // @Test + // public void testStartWithDefaultRunAsConfig() { + // + // deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); + // + // // Start dev mode. + // launchStartWithDefaultRunConfigFromAppRunAs(MVN_APP_NAME); + // + // goGlobal("Terminal"); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + + // "/target/liberty"); + // + // // If there are issues with the workspace, close the error dialog. + // pressWorkspaceErrorDialogProceedButton(bot); + // + // // Stop dev mode. + // launchStopWithRunAsShortcut(MVN_APP_NAME); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); + // } + // + // /** + // * Tests the start action initiated through: project -> Run As -> Run Configurations -> Liberty -> New configuration + // (customized) + // * -> Run. + // */ + // @Test + // public void testStartWithCustomRunAsConfig() { + // // Delete any previously created configs. + // deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); + // + // // Delete the test report files before we start this test. + // Path pathToITReport = Paths.get(projectPath.toString(), "target", "site", "failsafe-report.html"); + // boolean testReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); + // Assertions.assertTrue(testReportDeleted, () -> "File: " + pathToITReport + " was not be deleted."); + // + // // Start dev mode with parms. + // launchStartWithNewCustomRunConfig(MVN_APP_NAME, "-DhotTests=true"); + // goGlobal("Terminal"); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + + // "/target/liberty"); + // + // try { + // // Validate that the test reports were generated. + // LibertyPluginTestUtils.validateTestReportExists(pathToITReport); + // } finally { + // // Stop dev mode. + // launchStopWithRunAsShortcut(MVN_APP_NAME); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); + // } + // } + // + // /** + // * Tests the start, run tests, view IT report, view UT report, and stop run as shortcut actions. + // */ + // @Test + // public void testRunAsShortcutActions() { + // + // // Delete any previously created configs. + // deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); + // + // // Delete the test report files before we start this test. + // Path pathToITReport = Paths.get(projectPath.toString(), "target", "site", "failsafe-report.html"); + // boolean itReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); + // Assertions.assertTrue(itReportDeleted, () -> "Test report file: " + pathToITReport + " was not be deleted."); + // + // Path pathToUTReport = Paths.get(projectPath.toString(), "target", "site", "surefire-report.html"); + // boolean utReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); + // Assertions.assertTrue(utReportDeleted, () -> "Test report file: " + pathToITReport + " was not be deleted."); + // + // // Start dev mode. + // launchStartWithRunAsShortcut(MVN_APP_NAME); + // goGlobal("Terminal"); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + + // "/target/liberty"); + // + // // If there are issues with the workspace, close the error dialog. + // pressWorkspaceErrorDialogProceedButton(bot); + // + // try { + // // Run Tests. + // launchRunTestsWithRunAsShortcut(MVN_APP_NAME); + // + // // Validate that the reports were generated and the the browser editor was launched. + // LibertyPluginTestUtils.validateTestReportExists(pathToITReport); + // if (LibertyPluginTestUtils.isInternalBrowserSupportAvailable()) { + // launchViewITReportWithRunDebugAsShortcut(bot, MVN_APP_NAME); + // } + // + // LibertyPluginTestUtils.validateTestReportExists(pathToUTReport); + // if (LibertyPluginTestUtils.isInternalBrowserSupportAvailable()) { + // launchViewUTReportWithRunDebugAsShortcut(bot, MVN_APP_NAME); + // } + // } finally { + // // Stop dev mode. + // launchStopWithRunAsShortcut(MVN_APP_NAME); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); + // } + // } + // + // /** + // * Tests the start action initiated through: project -> Debug As -> Debug Configurations -> Liberty -> New configuration + // * (customized) -> Run. + // */ + // @Test + // public void testStartWithCustomDebugAsConfig() { + // + // deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); + // + // // Delete the test report files before we start this test. + // Path pathToITReport = Paths.get(projectPath.toString(), "target", "site", "failsafe-report.html"); + // boolean testReportDeleted = LibertyPluginTestUtils.deleteFile(pathToITReport.toFile()); + // Assertions.assertTrue(testReportDeleted, () -> "File: " + pathToITReport + " was not be deleted."); + // + // // Start dev mode with parms. + // launchStartWithNewCustomDebugConfig(MVN_APP_NAME, "-DhotTests=true"); + // goGlobal("Terminal"); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + + // "/target/liberty"); + // + // // If there are issues with the workspace, close the error dialog. + // pressWorkspaceErrorDialogProceedButton(bot); + // + // try { + // // Validate that the test reports were generated. + // LibertyPluginTestUtils.validateTestReportExists(pathToITReport); + // + // // Validate that a remote java application configuration was created and is named after the application. + // validateRemoteJavaAppCreation(MVN_APP_NAME); + // } catch (Exception e) { + // System.out.println("Caught exception: " + e); + // throw new RuntimeException(e); + // } finally { + // + // openJavaPerspectiveViaMenu(); + // + // // Stop dev mode using the Run As stop command. + // launchStopWithRunAsShortcut(MVN_APP_NAME); + // // terminal.show(); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); + // + // // Close the terminal. + // // terminal.close(); + // } + // } + // + // /** + // * Tests the start/stop debug as shortcut actions. + // */ + // @Test + // public void testStartWithDebugAsShortcut() { + // + // // Delete any previously created configs. + // deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); + // + // // Start dev mode. + // launchStartWithDebugAsShortcut(MVN_APP_NAME); + // + // goGlobal("Terminal"); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + + // "/target/liberty"); + // + // // If there are issues with the workspace, close the error dialog. + // pressWorkspaceErrorDialogProceedButton(bot); + // + // // Validate that a remote java application configuration was created and is named after the application. + // validateRemoteJavaAppCreation(MVN_APP_NAME); + // + // // Switch back to Java so we can find Pkg Explorer + // openJavaPerspectiveViaMenu(); + // + // // Stop dev mode using the Run As stop command. + // launchStopWithRunAsShortcut(MVN_APP_NAME); + // + // // terminal.show(); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); + // + // // Close the terminal. + // // terminal.close(); + // } + // + // @Test + // @Disabled + // public void testStartWithNoWrapperAndNoPreferencesSet() { + // + // // verify no wrapper present + // String localMvnwCmd = LibertyPluginTestUtils.onWindows() ? "mvnw.cmd" : "mvnw"; + // String absoluteMvnwCmd = projectPath.toAbsolutePath().toString() + localMvnwCmd; + // LibertyPluginTestUtils.validateWrapperInProject(false, absoluteMvnwCmd); + // + // // Start dev mode. + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START); + // + // // Validate application is not up and not running. + // LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); + // } + // + // @Test + // @DisabledOnMac + // public void testStartWithWrapperAndNoPreferencesSet() { + // + // unsetBuildCmdPathInPreferences(bot, "Maven"); + // + // // verify wrapper present + // String localMvnwCmd = LibertyPluginTestUtils.onWindows() ? "mvnw.cmd" : "mvnw"; + // String absoluteMvnwCmd = wrapperProjectPath + File.separator + localMvnwCmd; + // LibertyPluginTestUtils.validateWrapperInProject(true, absoluteMvnwCmd); + // + // // Start dev mode. + // launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_START); + // SWTBotView terminal = bot.viewByTitle("Terminal"); + // terminal.show(); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_WRAPPER_APP_NAME, true, + // wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); + // + // // If there are issues with the workspace, close the error dialog. + // pressWorkspaceErrorDialogProceedButton(bot); + // + // // Stop dev mode. + // launchDashboardAction(MVN_WRAPPER_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); + // terminal.show(); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(wrapperProjectPath.toAbsolutePath().toString() + "/target/liberty"); + // + // // Close the terminal. + // terminal.close(); + // + // setBuildCmdPathInPreferences(bot, "Maven"); + // } + // + // @Test + // @DisabledOnMac + // public void testStartWithNoWrapperAndPreferencesSet() { + // + // // verify no wrapper present + // String localMvnwCmd = LibertyPluginTestUtils.onWindows() ? "mvnw.cmd" : "mvnw"; + // String absoluteMvnwCmd = projectPath.toAbsolutePath().toString() + localMvnwCmd; + // LibertyPluginTestUtils.validateWrapperInProject(false, absoluteMvnwCmd); + // + // // Start dev mode. + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START); + // SWTBotView terminal = bot.viewByTitle("Terminal"); + // terminal.show(); + // + // // Validate application is up and running. + // LibertyPluginTestUtils.validateApplicationOutcome(MVN_APP_NAME, true, projectPath.toAbsolutePath().toString() + + // "/target/liberty"); + // + // // If there are issues with the workspace, close the error dialog. + // pressWorkspaceErrorDialogProceedButton(bot); + // + // // Stop dev mode. + // launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_STOP); + // terminal.show(); + // + // // Validate application stopped. + // LibertyPluginTestUtils.validateLibertyServerStopped(projectPath.toAbsolutePath().toString() + "/target/liberty"); + // + // // Close the terminal. + // terminal.close(); + // } + // + // /** + // * Tests that the default JRE set in the project's java build path matches what is marked as default in the Liberty Tools + // * configuration JRE tab. + // */ + // @Test + // public void testDefaultJRECompliance() { + // // Delete any previously created configs. + // deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); + // + // Shell configShell = launchRunConfigurationsDialogFromAppRunAs(MVN_APP_NAME); + // try { + // TreeItem libertyConfigTree = getLibertyTreeItemNoBot(configShell); + // + // context(libertyConfigTree, "New Configuration"); + // openJRETab(bot); + // String buildPathJRE = LibertyPluginTestUtils.getJREFromBuildpath(projectPath.toString()); + // + // Assertions.assertTrue(buildPathJRE != null, + // () -> "Unable to find the JRE configured in the project's build path (.classpath)."); + // + // SWTBotCombo comboJREBox = getComboTextBoxWithTextPrefix(bot, buildPathJRE); + // + // Assertions.assertTrue(comboJREBox != null, + // () -> "The java installation shown on the Liberty run configurations JRE tab does not contain the Java installation configured + // on project's the build path (claspath):" + // + buildPathJRE); + // Assertions.assertTrue(comboJREBox.isEnabled(), + // () -> "The JRE tab box showing Java installation \" + buildPathJRE + \" is not selected."); + // } finally { + // go("Apply", configShell); + // go("Close", configShell); + // } + // } + // + // /** + // * Tests that a non-Liberty project can be manually be categorized to be Liberty project. This test also tests the refresh + // * function. + // * + // * @throws Exception + // */ + // @Test + // public void testAddingProjectToDashboardManually() throws Exception { + // + // IProject iProject = LibertyPluginTestUtils.getProject(NON_DFLT_NAME); + // String projectName = iProject.getName(); + // + // // Make sure the application is no longer listed in the dashboard. + // List projectList = getDashboardContent(); + // boolean mavenAppFound = false; + // for (String project : projectList) { + // if (NON_DFLT_NAME.equals(project)) { + // mavenAppFound = true; + // break; + // } + // } + // + // Assertions.assertTrue(!mavenAppFound, () -> "Project " + projectName + " should not be listed in the dashboard."); + // + // // Add the project nature manually. + // enableLibertyTools(NON_DFLT_NAME); + // + // // Make sure the application is listed in the dashboard. + // List newProjectList = getDashboardContent(); + // boolean newMavenAppFound = false; + // for (String project : newProjectList) { + // if (NON_DFLT_NAME.equals(project)) { + // newMavenAppFound = true; + // break; + // } + // } + // + // Assertions.assertTrue(newMavenAppFound, () -> "The Maven project should be listed in the dashboard."); + // } /** * Tests that the correct launch configuration is chosen depending on "start" vs "start in container" @@ -968,6 +976,8 @@ public void testLaunchConfigurationMatching() { @Test public void testDebugSourceLookupContent() { + deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); + Shell configShell = launchDebugConfigurationsDialogFromAppRunAs(MVN_APP_NAME); boolean jarEntryFound = false; diff --git a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/utils/SWTBotPluginOperations.java b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/utils/SWTBotPluginOperations.java index a591562f..7cfb03c0 100644 --- a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/utils/SWTBotPluginOperations.java +++ b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/utils/SWTBotPluginOperations.java @@ -29,6 +29,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; @@ -48,7 +49,6 @@ import org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory; import org.eclipse.swtbot.swt.finder.utils.SWTUtils; import org.eclipse.swtbot.swt.finder.widgets.SWTBotCTabItem; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox; import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; import org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu; @@ -560,10 +560,9 @@ public static void checkRunInContainerCheckBox(Shell shell, String runDebugConfi Object appConfigEntry = find(runDebugConfigName, libertyConfigTree, Option.factory().useContains(true).widgetClass(TreeItem.class).build()); go(appConfigEntry); - Object parmLabel = find("Run in container", appConfigEntry, Option.factory().widgetClass(Label.class).build()); + Object button = find("Run in Container", appConfigEntry, Option.factory().widgetClass(Button.class).build()); - Control checkBox = ControlFinder.findControlInRange(parmLabel, SWTBotCheckBox.class, Direction.WEST); - go(checkBox); + go(button); } public static Object getAppInPackageExplorerTree(String appName) {