Skip to content

Commit 955d5fa

Browse files
committed
Remove obsolete AbstractLaunchTest class
The class is used as a superclass in the inheritance hierarchy of debug test but just contains utility methods that are better provided as utility method in a dedicated utility class than messing up the inheritance hierarchy. This change moves the utility methods to the existing TestUtil class and removed the obsolete class from the inheritance hierarchy.
1 parent bd34de0 commit 955d5fa

9 files changed

Lines changed: 70 additions & 75 deletions

File tree

debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,19 @@
2727
import java.util.function.Supplier;
2828

2929
import org.eclipse.core.internal.jobs.JobManager;
30+
import org.eclipse.core.runtime.CoreException;
3031
import org.eclipse.core.runtime.ILog;
3132
import org.eclipse.core.runtime.IStatus;
3233
import org.eclipse.core.runtime.Status;
3334
import org.eclipse.core.runtime.jobs.Job;
35+
import org.eclipse.debug.core.DebugPlugin;
36+
import org.eclipse.debug.core.ILaunchConfiguration;
37+
import org.eclipse.debug.core.ILaunchConfigurationType;
38+
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
39+
import org.eclipse.debug.core.ILaunchManager;
40+
import org.eclipse.debug.internal.ui.DebugUIPlugin;
41+
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager;
42+
import org.eclipse.debug.tests.launching.LaunchConfigurationTests;
3443
import org.eclipse.swt.widgets.Display;
3544
import org.junit.Assert;
3645
import org.osgi.framework.Bundle;
@@ -335,4 +344,42 @@ private static boolean belongsToFamilies(Job job, Object... excludedFamilies) {
335344
return false;
336345
}
337346

347+
/**
348+
* Returns the launch manager.
349+
*
350+
* @return launch manager
351+
*/
352+
public static ILaunchManager getLaunchManager() {
353+
return DebugPlugin.getDefault().getLaunchManager();
354+
}
355+
356+
/**
357+
* Returns the singleton instance of the <code>LaunchConfigurationManager</code>
358+
*
359+
* @return the singleton instance of the <code>LaunchConfigurationManager</code>
360+
*/
361+
public static LaunchConfigurationManager getLaunchConfigurationManager() {
362+
return DebugUIPlugin.getDefault().getLaunchConfigurationManager();
363+
}
364+
365+
/**
366+
* Returns a launch configuration with the given name, creating one if required.
367+
*
368+
* @param configurationName configuration name
369+
* @return launch configuration
370+
*/
371+
public static ILaunchConfiguration getLaunchConfiguration(String configurationName) throws CoreException {
372+
ILaunchManager manager = getLaunchManager();
373+
ILaunchConfiguration[] configurations = manager.getLaunchConfigurations();
374+
for (ILaunchConfiguration config : configurations) {
375+
if (config.getName().equals(configurationName)) {
376+
return config;
377+
}
378+
}
379+
ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(LaunchConfigurationTests.ID_TEST_LAUNCH_TYPE);
380+
ILaunchConfigurationWorkingCopy wc = type.newInstance(null, configurationName);
381+
ILaunchConfiguration saved = wc.doSave();
382+
return saved;
383+
}
384+
338385
}

debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AbstractLaunchTest.java

Lines changed: 0 additions & 68 deletions
This file was deleted.

debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package org.eclipse.debug.tests.launching;
1616

