diff --git a/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF b/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF index 0eac1691..1aecbac7 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF +++ b/bundles/io.openliberty.tools.eclipse.ui/META-INF/MANIFEST.MF @@ -7,12 +7,13 @@ Bundle-SymbolicName: io.openliberty.tools.eclipse.ui;singleton:=true Bundle-Version: 23.0.12.qualifier Bundle-Activator: io.openliberty.tools.eclipse.LibertyDevPlugin Export-Package: io.openliberty.tools.eclipse;x-friends:="io.openliberty.tools.eclipse.tests", + io.openliberty.tools.eclipse.debug;x-friends:="io.openliberty.tools.eclipse.tests", io.openliberty.tools.eclipse.ui.dashboard;x-friends:="io.openliberty.tools.eclipse.tests", io.openliberty.tools.eclipse.ui.launch;x-friends:="io.openliberty.tools.eclipse.tests", io.openliberty.tools.eclipse.ui.launch.shortcuts;x-friends:="io.openliberty.tools.eclipse.tests", io.openliberty.tools.eclipse.ui.preferences;x-friends:="io.openliberty.tools.eclipse.tests" Require-Bundle: org.eclipse.ui, - org.eclipse.equinox.preferences + org.eclipse.m2e.maven.runtime Bundle-RequiredExecutionEnvironment: JavaSE-17 Automatic-Module-Name: io.openliberty.tools.eclipse.ui Bundle-ActivationPolicy: lazy @@ -21,13 +22,22 @@ Import-Package: org.eclipse.core.commands, org.eclipse.core.resources, org.eclipse.core.runtime, org.eclipse.core.runtime.jobs, + org.eclipse.core.runtime.preferences, org.eclipse.debug.core, org.eclipse.debug.core.model, + org.eclipse.debug.core.sourcelookup, org.eclipse.debug.ui, + org.eclipse.debug.ui.sourcelookup, + org.eclipse.jdi, org.eclipse.jdt.core, + org.eclipse.jdt.debug.core, org.eclipse.jdt.debug.ui.launchConfigurations, org.eclipse.jdt.launching, + org.eclipse.jdt.launching.sourcelookup.containers, org.eclipse.jem.util.emf.workbench, + org.eclipse.m2e.core, + org.eclipse.m2e.core.embedder, + org.eclipse.m2e.core.project, org.eclipse.osgi.service.debug, org.eclipse.osgi.util, org.eclipse.swt.custom, @@ -40,7 +50,7 @@ Import-Package: org.eclipse.core.commands, org.eclipse.tm.terminal.view.ui.launcher, org.eclipse.tm.terminal.view.ui.manager, org.eclipse.tm.terminal.view.ui.tabs, - org.eclipse.ui, - org.eclipse.ui.handlers, - org.eclipse.ui.plugin, + org.gradle.tooling, + org.gradle.tooling.model, + org.gradle.tooling.model.eclipse, org.osgi.framework diff --git a/bundles/io.openliberty.tools.eclipse.ui/plugin.xml b/bundles/io.openliberty.tools.eclipse.ui/plugin.xml index 2447148c..c6cb7875 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/plugin.xml +++ b/bundles/io.openliberty.tools.eclipse.ui/plugin.xml @@ -373,6 +373,21 @@ + + + + + + + + + + @@ -380,7 +395,9 @@ name="Liberty" delegate="io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher" modes="run, debug" - id="io.openliberty.tools.eclipse.launch.type"> + id="io.openliberty.tools.eclipse.launch.type" + sourceLocatorId="io.openliberty.tools.eclipse.debug.libertySourceLookupDirector" + sourcePathComputerId="io.openliberty.tools.eclipse.debug.libertySourcePathComputer"> diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/CommandBuilder.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/CommandBuilder.java index fe9e14fb..2ecc603d 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/CommandBuilder.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/CommandBuilder.java @@ -15,7 +15,7 @@ import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; - +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.osgi.util.NLS; import io.openliberty.tools.eclipse.logging.Trace; diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java index 7ae81f7b..ff9b2a10 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DevModeOperations.java @@ -32,6 +32,7 @@ import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.jface.viewers.ISelection; @@ -46,6 +47,7 @@ import io.openliberty.tools.eclipse.CommandBuilder.CommandNotFoundException; import io.openliberty.tools.eclipse.Project.BuildType; +import io.openliberty.tools.eclipse.debug.DebugModeHandler; import io.openliberty.tools.eclipse.logging.Logger; import io.openliberty.tools.eclipse.logging.Trace; import io.openliberty.tools.eclipse.messages.Messages; @@ -151,7 +153,7 @@ public static DevModeOperations getInstance() { * @param javaHomePath The configuration java installation home to be set in the terminal running dev mode. * @param mode The configuration mode. */ - public void start(IProject iProject, String parms, String javaHomePath, String mode) { + public void start(IProject iProject, String parms, String javaHomePath, ILaunch launch, String mode) { if (Trace.isEnabled()) { Trace.getTracer().traceEntry(Trace.TRACE_TOOLS, new Object[] { iProject, parms, javaHomePath, mode }); @@ -232,13 +234,13 @@ public void start(IProject iProject, String parms, String javaHomePath, String m + "does not appear to be a Maven or Gradle built project."); } + // Start a terminal and run the application in dev mode. + startDevMode(cmd, projectName, projectPath, javaHomePath); + // If there is a debugPort, start the job to attach the debugger to the Liberty server JVM. if (debugPort != null) { - debugModeHandler.startDebugAttacher(project, debugPort); + debugModeHandler.startDebugAttacher(project, launch, debugPort); } - - // Start a terminal and run the application in dev mode. - startDevMode(cmd, projectName, projectPath, javaHomePath); } catch (CommandNotFoundException e) { String msg = "Maven or Gradle command not found for project " + projectName; if (Trace.isEnabled()) { @@ -266,7 +268,7 @@ public void start(IProject iProject, String parms, String javaHomePath, String m * @param javaHomePath The configuration java installation home to be set in the terminal running dev mode. * @param mode The configuration mode. */ - public void startInContainer(IProject iProject, String parms, String javaHomePath, String mode) { + public void startInContainer(IProject iProject, String parms, String javaHomePath, ILaunch launch, String mode) { if (Trace.isEnabled()) { Trace.getTracer().traceEntry(Trace.TRACE_TOOLS, new Object[] { iProject, parms, javaHomePath, mode }); @@ -347,13 +349,13 @@ public void startInContainer(IProject iProject, String parms, String javaHomePat + "does not appear to be a Maven or Gradle built project."); } + // Start a terminal and run the application in dev mode. + startDevMode(cmd, projectName, projectPath, javaHomePath); + // If there is a debugPort, start the job to attach the debugger to the Liberty server JVM. if (debugPort != null) { - debugModeHandler.startDebugAttacher(project, debugPort); + debugModeHandler.startDebugAttacher(project, launch, debugPort); } - - // Start a terminal and run the application in dev mode. - startDevMode(cmd, projectName, projectPath, javaHomePath); } catch (Exception e) { String msg = "An error was detected during the start in container request on project " + projectName; if (Trace.isEnabled()) { diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DebugModeHandler.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/DebugModeHandler.java similarity index 74% rename from bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DebugModeHandler.java rename to bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/DebugModeHandler.java index 76c9932d..02b81199 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/DebugModeHandler.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/DebugModeHandler.java @@ -10,11 +10,12 @@ * Contributors: * IBM Corporation - initial implementation *******************************************************************************/ -package io.openliberty.tools.eclipse; +package io.openliberty.tools.eclipse.debug; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; +import java.io.IOException; import java.net.ConnectException; import java.net.ServerSocket; import java.net.Socket; @@ -22,29 +23,27 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; -import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationType; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.jdt.core.JavaCore; +import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.jdi.Bootstrap; +import org.eclipse.jdi.TimeoutException; +import org.eclipse.jdt.debug.core.JDIDebugModel; import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; +import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IViewPart; @@ -53,12 +52,19 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.connect.AttachingConnector; +import com.sun.jdi.connect.Connector; +import com.sun.jdi.connect.Connector.Argument; +import com.sun.jdi.connect.IllegalConnectorArgumentsException; + +import io.openliberty.tools.eclipse.DevModeOperations; +import io.openliberty.tools.eclipse.LibertyDevPlugin; +import io.openliberty.tools.eclipse.Project; import io.openliberty.tools.eclipse.Project.BuildType; import io.openliberty.tools.eclipse.logging.Trace; import io.openliberty.tools.eclipse.messages.Messages; import io.openliberty.tools.eclipse.ui.dashboard.DashboardView; -import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationHelper; -import io.openliberty.tools.eclipse.ui.launch.StartTab; import io.openliberty.tools.eclipse.ui.terminal.ProjectTabController; import io.openliberty.tools.eclipse.ui.terminal.TerminalListener; import io.openliberty.tools.eclipse.utils.ErrorHandler; @@ -89,9 +95,6 @@ public class DebugModeHandler { /** Job status return code indicating that an error took place while attempting to attach the debugger to the JVM. */ public static int JOB_STATUS_DEBUGGER_CONN_ERROR = 1; - /** Instance to this class. */ - private LaunchConfigurationHelper launchConfigHelper = LaunchConfigurationHelper.getInstance(); - /** DevModeOperations instance. */ private DevModeOperations devModeOps; @@ -209,11 +212,12 @@ public String calculateDebugPort(Project project, String inputParms) throws Exce * Starts the job that will attempt to connect the debugger with the server's JVM. * * @param project The project for which the debugger needs to be attached. + * @param launch The launch to which the debug target will be added. * @param debugPort The debug port to use to attach the debugger to. * * @throws Exception */ - public void startDebugAttacher(Project project, String debugPort) { + public void startDebugAttacher(Project project, ILaunch launch, String debugPort) { String projectName = project.getIProject().getName(); Job job = new Job("Attaching Debugger to JVM...") { @@ -229,7 +233,13 @@ protected IStatus run(IProgressMonitor monitor) { return Status.CANCEL_STATUS; } - createRemoteJavaAppDebugConfig(project, DEFAULT_ATTACH_HOST, portToConnect, monitor); + AttachingConnector connector = getAttachingConnector(); + Map map = connector.defaultArguments(); + configureConnector(map, DEFAULT_ATTACH_HOST, Integer.parseInt(portToConnect)); + IDebugTarget debugTarget = createRemoteJDTDebugTarget(launch, Integer.parseInt(portToConnect), DEFAULT_ATTACH_HOST, + connector, map); + + launch.addDebugTarget(debugTarget); } catch (Exception e) { return new Status(IStatus.ERROR, LibertyDevPlugin.PLUGIN_ID, JOB_STATUS_DEBUGGER_CONN_ERROR, @@ -285,6 +295,120 @@ public void run() { job.schedule(); } + private AttachingConnector getAttachingConnector() { + List connectors = Bootstrap.virtualMachineManager().attachingConnectors(); + for (int i = 0; i < connectors.size(); i++) { + AttachingConnector c = (AttachingConnector) connectors.get(i); + if ("com.sun.jdi.SocketAttach".equals(c.name())) + return c; + } + + return null; + } + + /** + * Configure the connector properties. + * + * @param map argument map + * @param host the host name or IP address + * @param portNumber the port number + */ + private void configureConnector(Map map, String host, int portNumber) { + Connector.StringArgument hostArg = (Connector.StringArgument) map.get("hostname"); + hostArg.setValue(host); + + Connector.IntegerArgument portArg = (Connector.IntegerArgument) map.get("port"); + portArg.setValue(portNumber); + + // This timeout value is directly configurable from the "Launch timeout" in Eclipse Preferences. + // At the point when we connect, we already confirmed that we are able to connect to the socket, + // so this may not come into play. However, we are keeping it here just in case. + Connector.IntegerArgument timeoutArg = (Connector.IntegerArgument) map.get("timeout"); + if (timeoutArg != null) { + int timeout = Platform.getPreferencesService().getInt( + "org.eclipse.jdt.launching", + JavaRuntime.PREF_CONNECT_TIMEOUT, + JavaRuntime.DEF_CONNECT_TIMEOUT, + null); + timeoutArg.setValue(timeout); + } + } + + private IDebugTarget createRemoteJDTDebugTarget(ILaunch launch, int remoteDebugPortNum, String hostName, + AttachingConnector connector, Map map) throws CoreException { + if (launch == null || hostName == null || hostName.length() == 0) { + return null; + } + VirtualMachine remoteVM = null; + Exception ex = null; + IDebugTarget debugTarget = null; + try { + remoteVM = attachJVM(hostName, remoteDebugPortNum, connector, map); + } catch (Exception e) { + ex = e; + } + if (remoteVM == null) { + throw new CoreException( + new Status(IStatus.ERROR, this.getClass(), IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED, "", ex)); + } + debugTarget = JDIDebugModel.newDebugTarget(launch, remoteVM, hostName + ":" + remoteDebugPortNum, null, true, false, true); + return debugTarget; + } + + /** + * Connect the debugger to the debug port of the target VM + * + * @param hostName + * @param port + * @param connector + * @param map + * + * @return + */ + private VirtualMachine attachJVM(String hostName, int port, AttachingConnector connector, Map map) { + + // At this point, the "waitForSocketActivation" method has already been called so we know that we are able + // to connect to the Liberty server's debug port. However, there is still a gap here where we can get a + // connection refused exception when we attempt to attach the debugger. This could potentially be due to a difference in + // how we are writing to the socket, but whatever the reason, we have a timeout mechanism here as well to attempt the + // connection every 100ms for 10 seconds. Any IOExceptions like a "connection refused" will trigger a retry. Any timeout + // exceptions within the connector itself will not trigger a retry. We will catch that in the calling method and + // expose the timeout there. If we exhaust out retries we will return null and the calling method will throw a connection + // error. + + VirtualMachine vm = null; + int timeOut = 10000; + try { + try { + vm = connector.attach(map); + } catch (IOException e) { + if (Trace.isEnabled()) { + Trace.getTracer().trace(Trace.TRACE_UI, + "Error occured while trying to connect to the remote virtual machine " + e.getMessage(), e); + } + } catch (TimeoutException e2) { + // do nothing + } + + while (vm == null && timeOut > 0) { + try { + Thread.sleep(100); + } catch (Exception e) { + // do nothing + } + timeOut = timeOut - 100; + try { + vm = connector.attach(map); + } catch (IOException e) { + // do nothing + } + } + } catch (IllegalConnectorArgumentsException e) { + // Do nothing, return vm as null if it fails + } + return vm; + } + /** * Opens the debug perspective with the terminal and liberty dashboard views. */ @@ -430,91 +554,6 @@ public String readDebugPortFromServerEnv(File serverEnv) throws Exception { return port; } - /** - * Returns a new Remote Java Application debug configuration. - * - * @param configuration The configuration being processed. - * @param host The JVM host to connect to. - * @param port The JVM port to connect to. - * @param monitor The progress monitor. - * - * @return A new Remote Java Application debug configuration. - * - * @throws Exception - */ - private ILaunch createRemoteJavaAppDebugConfig(Project project, String host, String port, IProgressMonitor monitor) throws Exception { - // There are cases where some modules of a multi-module project may not be categorized as Java projects. - // The Remote Java Application configuration requires that the project being processed is a Java project. - // Given this requirement, multi-module projects that contain modules with liberty server configuration that - // are not considered Java projects may not be able to run debug mode. - // A compromise to go around this case is to obtain configuration information from a child or peer project that - // is considered to be Java project. - // Therefore, the following code obtains Java configuration information from an associated Java project and - // uses it on behalf of the application being processed. - IProject iProject = project.getIProject(); - String projectName = iProject.getName(); - String associatedProjectName = projectName; - if (!iProject.hasNature(JavaCore.NATURE_ID)) { - Project associatedProject = project.getAssociatedJavaProject(project); - if (associatedProject != null) { - associatedProjectName = associatedProject.getName(); - } else { - throw new Exception("Project " + projectName + " is not a Java project. Associated Java projects not found."); - } - } - - ILaunchManager iLaunchManager = DebugPlugin.getDefault().getLaunchManager(); - ILaunchConfigurationType remoteJavaAppConfigType = iLaunchManager - .getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION); - ILaunchConfiguration[] remoteJavaAppConfigs = iLaunchManager.getLaunchConfigurations(remoteJavaAppConfigType); - ILaunchConfigurationWorkingCopy remoteJavaAppConfigWCopy = null; - - // Find the configurations associated with the project. - List projectAssociatedConfigs = new ArrayList(); - for (ILaunchConfiguration remoteJavaAppConfig : remoteJavaAppConfigs) { - String savedProjectName = remoteJavaAppConfig.getAttribute(StartTab.PROJECT_NAME, (String) null); - if (savedProjectName != null && savedProjectName.equals(projectName)) { - projectAssociatedConfigs.add(remoteJavaAppConfig); - } - } - - // Find the configuration used last. - if (projectAssociatedConfigs.size() > 0) { - ILaunchConfiguration lastUsedConfig = launchConfigHelper.getLastRunConfiguration(projectAssociatedConfigs); - remoteJavaAppConfigWCopy = lastUsedConfig.getWorkingCopy(); - } - - // If an existing configuration was not found, create one. - if (remoteJavaAppConfigWCopy == null) { - String configName = launchConfigHelper.buildConfigurationName(projectName); - remoteJavaAppConfigWCopy = remoteJavaAppConfigType.newInstance(null, configName); - remoteJavaAppConfigWCopy.setAttribute(StartTab.PROJECT_NAME, projectName); - remoteJavaAppConfigWCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, associatedProjectName); - remoteJavaAppConfigWCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, - IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); - remoteJavaAppConfigWCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, false); - } - - // Update the configuration with the current data. - Map connectMap = new HashMap<>(2); - connectMap.put("port", port); - connectMap.put("hostname", host); - remoteJavaAppConfigWCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, connectMap); - remoteJavaAppConfigWCopy.setAttribute(StartTab.PROJECT_RUN_TIME, String.valueOf(System.currentTimeMillis())); - - // - // Fixed issue: https://github.com/OpenLiberty/liberty-tools-eclipse/issues/372 - // by launching with the return value of remoteJavaAppConfigWCopy.doSave(), rather than the - // object (the "working copy") itself. - // - // Debated calling launch() with the doSave() return value vs. the value of - // remoteJavaAppConfigWCopy.getOriginal(). Decided on the former which - // seemed to be the more common usage pattern, though not entirely clear which is better. - // - ILaunchConfiguration updatedConfig = remoteJavaAppConfigWCopy.doSave(); - return updatedConfig.launch(ILaunchManager.DEBUG_MODE, monitor); - } - /** * Waits for the JDWP socket on the JVM to start listening for connections. * @@ -527,6 +566,14 @@ private ILaunch createRemoteJavaAppDebugConfig(Project project, String host, Str * @throws Exception */ private String waitForSocketActivation(Project project, String host, String port, IProgressMonitor monitor) throws Exception { + + // This is the first of several timeout mechanisms during the debugger connection. This method + // will attempt a write to the debug port of the target VM (Liberty server) once every second for + // 3 minutes. This seems like a reasonable amount of time for the debug port to become available + // so for now we are not making this timeout configurable. If in the future, we need to expose + // this timeout value, we could potentially tie it to the "Launch timeout" setting of in the + // Eclipse "Debug" preferences. + byte[] handshakeString = "JDWP-Handshake".getBytes(StandardCharsets.US_ASCII); int retryLimit = 180; int envReadInterval = 2; diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertySourceLookupDirector.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertySourceLookupDirector.java new file mode 100644 index 00000000..3470ca4e --- /dev/null +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertySourceLookupDirector.java @@ -0,0 +1,32 @@ +/******************************************************************************* +* Copyright (c) 2023 IBM Corporation and others. +* +* 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 +* +* Contributors: +* IBM Corporation - initial implementation +*******************************************************************************/ +package io.openliberty.tools.eclipse.debug; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; +import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant; +import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourceLookupParticipant; + +public class LibertySourceLookupDirector extends AbstractSourceLookupDirector { + + @Override + public void initializeParticipants() { + final List participants = new ArrayList<>(); + + participants.add(new JavaSourceLookupParticipant()); + + addParticipants(participants.toArray(new ISourceLookupParticipant[participants.size()])); + } +} 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 new file mode 100644 index 00000000..8bdb1d0f --- /dev/null +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/debug/LibertySourcePathComputer.java @@ -0,0 +1,204 @@ +/******************************************************************************* +* Copyright (c) 2023 IBM Corporation and others. +* +* 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 +* +* Contributors: +* IBM Corporation - initial implementation +*******************************************************************************/ +package io.openliberty.tools.eclipse.debug; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.project.MavenProject; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.sourcelookup.ISourceContainer; +import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.launching.IRuntimeClasspathEntry; +import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.m2e.core.MavenPlugin; +import org.eclipse.m2e.core.project.IMavenProjectFacade; +import org.eclipse.m2e.core.project.IMavenProjectRegistry; +import org.gradle.tooling.GradleConnector; +import org.gradle.tooling.ProjectConnection; +import org.gradle.tooling.model.ExternalDependency; +import org.gradle.tooling.model.GradleModuleVersion; +import org.gradle.tooling.model.eclipse.EclipseProject; + +import io.openliberty.tools.eclipse.DevModeOperations; +import io.openliberty.tools.eclipse.Project; +import io.openliberty.tools.eclipse.ui.launch.StartTab; + +public class LibertySourcePathComputer implements ISourcePathComputerDelegate { + + ArrayList unresolvedClasspathEntries; + + @Override + public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { + + unresolvedClasspathEntries = new ArrayList(); + + /* + * This method computes the default source lookup paths for a particular launch configuration. We are doing this in two ways: + * . + * 1. We are first computing the runtime classpath entries. This is in-line with what Remote Java Application does. + * . + * 2. We are finding any project dependencies that are also present in the current Eclipse workspace and adding those projects. + * . For this step we are using m2e and gradle/buildship APIs to get lists of the dependency artifacts and then checking if those + * . artifact coordinates map to any existing projects in the workspace. At the moment, the dependency projects must be Maven + * . projects. M2e offers APIs to lookup Maven projects in the workspace based on artifact coordinates, + * . but Gradle/Buildship does not offer similar capabilities for Gradle projects. + */ + + // Get current project + String projectName = configuration.getAttribute(StartTab.PROJECT_NAME, (String) null); + + Project project = DevModeOperations.getInstance().getProjectModel().getProject(projectName); + + // Get full list of projects (multi-mod, children, siblings, etc) + List baseProjects = getBaseProjects(project); + + // Loop through each + for (Project baseProject : baseProjects) { + + addRuntimeDependencies(baseProject.getIProject()); + + // Get project dependencies that are open in the same workspace + List projectDependencies = getProjectDependencies(baseProject); + + // Create the classpath entry for the project dependencies found + for (IProject dependencyProject : projectDependencies) { + + if (dependencyProject.isNatureEnabled(JavaCore.NATURE_ID)) { + IJavaProject dependencyJavaProject = JavaCore.create(dependencyProject); + unresolvedClasspathEntries.add(JavaRuntime.newDefaultProjectClasspathEntry(dependencyJavaProject)); + } + } + } + + // Resolve and get final list of source containers + IRuntimeClasspathEntry[] resolvedClasspathDependencies = JavaRuntime.resolveSourceLookupPath( + unresolvedClasspathEntries.toArray(new IRuntimeClasspathEntry[unresolvedClasspathEntries.size()]), configuration); + + ArrayList containersList = new ArrayList(); + + containersList.addAll(Arrays.asList(JavaRuntime.getSourceContainers(resolvedClasspathDependencies))); + + ISourceContainer[] containers = new ISourceContainer[containersList.size()]; + containersList.toArray(containers); + + return containers; + } + + private List getBaseProjects(Project project) { + List baseProjects = new ArrayList(); + + baseProjects.add(project); + + baseProjects.addAll(project.getChildJavaProjects()); + baseProjects.addAll(project.getPeerJavaProjects()); + + return baseProjects; + } + + private List getProjectDependencies(Project project) throws CoreException { + List projectDependencies = new ArrayList(); + + if (project.getBuildType() == Project.BuildType.MAVEN) { + + MavenProject mavenModuleProject = MavenPlugin.getMavenModelManager().readMavenProject(project.getIProject().getFile("pom.xml"), + new NullProgressMonitor()); + Set artifacts = mavenModuleProject.getArtifacts(); + + for (Artifact artifact : artifacts) { + + IProject localProject = getLocalProject(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion()); + if (localProject != null) { + projectDependencies.add(localProject); + } + } + } else { + GradleConnector connector = GradleConnector.newConnector(); + connector.forProjectDirectory(project.getIProject().getLocation().toFile()); + ProjectConnection connection = connector.connect(); + + try { + EclipseProject eclipseProject = connection.getModel(EclipseProject.class); + for (ExternalDependency externalDependency : eclipseProject.getClasspath()) { + + GradleModuleVersion gradleModuleVersion = externalDependency.getGradleModuleVersion(); + + IProject localProject = getLocalProject(gradleModuleVersion.getGroup(), gradleModuleVersion.getName(), + gradleModuleVersion.getVersion()); + if (localProject != null) { + projectDependencies.add(localProject); + } + } + } finally { + connection.close(); + } + } + + return projectDependencies; + } + + /** + * Get project if found in local workspace based on artifact coordinates + * + * @param groupId + * @param artifactId + * @param version + * + * @return + */ + private IProject getLocalProject(String groupId, String artifactId, String version) { + + // Check Maven projects + IMavenProjectRegistry mavenProjectRegistry = MavenPlugin.getMavenProjectRegistry(); + + IMavenProjectFacade mavenProjectFacade = mavenProjectRegistry.getMavenProject(groupId, artifactId, version); + + if (mavenProjectFacade != null) { + return mavenProjectFacade.getProject(); + } + + // TODO: Check Gradle projects + + return null; + } + + /** + * Adds classpath entries for runtime dependencies to the unresolved classpath entries list + * + * @param project + * + * @throws CoreException + */ + 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.computeUnresolvedRuntimeClasspath(JavaCore.create(project))); + for (IRuntimeClasspathEntry runtimeDependency : runtimeDependencies) { + if (!unresolvedClasspathEntries.contains(runtimeDependency)) { + unresolvedClasspathEntries.add(runtimeDependency); + } + } + } + } +} \ No newline at end of file diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/dashboard/DashboardView.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/dashboard/DashboardView.java index 7d92dfbf..0cb85faf 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/dashboard/DashboardView.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/dashboard/DashboardView.java @@ -248,7 +248,7 @@ private void createActions() { public void run() { IProject iProject = devModeOps.getSelectedDashboardProject(); try { - StartAction.run(iProject, null, ILaunchManager.RUN_MODE); + StartAction.run(iProject, ILaunchManager.RUN_MODE); } catch (Exception e) { String msg = "An error was detected during the " + APP_MENU_ACTION_START + " action."; if (Trace.isEnabled()) { @@ -293,7 +293,7 @@ public void run() { public void run() { IProject iProject = devModeOps.getSelectedDashboardProject(); try { - StartInContainerAction.run(iProject, null, ILaunchManager.RUN_MODE); + StartInContainerAction.run(iProject, ILaunchManager.RUN_MODE); } catch (Exception e) { String msg = "An error was detected during the " + APP_MENU_ACTION_START_IN_CONTAINER + " action."; @@ -315,7 +315,7 @@ public void run() { public void run() { IProject iProject = devModeOps.getSelectedDashboardProject(); try { - StartInContainerAction.run(iProject, null, ILaunchManager.DEBUG_MODE); + StartInContainerAction.run(iProject, ILaunchManager.DEBUG_MODE); } catch (Exception e) { String msg = "An error was detected during the " + APP_MENU_ACTION_DEBUG_IN_CONTAINER + " action."; @@ -337,7 +337,7 @@ public void run() { public void run() { IProject iProject = devModeOps.getSelectedDashboardProject(); try { - StartAction.run(iProject, null, ILaunchManager.DEBUG_MODE); + StartAction.run(iProject, ILaunchManager.DEBUG_MODE); } catch (Exception e) { String msg = "An error was detected during the " + APP_MENU_ACTION_DEBUG + " action."; if (Trace.isEnabled()) { diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigTabGroup.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigTabGroup.java index f34b7152..a0c62fb1 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigTabGroup.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigTabGroup.java @@ -15,6 +15,7 @@ import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationTab; +import org.eclipse.debug.ui.sourcelookup.SourceLookupTab; /** * Creates and groups run configuration view tabs. @@ -26,6 +27,6 @@ public class LaunchConfigTabGroup extends AbstractLaunchConfigurationTabGroup { */ @Override public void createTabs(ILaunchConfigurationDialog dialog, String mode) { - setTabs(new ILaunchConfigurationTab[] { new StartTab(), new JRETab() }); + setTabs(new ILaunchConfigurationTab[] { new StartTab(), new JRETab(), new SourceLookupTab() }); } } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationDelegateLauncher.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationDelegateLauncher.java index 16fe644c..4fb2f7b6 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationDelegateLauncher.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationDelegateLauncher.java @@ -25,9 +25,9 @@ import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; +import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.logging.Trace; import io.openliberty.tools.eclipse.messages.Messages; -import io.openliberty.tools.eclipse.ui.launch.shortcuts.StartAction; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -80,7 +80,7 @@ public void run() { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IProject configProject = root.getProject(configProjectName); - StartAction.run(configProject, configuration, mode); + launchDevMode(configProject, configuration, launch, mode); } catch (Exception e) { String msg = "An error was detected when configuration was launched" + configuration.getName() + "."; @@ -118,4 +118,53 @@ private void assertProjectsMatch(ILaunchConfiguration configuration, IProject se Trace.getTracer().traceExit(Trace.TRACE_UI); } } + + /** + * Starts dev mode + * + * @param iProject The project to process. + * @param iConfiguration The configuration for this start. + * @param launch The launch associated with this start + * @param mode The operation mode type. Run or debug. + * + * @throws Exception + */ + private void launchDevMode(IProject iProject, ILaunchConfiguration iConfiguration, ILaunch launch, String mode) throws Exception { + + if (Trace.isEnabled()) { + Trace.getTracer().traceEntry(Trace.TRACE_UI, new Object[] { iProject, iConfiguration, mode }); + } + + if (iProject == null) { + throw new Exception("Invalid project. Be sure to select a project first."); + } + + // Validate that the project is supported. + DevModeOperations devModeOps = DevModeOperations.getInstance(); + devModeOps.verifyProjectSupport(iProject); + + // If the configuration was not provided by the caller, determine what configuration to use. + LaunchConfigurationHelper launchConfigHelper = LaunchConfigurationHelper.getInstance(); + ILaunchConfiguration configuration = (iConfiguration != null) ? iConfiguration + : launchConfigHelper.getLaunchConfiguration(iProject, mode, RuntimeEnv.LOCAL); + + // Save the time when this configuration was processed. + launchConfigHelper.saveConfigProcessingTime(configuration); + + // Retrieve configuration data. + boolean runInContainer = configuration.getAttribute(StartTab.PROJECT_RUN_IN_CONTAINER, false); + String configParms = configuration.getAttribute(StartTab.PROJECT_START_PARM, (String) null); + String javaHomePath = JRETab.resolveJavaHome(configuration); + + // Process the action. + if (runInContainer) { + devModeOps.startInContainer(iProject, configParms, javaHomePath, launch, mode); + } else { + devModeOps.start(iProject, configParms, javaHomePath, launch, mode); + } + + if (Trace.isEnabled()) { + Trace.getTracer().traceExit(Trace.TRACE_UI); + } + } } diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationHelper.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationHelper.java index a5aa3f85..0d0463f1 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationHelper.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/LaunchConfigurationHelper.java @@ -57,6 +57,10 @@ public static LaunchConfigurationHelper getInstance() { * @throws Exception */ public ILaunchConfiguration getLaunchConfiguration(IProject iProject, String mode, RuntimeEnv runtimeEnv) throws Exception { + if (Trace.isEnabled()) { + Trace.getTracer().traceEntry(Trace.TRACE_UI, new Object[] { iProject, mode, runtimeEnv }); + } + DevModeOperations devModeOps = DevModeOperations.getInstance(); ILaunchConfiguration configuration = null; ILaunchManager iLaunchMgr = DebugPlugin.getDefault().getLaunchManager(); @@ -69,31 +73,35 @@ public ILaunchConfiguration getLaunchConfiguration(IProject iProject, String mod List matchingConfigList = filterLaunchConfigurations(existingConfigs, iProject.getName(), runtimeEnv); switch (matchingConfigList.size()) { - case 0: - // Create a new configuration. - String newName = iLaunchMgr.generateLaunchConfigurationName(iProject.getName()); - ILaunchConfigurationWorkingCopy workingCopy = iLaunchConfigType.newInstance(null, newName); - workingCopy.setAttribute(StartTab.PROJECT_NAME, iProject.getName()); - workingCopy.setAttribute(StartTab.PROJECT_START_PARM, devModeOps.getProjectModel().getDefaultStartParameters(iProject)); - //default to 'false', no container - boolean runInContainer = runtimeEnv.equals(RuntimeEnv.CONTAINER); - workingCopy.setAttribute(StartTab.PROJECT_RUN_IN_CONTAINER, runInContainer); - - String defaultJavaDef = JRETab.getDefaultJavaFromBuildPath(iProject); - if (defaultJavaDef != null) { - workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, defaultJavaDef); - } + case 0: + // Create a new configuration. + String newName = iLaunchMgr.generateLaunchConfigurationName(iProject.getName()); + ILaunchConfigurationWorkingCopy workingCopy = iLaunchConfigType.newInstance(null, newName); + workingCopy.setAttribute(StartTab.PROJECT_NAME, iProject.getName()); + workingCopy.setAttribute(StartTab.PROJECT_START_PARM, devModeOps.getProjectModel().getDefaultStartParameters(iProject)); + // default to 'false', no container + boolean runInContainer = runtimeEnv.equals(RuntimeEnv.CONTAINER); + workingCopy.setAttribute(StartTab.PROJECT_RUN_IN_CONTAINER, runInContainer); + + String defaultJavaDef = JRETab.getDefaultJavaFromBuildPath(iProject); + if (defaultJavaDef != null) { + workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, defaultJavaDef); + } + + configuration = workingCopy.doSave(); + break; + case 1: + // Return the found configuration. + configuration = matchingConfigList.get(0); + break; + default: + // Return the configuration that was run last. + configuration = getLastRunConfiguration(matchingConfigList); + break; + } - configuration = workingCopy.doSave(); - break; - case 1: - // Return the found configuration. - configuration = matchingConfigList.get(0); - break; - default: - // Return the configuration that was run last. - configuration = getLastRunConfiguration(matchingConfigList); - break; + if (Trace.isEnabled()) { + Trace.getTracer().traceExit(Trace.TRACE_TOOLS, new Object[] { iProject, configuration }); } return configuration; diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java index 5ac2541e..d572e699 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartAction.java @@ -14,6 +14,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jface.viewers.ISelection; import org.eclipse.osgi.util.NLS; @@ -22,11 +23,9 @@ import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.logging.Trace; import io.openliberty.tools.eclipse.messages.Messages; -import io.openliberty.tools.eclipse.ui.launch.JRETab; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher.RuntimeEnv; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationHelper; -import io.openliberty.tools.eclipse.ui.launch.StartTab; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -47,7 +46,7 @@ public void launch(ISelection selection, String mode) { } try { - run(iProject, null, mode); + run(iProject, mode); } catch (Exception e) { String msg = "An error was detected when the \"" + LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_START + "\" launch shortcut was processed."; @@ -75,7 +74,7 @@ public void launch(IEditorPart part, String mode) { } try { - run(iProject, null, mode); + run(iProject, mode); } catch (Exception e) { String msg = "An error was detected when the \"" + LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_START + "\" launch shortcut was processed."; @@ -99,42 +98,16 @@ public void launch(IEditorPart part, String mode) { * * @throws Exception */ - public static void run(IProject iProject, ILaunchConfiguration iConfiguration, String mode) throws Exception { - - if (Trace.isEnabled()) { - Trace.getTracer().traceEntry(Trace.TRACE_UI, new Object[] { iProject, iConfiguration, mode }); - } - - if (iProject == null) { - throw new Exception("Invalid project. Be sure to select a project first."); - } + public static void run(IProject iProject, String mode) throws Exception { // Validate that the project is supported. DevModeOperations devModeOps = DevModeOperations.getInstance(); devModeOps.verifyProjectSupport(iProject); - // If the configuration was not provided by the caller, determine what configuration to use. + // Determine what configuration to use. LaunchConfigurationHelper launchConfigHelper = LaunchConfigurationHelper.getInstance(); - ILaunchConfiguration configuration = (iConfiguration != null) ? iConfiguration - : launchConfigHelper.getLaunchConfiguration(iProject, mode, RuntimeEnv.LOCAL); - - // Save the time when this configuration was processed. - launchConfigHelper.saveConfigProcessingTime(configuration); + ILaunchConfiguration configuration = launchConfigHelper.getLaunchConfiguration(iProject, mode, RuntimeEnv.LOCAL); - // Retrieve configuration data. - boolean runInContainer = configuration.getAttribute(StartTab.PROJECT_RUN_IN_CONTAINER, false); - String configParms = configuration.getAttribute(StartTab.PROJECT_START_PARM, (String) null); - String javaHomePath = JRETab.resolveJavaHome(configuration); - - // Process the action. - if (runInContainer) { - devModeOps.startInContainer(iProject, configParms, javaHomePath, mode); - } else { - devModeOps.start(iProject, configParms, javaHomePath, mode); - } - - if (Trace.isEnabled()) { - Trace.getTracer().traceExit(Trace.TRACE_UI); - } + DebugUITools.launch(configuration, mode); } } \ No newline at end of file diff --git a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java index e860bc28..533fe833 100644 --- a/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java +++ b/bundles/io.openliberty.tools.eclipse.ui/src/io/openliberty/tools/eclipse/ui/launch/shortcuts/StartInContainerAction.java @@ -14,6 +14,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jface.viewers.ISelection; import org.eclipse.osgi.util.NLS; @@ -22,11 +23,9 @@ import io.openliberty.tools.eclipse.DevModeOperations; import io.openliberty.tools.eclipse.logging.Trace; import io.openliberty.tools.eclipse.messages.Messages; -import io.openliberty.tools.eclipse.ui.launch.JRETab; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher.RuntimeEnv; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationHelper; -import io.openliberty.tools.eclipse.ui.launch.StartTab; import io.openliberty.tools.eclipse.utils.ErrorHandler; import io.openliberty.tools.eclipse.utils.Utils; @@ -47,7 +46,7 @@ public void launch(ISelection selection, String mode) { } try { - run(iProject, null, mode); + run(iProject, mode); } catch (Exception e) { String msg = "An error was detected when the \"" + LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_START_CONTAINER + "\" launch shortcut was processed."; @@ -76,7 +75,7 @@ public void launch(IEditorPart part, String mode) { } try { - run(iProject, null, mode); + run(iProject, mode); } catch (Exception e) { String msg = "An error was detected when the \"" + LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_START_CONTAINER + "\" launch shortcut was processed."; @@ -102,26 +101,16 @@ public void launch(IEditorPart part, String mode) { * * @throws Exception */ - public static void run(IProject iProject, ILaunchConfiguration iConfiguration, String mode) throws Exception { - if (iProject == null) { - throw new Exception("Invalid project. Be sure to select a project first."); - } + public static void run(IProject iProject, String mode) throws Exception { // Validate that the project is supported. DevModeOperations devModeOps = DevModeOperations.getInstance(); devModeOps.verifyProjectSupport(iProject); - // If the configuration was not provided by the caller, determine what configuration to use. + // Determine what configuration to use. LaunchConfigurationHelper launchConfigHelper = LaunchConfigurationHelper.getInstance(); - ILaunchConfiguration configuration = (iConfiguration != null) ? iConfiguration - : launchConfigHelper.getLaunchConfiguration(iProject, mode, RuntimeEnv.CONTAINER); - - // Save the time when this configuration was processed. - launchConfigHelper.saveConfigProcessingTime(configuration); + ILaunchConfiguration configuration = launchConfigHelper.getLaunchConfiguration(iProject, mode, RuntimeEnv.CONTAINER); - // Process the action. - String configParms = configuration.getAttribute(StartTab.PROJECT_START_PARM, (String) null); - String javaHomePath = JRETab.resolveJavaHome(configuration); - devModeOps.startInContainer(iProject, configParms, javaHomePath, mode); + DebugUITools.launch(configuration, mode); } } \ No newline at end of file diff --git a/tests/META-INF/MANIFEST.MF b/tests/META-INF/MANIFEST.MF index 3cb1eee8..936a43d3 100644 --- a/tests/META-INF/MANIFEST.MF +++ b/tests/META-INF/MANIFEST.MF @@ -9,6 +9,7 @@ Require-Bundle: junit-jupiter-api;bundle-version="[5.8.0,6.0.0)", org.eclipse.ui, org.hamcrest.library;bundle-version="[1.3.0,2.2)" Import-Package: io.openliberty.tools.eclipse, + io.openliberty.tools.eclipse.debug, io.openliberty.tools.eclipse.ui.dashboard, io.openliberty.tools.eclipse.ui.launch, io.openliberty.tools.eclipse.ui.launch.shortcuts, 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 dc35309f..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 { @@ -31,6 +33,9 @@ dependencies { // test dependencies testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1' testImplementation 'commons-httpclient:commons-httpclient:3.1' + + // test shared lib jar + implementation 'test:shared-lib:1.0-SNAPSHOT' } diff --git a/tests/resources/applications/maven/liberty-maven-test-app/pom.xml b/tests/resources/applications/maven/liberty-maven-test-app/pom.xml index e073248f..3405976d 100644 --- a/tests/resources/applications/maven/liberty-maven-test-app/pom.xml +++ b/tests/resources/applications/maven/liberty-maven-test-app/pom.xml @@ -47,6 +47,13 @@ 5.8.1 test + + + + test + shared-lib + 1.0-SNAPSHOT + diff --git a/tests/resources/applications/maven/maven-multi-module/typeJ/war2/src/main/webapp/META-INF/MANIFEST.MF b/tests/resources/applications/maven/maven-multi-module/typeJ/war2/src/main/webapp/META-INF/MANIFEST.MF new file mode 100644 index 00000000..254272e1 --- /dev/null +++ b/tests/resources/applications/maven/maven-multi-module/typeJ/war2/src/main/webapp/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/tests/resources/applications/maven/test-shared-lib-jar/pom.xml b/tests/resources/applications/maven/test-shared-lib-jar/pom.xml new file mode 100644 index 00000000..6078669e --- /dev/null +++ b/tests/resources/applications/maven/test-shared-lib-jar/pom.xml @@ -0,0 +1,21 @@ + + + + 4.0.0 + + test + shared-lib + 1.0-SNAPSHOT + jar + + + UTF-8 + UTF-8 + 1.8 + 1.8 + + + diff --git a/tests/resources/applications/maven/test-shared-lib-jar/src/main/java/io/openliberty/guides/multimodules/lib/Converter.java b/tests/resources/applications/maven/test-shared-lib-jar/src/main/java/io/openliberty/guides/multimodules/lib/Converter.java new file mode 100644 index 00000000..4f14c700 --- /dev/null +++ b/tests/resources/applications/maven/test-shared-lib-jar/src/main/java/io/openliberty/guides/multimodules/lib/Converter.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * Copyright (c) 2017 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Initial implementation + *******************************************************************************/ +package io.openliberty.guides.multimodules.lib; + +public class Converter { + + public static int getFeet(int cm) { + int feet = (int) (cm / 30.48); + return feet; + } + + public static int getInches(int cm) { + double feet = cm / 30.48; + int inches = (int) (cm / 2.54) - ((int) feet * 12); + return inches; + } + + public static int sum(int a, int b) { + return a + b; + } + + public static int diff(int a, int b) { + return a - b; + } + + public static int product(int a, int b) { + return a * b; + } + + public static int quotient(int a, int b) { + return a / b; + } + +} 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 b381ccce..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 @@ -22,6 +22,7 @@ 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.launchCustomDebugFromDashboard; @@ -38,14 +39,18 @@ import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchStopWithRunAsShortcut; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchViewTestReportWithRunDebugAsShortcut; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.openJRETab; +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.refreshDashboard; 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; @@ -55,10 +60,13 @@ import java.util.concurrent.TimeUnit; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; 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; @@ -97,11 +105,18 @@ public class LibertyPluginSWTBotGradleTest extends AbstractLibertyPluginSWTBotTe */ static final String GRADLE_WRAPPER_APP_NAME = "liberty-gradle-test-wrapper-app"; + /** + * Shared lib jar project name. + */ + static final String MVN_SHARED_LIB_NAME = "shared-lib"; + static String testAppPath; static String testWrapperAppPath; static ArrayList projectsToInstall = new ArrayList(); + static ArrayList mavenProjectToInstall = new ArrayList(); + /** * Expected menu items. */ @@ -130,6 +145,7 @@ public class LibertyPluginSWTBotGradleTest extends AbstractLibertyPluginSWTBotTe /** * Setup. * + * @throws IOException * @throws CoreException * @throws InterruptedException */ @@ -151,6 +167,27 @@ public static void setup() throws Exception { importGradleApplications(projectsToInstall); + // Install Maven shared lib project + Path sharedLibProjectPath = Paths.get("resources", "applications", "maven", "test-shared-lib-jar"); + mavenProjectToInstall.add(sharedLibProjectPath.toString()); + for (String p : mavenProjectToInstall) { + cleanupProject(p); + } + 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(); @@ -165,6 +202,11 @@ public static void cleanup() { for (File p : projectsToInstall) { cleanupProject(p.toString()); } + + for (String p : mavenProjectToInstall) { + cleanupProject(p); + } + unsetBuildCmdPathInPreferences(bot, "Gradle"); } @@ -183,7 +225,7 @@ public static void cleanup() { public static final void validateBeforeTestRun() { // Though supposedly we use blocking methods to do the import, it seems Eclipse has the ability to break out of a deadlock - // by interrupting our thread, and we also seem to be causing one due to changing compiler settings. Since we haven't debugged + // by interrupting our thread, and we also seem to be causing one due to changing compiler settings. Since we haven't debugged // the latter, we'll introduce this wait. try { Thread.sleep(Integer.parseInt(System.getProperty("io.liberty.tools.eclipse.tests.app.import.wait", "0"))); @@ -794,4 +836,47 @@ public void testDefaultJRECompliance() { go("Close", configShell); } } + + /** + * Tests that the correct dependency projects are added to the debug source lookup list + * NOTE: At the moment we only support Maven dependency projects which is why we are + * using a Maven jar project to test + */ + @Test + public void testDebugSourceLookupContent() { + + deleteLibertyToolsRunConfigEntriesFromAppRunAs(GRADLE_APP_NAME); + + Shell configShell = launchDebugConfigurationsDialogFromAppRunAs(GRADLE_APP_NAME); + + boolean jarEntryFound = false; + + try { + Object libertyConfigTree = getLibertyTreeItemNoBot(configShell); + + context(libertyConfigTree, "New Configuration"); + + openSourceTab(bot); + + SWTBotTreeItem defaultSourceLookupTree = new SWTBotTreeItem((TreeItem) getDefaultSourceLookupTreeItemNoBot(configShell)); + + // Lookup test-shared-lib-jar project + try { + defaultSourceLookupTree.getNode(MVN_SHARED_LIB_NAME); + jarEntryFound = true; + } catch (WidgetNotFoundException wnfe) { + // Jar project was not found in source lookup list. + } + + } finally { + go("Close", configShell); + deleteLibertyToolsRunConfigEntriesFromAppRunAs(GRADLE_APP_NAME); + } + + // Validate dependency projects are in source lookup list + Assertions.assertTrue(jarEntryFound, + "The dependency project, " + MVN_SHARED_LIB_NAME + ", was not listed in the source lookup list for project " + + GRADLE_APP_NAME); + + } } 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 b4be2482..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 @@ -15,62 +15,45 @@ import static io.openliberty.tools.eclipse.test.it.utils.MagicWidgetFinder.context; import static io.openliberty.tools.eclipse.test.it.utils.MagicWidgetFinder.go; 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.launchCustomDebugFromDashboard; -import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchCustomRunFromDashboard; +import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.getRunConfigurationsShell; 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.widgets.SWTBotCombo; +import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException; 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; @@ -95,6 +78,11 @@ public class LibertyPluginSWTBotMavenTest extends AbstractLibertyPluginSWTBotTes */ static final String NON_DFLT_NAME = "non.dflt.server.xml.path"; + /** + * Shared lib jar project name. + */ + static final String MVN_SHARED_LIB_NAME = "shared-lib"; + /** * Test app relative path. */ @@ -110,6 +98,11 @@ public class LibertyPluginSWTBotMavenTest extends AbstractLibertyPluginSWTBotTes */ static final Path nonDfltProjectPath = Paths.get("resources", "applications", "maven", "non-dflt-server-xml-path"); + /** + * Test shared lib relative path. + */ + static final Path sharedLibProjectPath = Paths.get("resources", "applications", "maven", "test-shared-lib-jar"); + static ArrayList projectPaths = new ArrayList(); /** @@ -140,6 +133,8 @@ public class LibertyPluginSWTBotMavenTest extends AbstractLibertyPluginSWTBotTes /** * Setup. + * + * @throws Exception */ @BeforeAll public static void setup() throws Exception { @@ -150,16 +145,29 @@ public static void setup() throws Exception { projectPaths.add(projectPath.toString()); projectPaths.add(wrapperProjectPath.toString()); projectPaths.add(nonDfltProjectPath.toString()); + 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(); @@ -280,628 +288,726 @@ 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 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. + * Tests that the correct launch configuration is chosen depending on "start" vs "start in container" + * This test will run "Start..." and check "Run in container". A subsequent "Start" should run dev mode locally + * as the "Start" action should filter out any existing "container" configurations. */ @Test - public void testDashboardDebugWithCustomConfigAction() { + public void testLaunchConfigurationMatching() { // 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."); + // Launch "Run Configurations" window and check "Run in container" + launchDashboardAction(MVN_APP_NAME, DashboardView.APP_MENU_ACTION_START_CONFIG); + Shell shell = getRunConfigurationsShell(); + checkRunInContainerCheckBox(shell, MVN_APP_NAME); - 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."); + // No need to run here. Just Apply and Close. + go("Apply", shell); + go("Close", shell); - // Start dev mode. + // Start dev mode. This should start locally. 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. + // Since the app should be started locally, we should be able to validate that the app is up and running. + // Since our tests cannot run docker, any "failed" start would indicate we did not start locally. + // There is certainly room for improvement here like perhaps reading the Terminal window for "devc" vs "dev" commands, but this is + // ok for now. 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); + 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 (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. + * Tests that the correct dependency projects are added to the debug source lookup list */ @Test - public void testStartWithCustomDebugAsConfig() { + public void testDebugSourceLookupContent() { 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"); + Shell configShell = launchDebugConfigurationsDialogFromAppRunAs(MVN_APP_NAME); - // If there are issues with the workspace, close the error dialog. - pressWorkspaceErrorDialogProceedButton(bot); + boolean jarEntryFound = false; 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); + Object 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)."); + openSourceTab(bot); - SWTBotCombo comboJREBox = getComboTextBoxWithTextPrefix(bot, buildPathJRE); + SWTBotTreeItem defaultSourceLookupTree = new SWTBotTreeItem((TreeItem) getDefaultSourceLookupTreeItemNoBot(configShell)); + + // Lookup test-shared-lib-jar project + try { + defaultSourceLookupTree.getNode(MVN_SHARED_LIB_NAME); + jarEntryFound = true; + } catch (WidgetNotFoundException wnfe) { + // Jar project was not found in source lookup list. + } - 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); + deleteLibertyToolsRunConfigEntriesFromAppRunAs(MVN_APP_NAME); } - } - - /** - * 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; - } - } + // Validate dependency projects are in source lookup list + Assertions.assertTrue(jarEntryFound, + "The dependency project, " + MVN_SHARED_LIB_NAME + ", was not listed in the source lookup list for project " + + MVN_APP_NAME); - Assertions.assertTrue(newMavenAppFound, () -> "The Maven project should be listed in the dashboard."); } } diff --git a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMultiModMavenTest.java b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMultiModMavenTest.java index 8050456e..76169031 100644 --- a/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMultiModMavenTest.java +++ b/tests/src/main/java/io/openliberty/tools/eclipse/test/it/LibertyPluginSWTBotMultiModMavenTest.java @@ -12,15 +12,19 @@ *******************************************************************************/ package io.openliberty.tools.eclipse.test.it; +import static io.openliberty.tools.eclipse.test.it.utils.MagicWidgetFinder.context; import static io.openliberty.tools.eclipse.test.it.utils.MagicWidgetFinder.go; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.deleteLibertyToolsRunConfigEntriesFromAppRunAs; 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.launchDebugConfigurationsDialogFromAppRunAs; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchRunConfigurationsDialogFromAppRunAs; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchStartWithDefaultRunConfigFromAppRunAs; import static io.openliberty.tools.eclipse.test.it.utils.SWTBotPluginOperations.launchStopWithRunAsShortcut; +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; @@ -34,7 +38,9 @@ import org.eclipse.core.resources.ResourcesPlugin; 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.SWTBotMenu; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem; import org.junit.jupiter.api.AfterAll; @@ -60,6 +66,21 @@ public class LibertyPluginSWTBotMultiModMavenTest extends AbstractLibertyPluginS */ static final String MVN_APP_NAME = "guide-maven-multimodules-pom"; + /** + * Parent name. + */ + static final String MVN_PARENT_NAME = "guide-maven-multimodules"; + + /** + * Jar sub-module name. + */ + static final String MVN_JAR_NAME = "guide-maven-multimodules-jar"; + + /** + * War sub-module name + */ + static final String MVN_WAR_NAME = "guide-maven-multimodules-war1"; + /** * Path to import from, in this case the multi-module root */ @@ -274,4 +295,99 @@ public void testStartWithDefaultRunAsConfig() { // Close the terminal. terminal.close(); } + + /** + * Tests that the correct dependency projects are added to the debug source lookup list + */ + @Test + public void testDebugSourceLookupContentSiblingModule() { + + Shell configShell = launchDebugConfigurationsDialogFromAppRunAs(MVN_APP_NAME); + + boolean jarEntryFound = false; + boolean warEntryFound = false; + + try { + Object libertyConfigTree = getLibertyTreeItemNoBot(configShell); + + context(libertyConfigTree, "New Configuration"); + + openSourceTab(bot); + + SWTBotTreeItem defaultSourceLookupTree = new SWTBotTreeItem((TreeItem) getDefaultSourceLookupTreeItemNoBot(configShell)); + + try { + defaultSourceLookupTree.getNode(MVN_JAR_NAME); + jarEntryFound = true; + } catch (WidgetNotFoundException wnfe) { + // Jar project was not found in source lookup list. + } + + // Lookup war project + try { + defaultSourceLookupTree.getNode(MVN_WAR_NAME); + warEntryFound = true; + } catch (WidgetNotFoundException wnfe) { + // War project was not found in source lookup list. + } + + } finally { + go("Close", configShell); + } + + // Validate dependency projects are in source lookup list + Assertions.assertTrue(jarEntryFound, + "The sibling module project, " + MVN_JAR_NAME + ", was not listed in the source lookup list for project " + MVN_APP_NAME); + Assertions.assertTrue(warEntryFound, + "The sibling module project, " + MVN_WAR_NAME + ", was not listed in the source lookup list for project " + MVN_APP_NAME); + + } + + /** + * Tests that the correct dependency projects are added to the debug source lookup list when starting the parent module + */ + @Test + public void testDebugSourceLookupContentParentModule() { + + Shell configShell = launchDebugConfigurationsDialogFromAppRunAs(MVN_PARENT_NAME); + + boolean jarEntryFound = false; + boolean warEntryFound = false; + + try { + Object libertyConfigTree = getLibertyTreeItemNoBot(configShell); + + context(libertyConfigTree, "New Configuration"); + + openSourceTab(bot); + + SWTBotTreeItem defaultSourceLookupTree = new SWTBotTreeItem((TreeItem) getDefaultSourceLookupTreeItemNoBot(configShell)); + + // Lookup jar project + try { + defaultSourceLookupTree.getNode(MVN_JAR_NAME); + jarEntryFound = true; + } catch (WidgetNotFoundException wnfe) { + // Jar project was not found in source lookup list. + } + + // Lookup war project + try { + defaultSourceLookupTree.getNode(MVN_WAR_NAME); + warEntryFound = true; + } catch (WidgetNotFoundException wnfe) { + // War project was not found in source lookup list. + } + + } finally { + go("Close", configShell); + } + + // Validate dependency projects are in source lookup list + Assertions.assertTrue(jarEntryFound, + "The child module project, " + MVN_JAR_NAME + ", was not listed in the source lookup list for project " + MVN_PARENT_NAME); + Assertions.assertTrue(warEntryFound, + "The child module project, " + MVN_WAR_NAME + ", was not listed in the source lookup list for project " + MVN_PARENT_NAME); + + } } 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 227e52e6..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; @@ -124,24 +125,25 @@ public void run() { public static void openJavaPerspectiveViaMenu() { Object windowMenu = findGlobal("Window", Option.factory().widgetClass(MenuItem.class).build()); - + if (new SWTWorkbenchBot().activePerspective().getLabel().equals("Java")) { - // Won't be an option to switch to if already active + // Won't be an option to switch to if already active return; } else { goMenuItem(windowMenu, "Perspective", "Open Perspective", "Java"); } } - + public static SWTBotTable getDashboardTable() { openDashboardUsingToolbar(); Object dashboardView = findGlobal(DASHBOARD_VIEW_TITLE, Option.factory().widgetClass(ViewPart.class).build()); - Table table = ((DashboardView)dashboardView).getTable(); + Table table = ((DashboardView) dashboardView).getTable(); return new SWTBotTable(table); } /** * Returns a list of entries on the Open Liberty dashboard. + * * @return A list of entries on the Open Liberty dashboard. */ public static List getDashboardContent() { @@ -194,6 +196,7 @@ public static void refreshProjectUsingExplorerView(String appName) { /** * Launches a dashboard action for the specified application name. + * * @param appName The application name to select. * @param action The action to select */ @@ -292,7 +295,7 @@ public static void setBuildCmdPathInPreferences(SWTWorkbenchBot bot, String buil String finalMvnExecutableLoc = null; String finalGradleExecutableLoc = null; - Object locationLabel = null; + Object locationLabel = null; Object locationText = null; finalMvnExecutableLoc = System.getProperty("io.liberty.tools.eclipse.tests.mvnexecutable.path"); @@ -314,7 +317,7 @@ public static void setBuildCmdPathInPreferences(SWTWorkbenchBot bot, String buil } goGlobal("Apply and Close"); - } + } public static void unsetBuildCmdPathInPreferences(SWTWorkbenchBot bot, String buildTool) { @@ -324,12 +327,12 @@ public static void unsetBuildCmdPathInPreferences(SWTWorkbenchBot bot, String bu if (Platform.getOS().equals(Platform.OS_MACOSX)) { return; } - + Object windowMenu = findGlobal("Window", Option.factory().widgetClass(MenuItem.class).build()); goMenuItem(windowMenu, "Preferences"); findGlobal("Liberty", Option.factory().widgetClass(TreeItem.class).build()); - + goGlobal("Restore Defaults"); goGlobal("Apply and Close"); } @@ -342,13 +345,13 @@ public static void unsetBuildCmdPathInPreferences(SWTWorkbenchBot bot, String bu public static Shell launchRunConfigurationsDialogFromAppRunAs(String appName) { Object project = getAppInPackageExplorerTree(appName); - + MagicWidgetFinder.context(project, "Run As", "Run Configurations..."); // Return the newly launched configurations shell return (Shell) findGlobal("Run Configurations", Option.factory().widgetClass(Shell.class).build()); } - + /** * Launches the run configuration dialog. * @@ -357,7 +360,7 @@ public static Shell launchRunConfigurationsDialogFromAppRunAs(String appName) { public static Shell launchDebugConfigurationsDialogFromAppRunAs(String appName) { Object project = getAppInPackageExplorerTree(appName); - + MagicWidgetFinder.context(project, "Debug As", "Debug Configurations..."); // Return the newly launched configurations shell @@ -387,13 +390,19 @@ public static SWTBotTreeItem getLibertyTreeItem(Shell shell) { } public static TreeItem getLibertyTreeItemNoBot(Shell shell) { - TreeItem ti = (TreeItem)find(LAUNCH_CONFIG_LIBERTY_MENU_NAME, shell); + TreeItem ti = (TreeItem) find(LAUNCH_CONFIG_LIBERTY_MENU_NAME, shell); expandTreeItem(ti); return ti; } - + + public static TreeItem getDefaultSourceLookupTreeItemNoBot(Shell shell) { + TreeItem ti = (TreeItem) find("Default", shell); + expandTreeItem(ti); + return ti; + } + public static SWTBotTreeItem getRemoteJavaAppConfigMenuItem(Shell shell) { - return new SWTBotTreeItem((TreeItem)find(LAUNCH_CONFIG_REMOTE_JAVA_APP, shell)); + return new SWTBotTreeItem((TreeItem) find(LAUNCH_CONFIG_REMOTE_JAVA_APP, shell)); } /** @@ -408,7 +417,7 @@ public static void deleteLibertyToolsRunConfigEntriesFromAppRunAs(String appName try { SWTBotTreeItem libertyToolsEntry = getLibertyTreeItem(configShell); - + Assertions.assertTrue((libertyToolsEntry != null), () -> "The Liberty entry was not found in run Configurations dialog."); List configs = libertyToolsEntry.getNodes(); @@ -441,7 +450,7 @@ public static void deleteLibertyToolsDebugConfigEntriesFromMenu() { } // Delete debug mode Remote Java Application configurations - SWTBotTreeItem remoteJavaAppEntry = getRemoteJavaAppConfigMenuItem(configShell); + SWTBotTreeItem remoteJavaAppEntry = getRemoteJavaAppConfigMenuItem(configShell); Assertions.assertTrue((remoteJavaAppEntry != null), () -> "The " + LAUNCH_CONFIG_REMOTE_JAVA_APP + " entry was not found in run Configurations dialog."); @@ -453,7 +462,7 @@ public static void deleteLibertyToolsDebugConfigEntriesFromMenu() { MagicWidgetFinder.go("Close", configShell); } } - + private static void deleteRunDebugConfigEntry(SWTBotTreeItem parentTree, String configName) { go(configName, parentTree); goGlobal("Delete selected launch configuration(s)", Option.factory().widgetClass(ToolItem.class).useContains(true).build()); @@ -468,9 +477,9 @@ private static void deleteRunDebugConfigEntry(SWTBotTreeItem parentTree, String public static void launchStartWithDefaultRunConfigFromAppRunAs(String appName) { Object project = getAppInPackageExplorerTree(appName); - context(project, "Run As", + context(project, "Run As", WidgetMatcherFactory.withRegex(".*" + LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_START + ".*")); - + } /** @@ -489,7 +498,7 @@ public static void launchStartWithNewCustomRunConfig(String appName, String cust /** * Launches dev mode with parms using a new Liberty configuration: project -> Debug As -> Debug Configurations -> Liberty -> New * configuration (default) -> update parms -> Debug. Note that the changes are not saved. - * + * * @param appName The application name. * @param customParms The parameter(s) to pass to the dev mode start action. */ @@ -498,7 +507,7 @@ public static void launchStartWithNewCustomDebugConfig(String appName, String cu createAndSetNewCustomConfig(shell, customParms); go("Debug", shell); } - + public static void createAndSetNewCustomConfig(Shell shell, String customParms) { Object libertyConfigTree = find(LAUNCH_CONFIG_LIBERTY_MENU_NAME, shell); @@ -508,35 +517,35 @@ public static void createAndSetNewCustomConfig(Shell shell, String customParms) Control parmText = ControlFinder.findControlInRange(parmLabel, Text.class, Direction.EAST); set(parmText, customParms); } - + public static Shell getDebugConfigurationsShell() { - return (Shell) findGlobal("Debug Configurations", Option.factory().widgetClass(Shell.class).build()); + return (Shell) findGlobal("Debug Configurations", Option.factory().widgetClass(Shell.class).build()); } - + public static Shell getRunConfigurationsShell() { - return (Shell) findGlobal("Run Configurations", Option.factory().widgetClass(Shell.class).build()); + return (Shell) findGlobal("Run Configurations", Option.factory().widgetClass(Shell.class).build()); } - + public static void launchCustomDebugFromDashboard(String appName, String customParms) { - launchDashboardAction(appName, DashboardView.APP_MENU_ACTION_DEBUG_CONFIG); + launchDashboardAction(appName, DashboardView.APP_MENU_ACTION_DEBUG_CONFIG); Shell shell = getDebugConfigurationsShell(); setCustomStartParmsFromShell(shell, appName, customParms); go("Debug", shell); } public static void launchCustomRunFromDashboard(String appName, String customParms) { - launchDashboardAction(appName, DashboardView.APP_MENU_ACTION_START_CONFIG); + launchDashboardAction(appName, DashboardView.APP_MENU_ACTION_START_CONFIG); Shell shell = getRunConfigurationsShell(); setCustomStartParmsFromShell(shell, appName, customParms); go("Run", shell); } - public static void setCustomStartParmsFromShell(Shell shell, String runDebugConfigName, String customParms) { - - Object libertyConfigTree = getLibertyTreeItem(shell); - Object appConfigEntry = find(runDebugConfigName, libertyConfigTree, Option.factory().useContains(true).widgetClass(TreeItem.class).build()); + Object libertyConfigTree = getLibertyTreeItem(shell); + + Object appConfigEntry = find(runDebugConfigName, libertyConfigTree, + Option.factory().useContains(true).widgetClass(TreeItem.class).build()); go(appConfigEntry); Object parmLabel = find("Start parameters:", appConfigEntry, Option.factory().widgetClass(Label.class).build()); @@ -544,12 +553,24 @@ public static void setCustomStartParmsFromShell(Shell shell, String runDebugConf set(parmText, customParms); } + public static void checkRunInContainerCheckBox(Shell shell, String runDebugConfigName) { + + Object libertyConfigTree = getLibertyTreeItem(shell); + + Object appConfigEntry = find(runDebugConfigName, libertyConfigTree, + Option.factory().useContains(true).widgetClass(TreeItem.class).build()); + go(appConfigEntry); + Object button = find("Run in Container", appConfigEntry, Option.factory().widgetClass(Button.class).build()); + + go(button); + } + public static Object getAppInPackageExplorerTree(String appName) { openJavaPerspectiveViaMenu(); Object windowMenu = findGlobal("Window", Option.factory().widgetClass(MenuItem.class).build()); goMenuItem(windowMenu, "Show View", "Package Explorer"); Object peView = MagicWidgetFinder.findGlobal("Package Explorer"); - + Object project = MagicWidgetFinder.find(appName, peView, Option.factory().useContains(true).widgetClass(TreeItem.class).build()); go(project); return project; @@ -590,7 +611,6 @@ public static void launchStopWithRunAsShortcut(String appName) { WidgetMatcherFactory.withRegex(".*" + LaunchConfigurationDelegateLauncher.LAUNCH_SHORTCUT_STOP + ".*")); } - /** * Launches the run tests action using the run as configuration shortcut. * @@ -673,7 +693,7 @@ public static void enableLibertyTools(String appName) { Object project = getAppInPackageExplorerTree(appName); - context(project, "Configure", + context(project, "Configure", WidgetMatcherFactory.withRegex(".*" + EXPLORER_CONFIGURE_MENU_ENABLE_LIBERTY_TOOLS + ".*")); } @@ -827,6 +847,20 @@ public static void openJRETab(SWTWorkbenchBot bot) { tabItem.activate().setFocus(); } + /** + * Switches the Liberty run configuration main tab to the Source Tab. A Liberty configuration must be opened prior to calling this + * method. + * + * @param bot The SWTWorkbenchBot instance. + */ + public static void openSourceTab(SWTWorkbenchBot bot) { + SWTBotShell shell = bot.shell("Debug Configurations"); + shell.activate().setFocus(); + SWTBot shellBot = shell.bot(); + SWTBotCTabItem tabItem = shellBot.cTabItem("Source"); + tabItem.activate().setFocus(); + } + /** * Presses the Proceed button if it exists on the error in workspace dialog. * @@ -836,7 +870,7 @@ public static void pressWorkspaceErrorDialogProceedButton(SWTWorkbenchBot bot) { try { bot.button("Proceed").click(); } catch (Exception e) { - // Not a problem if error wasn't generated. Continue... + // Not a problem if error wasn't generated. Continue... } } @@ -923,5 +957,4 @@ public boolean matches(Object object) { } } - } diff --git a/tests/src/main/java/io/openliberty/tools/eclipse/test/ut/LibertyPluginUnitTest.java b/tests/src/main/java/io/openliberty/tools/eclipse/test/ut/LibertyPluginUnitTest.java index cf364702..998506cd 100644 --- a/tests/src/main/java/io/openliberty/tools/eclipse/test/ut/LibertyPluginUnitTest.java +++ b/tests/src/main/java/io/openliberty/tools/eclipse/test/ut/LibertyPluginUnitTest.java @@ -36,8 +36,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; -import io.openliberty.tools.eclipse.DebugModeHandler; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationDelegateLauncher.RuntimeEnv; +import io.openliberty.tools.eclipse.debug.DebugModeHandler; import io.openliberty.tools.eclipse.ui.launch.LaunchConfigurationHelper; import io.openliberty.tools.eclipse.ui.launch.StartTab;