Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rennie2014-08-05 16:22:02 +0000
committerMike Rennie2014-08-05 16:22:02 +0000
commit5c825eba98cb4bdc1e263a8f48592971484b2623 (patch)
treecc6911d1b12dab765d116608c26b94238b9b106c
parent4f500655f939aceeb1b96a11aec968af7bce1501 (diff)
downloadeclipse.platform.debug-5c825eba98cb4bdc1e263a8f48592971484b2623.tar.gz
eclipse.platform.debug-5c825eba98cb4bdc1e263a8f48592971484b2623.tar.xz
eclipse.platform.debug-5c825eba98cb4bdc1e263a8f48592971484b2623.zip
Bug 437122 - Stale launches in Debug view after canceling "Save andI20140806-0800I20140805-2000
Launch" dialog - unit tests Change-Id: I52464a557cccf2245d552b2fb5a40be476f236fd
-rw-r--r--org.eclipse.debug.tests/Platform Debug Test Suite.launch2
-rwxr-xr-xorg.eclipse.debug.tests/plugin.properties3
-rw-r--r--org.eclipse.debug.tests/plugin.xml6
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/CancellingLaunchDelegate.java60
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java117
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/TestLaunchDelegate.java8
6 files changed, 188 insertions, 8 deletions
diff --git a/org.eclipse.debug.tests/Platform Debug Test Suite.launch b/org.eclipse.debug.tests/Platform Debug Test Suite.launch
index c1e027bc5..4372b9637 100644
--- a/org.eclipse.debug.tests/Platform Debug Test Suite.launch
+++ b/org.eclipse.debug.tests/Platform Debug Test Suite.launch
@@ -23,7 +23,7 @@
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.debug.tests.AutomatedSuite"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.debug.tests"/>
diff --git a/org.eclipse.debug.tests/plugin.properties b/org.eclipse.debug.tests/plugin.properties
index d4f2ab171..d8d27f7ca 100755
--- a/org.eclipse.debug.tests/plugin.properties
+++ b/org.eclipse.debug.tests/plugin.properties
@@ -16,4 +16,5 @@ renderingType.name = Rendering One
renderingType.name.0 = Rendering Two
renderingType.name.1 = Rendering Default
launchConfigurationType.name = Test Launch Type
-extension.name = Debug File System \ No newline at end of file
+extension.name = Debug File System
+launchConfigurationType.name.0 = Cancelling Launch Type \ No newline at end of file
diff --git a/org.eclipse.debug.tests/plugin.xml b/org.eclipse.debug.tests/plugin.xml
index acfac4c0a..c9492fd93 100644
--- a/org.eclipse.debug.tests/plugin.xml
+++ b/org.eclipse.debug.tests/plugin.xml
@@ -62,6 +62,12 @@
modes="run, debug"
name="%launchConfigurationType.name">
</launchConfigurationType>
+ <launchConfigurationType
+ delegate="org.eclipse.debug.tests.launching.CancellingLaunchDelegate"
+ id="cancelling.type"
+ modes="run"
+ name="%launchConfigurationType.name.0">
+ </launchConfigurationType>
</extension>
<extension
id="debugFS"
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/CancellingLaunchDelegate.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/CancellingLaunchDelegate.java
new file mode 100644
index 000000000..5c763820b
--- /dev/null
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/CancellingLaunchDelegate.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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 API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.tests.launching;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.Launch;
+import org.eclipse.debug.core.model.ILaunchConfigurationDelegate2;
+import org.eclipse.debug.core.model.ISourceLocator;
+
+/**
+ * Test launch delegate that will always cancel the launch
+ *
+ * @since 3.9.100
+ */
+public class CancellingLaunchDelegate implements ILaunchConfigurationDelegate2 {
+
+ class CancellingLaunch extends Launch {
+
+ public CancellingLaunch(ILaunchConfiguration launchConfiguration, String mode, ISourceLocator locator) {
+ super(launchConfiguration, mode, locator);
+ setAttribute("cancel.launch", Boolean.toString(true)); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ // do nothing, this thing does not launch
+ }
+
+ @Override
+ public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
+ return new CancellingLaunch(configuration, "run", null); //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
+ return configuration.getAttribute("cancel.buildForLaunch", true); //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean finalLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
+ return configuration.getAttribute("cancel.finalLaunchCheck", true); //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
+ return configuration.getAttribute("cancel.preLaunchCheck", true); //$NON-NLS-1$
+ }
+}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java
index aa8964576..7cdb3eab5 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java
@@ -10,9 +10,14 @@
*******************************************************************************/
package org.eclipse.debug.tests.launching;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
+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.internal.core.LaunchManager;
+import org.eclipse.debug.tests.launching.CancellingLaunchDelegate.CancellingLaunch;
/**
*
@@ -201,4 +206,116 @@ public class LaunchManagerTests extends AbstractLaunchTest {
label = LaunchManager.removeAccelerators(text);
assertEquals("the label should be 'Remove'", "Remove", label); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ /**
+ * Create a new configuration that will cancel one of the three checks: 1.
+ * preLaunchCheck 2. finalLaunchCheck 3. buildForLaunch
+ *
+ * @param pre If the prelaunchCheck should cancel
+ * @param fin If the fnalLaunchCheck should cancel
+ * @param build If the buildForLaunch check should cancel
+ * @return the new {@link ILaunchConfiguration}
+ * @since 3.9.100
+ */
+ ILaunchConfiguration getCancellingConfiguration(boolean pre, boolean fin, boolean build) throws Exception {
+ ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType("cancelling.type"); //$NON-NLS-1$
+ if (type != null) {
+ ILaunchConfigurationWorkingCopy copy = type.newInstance(null, getLaunchManager().generateLaunchConfigurationName("cancelling")); //$NON-NLS-1$
+ copy.setAttribute("cancel.preLaunchCheck", !pre); //$NON-NLS-1$
+ copy.setAttribute("cancel.finalLaunchCheck", !fin); //$NON-NLS-1$
+ copy.setAttribute("cancel.buildForLaunch", !build); //$NON-NLS-1$
+ return copy.doSave();
+ }
+ return null;
+ }
+
+ /**
+ * Checks if the expected number of cancelled launches appear in the manager
+ *
+ * @param count the expected count
+ * @since 3.9.100
+ */
+ void hasCancellingLaunches(int count) {
+ ILaunch[] launches = getLaunchManager().getLaunches();
+ int num = 0;
+ for (int i = 0; i < launches.length; i++) {
+ if (launches[i] instanceof CancellingLaunch) {
+ num++;
+ }
+ }
+ assertEquals("The number of expected launches is wrong", count, num); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests if a launch is properly removed from the launch manager when
+ * #preLaunchCheck is cancelled
+ *
+ * @throws Exception
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=437122
+ * @since 3.9.100
+ */
+ public void testCancelledPreLaunchCheck() throws Exception {
+ ILaunchConfiguration config = getCancellingConfiguration(true, false, false);
+ assertNotNull("The cancelling config should have been created", config); //$NON-NLS-1$
+ try {
+ hasCancellingLaunches(0);
+ config.launch("run", new NullProgressMonitor()); //$NON-NLS-1$
+ hasCancellingLaunches(0);
+ } finally {
+ ILaunch[] launches = getLaunchManager().getLaunches();
+ for (int i = 0; i < launches.length; i++) {
+ getLaunchManager().removeLaunch(launches[i]);
+ }
+ config.delete();
+ }
+ }
+
+ /**
+ * Tests if a launch is properly removed from the launch manager when
+ * #finalLaunchCheck is cancelled
+ *
+ * @throws Exception
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=437122
+ * @since 3.9.100
+ */
+ public void testCancelledFinalLaunchCheck() throws Exception {
+ ILaunchConfiguration config = getCancellingConfiguration(false, true, false);
+ assertNotNull("The cancelling config should have been created", config); //$NON-NLS-1$
+ try {
+ hasCancellingLaunches(0);
+ config.launch("run", new NullProgressMonitor()); //$NON-NLS-1$
+ hasCancellingLaunches(0);
+ } finally {
+ ILaunch[] launches = getLaunchManager().getLaunches();
+ for (int i = 0; i < launches.length; i++) {
+ getLaunchManager().removeLaunch(launches[i]);
+ }
+ config.delete();
+ }
+ }
+
+ /**
+ * Tests if a launch is properly removed from the launch manager when
+ * #buildFoLaunch is cancelled
+ *
+ * @throws Exception
+ * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=437122
+ * @since 3.9.100
+ */
+ public void testCancelledBuildForLaunch() throws Exception {
+ ILaunchConfiguration config = getCancellingConfiguration(false, false, true);
+ assertNotNull("The cancelling config should have been created", config); //$NON-NLS-1$
+ try {
+ hasCancellingLaunches(0);
+ config.launch("run", new NullProgressMonitor()); //$NON-NLS-1$
+ hasCancellingLaunches(1); // XXX #buildForLaunch does not remove the
+ // launch
+ } finally {
+ ILaunch[] launches = getLaunchManager().getLaunches();
+ for (int i = 0; i < launches.length; i++) {
+ getLaunchManager().removeLaunch(launches[i]);
+ }
+ config.delete();
+ }
+ }
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/TestLaunchDelegate.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/TestLaunchDelegate.java
index ff80f8830..4a83dbfbe 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/TestLaunchDelegate.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/TestLaunchDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
+ * Copyright (c) 2009, 2014 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
@@ -17,16 +17,12 @@ import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
/**
- * An empty lauch delegate
+ * An empty launch delegate
*/
public class TestLaunchDelegate extends LaunchConfigurationDelegate {
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
- */
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
// do nothing
}
-
}

Back to the top