1717
import static org.assertj.core.api.Assertions.assertThat;
18+
import static org.eclipse.debug.tests.TestUtil.getLaunchManager;
1819
import static org.junit.Assert.assertEquals;
1920
import static org.junit.Assert.assertFalse;
2021
import static org.junit.Assert.assertNotEquals;
@@ -77,6 +78,7 @@
7778
import org.eclipse.debug.core.model.IProcess;
7879
import org.eclipse.debug.internal.core.LaunchConfiguration;
7980
import org.eclipse.debug.internal.core.LaunchManager;
81+
import org.eclipse.debug.tests.AbstractDebugTest;
8082
import org.eclipse.debug.tests.TestsPlugin;
8183
import org.eclipse.debug.tests.console.MockProcess;
8284
import org.eclipse.debug.ui.DebugUITools;
@@ -91,7 +93,7 @@
9193
* Tests for launch configurations
9294
*/
9395
@SuppressWarnings("deprecation")
94-
public class LaunchConfigurationTests extends AbstractLaunchTest implements ILaunchConfigurationListener {
96+
public class LaunchConfigurationTests extends AbstractDebugTest implements ILaunchConfigurationListener {
9597

9698
/**
9799
* Identifier of test launch configuration type extension

debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchFavoriteTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
package org.eclipse.debug.tests.launching;
1515

1616
import static org.assertj.core.api.Assertions.assertThat;
17+
import static org.eclipse.debug.tests.TestUtil.getLaunchConfigurationManager;
1718
import static org.junit.Assert.assertFalse;
1819
import static org.junit.Assert.assertNotNull;
1920
import static org.junit.Assert.assertTrue;
@@ -25,6 +26,7 @@
2526
import org.eclipse.debug.core.ILaunchConfiguration;
2627
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
2728
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
29+
import org.eclipse.debug.tests.AbstractDebugTest;
2830
import org.eclipse.debug.ui.IDebugUIConstants;
2931
import org.junit.After;
3032
import org.junit.Before;
@@ -36,7 +38,7 @@
3638
*
3739
* @since 3.6
3840
*/
39-
public class LaunchFavoriteTests extends AbstractLaunchTest {
41+
public class LaunchFavoriteTests extends AbstractDebugTest {
4042

4143
/**
4244
* Configuration to use for the test. One is created for each test during

debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
package org.eclipse.debug.tests.launching;
1515

1616
import static org.assertj.core.api.Assertions.assertThat;
17+
import static org.eclipse.debug.tests.TestUtil.getLaunchConfiguration;
18+
import static org.eclipse.debug.tests.TestUtil.getLaunchConfigurationManager;
19+
import static org.eclipse.debug.tests.TestUtil.getLaunchManager;
1720
import static org.junit.Assert.assertEquals;
1821
import static org.junit.Assert.assertTrue;
1922

@@ -50,13 +53,14 @@
5053
import org.eclipse.debug.internal.core.groups.GroupLaunchElement.GroupElementPostLaunchAction;
5154
import org.eclipse.debug.internal.ui.DebugUIPlugin;
5255
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
56+
import org.eclipse.debug.tests.AbstractDebugTest;
5357
import org.eclipse.debug.tests.TestUtil;
5458
import org.eclipse.debug.ui.IDebugUIConstants;
5559
import org.junit.After;
5660
import org.junit.Before;
5761
import org.junit.Test;
5862

59-
public class LaunchGroupTests extends AbstractLaunchTest {
63+
public class LaunchGroupTests extends AbstractDebugTest {
6064

6165
private static final String GROUP_TYPE = "org.eclipse.debug.core.groups.GroupLaunchConfigurationType"; //$NON-NLS-1$
6266
private static final String DEF_GRP_NAME = "Test Group"; //$NON-NLS-1$

debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchHistoryTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
package org.eclipse.debug.tests.launching;
1515

1616
import static org.assertj.core.api.Assertions.assertThat;
17+
import static org.eclipse.debug.tests.TestUtil.getLaunchConfiguration;
18+
import static org.eclipse.debug.tests.TestUtil.getLaunchConfigurationManager;
1719
import static org.junit.Assert.assertEquals;
1820
import static org.junit.Assert.assertNotNull;
1921
import static org.junit.Assert.assertTrue;
@@ -25,6 +27,7 @@
2527
import org.eclipse.debug.core.ILaunchManager;
2628
import org.eclipse.debug.internal.ui.DebugUIPlugin;
2729
import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory;
30+
import org.eclipse.debug.tests.AbstractDebugTest;
2831
import org.eclipse.debug.ui.IDebugUIConstants;
2932
import org.eclipse.jface.preference.PreferenceMemento;
3033
import org.junit.After;
@@ -40,7 +43,7 @@
4043
*
4144
* @since 3.3
4245
*/
43-
public class LaunchHistoryTests extends AbstractLaunchTest {
46+
public class LaunchHistoryTests extends AbstractDebugTest {
4447

4548
private final PreferenceMemento prefMemento = new PreferenceMemento();
4649

debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*******************************************************************************/
1414
package org.eclipse.debug.tests.launching;
1515

16+
import static org.eclipse.debug.tests.TestUtil.getLaunchConfiguration;
17+
import static org.eclipse.debug.tests.TestUtil.getLaunchManager;
1618
import static org.junit.Assert.assertEquals;
1719
import static org.junit.Assert.assertFalse;
1820
import static org.junit.Assert.assertNotNull;
@@ -35,6 +37,7 @@
3537
import org.eclipse.debug.core.ILaunchManager;
3638
import org.eclipse.debug.internal.core.LaunchManager;
3739
import org.eclipse.debug.internal.ui.DebugUIPlugin;
40+
import org.eclipse.debug.tests.AbstractDebugTest;
3841
import org.eclipse.debug.tests.launching.CancellingLaunchDelegate.CancellingLaunch;
3942
import org.eclipse.debug.tests.launching.ThrowingLaunchDelegate.ThrowingEnum;
4043
import org.eclipse.debug.tests.launching.ThrowingLaunchDelegate.ThrowingLaunch;
@@ -50,7 +53,7 @@
5053
* @since 3.6
5154
*/
5255
@SuppressWarnings("deprecation")
53-
public class LaunchManagerTests extends AbstractLaunchTest {
56+
public class LaunchManagerTests extends AbstractDebugTest {
5457

5558

5659
/**

debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.eclipse.debug.core.model.IDebugTarget;
4747
import org.eclipse.debug.core.model.IDisconnect;
4848
import org.eclipse.debug.core.model.IProcess;
49+
import org.eclipse.debug.tests.AbstractDebugTest;
4950
import org.junit.Before;
5051
import org.junit.ClassRule;
5152
import org.junit.Test;
@@ -56,7 +57,7 @@
5657
*
5758
* @since 3.10
5859
*/
59-
public class LaunchTests extends AbstractLaunchTest {
60+
public class LaunchTests extends AbstractDebugTest {
6061

6162
/**
6263
* Windows MAX_PATH limit for file paths. See

debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/RefreshTabTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.eclipse.debug.core.RefreshUtil;
3030
import org.eclipse.debug.internal.core.RefreshScopeComparator;
3131
import org.eclipse.debug.internal.core.sourcelookup.SourceLocatorMementoComparator;
32+
import org.eclipse.debug.tests.AbstractDebugTest;
3233
import org.eclipse.debug.tests.TestsPlugin;
3334
import org.eclipse.debug.ui.RefreshTab;
3435
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -44,7 +45,7 @@
4445
/**
4546
* Tests the refresh tab.
4647
*/
47-
public class RefreshTabTests extends AbstractLaunchTest {
48+
public class RefreshTabTests extends AbstractDebugTest {
4849

4950
/**
5051
* Sets the selected resource in the navigator view.

0 commit comments

Comments
 (0)