diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java index 56e942994da..69c3a8c6345 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestUtil.java @@ -28,10 +28,19 @@ import java.util.function.Supplier; import org.eclipse.core.internal.jobs.JobManager; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.ILog; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.debug.core.DebugPlugin; +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.debug.internal.ui.DebugUIPlugin; +import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; +import org.eclipse.debug.tests.launching.LaunchConfigurationTests; import org.eclipse.swt.widgets.Display; import org.junit.Assert; import org.osgi.framework.Bundle; @@ -332,4 +341,42 @@ private static boolean belongsToFamilies(Job job, Object... excludedFamilies) { return false; } + /** + * Returns the launch manager. + * + * @return launch manager + */ + public static ILaunchManager getLaunchManager() { + return DebugPlugin.getDefault().getLaunchManager(); + } + + /** + * Returns the singleton instance of the LaunchConfigurationManager + * + * @return the singleton instance of the LaunchConfigurationManager + */ + public static LaunchConfigurationManager getLaunchConfigurationManager() { + return DebugUIPlugin.getDefault().getLaunchConfigurationManager(); + } + + /** + * Returns a launch configuration with the given name, creating one if required. + * + * @param configurationName configuration name + * @return launch configuration + */ + public static ILaunchConfiguration getLaunchConfiguration(String configurationName) throws CoreException { + ILaunchManager manager = getLaunchManager(); + ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(); + for (ILaunchConfiguration config : configurations) { + if (config.getName().equals(configurationName)) { + return config; + } + } + ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(LaunchConfigurationTests.ID_TEST_LAUNCH_TYPE); + ILaunchConfigurationWorkingCopy wc = type.newInstance(null, configurationName); + ILaunchConfiguration saved = wc.doSave(); + return saved; + } + } diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AbstractLaunchTest.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AbstractLaunchTest.java deleted file mode 100644 index f143c8694d9..00000000000 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/AbstractLaunchTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.tests.launching; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.DebugPlugin; -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.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationManager; - -/** - * Common function for launch related tests. - */ -public abstract class AbstractLaunchTest { - - /** - * Returns the launch manager. - * - * @return launch manager - */ - protected ILaunchManager getLaunchManager() { - return DebugPlugin.getDefault().getLaunchManager(); - } - - /** - * Returns the singleton instance of the LaunchConfigurationManager - * - * @return the singleton instance of the LaunchConfigurationManager - */ - protected LaunchConfigurationManager getLaunchConfigurationManager() { - return DebugUIPlugin.getDefault().getLaunchConfigurationManager(); - } - - /** - * Returns a launch configuration with the given name, creating one if required. - * - * @param configurationName configuration name - * @return launch configuration - */ - protected ILaunchConfiguration getLaunchConfiguration(String configurationName) throws CoreException { - ILaunchManager manager = getLaunchManager(); - ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(); - for (ILaunchConfiguration config : configurations) { - if (config.getName().equals(configurationName)) { - return config; - } - } - ILaunchConfigurationType type = getLaunchManager().getLaunchConfigurationType(LaunchConfigurationTests.ID_TEST_LAUNCH_TYPE); - ILaunchConfigurationWorkingCopy wc = type.newInstance(null, configurationName); - ILaunchConfiguration saved = wc.doSave(); - return saved; - } -} diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java index 49c67f23367..ba6b39c81fd 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java @@ -15,6 +15,7 @@ package org.eclipse.debug.tests.launching; import static org.assertj.core.api.Assertions.assertThat; +import static org.eclipse.debug.tests.TestUtil.getLaunchManager; import static org.eclipse.debug.tests.TestUtil.waitWhile; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -92,7 +93,7 @@ * Tests for launch configurations */ @SuppressWarnings("deprecation") -public class LaunchConfigurationTests extends AbstractLaunchTest implements ILaunchConfigurationListener { +public class LaunchConfigurationTests implements ILaunchConfigurationListener { /** * Identifier of test launch configuration type extension diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchFavoriteTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchFavoriteTests.java index 41823b25366..22c9b5a51b5 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchFavoriteTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchFavoriteTests.java @@ -14,6 +14,7 @@ package org.eclipse.debug.tests.launching; import static org.assertj.core.api.Assertions.assertThat; +import static org.eclipse.debug.tests.TestUtil.getLaunchConfigurationManager; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -25,6 +26,7 @@ import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.internal.ui.launchConfigurations.LaunchHistory; +import org.eclipse.debug.tests.TestUtil; import org.eclipse.debug.ui.IDebugUIConstants; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -37,7 +39,7 @@ * * @since 3.6 */ -public class LaunchFavoriteTests extends AbstractLaunchTest { +public class LaunchFavoriteTests { /** * Configuration to use for the test. One is created for each test during @@ -64,7 +66,7 @@ public void setUp(TestInfo testInfo) throws Exception { // clear the favorites getRunLaunchHistory().setFavorites(new ILaunchConfiguration[0]); getDebugLaunchHistory().setFavorites(new ILaunchConfiguration[0]); - fConfig = getLaunchConfiguration(testInfo.getDisplayName()); + fConfig = TestUtil.getLaunchConfiguration(testInfo.getDisplayName()); } @AfterEach diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java index 49ff8588033..42f896edac7 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchGroupTests.java @@ -14,6 +14,9 @@ package org.eclipse.debug.tests.launching; import static org.assertj.core.api.Assertions.assertThat; +import static org.eclipse.debug.tests.TestUtil.getLaunchConfiguration; +import static org.eclipse.debug.tests.TestUtil.getLaunchConfigurationManager; +import static org.eclipse.debug.tests.TestUtil.getLaunchManager; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -57,7 +60,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInfo; -public class LaunchGroupTests extends AbstractLaunchTest { +public class LaunchGroupTests { private static final String GROUP_TYPE = "org.eclipse.debug.core.groups.GroupLaunchConfigurationType"; //$NON-NLS-1$ private static final String DEF_GRP_NAME = "Test Group"; //$NON-NLS-1$ diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchHistoryTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchHistoryTests.java index f28177bda97..5fe59bd9d5a 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchHistoryTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchHistoryTests.java @@ -14,6 +14,8 @@ package org.eclipse.debug.tests.launching; import static org.assertj.core.api.Assertions.assertThat; +import static org.eclipse.debug.tests.TestUtil.getLaunchConfiguration; +import static org.eclipse.debug.tests.TestUtil.getLaunchConfigurationManager; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -40,7 +42,7 @@ * * @since 3.3 */ -public class LaunchHistoryTests extends AbstractLaunchTest { +public class LaunchHistoryTests { private final PreferenceMemento prefMemento = new PreferenceMemento(); diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java index 139f0afaae0..f075f8328a2 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchManagerTests.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.debug.tests.launching; +import static org.eclipse.debug.tests.TestUtil.getLaunchConfiguration; +import static org.eclipse.debug.tests.TestUtil.getLaunchManager; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -50,7 +52,7 @@ * @since 3.6 */ @SuppressWarnings("deprecation") -public class LaunchManagerTests extends AbstractLaunchTest { +public class LaunchManagerTests { /** diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java index 767de923458..a82f999c833 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchTests.java @@ -57,7 +57,7 @@ * * @since 3.10 */ -public class LaunchTests extends AbstractLaunchTest { +public class LaunchTests { /** * Windows MAX_PATH limit for file paths. See diff --git a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/RefreshTabTests.java b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/RefreshTabTests.java index f6437ba9e2e..e91ea92df6a 100644 --- a/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/RefreshTabTests.java +++ b/debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/RefreshTabTests.java @@ -44,7 +44,7 @@ /** * Tests the refresh tab. */ -public class RefreshTabTests extends AbstractLaunchTest { +public class RefreshTabTests { /** * Sets the selected resource in the navigator view.