diff --git a/ui/org.eclipse.pde.ui.tests/pom.xml b/ui/org.eclipse.pde.ui.tests/pom.xml index 74f53c06b5d..bbc8251291a 100644 --- a/ui/org.eclipse.pde.ui.tests/pom.xml +++ b/ui/org.eclipse.pde.ui.tests/pom.xml @@ -25,7 +25,7 @@ -warn:-discouraged true ${project.artifactId} - org.eclipse.pde.ui.tests.AllPDEMinimalTests + org.eclipse.pde.ui.tests.AllPDETests diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/AllPDEMinimalTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/AllPDEMinimalTests.java deleted file mode 100644 index d7f7ecb091d..00000000000 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/AllPDEMinimalTests.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 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.pde.ui.tests; - -import org.eclipse.pde.core.tests.internal.AllPDECoreTests; -import org.eclipse.pde.core.tests.internal.classpath.ClasspathResolutionTest; -import org.eclipse.pde.core.tests.internal.core.builders.BundleErrorReporterTest; -import org.eclipse.pde.core.tests.internal.util.PDESchemaHelperTest; -import org.eclipse.pde.ui.tests.build.properties.AllValidatorTests; -import org.eclipse.pde.ui.tests.classpathresolver.ClasspathResolverTest; -import org.eclipse.pde.ui.tests.launcher.AllLauncherTests; -import org.eclipse.pde.ui.tests.model.bundle.AllBundleModelTests; -import org.eclipse.pde.ui.tests.model.xml.AllXMLModelTests; -import org.eclipse.pde.ui.tests.nls.AllNLSTests; -import org.eclipse.pde.ui.tests.preferences.AllPreferenceTests; -import org.eclipse.pde.ui.tests.project.BundleRootTests; -import org.eclipse.pde.ui.tests.project.DynamicPluginProjectReferencesTest; -import org.eclipse.pde.ui.tests.project.PluginRegistryTestsMinimal; -import org.eclipse.pde.ui.tests.project.ProjectCreationTests; -import org.eclipse.pde.ui.tests.runtime.AllPDERuntimeTests; -import org.eclipse.pde.ui.tests.target.AllTargetMinimalTests; -import org.eclipse.pde.ui.tests.views.log.AllLogViewTests; -import org.eclipse.pde.ui.tests.wizards.AllNewProjectMinimalTests; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * They run on minimal plugin bundles and dont require the whole SDK ( for - * hudson gerrit). This class is refactored out of AllPDETests - * - */ - -@RunWith(Suite.class) -@SuiteClasses({ AllTargetMinimalTests.class, AllNewProjectMinimalTests.class, AllPreferenceTests.class, - // AllImportTests.class, - AllBundleModelTests.class, AllXMLModelTests.class, AllValidatorTests.class, AllNLSTests.class, - AllPDERuntimeTests.class, - // ExportBundleTests.class, - AllLauncherTests.class, AllLogViewTests.class, ProjectCreationTests.class, BundleRootTests.class, - PluginRegistryTestsMinimal.class, ClasspathResolverTest.class, PDESchemaHelperTest.class, - DynamicPluginProjectReferencesTest.class, - // ClasspathContributorTest.class - ClasspathResolutionTest.class, - BundleErrorReporterTest.class, - AllPDECoreTests.class -}) -public class AllPDEMinimalTests { - -} diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/AllPDETests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/AllPDETests.java index e4f7f8e59ff..1efac64e24f 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/AllPDETests.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/AllPDETests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005,2021 IBM Corporation and others. + * Copyright (c) 2005, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -15,6 +15,8 @@ import org.eclipse.pde.core.tests.internal.AllPDECoreTests; import org.eclipse.pde.core.tests.internal.classpath.ClasspathResolutionTest; +import org.eclipse.pde.core.tests.internal.core.builders.BundleErrorReporterTest; +import org.eclipse.pde.core.tests.internal.util.PDESchemaHelperTest; import org.eclipse.pde.ui.tests.build.properties.AllValidatorTests; import org.eclipse.pde.ui.tests.classpathcontributor.ClasspathContributorTest; import org.eclipse.pde.ui.tests.classpathresolver.ClasspathResolverTest; @@ -38,27 +40,29 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) -@SuiteClasses({ - AllTargetTests.class, - AllNewProjectTests.class, - AllPreferenceTests.class, - AllImportTests.class, - AllBundleModelTests.class, - AllXMLModelTests.class, - AllValidatorTests.class, - AllNLSTests.class, - AllPDERuntimeTests.class, - ExportBundleTests.class, - AllLauncherTests.class, - AllLogViewTests.class, - ProjectCreationTests.class, - BundleRootTests.class, - PluginRegistryTests.class, - ClasspathResolverTest.class, - ClasspathContributorTest.class, - DynamicPluginProjectReferencesTest.class, - ClasspathResolutionTest.class, - AllPDECoreTests.class +@SuiteClasses({ // + AllTargetTests.class, // + AllNewProjectTests.class, // + AllPreferenceTests.class, // + AllImportTests.class, // + AllBundleModelTests.class, // + AllXMLModelTests.class, // + AllValidatorTests.class, // + AllNLSTests.class, // + AllPDERuntimeTests.class, // + ExportBundleTests.class, // + AllLauncherTests.class, // + AllLogViewTests.class, // + ProjectCreationTests.class, // + BundleRootTests.class, // + PluginRegistryTests.class, // + ClasspathResolverTest.class, // + PDESchemaHelperTest.class, // + ClasspathContributorTest.class, // + DynamicPluginProjectReferencesTest.class, // + ClasspathResolutionTest.class, // + BundleErrorReporterTest.class, // + AllPDECoreTests.class // }) public class AllPDETests { diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestCase.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestCase.java index 64e1015a91e..6f9b268740d 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestCase.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/PDETestCase.java @@ -14,6 +14,12 @@ package org.eclipse.pde.ui.tests; import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspaceRoot; @@ -22,6 +28,7 @@ import org.eclipse.core.runtime.ICoreRunnable; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; @@ -131,4 +138,15 @@ private static void closeIntro(final IWorkbench wb) { } } } + + public static void assumeRunningInStandaloneEclipseSDK() { + try { + Path location = Path.of(Platform.getInstallLocation().getURL().toURI()); + for (String directory : List.of("plugins", "features")) { + assumeTrue("Not running in a standalone Eclipse SDK", Files.isDirectory(location.resolve(directory))); + } + } catch (URISyntaxException e) { + throw new IllegalStateException(e); + } + } } diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/PluginRegistryTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/PluginRegistryTests.java index e7575d05ddc..32d32468b21 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/PluginRegistryTests.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/PluginRegistryTests.java @@ -15,10 +15,20 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.osgi.service.resolver.VersionRange; import org.eclipse.pde.core.plugin.IMatchRules; +import org.eclipse.pde.core.plugin.IPluginBase; import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.plugin.PluginRegistry; +import org.eclipse.pde.core.plugin.PluginRegistry.PluginFilter; +import org.eclipse.pde.core.project.IBundleProjectDescription; import org.junit.Test; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.Version; @@ -28,11 +38,160 @@ * * @since 3.6 */ -public class PluginRegistryTests extends PluginRegistryTestsMinimal { +public class PluginRegistryTests { + + @Test + public void testMatchNone() { + IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", null, IMatchRules.NONE, null); + assertNotNull(model); + assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); + } + + @Test + public void testMatchGreaterOrEqual() { + IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", "3.0.0", + IMatchRules.GREATER_OR_EQUAL, null); + assertNotNull(model); + assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); + } + + @Test + public void testMatchPerfect() { + IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", "3.0.0", IMatchRules.PERFECT, null); + assertNull(model); + } + + @Test + public void testMatchCompatible() { + IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", "3.6.0", IMatchRules.COMPATIBLE, + null); + assertNotNull(model); + assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); + } + + @Test + public void testMatchCompatibleNone() { + IPluginModelBase model = PluginRegistry.findModel("org.eclipse.pde.core", "2.6.0", IMatchRules.COMPATIBLE, + null); + assertNull(model); + } + + @Test + public void testMatchPrefix() { + IPluginModelBase model = PluginRegistry.findModel("org.eclipse", "3.6.0", IMatchRules.PREFIX, null); + // prefix rule is not supported by this API, should return null + assertNull(model); + } + + @Test + public void testRangeNone() { + IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", null, null); + assertNotNull(model); + assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); + } + + @Test + public void testOverlapRange() { + IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", new VersionRange("[2.0.0,4.0.0)"), + null); + assertNotNull(model); + assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); + } + + @Test + public void testMinRange() { + IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", new VersionRange("3.0.0"), null); + assertNotNull(model); + assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); + } + + @Test + public void testUnmatchedRange() { + IPluginModelBase model = PluginRegistry.findModel("org.eclipse.pde.core", new VersionRange("[1.0.0,2.0.0)"), + null); + assertNull(model); + } + + @Test + public void testRangeWithFilterMatch() { + PluginFilter filter = new PluginFilter() { + @Override + public boolean accept(IPluginModelBase model) { + IPluginBase base = model.getPluginBase(); + if (base != null) { + String id = base.getId(); + if (id != null) { + return id.startsWith("org.eclipse"); + } + } + return false; + } + }; + IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", new VersionRange("[2.0.0,4.0.0)"), + filter); + assertNotNull(model); + assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); + } + + @Test + public void testRangeWithFilterNoMatch() { + PluginFilter filter = new PluginFilter() { + @Override + public boolean accept(IPluginModelBase model) { + IPluginBase base = model.getPluginBase(); + if (base != null) { + String id = base.getId(); + if (id != null) { + return id.startsWith("xyz"); + } + } + return false; + } + }; + IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", new VersionRange("[2.0.0,4.0.0)"), + filter); + assertNull(model); + } + + @Test + public void testSingleRangeMatch() { + IPluginModelBase[] models = PluginRegistry.findModels("org.eclipse.jdt.debug", + new VersionRange("[1.0.0,4.0.0)"), null); + assertNotNull(models); + assertEquals(1, models.length); + assertEquals("org.eclipse.jdt.debug", models[0].getPluginBase().getId()); + } + + @Test + public void testWorkspaceOverTarget() throws CoreException { + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("org.junit"); + try { + IBundleProjectDescription description = ProjectCreationTests.getBundleProjectService() + .getDescription(project); + description.setSymbolicName("org.junit"); + description.setBundleVersion(new Version("4.3.2")); + description.setBundleVendor("bogus"); + description.apply(null); + + waitForBuild(); + + IPluginModelBase[] models = PluginRegistry.findModels("org.junit", new VersionRange("[3.8.2,4.8.2]"), null); + assertNotNull(models); + assertEquals(1, models.length); + assertEquals("org.junit", models[0].getPluginBase().getId()); + assertEquals(project, models[0].getUnderlyingResource().getProject()); + + } finally { + if (project.exists()) { + project.delete(true, null); + waitForBuild(); + } + } + } @Test public void testMatchEquivalent() { - Version testsVersion = FrameworkUtil.getBundle(getClass()).getVersion(); + Version testsVersion = FrameworkUtil.getBundle(PluginRegistryTests.class).getVersion(); IPluginModelBase model = PluginRegistry.findModel("org.eclipse.pde.ui.tests", String.format("%s.%s.%s", testsVersion.getMajor(), testsVersion.getMinor(), testsVersion.getMicro()), IMatchRules.EQUIVALENT, @@ -40,4 +199,22 @@ public void testMatchEquivalent() { assertNotNull("NOTE: This test might also fail because the version of the bundle got changed.", model); assertEquals("org.eclipse.pde.ui.tests", model.getPluginBase().getId()); } + + /** + * Wait for builds to complete + */ + public static void waitForBuild() { + boolean wasInterrupted = false; + do { + try { + Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null); + Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_BUILD, null); + wasInterrupted = false; + } catch (OperationCanceledException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + wasInterrupted = true; + } + } while (wasInterrupted); + } } diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/PluginRegistryTestsMinimal.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/PluginRegistryTestsMinimal.java deleted file mode 100644 index c03f21cc3cb..00000000000 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/PluginRegistryTestsMinimal.java +++ /dev/null @@ -1,204 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2017 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.pde.ui.tests.project; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.osgi.service.resolver.VersionRange; -import org.eclipse.pde.core.plugin.IMatchRules; -import org.eclipse.pde.core.plugin.IPluginBase; -import org.eclipse.pde.core.plugin.IPluginModelBase; -import org.eclipse.pde.core.plugin.PluginRegistry; -import org.eclipse.pde.core.plugin.PluginRegistry.PluginFilter; -import org.eclipse.pde.core.project.IBundleProjectDescription; -import org.junit.Test; -import org.osgi.framework.Version; - -/** - * Tests for plug-in searching /** Tests whether targets and bundle containers - * manage features correctly. Runs on minimal bundles and not the whole eclipse - * SDK. This class is refactored out of PluginRegistryTests - * - * @since 3.6 - */ - -public class PluginRegistryTestsMinimal { - - @Test - public void testMatchNone() { - IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", null, IMatchRules.NONE, null); - assertNotNull(model); - assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); - } - - @Test - public void testMatchGreaterOrEqual() { - IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", "3.0.0", IMatchRules.GREATER_OR_EQUAL, null); - assertNotNull(model); - assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); - } - - @Test - public void testMatchPerfect() { - IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", "3.0.0", IMatchRules.PERFECT, null); - assertNull(model); - } - - @Test - public void testMatchCompatible() { - IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", "3.6.0", IMatchRules.COMPATIBLE, - null); - assertNotNull(model); - assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); - } - - @Test - public void testMatchCompatibleNone() { - IPluginModelBase model = PluginRegistry.findModel("org.eclipse.pde.core", "2.6.0", IMatchRules.COMPATIBLE, null); - assertNull(model); - } - - @Test - public void testMatchPrefix() { - IPluginModelBase model = PluginRegistry.findModel("org.eclipse", "3.6.0", IMatchRules.PREFIX, null); - // prefix rule is not supported by this API, should return null - assertNull(model); - } - - @Test - public void testRangeNone() { - IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", null, null); - assertNotNull(model); - assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); - } - - @Test - public void testOverlapRange() { - IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", new VersionRange("[2.0.0,4.0.0)"), null); - assertNotNull(model); - assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); - } - - @Test - public void testMinRange() { - IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", new VersionRange("3.0.0"), null); - assertNotNull(model); - assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); - } - - @Test - public void testUnmatchedRange() { - IPluginModelBase model = PluginRegistry.findModel("org.eclipse.pde.core", new VersionRange("[1.0.0,2.0.0)"), null); - assertNull(model); - } - - @Test - public void testRangeWithFilterMatch() { - PluginFilter filter = new PluginFilter() { - @Override - public boolean accept(IPluginModelBase model) { - IPluginBase base = model.getPluginBase(); - if (base != null) { - String id = base.getId(); - if (id != null) { - return id.startsWith("org.eclipse"); - } - } - return false; - } - }; - IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", new VersionRange("[2.0.0,4.0.0)"), filter); - assertNotNull(model); - assertEquals("org.eclipse.jdt.debug", model.getPluginBase().getId()); - } - - @Test - public void testRangeWithFilterNoMatch() { - PluginFilter filter = new PluginFilter() { - @Override - public boolean accept(IPluginModelBase model) { - IPluginBase base = model.getPluginBase(); - if (base != null) { - String id = base.getId(); - if (id != null) { - return id.startsWith("xyz"); - } - } - return false; - } - }; - IPluginModelBase model = PluginRegistry.findModel("org.eclipse.jdt.debug", new VersionRange("[2.0.0,4.0.0)"), filter); - assertNull(model); - } - - @Test - public void testSingleRangeMatch() { - IPluginModelBase[] models = PluginRegistry.findModels("org.eclipse.jdt.debug", - new VersionRange("[1.0.0,4.0.0)"), null); - assertNotNull(models); - assertEquals(1, models.length); - assertEquals("org.eclipse.jdt.debug", models[0].getPluginBase().getId()); - } - - @Test - public void testWorkspaceOverTarget() throws CoreException { - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("org.junit"); - try { - IBundleProjectDescription description = ProjectCreationTests.getBundleProjectService().getDescription(project); - description.setSymbolicName("org.junit"); - description.setBundleVersion(new Version("4.3.2")); - description.setBundleVendor("bogus"); - description.apply(null); - - waitForBuild(); - - IPluginModelBase[] models = PluginRegistry.findModels("org.junit", new VersionRange("[3.8.2,4.8.2]"), null); - assertNotNull(models); - assertEquals(1, models.length); - assertEquals("org.junit", models[0].getPluginBase().getId()); - assertEquals(project, models[0].getUnderlyingResource().getProject()); - - } finally { - if (project.exists()) { - project.delete(true, null); - waitForBuild(); - } - } - } - - /** - * Wait for builds to complete - */ - public static void waitForBuild() { - boolean wasInterrupted = false; - do { - try { - Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null); - Job.getJobManager().join(ResourcesPlugin.FAMILY_MANUAL_BUILD, null); - wasInterrupted = false; - } catch (OperationCanceledException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - wasInterrupted = true; - } - } while (wasInterrupted); - } -} diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/AllTargetMinimalTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/AllTargetMinimalTests.java deleted file mode 100644 index a6c94b2a575..00000000000 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/AllTargetMinimalTests.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2017 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.pde.ui.tests.target; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * They run on minimal plugin bundles and dont require the whole SDK ( for - * hudson gerrit). This class is refactored out of AllTargetTests - * - */ -@RunWith(Suite.class) -@SuiteClasses({ - TargetEnvironmentTestCase.class, // - TargetPlatformHelperTests.class, // - // LocalTargetDefinitionTests.class, - // WorkspaceTargetDefinitionTests.class - MinimalTargetDefinitionPersistenceTests.class, // - MinimalTargetDefinitionResolutionTests.class, // - MinimalTargetDefinitionFeatureResolutionTests.class, // - IUBundleContainerTests.class, // - ProfileContainerTests.class -}) -public class AllTargetMinimalTests { -} diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java index e9e8966492b..b78589cde7e 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/LocalTargetDefinitionTests.java @@ -55,7 +55,9 @@ import org.eclipse.pde.internal.core.target.TargetDefinitionPersistenceHelper; import org.eclipse.pde.internal.core.target.TargetPlatformService; import org.eclipse.pde.internal.launching.launcher.LaunchArgumentsHelper; +import org.eclipse.pde.ui.tests.PDETestCase; import org.eclipse.pde.ui.tests.PDETestsPlugin; +import org.junit.BeforeClass; import org.junit.Test; import org.osgi.framework.ServiceReference; @@ -69,6 +71,11 @@ */ public class LocalTargetDefinitionTests extends AbstractTargetTest { + @BeforeClass + public static void requireStandaloneEclipseSDKEnvironment() { + PDETestCase.assumeRunningInStandaloneEclipseSDK(); + } + public static final NameVersionDescriptor MULTI_VERSION_LOW_DESCRIPTION = new NameVersionDescriptor( "a.typical.bundle", "1.0.0.200907071058"); public static final NameVersionDescriptor MULTI_VERSION_HIGH_DESCRIPTION = new NameVersionDescriptor( diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/MinimalTargetDefinitionFeatureResolutionTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/MinimalTargetDefinitionFeatureResolutionTests.java deleted file mode 100644 index 2e2750ab147..00000000000 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/MinimalTargetDefinitionFeatureResolutionTests.java +++ /dev/null @@ -1,378 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2018 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.pde.ui.tests.target; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.pde.core.plugin.TargetPlatform; -import org.eclipse.pde.core.target.ITargetDefinition; -import org.eclipse.pde.core.target.ITargetLocation; -import org.eclipse.pde.core.target.NameVersionDescriptor; -import org.eclipse.pde.core.target.TargetBundle; -import org.eclipse.pde.core.target.TargetFeature; -import org.eclipse.pde.internal.core.PDECore; -import org.eclipse.pde.internal.core.ifeature.IFeatureModel; -import org.junit.Test; - -/** - * Tests whether targets and bundle containers manage features correctly. Runs - * on minimal bundles and not the whole eclipse SDK. This class is refactored - * out of TargetDefinitionFeatureResolutionTests - */ -public class MinimalTargetDefinitionFeatureResolutionTests extends AbstractTargetTest { - - /** - * Tests that a directory bundle container provides the correct features to - * a target - */ - @Test - public void testDirectoryBundleContainer() throws Exception { - ITargetDefinition definition = getNewTarget(); - ITargetLocation directoryContainer = getTargetService() - .newDirectoryLocation(TargetPlatform.getDefaultLocation()); - - assertNull(directoryContainer.getFeatures()); - - IFeatureModel[] expectedFeatures = PDECore.getDefault().getFeatureModelManager().getModels(); - Set expectedIDs = new HashSet<>(); - for (IFeatureModel expectedFeature : expectedFeatures) { - expectedIDs.add(expectedFeature.getFeature().getId()); - } - - directoryContainer.resolve(definition, null); - TargetFeature[] features = directoryContainer.getFeatures(); - assertNotNull(features); - - for (TargetFeature feature : features) { - String currentID = feature.getId(); - assertTrue("Extra feature in result: " + currentID, expectedIDs.contains(currentID)); - expectedIDs.remove(currentID); - } - - assertTrue("Not all expected features returned by the container: " + expectedIDs.toString(), - expectedIDs.isEmpty()); - } - - /** - * Tests that a profile (installation) bundle container provides the correct - * features to a target - */ - @Test - public void testProfileBundleContainer() throws Exception { - ITargetDefinition definition = getNewTarget(); - ITargetLocation profileContainer = getTargetService().newProfileLocation(TargetPlatform.getDefaultLocation(), - null); - - assertNull(profileContainer.getFeatures()); - - IFeatureModel[] expectedFeatures = PDECore.getDefault().getFeatureModelManager().getModels(); - Set expectedIDs = new HashSet<>(); - for (IFeatureModel expectedFeature : expectedFeatures) { - expectedIDs.add(expectedFeature.getFeature().getId()); - } - - profileContainer.resolve(definition, null); - TargetFeature[] features = profileContainer.getFeatures(); - assertNotNull(features); - - for (TargetFeature feature : features) { - String currentID = feature.getId(); - assertTrue("Extra feature in result: " + currentID, expectedIDs.contains(currentID)); - expectedIDs.remove(currentID); - } - - assertTrue("Not all expected features returned by the container: " + expectedIDs.toString(), - expectedIDs.isEmpty()); - } - - @Test - public void testExplicitIncludes() throws Exception { - // Use the modified JDT features as we know their versions - ITargetDefinition definition = getNewTarget(); - IPath location = extractModifiedFeatures(); - - ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); - definition.setTargetLocations(new ITargetLocation[] { container }); - definition.resolve(null); - - List expected = new ArrayList<>(); - expected.add("org.eclipse.jdt"); - expected.add("org.eclipse.jdt.launching"); - expected.add("org.eclipse.jdt.launching.source"); - // 2 versions of JUnit - expected.add("org.junit"); - expected.add("org.junit.source"); - expected.add("org.junit"); - expected.add("org.junit.source"); - expected.add("org.junit4"); - if (Platform.getOS().equals(Platform.OS_MACOSX)) { - expected.add("org.eclipse.jdt.launching.macosx"); - expected.add("org.eclipse.jdt.launching.macosx.source"); - } - - NameVersionDescriptor[] allFeatures = new NameVersionDescriptor[] { - new NameVersionDescriptor("org.eclipse.jdt", "3.6.0.v20100105-0800-7z8VFR9FMTb52_pOyKHhoek1", - NameVersionDescriptor.TYPE_FEATURE), - new NameVersionDescriptor("org.eclipse.jdt.source", "3.6.0.v20100105-0800-7z8VFR9FMTb52_pOyKHhoek1", - NameVersionDescriptor.TYPE_FEATURE) }; - definition.setIncluded(allFeatures); - TargetBundle[] bundles = definition.getBundles(); - - for (TargetBundle bundle : bundles) { - String symbolicName = bundle.getBundleInfo().getSymbolicName(); - expected.remove(symbolicName); - if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) { - // the bundle should be missing unless on Mac - IStatus status = bundle.getStatus(); - if (Platform.getOS().equals(Platform.OS_MACOSX)) { - assertTrue("Mac bundle should be present", status.isOK()); - } else { - assertFalse("Mac bundle should be missing", status.isOK()); - assertEquals("Mac bundle should be mssing", TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST, - status.getCode()); - } - } - } - for (String name : expected) { - System.err.println("Missing: " + name); - } - assertTrue("Wrong bundles in JDT feature", expected.isEmpty()); - - } - - @Test - public void testSingleInclude() throws Exception { - // Use the modified JDT features as we know their versions - ITargetDefinition definition = getNewTarget(); - IPath location = extractModifiedFeatures(); - - ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); - definition.setTargetLocations(new ITargetLocation[] { container }); - definition.resolve(null); - - List expected = new ArrayList<>(); - expected.add("org.eclipse.jdt"); - expected.add("org.eclipse.jdt.launching"); - // 2 versions of JUnit - expected.add("org.junit"); - expected.add("org.junit"); - expected.add("org.junit4"); - if (Platform.getOS().equals(Platform.OS_MACOSX)) { - expected.add("org.eclipse.jdt.launching.macosx"); - } - - NameVersionDescriptor[] allFeatures = new NameVersionDescriptor[] { - new NameVersionDescriptor("org.eclipse.jdt", null, NameVersionDescriptor.TYPE_FEATURE) }; - definition.setIncluded(allFeatures); - TargetBundle[] bundles = definition.getBundles(); - - for (TargetBundle bundle : bundles) { - String symbolicName = bundle.getBundleInfo().getSymbolicName(); - expected.remove(symbolicName); - if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) { - // the bundle should be missing unless on Mac - IStatus status = bundle.getStatus(); - if (Platform.getOS().equals(Platform.OS_MACOSX)) { - assertTrue("Mac bundle should be present", status.isOK()); - } else { - assertFalse("Mac bundle should be missing", status.isOK()); - assertEquals("Mac bundle should be missing", TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST, - status.getCode()); - } - } - } - for (String name : expected) { - System.err.println("Missing: " + name); - } - assertTrue("Wrong bundles in JDT feature", expected.isEmpty()); - } - - @Test - public void testMixedIncludes() throws Exception { - // Use the modified JDT features as we know their versions - ITargetDefinition definition = getNewTarget(); - IPath location = extractModifiedFeatures(); - - ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); - definition.setTargetLocations(new ITargetLocation[] { container }); - definition.resolve(null); - - List expected = new ArrayList<>(); - expected.add("org.eclipse.jdt"); - expected.add("org.eclipse.jdt.launching"); - // 2 versions of JUnit - expected.add("org.junit"); - expected.add("org.junit"); - expected.add("org.junit4"); - if (Platform.getOS().equals(Platform.OS_MACOSX)) { - expected.add("org.eclipse.jdt.launching.macosx"); - } - - NameVersionDescriptor[] allFeatures = new NameVersionDescriptor[] { - new NameVersionDescriptor("org.eclipse.jdt", null, NameVersionDescriptor.TYPE_FEATURE), - new NameVersionDescriptor("org.eclipse.jdt", null, NameVersionDescriptor.TYPE_PLUGIN) }; - definition.setIncluded(allFeatures); - TargetBundle[] bundles = definition.getBundles(); - - for (TargetBundle bundle : bundles) { - String symbolicName = bundle.getBundleInfo().getSymbolicName(); - expected.remove(symbolicName); - if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) { - // the bundle should be missing unless on Mac - IStatus status = bundle.getStatus(); - if (Platform.getOS().equals(Platform.OS_MACOSX)) { - assertTrue("Mac bundle should be present", status.isOK()); - } else { - assertFalse("Mac bundle should be missing", status.isOK()); - assertEquals("Mac bundle should be mssing", TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST, - status.getCode()); - } - } - } - for (String name : expected) { - System.err.println("Missing: " + name); - } - assertTrue("Wrong bundles in JDT feature", expected.isEmpty()); - } - - @Test - public void testMissingFeatures() throws Exception { - // Use the modified JDT features as we know their versions - ITargetDefinition definition = getNewTarget(); - IPath location = extractModifiedFeatures(); - - ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); - definition.setTargetLocations(new ITargetLocation[] { container }); - definition.resolve(null); - - NameVersionDescriptor[] allFeatures = new NameVersionDescriptor[] { - new NameVersionDescriptor("DOES_NOT_EXIST", null, NameVersionDescriptor.TYPE_FEATURE), }; - definition.setIncluded(allFeatures); - TargetBundle[] bundles = definition.getBundles(); - - assertNotNull("Target didn't resolve", bundles); - assertEquals("Wrong number of included bundles", 1, bundles.length); - - IStatus definitionStatus = definition.getStatus(); - assertEquals("Wrong severity", IStatus.ERROR, definitionStatus.getSeverity()); - - IStatus[] children = definitionStatus.getChildren(); - assertEquals("Wrong number of statuses", 1, children.length); - assertEquals("Wrong severity", IStatus.ERROR, children[0].getSeverity()); - assertEquals(TargetBundle.STATUS_FEATURE_DOES_NOT_EXIST, children[0].getCode()); - - // Check that removing the included bundles and resolving removes the - // errors. - definition.setIncluded(null); - assertTrue(definition.isResolved()); - assertTrue(definition.getStatus().isOK()); - assertTrue(definition.getBundles().length > 4); - } - - @Test - public void testMissingFeatureVersion() throws Exception { - // Use the modified JDT features as we know their versions - ITargetDefinition definition = getNewTarget(); - IPath location = extractModifiedFeatures(); - - ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); - definition.setTargetLocations(new ITargetLocation[] { container }); - definition.resolve(null); - - List expected = new ArrayList<>(); - expected.add("org.eclipse.jdt"); - expected.add("org.eclipse.jdt.launching"); - // 2 versions of JUnit - expected.add("org.junit"); - expected.add("org.junit"); - expected.add("org.junit4"); - if (Platform.getOS().equals(Platform.OS_MACOSX)) { - expected.add("org.eclipse.jdt.launching.macosx"); - } - - NameVersionDescriptor[] allFeatures = new NameVersionDescriptor[] { - new NameVersionDescriptor("org.eclipse.jdt", "DOES_NOT_EXIST", NameVersionDescriptor.TYPE_FEATURE) }; - definition.setIncluded(allFeatures); - TargetBundle[] bundles = definition.getBundles(); - - for (TargetBundle bundle : bundles) { - String symbolicName = bundle.getBundleInfo().getSymbolicName(); - expected.remove(symbolicName); - if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) { - // the bundle should be missing unless on Mac - IStatus status = bundle.getStatus(); - if (Platform.getOS().equals(Platform.OS_MACOSX)) { - assertTrue("Mac bundle should be present", status.isOK()); - } else { - assertFalse("Mac bundle should be missing", status.isOK()); - assertEquals("Mac bundle should be mssing", TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST, - status.getCode()); - } - } - } - for (String name : expected) { - System.err.println("Missing: " + name); - } - assertTrue("Wrong bundles in JDT feature", expected.isEmpty()); - } - - @Test - public void testMissingMixed() throws Exception { - // Use the modified JDT features as we know their versions - ITargetDefinition definition = getNewTarget(); - IPath location = extractModifiedFeatures(); - - ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); - definition.setTargetLocations(new ITargetLocation[] { container }); - definition.resolve(null); - - NameVersionDescriptor[] allFeatures = new NameVersionDescriptor[] { - new NameVersionDescriptor("DOES_NOT_EXIST", null, NameVersionDescriptor.TYPE_FEATURE), - new NameVersionDescriptor("DOES_NOT_EXIST", null, NameVersionDescriptor.TYPE_PLUGIN), - new NameVersionDescriptor("org.eclipse.jdt", "DOES_NOT_EXIST", NameVersionDescriptor.TYPE_PLUGIN), }; - definition.setIncluded(allFeatures); - TargetBundle[] bundles = definition.getBundles(); - - assertNotNull("Target didn't resolve", bundles); - assertEquals("Wrong number of included bundles", 1, bundles.length); - - IStatus definitionStatus = definition.getStatus(); - assertEquals("Wrong severity", IStatus.ERROR, definitionStatus.getSeverity()); - - IStatus[] children = definitionStatus.getChildren(); - assertEquals("Wrong number of statuses", 1, children.length); - assertEquals("Wrong severity", IStatus.ERROR, children[0].getSeverity()); - assertEquals(TargetBundle.STATUS_FEATURE_DOES_NOT_EXIST, children[0].getCode()); - - // Check that removing the included bundles and resolving removes the - // errors. - definition.setIncluded(null); - assertTrue(definition.isResolved()); - assertTrue(definition.getStatus().isOK()); - assertTrue(definition.getBundles().length > 4); - } - -} \ No newline at end of file diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/MinimalTargetDefinitionPersistenceTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/MinimalTargetDefinitionPersistenceTests.java deleted file mode 100644 index 02e31aa8160..00000000000 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/MinimalTargetDefinitionPersistenceTests.java +++ /dev/null @@ -1,653 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2018 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.pde.ui.tests.target; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.variables.VariablesPlugin; -import org.eclipse.jdt.launching.JavaRuntime; -import org.eclipse.pde.core.plugin.TargetPlatform; -import org.eclipse.pde.core.target.ITargetDefinition; -import org.eclipse.pde.core.target.ITargetHandle; -import org.eclipse.pde.core.target.ITargetLocation; -import org.eclipse.pde.core.target.ITargetPlatformService; -import org.eclipse.pde.core.target.NameVersionDescriptor; -import org.eclipse.pde.internal.core.target.DirectoryBundleContainer; -import org.eclipse.pde.internal.core.target.FeatureBundleContainer; -import org.eclipse.pde.internal.core.target.IUBundleContainer; -import org.eclipse.pde.internal.core.target.ProfileBundleContainer; -import org.eclipse.pde.internal.core.target.TargetDefinition; -import org.eclipse.pde.internal.core.target.TargetDefinitionPersistenceHelper; -import org.eclipse.pde.ui.tests.PDETestsPlugin; -import org.junit.Test; -import org.osgi.framework.ServiceReference; - -/** - * Tests the persistence of target definitions. Tests memento creation, reading - * of old target files, and writing of the model. Runs on the minimal bundles - * and don't require the whole eclipse SDK.This class is refactored out of - * TargetDefinitionPersistenceTests - * - */ -public class MinimalTargetDefinitionPersistenceTests { - - protected void assertTargetDefinitionsEqual(ITargetDefinition targetA, ITargetDefinition targetB) { - assertTrue("Target content not equal", ((TargetDefinition) targetA).isContentEqual(targetB)); - } - - /** - * Returns the target platform service or null if none - * - * @return target platform service - */ - protected ITargetPlatformService getTargetService() { - ServiceReference reference = PDETestsPlugin.getBundleContext() - .getServiceReference(ITargetPlatformService.class); - assertNotNull("Missing target platform service", reference); - return PDETestsPlugin.getBundleContext().getService(reference); - } - - /** - * Returns the resolved location of the specified bundle container. - * - * @param container - * bundle container - * @return resolved location - * @throws CoreException - */ - protected String getResolvedLocation(ITargetLocation container) throws CoreException { - return container.getLocation(true); - } - - /** - * Returns the location of the JDT feature in the running host as a path in - * the local file system. - * - * @return path to JDT feature - */ - protected IPath getJdtFeatureLocation() { - IPath path = IPath.fromOSString(TargetPlatform.getDefaultLocation()); - path = path.append("features"); - File dir = path.toFile(); - assertTrue("Missing features directory", dir.exists() && !dir.isFile()); - String[] files = dir.list(); - String location = null; - for (String file : files) { - if (file.startsWith("org.eclipse.jdt_")) { - location = path.append(file).toOSString(); - break; - } - } - assertNotNull("Missing JDT feature", location); - return IPath.fromOSString(location); - } - - /** - * Tests restoration of a handle to target definition in an IFile - * - * @throws CoreException - */ - @Test - public void testWorkspaceTargetHandleMemento() throws CoreException { - ITargetPlatformService service = getTargetService(); - IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(IPath.fromOSString("does/not/exist")); - ITargetHandle handle = service.getTarget(file); - assertFalse("Target should not exist", handle.exists()); - String memento = handle.getMemento(); - assertNotNull("Missing memento", memento); - ITargetHandle handle2 = service.getTarget(memento); - assertEquals("Restore failed", handle, handle2); - IFile file2 = ResourcesPlugin.getWorkspace().getRoot().getFile(IPath.fromOSString("does/not/exist/either")); - ITargetHandle handle3 = service.getTarget(file2); - assertFalse("Should be different targets", handle.equals(handle3)); - } - - /** - * Tests restoration of a handle to target definition in local metadata - * - * @throws CoreException - * @throws InterruptedException - */ - @Test - public void testLocalTargetHandleMemento() throws CoreException, InterruptedException { - ITargetPlatformService service = getTargetService(); - ITargetHandle handle = service.newTarget().getHandle(); - assertFalse("Target should not exist", handle.exists()); - String memento = handle.getMemento(); - assertNotNull("Missing memento", memento); - ITargetHandle handle2 = service.getTarget(memento); - assertEquals("Restore failed", handle, handle2); - ITargetHandle handle3 = service.newTarget().getHandle(); - assertFalse("Should be different targets", handle.equals(handle3)); - } - - /** - * Tests restoration of a handle to target definition in external URI - * - * @throws CoreException - * @throws InterruptedException - */ - @Test - public void testExternalFileTargetHandleMemento() throws CoreException, InterruptedException { - ITargetPlatformService service = getTargetService(); - URI uri = null; - try { - uri = new URI("file:///does/not/exist"); - } catch (URISyntaxException e) { - } - // IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new - // Path("does/not/exist")); - ITargetHandle handle = service.getTarget(uri); - assertFalse("Target should not exist", handle.exists()); - String memento = handle.getMemento(); - assertNotNull("Missing memento", memento); - ITargetHandle handle2 = service.getTarget(memento); - assertEquals("Restore failed", handle, handle2); - // IFile file2 = ResourcesPlugin.getWorkspace().getRoot().getFile(new - // Path("does/not/exist/either")); - URI uri2 = null; - try { - uri2 = new URI("file://even/this/file/does/not/exist"); - } catch (URISyntaxException e) { - } - ITargetHandle handle3 = service.getTarget(uri2); - assertFalse("Should be different targets", handle.equals(handle3)); - } - - /** - * Tests that a complex metadata based target definition can be serialized - * to xml, then deserialized without any loss of data. - * - * @throws Exception - */ - - /** - * Tests that an empty target definition can be serialized to xml, then - * deserialized without any loss of data. - * - * @throws Exception - */ - @Test - public void testPersistEmptyDefinition() throws Exception { - ITargetDefinition definitionA = getTargetService().newTarget(); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - TargetDefinitionPersistenceHelper.persistXML(definitionA, outputStream); - ITargetDefinition definitionB = getTargetService().newTarget(); - ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); - TargetDefinitionPersistenceHelper.initFromXML(definitionB, inputStream); - assertTargetDefinitionsEqual(definitionA, definitionB); - } - - /** - * Reads a target definition file from the tests/targets/target-files - * location with the given name. Note that ".target" will be appended. - * - * @param name - * @return target definition - * @throws Exception - */ - protected ITargetDefinition readOldTarget(String name) throws Exception { - URL url = PDETestsPlugin.getBundleContext().getBundle() - .getEntry("/tests/targets/target-files/" + name + ".trgt"); - File file = new File(FileLocator.toFileURL(url).getFile()); - ITargetDefinition target = getTargetService().newTarget(); - try (FileInputStream stream = new FileInputStream(file)) { - TargetDefinitionPersistenceHelper.initFromXML(target, stream); - } - return target; - } - - /** - * Tests that we can de-serialize an old style target definition file - * (version 3.2) and retrieve the correct contents. - * - * @throws Exception - */ - @Test - public void testReadOldBasicTargetFile() throws Exception { - ITargetDefinition target = readOldTarget("basic"); - - assertEquals("Wrong name", "Basic", target.getName()); - assertNull(target.getArch()); - assertNull(target.getOS()); - assertNull(target.getNL()); - assertNull(target.getWS()); - assertNull(target.getProgramArguments()); - assertNull(target.getVMArguments()); - assertNull(target.getImplicitDependencies()); - assertNull(target.getJREContainer()); - - ITargetLocation[] containers = target.getTargetLocations(); - assertEquals("Wrong number of bundles", 1, containers.length); - assertTrue("Container should be a profile container", containers[0] instanceof ProfileBundleContainer); - assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()), - IPath.fromOSString(getResolvedLocation(containers[0]))); - } - - /** - * Tests that we can de-serialize an old style target definition file - * (version 3.2) and retrieve the correct contents. - * - * @throws Exception - */ - @Test - public void testReadOldBasicDirectoryTargetFile() throws Exception { - ITargetDefinition target = readOldTarget("directory"); - - assertEquals("Wrong name", "Directory", target.getName()); - assertNull(target.getArch()); - assertNull(target.getOS()); - assertNull(target.getNL()); - assertNull(target.getWS()); - assertNull(target.getProgramArguments()); - assertNull(target.getVMArguments()); - assertNull(target.getImplicitDependencies()); - assertNull(target.getJREContainer()); - - ITargetLocation[] containers = target.getTargetLocations(); - assertEquals("Wrong number of bundles", 1, containers.length); - assertTrue("Container should be a directory container", containers[0] instanceof DirectoryBundleContainer); - assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("plugins"), - IPath.fromOSString(getResolvedLocation(containers[0]))); - } - - /** - * Tests that we can de-serialize an old style target definition file - * (version 3.2) and retrieve the correct contents. - * - * @throws Exception - */ - @Test - public void testReadOldSpecificTargetFile() throws Exception { - ITargetDefinition target = readOldTarget("specific"); - - assertEquals("Wrong name", "Specific Settings", target.getName()); - assertEquals("x86", target.getArch()); - assertEquals("linux", target.getOS()); - assertEquals("en_US", target.getNL()); - assertEquals("gtk", target.getWS()); - assertEquals("pgm1 pgm2", target.getProgramArguments()); - assertEquals("-Dfoo=\"bar\"", target.getVMArguments()); - assertEquals( - JavaRuntime - .newJREContainerPath(JavaRuntime.getExecutionEnvironmentsManager().getEnvironment( - "J2SE-1.4")), - target.getJREContainer()); - - NameVersionDescriptor[] infos = target.getImplicitDependencies(); - assertEquals("Wrong number of implicit dependencies", 2, infos.length); - Set set = new HashSet<>(); - for (NameVersionDescriptor info : infos) { - set.add(info.getId()); - } - assertTrue("Missing ", set.remove("org.eclipse.jdt.debug")); - assertTrue("Missing ", set.remove("org.eclipse.debug.core")); - assertTrue(set.isEmpty()); - - ITargetLocation[] containers = target.getTargetLocations(); - assertEquals("Wrong number of bundles", 1, containers.length); - assertTrue("Container should be a directory container", containers[0] instanceof DirectoryBundleContainer); - assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("plugins"), - IPath.fromOSString(getResolvedLocation(containers[0]))); - } - - /** - * Tests that we can de-serialize an old style target definition file - * (version 3.2) and retrieve the correct contents. - * - * @throws Exception - */ - @Test - public void testReadOldAdditionLocationsTargetFile() throws Exception { - ITargetDefinition target = readOldTarget("additionalLocations"); - - assertEquals("Wrong name", "Additional Locations", target.getName()); - assertNull(target.getArch()); - assertNull(target.getOS()); - assertNull(target.getNL()); - assertNull(target.getWS()); - assertNull(target.getProgramArguments()); - assertNull(target.getVMArguments()); - assertNull(target.getJREContainer()); - assertNull(target.getImplicitDependencies()); - - ITargetLocation[] containers = target.getTargetLocations(); - assertEquals("Wrong number of bundles", 3, containers.length); - assertTrue(containers[0] instanceof ProfileBundleContainer); - assertTrue(containers[1] instanceof DirectoryBundleContainer); - assertTrue(containers[2] instanceof DirectoryBundleContainer); - - assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()), - IPath.fromOSString(getResolvedLocation(containers[0]))); - - String string = VariablesPlugin.getDefault().getStringVariableManager() - .performStringSubstitution("${workspace_loc}"); - assertEquals("Wrong 1st additional location", IPath.fromOSString(string).append("stuff"), - IPath.fromOSString(getResolvedLocation(containers[1]))); - - assertEquals("Wrong 2nd additional location", IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("dropins"), - IPath.fromOSString(getResolvedLocation(containers[2]))); - } - - /** - * Tests that we can de-serialize an old style target definition file - * (version 3.2) and retrieve the correct contents. - * - * @throws Exception - */ - @Test - public void testReadOldFeaturesTargetFile() throws Exception { - ITargetDefinition target = readOldTarget("featureLocations"); - - assertEquals("Wrong name", "Features", target.getName()); - assertNull(target.getArch()); - assertNull(target.getOS()); - assertNull(target.getNL()); - assertNull(target.getWS()); - assertNull(target.getProgramArguments()); - assertNull(target.getVMArguments()); - assertNull(target.getJREContainer()); - assertNull(target.getImplicitDependencies()); - - ITargetLocation[] containers = target.getTargetLocations(); - assertEquals("Wrong number of bundles", 2, containers.length); - assertTrue(containers[0] instanceof FeatureBundleContainer); - assertTrue(containers[1] instanceof FeatureBundleContainer); - - assertEquals("Wrong feature location", "org.eclipse.jdt", - ((FeatureBundleContainer) containers[0]).getFeatureId()); - assertEquals("Wrong feature location", "org.eclipse.platform", - ((FeatureBundleContainer) containers[1]).getFeatureId()); - } - - /** - * Tests that we can de-serialize an old style target definition file - * (version 3.2) and retrieve the correct contents. - * - * @throws Exception - */ - @Test - public void testReadOldRestrictionsTargetFile() throws Exception { - ITargetDefinition target = readOldTarget("restrictions"); - - assertEquals("Wrong name", "Restrictions", target.getName()); - assertNull(target.getArch()); - assertNull(target.getOS()); - assertNull(target.getNL()); - assertNull(target.getWS()); - assertNull(target.getProgramArguments()); - assertNull(target.getVMArguments()); - assertNull(target.getJREContainer()); - assertNull(target.getImplicitDependencies()); - - ITargetLocation[] containers = target.getTargetLocations(); - assertEquals("Wrong number of containers", 3, containers.length); - assertTrue(containers[0] instanceof ProfileBundleContainer); - assertTrue(containers[1] instanceof FeatureBundleContainer); - assertTrue(containers[2] instanceof DirectoryBundleContainer); - - assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()), - IPath.fromOSString(getResolvedLocation(containers[0]))); - assertEquals("Wrong 1st additional location", "org.eclipse.jdt", - ((FeatureBundleContainer) containers[1]).getFeatureId()); - assertEquals("Wrong 2nd additional location", IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("dropins"), - IPath.fromOSString(getResolvedLocation(containers[2]))); - - NameVersionDescriptor[] restrictions = new NameVersionDescriptor[] { - new NameVersionDescriptor("org.eclipse.debug.core", null), - new NameVersionDescriptor("org.eclipse.debug.ui", null), - new NameVersionDescriptor("org.eclipse.jdt.debug", null), - new NameVersionDescriptor("org.eclipse.jdt.debug.ui", null), - new NameVersionDescriptor("org.eclipse.jdt.launching", null) }; - - NameVersionDescriptor[] actual = target.getIncluded(); - assertNotNull(actual); - assertEquals("Wrong number of restrictions", restrictions.length, actual.length); - for (int j = 0; j < actual.length; j++) { - assertEquals("Wrong restriction", restrictions[j], actual[j]); - } - } - - /** - * Tests that we can de-serialize an old style target definition file - * (version 3.2) that has extra/unsupported tags and retrieve the correct - * contents. - * - * @throws Exception - */ - @Test - public void testReadOldTargetFileWithUnknownTags() throws Exception { - ITargetDefinition target = readOldTarget("extratags"); - - assertEquals("Wrong name", "Restrictions", target.getName()); - assertNull(target.getArch()); - assertNull(target.getOS()); - assertNull(target.getNL()); - assertNull(target.getWS()); - assertNull(target.getProgramArguments()); - assertNull(target.getVMArguments()); - assertNull(target.getJREContainer()); - assertNull(target.getImplicitDependencies()); - - ITargetLocation[] containers = target.getTargetLocations(); - assertEquals("Wrong number of bundles", 3, containers.length); - assertTrue(containers[0] instanceof ProfileBundleContainer); - assertTrue(containers[1] instanceof FeatureBundleContainer); - assertTrue(containers[2] instanceof DirectoryBundleContainer); - - assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()), - IPath.fromOSString(getResolvedLocation(containers[0]))); - assertEquals("Wrong 1st additional location", "org.eclipse.jdt", - ((FeatureBundleContainer) containers[1]).getFeatureId()); - assertEquals("Wrong 2nd additional location", IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("dropins"), - IPath.fromOSString(getResolvedLocation(containers[2]))); - - NameVersionDescriptor[] restrictions = new NameVersionDescriptor[] { - new NameVersionDescriptor("org.eclipse.debug.core", null), - new NameVersionDescriptor("org.eclipse.debug.ui", null), - new NameVersionDescriptor("org.eclipse.jdt.debug", null), - new NameVersionDescriptor("org.eclipse.jdt.debug.ui", null), - new NameVersionDescriptor("org.eclipse.jdt.launching", null) }; - - NameVersionDescriptor[] actual = target.getIncluded(); - assertNotNull(actual); - assertEquals("Wrong number of restrictions", restrictions.length, actual.length); - for (int j = 0; j < actual.length; j++) { - assertEquals("Wrong restriction", restrictions[j], actual[j]); - } - } - - /** - * Tests that we can de-serialize an old style target definition file - * (version 3.2) and retrieve the correct contents with optional bundles. - * - * @throws Exception - */ - @Test - public void testReadOldOptionalTargetFile() throws Exception { - ITargetDefinition target = readOldTarget("optional"); - - assertEquals("Wrong name", "Optional", target.getName()); - assertNull(target.getArch()); - assertNull(target.getOS()); - assertNull(target.getNL()); - assertNull(target.getWS()); - assertNull(target.getProgramArguments()); - assertNull(target.getVMArguments()); - assertNull(target.getImplicitDependencies()); - assertNull(target.getJREContainer()); - - ITargetLocation[] containers = target.getTargetLocations(); - assertEquals("Wrong number of bundles", 2, containers.length); - assertTrue("Container should be a profile container", containers[0] instanceof ProfileBundleContainer); - assertTrue("Container should be a profile container", containers[1] instanceof FeatureBundleContainer); - assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()), - IPath.fromOSString(getResolvedLocation(containers[0]))); - assertEquals("Wrong feature location", "org.eclipse.jdt", - ((FeatureBundleContainer) containers[1]).getFeatureId()); - - // Old optional settings are added to includes - NameVersionDescriptor[] included = new NameVersionDescriptor[] { - new NameVersionDescriptor("org.eclipse.debug.core", null), - new NameVersionDescriptor("org.eclipse.debug.examples.core", null), - new NameVersionDescriptor("org.eclipse.debug.examples.ui", null), - new NameVersionDescriptor("org.eclipse.debug.ui", null), - new NameVersionDescriptor("org.eclipse.jdt.debug", null), - new NameVersionDescriptor("org.eclipse.jdt.debug.ui", null), - new NameVersionDescriptor("org.eclipse.jdt.launching", null) }; - - NameVersionDescriptor[] actual = target.getIncluded(); - assertNotNull(actual); - assertEquals("Wrong number of inclusions", included.length, actual.length); - for (int j = 0; j < actual.length; j++) { - assertEquals("Wrong restriction", included[j], actual[j]); - } - } - - /** - * Test for bug 268709, if the content section is included in the xml, but - * there are no specific plug-ins or features as well as no - * useAllPlugins=true setting, treat the file as though it did include all - * plug-ins from the directory. - */ - @Test - public void testEmptyContentSection() throws Exception { - ITargetDefinition target = readOldTarget("emptycontent"); - - ITargetLocation[] containers = target.getTargetLocations(); - assertEquals("Wrong number of bundles", 1, containers.length); - assertTrue("Container should be a directory container", containers[0] instanceof DirectoryBundleContainer); - assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("plugins"), - IPath.fromOSString(getResolvedLocation(containers[0]))); - - target.resolve(null); - - assertTrue("Should have resolved bundles", target.getBundles().length > 0); - - } - - /** - * Test for bug 264139. Tests that when a target definition specifies - * "useAllPlugins=true" that we ignore specific plug-ins/features specified - * in the file during migration. - * - * @throws Exception - */ - @Test - public void testMigrationOfUseAllWithRestrictions() throws Exception { - ITargetDefinition target = readOldTarget("eclipse-serverside"); - ITargetLocation[] containers = target.getTargetLocations(); - assertEquals(6, containers.length); - validateTypeAndLocation(containers[0], ProfileBundleContainer.class, - "${resource_loc:/target-platforms/eclipse-equinox-SDK-3.5M5/eclipse}"); - validateTypeAndLocation(containers[1], DirectoryBundleContainer.class, - "${resource_loc:/target-platforms/eclipse-3.5M5-delta-pack/eclipse}"); - validateTypeAndLocation(containers[2], DirectoryBundleContainer.class, - "${resource_loc:/target-platforms/eclipse-pde-headless-3.5M5}"); - validateTypeAndLocation(containers[3], DirectoryBundleContainer.class, - "${resource_loc:/target-platforms/eclipse-test-framework-3.5M5/eclipse}"); - validateTypeAndLocation(containers[4], DirectoryBundleContainer.class, - "${resource_loc:/target-platforms/eclipse-core-plugins-3.5M5}"); - validateTypeAndLocation(containers[5], DirectoryBundleContainer.class, - "${resource_loc:/target-platforms/3rdparty-bundles}"); - } - - /** - * Validates the type and location of a bundle container. - * - * @param container - * container to validate - * @param clazz - * the type of container expected - * @param rawLocation - * its unresolved location - * @throws CoreException - * if something goes wrong - */ - protected void validateTypeAndLocation(ITargetLocation container, Class clazz, String rawLocation) - throws CoreException { - assertTrue(clazz.isInstance(container)); - assertEquals(rawLocation, container.getLocation(false)); - } - - /** - * Tests that we increment the sequence number correctly when target is - * modified contents. - * - * @throws Exception - */ - @Test - public void testSequenceNumberChange() throws Exception { - ITargetDefinition target = readOldTarget("featureLocations"); - - assertEquals("Wrong name", "Features", target.getName()); - TargetDefinition targetDef = (TargetDefinition) target; - int currentSeqNo = targetDef.getSequenceNumber(); - target.setArch("x86"); - asssrtSequenceNumber("Arch", currentSeqNo, targetDef); - - currentSeqNo = targetDef.getSequenceNumber(); - target.setOS("win32"); - asssrtSequenceNumber("OS", currentSeqNo, targetDef); - - currentSeqNo = targetDef.getSequenceNumber(); - target.setNL("hi_IN"); - asssrtSequenceNumber("NL", currentSeqNo, targetDef); - - currentSeqNo = targetDef.getSequenceNumber(); - target.setWS("carbon"); - asssrtSequenceNumber("WS", currentSeqNo, targetDef); - - ITargetLocation[] newContainers = new ITargetLocation[1]; - newContainers[0] = new DirectoryBundleContainer("Path"); - currentSeqNo = targetDef.getSequenceNumber(); - target.setTargetLocations(newContainers); - asssrtSequenceNumber("Bundle Containers", currentSeqNo, targetDef); - } - - private void asssrtSequenceNumber(String name, int currentSeqNo, TargetDefinition targetDef) { - assertEquals("Sequence number did not increment after updating '" + name + "'", currentSeqNo + 1, - targetDef.getSequenceNumber()); - } - - @Test - public void testIncludeSource() throws Exception { - ITargetDefinition target = readOldTarget("SoftwareSiteTarget"); - ITargetLocation[] containers = target.getTargetLocations(); - assertEquals(1, containers.length); - assertTrue(containers[0] instanceof IUBundleContainer); - IUBundleContainer iubc = (IUBundleContainer) containers[0]; - assertTrue(iubc.getIncludeSource()); - } - -} \ No newline at end of file diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/MinimalTargetDefinitionResolutionTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/MinimalTargetDefinitionResolutionTests.java deleted file mode 100644 index 5838e042495..00000000000 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/MinimalTargetDefinitionResolutionTests.java +++ /dev/null @@ -1,401 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2017 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.pde.ui.tests.target; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.p2.metadata.IInstallableUnit; -import org.eclipse.jdt.launching.JavaRuntime; -import org.eclipse.pde.core.plugin.TargetPlatform; -import org.eclipse.pde.core.target.ITargetDefinition; -import org.eclipse.pde.core.target.ITargetLocation; -import org.eclipse.pde.core.target.ITargetPlatformService; -import org.eclipse.pde.core.target.NameVersionDescriptor; -import org.eclipse.pde.core.target.TargetBundle; -import org.eclipse.pde.internal.core.target.IUBundleContainer; -import org.junit.Test; - -/** - * Runs on minimal bundles and don't require full eclipse SDK.This class is - * refactored out of TargetDefinitionResolutionTests - * - */ -public class MinimalTargetDefinitionResolutionTests extends AbstractTargetTest { - @Test - public void testInvalidBundleContainers() throws Exception { - ITargetDefinition definition = getNewTarget(); - - ITargetLocation directoryContainer = getTargetService().newDirectoryLocation("***SHOULD NOT EXIST***"); - IStatus status = directoryContainer.resolve(definition, null); - assertEquals("Incorrect severity", IStatus.ERROR, status.getSeverity()); - - ITargetLocation profileContainer = getTargetService().newProfileLocation("***SHOULD NOT EXIST***", null); - status = directoryContainer.resolve(definition, null); - assertEquals("Incorrect severity", IStatus.ERROR, status.getSeverity()); - - ITargetLocation featureContainer = getTargetService().newFeatureLocation("***SHOULD NOT EXIST***", - "org.eclipse.jdt", ""); - status = directoryContainer.resolve(definition, null); - assertEquals("Incorrect severity", IStatus.ERROR, status.getSeverity()); - - definition.setTargetLocations(new ITargetLocation[] { directoryContainer, profileContainer, featureContainer }); - status = definition.resolve(null); - IStatus[] children = status.getChildren(); - assertEquals("Wrong number of children", 3, children.length); - for (IStatus element : children) { - assertEquals("Incorrect severity", IStatus.ERROR, element.getSeverity()); - assertFalse("Failed resolution should be single status", element.isMultiStatus()); - } - } - - /** - * Tests that if we find a bundle with a bad or missing manifest when - * resolving we create the correct status. - * - * @see TargetBundle.STATUS_INVALID_MANIFEST - * @throws Exception - */ - @Test - public void testInvalidManifest() throws Exception { - // TODO Should we have tests for this? - } - - @Test - public void testResolutionCaching() throws Exception { - ITargetDefinition definition = getNewTarget(); - assertTrue(definition.isResolved()); - assertNotNull("Bundles not available when resolved", definition.getBundles()); - assertEquals("Wrong number of bundles", 0, definition.getBundles().length); - - // Resolving with errors should stay resolved, solving a definition - // should resolve all targets - ITargetLocation brokenContainer = getTargetService().newDirectoryLocation("***SHOULD NOT EXIST***"); - assertFalse(brokenContainer.isResolved()); - assertNull("Bundles available when unresolved", brokenContainer.getBundles()); - definition.setTargetLocations(new ITargetLocation[] { brokenContainer }); - assertFalse(definition.isResolved()); - assertNull("Bundles available when unresolved", definition.getBundles()); - IStatus status = definition.resolve(null); - assertEquals("Incorrect Severity", IStatus.ERROR, status.getSeverity()); - assertTrue(brokenContainer.isResolved()); - assertNotNull("Bundles not available when resolved", brokenContainer.getBundles()); - assertTrue(definition.isResolved()); - assertNotNull("Bundles not available when resolved", definition.getBundles()); - - // Adding an unresolved container should make the target unresolved, - // resolving the container should resolve the target - ITargetLocation profileContainer = getTargetService().newProfileLocation(TargetPlatform.getDefaultLocation(), - null); - assertFalse(profileContainer.isResolved()); - assertNull("Bundles available when unresolved", profileContainer.getBundles()); - definition.setTargetLocations(new ITargetLocation[] { brokenContainer, profileContainer }); - assertFalse(definition.isResolved()); - assertNull("Bundles available when unresolved", definition.getBundles()); - status = profileContainer.resolve(definition, null); - assertEquals("Incorrect Severity", IStatus.OK, status.getSeverity()); - assertEquals("Incorrect Severity", IStatus.ERROR, definition.getStatus().getSeverity()); - assertTrue(profileContainer.isResolved()); - assertNotNull("Bundles not available when resolved", profileContainer.getBundles()); - assertTrue(definition.isResolved()); - assertNotNull("Bundles not available when resolved", definition.getBundles()); - - // Having a bundle status does not prevent the resolution, adding a - // resolved container should leave the target resolved - ITargetLocation includesContainer = getTargetService().newProfileLocation(TargetPlatform.getDefaultLocation(), - null); - assertFalse(includesContainer.isResolved()); - assertNull("Bundles available when unresolved", includesContainer.getBundles()); - status = includesContainer.resolve(definition, null); - assertTrue(includesContainer.isResolved()); - assertNotNull("Bundles not available when resolved", includesContainer.getBundles()); - assertEquals("Incorrect Severity", IStatus.OK, status.getSeverity()); - assertEquals("Incorrect Severity", IStatus.OK, includesContainer.getStatus().getSeverity()); - definition.setTargetLocations(new ITargetLocation[] { brokenContainer, profileContainer }); - definition.setIncluded(new NameVersionDescriptor[] { new NameVersionDescriptor("bogus", null), - new NameVersionDescriptor("org.eclipse.platform", "666.666.666") }); - assertTrue(definition.isResolved()); - assertEquals("Incorrect Severity", IStatus.ERROR, definition.getStatus().getSeverity()); - assertNotNull("Bundles not available when resolved", definition.getBundles()); - - // Setting includes, etc. should not unresolve the target - definition.setIncluded(null); - assertTrue(definition.isResolved()); - definition.setIncluded(new NameVersionDescriptor[] { new NameVersionDescriptor("bogus", null), - new NameVersionDescriptor("org.eclipse.platform", "666.666.666") }); - assertTrue(definition.isResolved()); - definition.setName("name"); - definition.setOS("os"); - definition.setWS("ws"); - definition.setArch("arch"); - definition.setNL("nl"); - definition.setProgramArguments("program\nargs"); - definition.setVMArguments("vm\nargs"); - definition.setJREContainer(JavaRuntime.newDefaultJREContainerPath()); - NameVersionDescriptor[] implicit = new NameVersionDescriptor[] { - new NameVersionDescriptor("org.eclipse.jdt.launching", null), - new NameVersionDescriptor("org.eclipse.jdt.debug", null) }; - definition.setImplicitDependencies(implicit); - assertTrue(definition.isResolved()); - definition.setName(null); - definition.setOS(null); - definition.setWS(null); - definition.setArch(null); - definition.setNL(null); - definition.setProgramArguments(null); - definition.setVMArguments(null); - definition.setJREContainer(null); - definition.setImplicitDependencies(null); - assertTrue(definition.isResolved()); - - definition.setTargetLocations(null); - assertTrue(definition.isResolved()); - assertNotNull("Bundles not available when resolved", definition.getBundles()); - - } - - - - /** - * Tests that a target definition is in synch with the target platform. - * - * @throws Exception - */ - @Test - public void testTargetInSynch() throws Exception { - IPath location = extractAbcdePlugins(); - IPath dirPath = location.append("plugins"); - ITargetDefinition definition = getNewTarget(); - ITargetLocation container = getTargetService().newDirectoryLocation(dirPath.toOSString()); - definition.setTargetLocations(new ITargetLocation[] { container }); - definition.resolve(null); - TargetBundle[] allBundles = definition.getAllBundles(); - assertEquals(10, allBundles.length); - - try { - setTargetPlatform(definition); - IStatus status = getTargetService().compareWithTargetPlatform(definition); - assertTrue(status.isOK()); - } finally { - resetTargetPlatform(); - } - } - - /** - * Tests that a target definition is in synch with the target platform when - * there are duplicates in the target definition (duplicates should be - * ignored). - * - * @throws Exception - */ - @Test - public void testTargetInSynchWithDuplicates() throws Exception { - IPath location = extractAbcdePlugins(); - IPath dirPath = location.append("plugins"); - ITargetDefinition definition = getNewTarget(); - ITargetLocation container = getTargetService().newDirectoryLocation(dirPath.toOSString()); - ITargetLocation container2 = getTargetService().newDirectoryLocation(dirPath.toOSString()); - definition.setTargetLocations(new ITargetLocation[] { container, container2 }); - definition.resolve(null); - TargetBundle[] allBundles = definition.getAllBundles(); - assertEquals(20, allBundles.length); - - try { - setTargetPlatform(definition); - IStatus status = getTargetService().compareWithTargetPlatform(definition); - assertTrue(status.isOK()); - } finally { - resetTargetPlatform(); - } - } - - /** - * Tests that a target definition is not in synch with the target platform - * when a bundle is deleted from the underlying files system (target - * platform). - * - * @throws Exception - */ - @Test - public void testTargetMissingBundle() throws Exception { - IPath location = extractAbcdePlugins(); - IPath dirPath = location.append("plugins"); - ITargetDefinition definition = getNewTarget(); - ITargetLocation container = getTargetService().newDirectoryLocation(dirPath.toOSString()); - definition.setTargetLocations(new ITargetLocation[] { container }); - - try { - setTargetPlatform(definition); - // delete a bundle - IPath bundle = dirPath.append("bundle.a_1.0.0.jar"); - assertTrue(bundle.toFile().exists()); - bundle.toFile().delete(); - // force definition to re-resolve - ITargetDefinition copy = getTargetService().newTarget(); - getTargetService().copyTargetDefinition(definition, copy); - copy.resolve(null); - IStatus status = getTargetService().compareWithTargetPlatform(copy); - assertNotNull(status); - assertFalse(status.isOK()); - IStatus[] children = status.getChildren(); - assertEquals(1, children.length); - assertEquals(ITargetPlatformService.STATUS_MISSING_FROM_TARGET_DEFINITION, children[0].getCode()); - assertEquals("bundle.a", children[0].getMessage()); - } finally { - resetTargetPlatform(); - } - } - - /** - * Tests that a target definition will warn if an expected bundle does not - * exist on the file system. - * - * @throws Exception - */ - @Test - public void testTargetPlatformMissingBundle() throws Exception { - IPath location = extractAbcdePlugins(); - IPath dirPath = location.append("plugins"); - // delete a bundle - IPath bundle = dirPath.append("bundle.a_1.0.0.jar"); - File jar = bundle.toFile(); - assertTrue(jar.exists()); - jar.delete(); - - ITargetDefinition definition = getTargetService().newTarget(); - ITargetLocation container = getTargetService().newDirectoryLocation(dirPath.toOSString()); - definition.setTargetLocations(new ITargetLocation[] { container }); - definition.resolve(null); - TargetBundle[] allBundles = definition.getAllBundles(); - assertEquals(9, allBundles.length); - - try { - setTargetPlatform(definition); - // force definition to re-resolve - ITargetDefinition copy = getTargetService().newTarget(); - getTargetService().copyTargetDefinition(definition, copy); - // add the bundle back to the file system - extractAbcdePlugins(); - - copy.resolve(null); - IStatus status = getTargetService().compareWithTargetPlatform(copy); - assertNotNull(status); - assertFalse(status.isOK()); - IStatus[] children = status.getChildren(); - assertEquals(1, children.length); - assertEquals(ITargetPlatformService.STATUS_MISSING_FROM_TARGET_PLATFORM, children[0].getCode()); - assertEquals("bundle.a", children[0].getMessage()); - } finally { - resetTargetPlatform(); - } - } - - /** - * Tests the two options on IU bundle containers for controlling how the - * site will be resolved - * - * @throws Exception - */ - @Test - public void testSiteContainerIncludeSettings() throws Exception { - ITargetDefinition target = getNewTarget(); - IUBundleContainer containerA = (IUBundleContainer) getTargetService().newIULocation(new IInstallableUnit[0], - null, IUBundleContainer.INCLUDE_REQUIRED); - IUBundleContainer containerB = (IUBundleContainer) getTargetService().newIULocation( - new String[] { "unit1", "unit2" }, new String[] { "1.0", "2.0" }, null, - IUBundleContainer.INCLUDE_REQUIRED); - target.setTargetLocations(new ITargetLocation[] { containerA, containerB }); - - // Check default settings - assertTrue(containerA.getIncludeAllRequired()); - assertFalse(containerA.getIncludeAllEnvironments()); - assertFalse(containerA.getIncludeSource()); - assertTrue(containerB.getIncludeAllRequired()); - assertFalse(containerB.getIncludeAllEnvironments()); - assertFalse(containerB.getIncludeSource()); - - // Check basic changes - int flags = IUBundleContainer.INCLUDE_ALL_ENVIRONMENTS | IUBundleContainer.INCLUDE_SOURCE; - containerA = (IUBundleContainer) getTargetService().newIULocation(new IInstallableUnit[0], null, flags); - containerB = (IUBundleContainer) getTargetService().newIULocation(new String[] { "unit1", "unit2" }, - new String[] { "1.0", "2.0" }, null, flags); - target.setTargetLocations(new ITargetLocation[] { containerA, containerB }); - assertFalse(containerA.getIncludeAllRequired()); - assertTrue(containerA.getIncludeAllEnvironments()); - assertTrue(containerA.getIncludeSource()); - - // Check that all containers are updated in the target if target is - // passed as argument - flags = IUBundleContainer.INCLUDE_ALL_ENVIRONMENTS | IUBundleContainer.INCLUDE_SOURCE; - containerA = (IUBundleContainer) getTargetService().newIULocation(new IInstallableUnit[0], null, flags); - flags = IUBundleContainer.INCLUDE_REQUIRED; - containerB = (IUBundleContainer) getTargetService().newIULocation(new String[] { "unit1", "unit2" }, - new String[] { "1.0", "2.0" }, null, flags); - - target.setTargetLocations(new ITargetLocation[] { containerA, containerB }); - assertTrue(containerA.getIncludeAllRequired()); - assertFalse(containerA.getIncludeAllEnvironments()); - assertFalse(containerA.getIncludeSource()); - assertTrue(containerB.getIncludeAllRequired()); - assertFalse(containerB.getIncludeAllEnvironments()); - assertFalse(containerB.getIncludeSource()); - - // now switch the order of A and B - target.setTargetLocations(new ITargetLocation[] { containerB, containerA }); - assertFalse(containerA.getIncludeAllRequired()); - assertTrue(containerA.getIncludeAllEnvironments()); - assertTrue(containerA.getIncludeSource()); - assertFalse(containerB.getIncludeAllRequired()); - assertTrue(containerB.getIncludeAllEnvironments()); - assertTrue(containerB.getIncludeSource()); - } - - @Test - public void testNameVersionDescriptor() { - NameVersionDescriptor d1 = new NameVersionDescriptor("a.b.c", "1.0.0"); - NameVersionDescriptor d2 = new NameVersionDescriptor("a.b.c", "1.0.0"); - assertEquals(d1, d2); - - d1 = new NameVersionDescriptor("a.b.c", "1.0.0"); - d2 = new NameVersionDescriptor("a.b.c", "1.0.1"); - assertFalse(d1.equals(d2)); - - d1 = new NameVersionDescriptor("a.b.c", "1.0.0"); - d2 = new NameVersionDescriptor("a.b.e", "1.0.0"); - assertFalse(d1.equals(d2)); - - d1 = new NameVersionDescriptor("a.b.c", null); - d2 = new NameVersionDescriptor("a.b.c", null); - assertEquals(d1, d2); - - d1 = new NameVersionDescriptor("a.b.c", null); - d2 = new NameVersionDescriptor("a.b.e", null); - assertFalse(d1.equals(d2)); - - d1 = new NameVersionDescriptor("a.b.c", null); - d2 = new NameVersionDescriptor("a.b.c", "1.0.0"); - assertFalse(d1.equals(d2)); - - d1 = new NameVersionDescriptor("a.b.c", "1.0.0"); - d2 = new NameVersionDescriptor("a.b.c", null); - assertFalse(d1.equals(d2)); - } -} \ No newline at end of file diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionFeatureResolutionTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionFeatureResolutionTests.java index 1b49cfb58b0..62428d7573c 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionFeatureResolutionTests.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionFeatureResolutionTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2017 IBM Corporation and others. + * Copyright (c) 2009, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,16 +14,28 @@ package org.eclipse.pde.ui.tests.target; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.pde.core.plugin.TargetPlatform; import org.eclipse.pde.core.target.ITargetDefinition; import org.eclipse.pde.core.target.ITargetLocation; +import org.eclipse.pde.core.target.NameVersionDescriptor; +import org.eclipse.pde.core.target.TargetBundle; import org.eclipse.pde.core.target.TargetFeature; import org.eclipse.pde.internal.core.PDECore; import org.eclipse.pde.internal.core.ifeature.IFeatureModel; +import org.eclipse.pde.ui.tests.PDETestCase; import org.junit.Test; /** @@ -31,13 +43,346 @@ * * @since 3.6 */ -public class TargetDefinitionFeatureResolutionTests extends MinimalTargetDefinitionFeatureResolutionTests { +public class TargetDefinitionFeatureResolutionTests extends AbstractTargetTest { + + /** + * Tests that a directory bundle container provides the correct features to + * a target + */ + @Test + public void testDirectoryBundleContainer() throws Exception { + ITargetDefinition definition = getNewTarget(); + ITargetLocation directoryContainer = getTargetService() + .newDirectoryLocation(TargetPlatform.getDefaultLocation()); + + assertNull(directoryContainer.getFeatures()); + + IFeatureModel[] expectedFeatures = PDECore.getDefault().getFeatureModelManager().getModels(); + Set expectedIDs = new HashSet<>(); + for (IFeatureModel expectedFeature : expectedFeatures) { + expectedIDs.add(expectedFeature.getFeature().getId()); + } + + directoryContainer.resolve(definition, null); + TargetFeature[] features = directoryContainer.getFeatures(); + assertNotNull(features); + + for (TargetFeature feature : features) { + String currentID = feature.getId(); + assertTrue("Extra feature in result: " + currentID, expectedIDs.contains(currentID)); + expectedIDs.remove(currentID); + } + + assertTrue("Not all expected features returned by the container: " + expectedIDs.toString(), + expectedIDs.isEmpty()); + } + + /** + * Tests that a profile (installation) bundle container provides the correct + * features to a target + */ + @Test + public void testProfileBundleContainer() throws Exception { + ITargetDefinition definition = getNewTarget(); + ITargetLocation profileContainer = getTargetService().newProfileLocation(TargetPlatform.getDefaultLocation(), + null); + + assertNull(profileContainer.getFeatures()); + + IFeatureModel[] expectedFeatures = PDECore.getDefault().getFeatureModelManager().getModels(); + Set expectedIDs = new HashSet<>(); + for (IFeatureModel expectedFeature : expectedFeatures) { + expectedIDs.add(expectedFeature.getFeature().getId()); + } + + profileContainer.resolve(definition, null); + TargetFeature[] features = profileContainer.getFeatures(); + assertNotNull(features); + + for (TargetFeature feature : features) { + String currentID = feature.getId(); + assertTrue("Extra feature in result: " + currentID, expectedIDs.contains(currentID)); + expectedIDs.remove(currentID); + } + + assertTrue("Not all expected features returned by the container: " + expectedIDs.toString(), + expectedIDs.isEmpty()); + } + + @Test + public void testExplicitIncludes() throws Exception { + // Use the modified JDT features as we know their versions + ITargetDefinition definition = getNewTarget(); + IPath location = extractModifiedFeatures(); + + ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); + definition.setTargetLocations(new ITargetLocation[] { container }); + definition.resolve(null); + + List expected = new ArrayList<>(); + expected.add("org.eclipse.jdt"); + expected.add("org.eclipse.jdt.launching"); + expected.add("org.eclipse.jdt.launching.source"); + // 2 versions of JUnit + expected.add("org.junit"); + expected.add("org.junit.source"); + expected.add("org.junit"); + expected.add("org.junit.source"); + expected.add("org.junit4"); + if (Platform.getOS().equals(Platform.OS_MACOSX)) { + expected.add("org.eclipse.jdt.launching.macosx"); + expected.add("org.eclipse.jdt.launching.macosx.source"); + } + + NameVersionDescriptor[] allFeatures = new NameVersionDescriptor[] { + new NameVersionDescriptor("org.eclipse.jdt", "3.6.0.v20100105-0800-7z8VFR9FMTb52_pOyKHhoek1", + NameVersionDescriptor.TYPE_FEATURE), + new NameVersionDescriptor("org.eclipse.jdt.source", "3.6.0.v20100105-0800-7z8VFR9FMTb52_pOyKHhoek1", + NameVersionDescriptor.TYPE_FEATURE) }; + definition.setIncluded(allFeatures); + TargetBundle[] bundles = definition.getBundles(); + + for (TargetBundle bundle : bundles) { + String symbolicName = bundle.getBundleInfo().getSymbolicName(); + expected.remove(symbolicName); + if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) { + // the bundle should be missing unless on Mac + IStatus status = bundle.getStatus(); + if (Platform.getOS().equals(Platform.OS_MACOSX)) { + assertTrue("Mac bundle should be present", status.isOK()); + } else { + assertFalse("Mac bundle should be missing", status.isOK()); + assertEquals("Mac bundle should be mssing", TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST, + status.getCode()); + } + } + } + for (String name : expected) { + System.err.println("Missing: " + name); + } + assertTrue("Wrong bundles in JDT feature", expected.isEmpty()); + + } + + @Test + public void testSingleInclude() throws Exception { + // Use the modified JDT features as we know their versions + ITargetDefinition definition = getNewTarget(); + IPath location = extractModifiedFeatures(); + + ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); + definition.setTargetLocations(new ITargetLocation[] { container }); + definition.resolve(null); + + List expected = new ArrayList<>(); + expected.add("org.eclipse.jdt"); + expected.add("org.eclipse.jdt.launching"); + // 2 versions of JUnit + expected.add("org.junit"); + expected.add("org.junit"); + expected.add("org.junit4"); + if (Platform.getOS().equals(Platform.OS_MACOSX)) { + expected.add("org.eclipse.jdt.launching.macosx"); + } + + NameVersionDescriptor[] allFeatures = new NameVersionDescriptor[] { + new NameVersionDescriptor("org.eclipse.jdt", null, NameVersionDescriptor.TYPE_FEATURE) }; + definition.setIncluded(allFeatures); + TargetBundle[] bundles = definition.getBundles(); + + for (TargetBundle bundle : bundles) { + String symbolicName = bundle.getBundleInfo().getSymbolicName(); + expected.remove(symbolicName); + if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) { + // the bundle should be missing unless on Mac + IStatus status = bundle.getStatus(); + if (Platform.getOS().equals(Platform.OS_MACOSX)) { + assertTrue("Mac bundle should be present", status.isOK()); + } else { + assertFalse("Mac bundle should be missing", status.isOK()); + assertEquals("Mac bundle should be missing", TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST, + status.getCode()); + } + } + } + for (String name : expected) { + System.err.println("Missing: " + name); + } + assertTrue("Wrong bundles in JDT feature", expected.isEmpty()); + } + + @Test + public void testMixedIncludes() throws Exception { + // Use the modified JDT features as we know their versions + ITargetDefinition definition = getNewTarget(); + IPath location = extractModifiedFeatures(); + + ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); + definition.setTargetLocations(new ITargetLocation[] { container }); + definition.resolve(null); + + List expected = new ArrayList<>(); + expected.add("org.eclipse.jdt"); + expected.add("org.eclipse.jdt.launching"); + // 2 versions of JUnit + expected.add("org.junit"); + expected.add("org.junit"); + expected.add("org.junit4"); + if (Platform.getOS().equals(Platform.OS_MACOSX)) { + expected.add("org.eclipse.jdt.launching.macosx"); + } + + NameVersionDescriptor[] allFeatures = new NameVersionDescriptor[] { + new NameVersionDescriptor("org.eclipse.jdt", null, NameVersionDescriptor.TYPE_FEATURE), + new NameVersionDescriptor("org.eclipse.jdt", null, NameVersionDescriptor.TYPE_PLUGIN) }; + definition.setIncluded(allFeatures); + TargetBundle[] bundles = definition.getBundles(); + + for (TargetBundle bundle : bundles) { + String symbolicName = bundle.getBundleInfo().getSymbolicName(); + expected.remove(symbolicName); + if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) { + // the bundle should be missing unless on Mac + IStatus status = bundle.getStatus(); + if (Platform.getOS().equals(Platform.OS_MACOSX)) { + assertTrue("Mac bundle should be present", status.isOK()); + } else { + assertFalse("Mac bundle should be missing", status.isOK()); + assertEquals("Mac bundle should be mssing", TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST, + status.getCode()); + } + } + } + for (String name : expected) { + System.err.println("Missing: " + name); + } + assertTrue("Wrong bundles in JDT feature", expected.isEmpty()); + } + + @Test + public void testMissingFeatures() throws Exception { + // Use the modified JDT features as we know their versions + ITargetDefinition definition = getNewTarget(); + IPath location = extractModifiedFeatures(); + + ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); + definition.setTargetLocations(new ITargetLocation[] { container }); + definition.resolve(null); + + NameVersionDescriptor[] allFeatures = new NameVersionDescriptor[] { + new NameVersionDescriptor("DOES_NOT_EXIST", null, NameVersionDescriptor.TYPE_FEATURE), }; + definition.setIncluded(allFeatures); + TargetBundle[] bundles = definition.getBundles(); + + assertNotNull("Target didn't resolve", bundles); + assertEquals("Wrong number of included bundles", 1, bundles.length); + + IStatus definitionStatus = definition.getStatus(); + assertEquals("Wrong severity", IStatus.ERROR, definitionStatus.getSeverity()); + + IStatus[] children = definitionStatus.getChildren(); + assertEquals("Wrong number of statuses", 1, children.length); + assertEquals("Wrong severity", IStatus.ERROR, children[0].getSeverity()); + assertEquals(TargetBundle.STATUS_FEATURE_DOES_NOT_EXIST, children[0].getCode()); + + // Check that removing the included bundles and resolving removes the + // errors. + definition.setIncluded(null); + assertTrue(definition.isResolved()); + assertTrue(definition.getStatus().isOK()); + assertTrue(definition.getBundles().length > 4); + } + + @Test + public void testMissingFeatureVersion() throws Exception { + // Use the modified JDT features as we know their versions + ITargetDefinition definition = getNewTarget(); + IPath location = extractModifiedFeatures(); + + ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); + definition.setTargetLocations(new ITargetLocation[] { container }); + definition.resolve(null); + + List expected = new ArrayList<>(); + expected.add("org.eclipse.jdt"); + expected.add("org.eclipse.jdt.launching"); + // 2 versions of JUnit + expected.add("org.junit"); + expected.add("org.junit"); + expected.add("org.junit4"); + if (Platform.getOS().equals(Platform.OS_MACOSX)) { + expected.add("org.eclipse.jdt.launching.macosx"); + } + + NameVersionDescriptor[] allFeatures = new NameVersionDescriptor[] { + new NameVersionDescriptor("org.eclipse.jdt", "DOES_NOT_EXIST", NameVersionDescriptor.TYPE_FEATURE) }; + definition.setIncluded(allFeatures); + TargetBundle[] bundles = definition.getBundles(); + + for (TargetBundle bundle : bundles) { + String symbolicName = bundle.getBundleInfo().getSymbolicName(); + expected.remove(symbolicName); + if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) { + // the bundle should be missing unless on Mac + IStatus status = bundle.getStatus(); + if (Platform.getOS().equals(Platform.OS_MACOSX)) { + assertTrue("Mac bundle should be present", status.isOK()); + } else { + assertFalse("Mac bundle should be missing", status.isOK()); + assertEquals("Mac bundle should be mssing", TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST, + status.getCode()); + } + } + } + for (String name : expected) { + System.err.println("Missing: " + name); + } + assertTrue("Wrong bundles in JDT feature", expected.isEmpty()); + } + + @Test + public void testMissingMixed() throws Exception { + // Use the modified JDT features as we know their versions + ITargetDefinition definition = getNewTarget(); + IPath location = extractModifiedFeatures(); + + ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); + definition.setTargetLocations(new ITargetLocation[] { container }); + definition.resolve(null); + + NameVersionDescriptor[] allFeatures = new NameVersionDescriptor[] { + new NameVersionDescriptor("DOES_NOT_EXIST", null, NameVersionDescriptor.TYPE_FEATURE), + new NameVersionDescriptor("DOES_NOT_EXIST", null, NameVersionDescriptor.TYPE_PLUGIN), + new NameVersionDescriptor("org.eclipse.jdt", "DOES_NOT_EXIST", NameVersionDescriptor.TYPE_PLUGIN), }; + definition.setIncluded(allFeatures); + TargetBundle[] bundles = definition.getBundles(); + + assertNotNull("Target didn't resolve", bundles); + assertEquals("Wrong number of included bundles", 1, bundles.length); + + IStatus definitionStatus = definition.getStatus(); + assertEquals("Wrong severity", IStatus.ERROR, definitionStatus.getSeverity()); + + IStatus[] children = definitionStatus.getChildren(); + assertEquals("Wrong number of statuses", 1, children.length); + assertEquals("Wrong severity", IStatus.ERROR, children[0].getSeverity()); + assertEquals(TargetBundle.STATUS_FEATURE_DOES_NOT_EXIST, children[0].getCode()); + + // Check that removing the included bundles and resolving removes the + // errors. + definition.setIncluded(null); + assertTrue(definition.isResolved()); + assertTrue(definition.getStatus().isOK()); + assertTrue(definition.getBundles().length > 4); + } /** * Tests that a feature bundle container provides the correct features to a target */ @Test - public void testFeatureBundleContainer() throws Exception{ + public void testFeatureBundleContainer() throws Exception { + PDETestCase.assumeRunningInStandaloneEclipseSDK(); + ITargetDefinition definition = getNewTarget(); ITargetLocation featureContainer = getTargetService().newFeatureLocation(TargetPlatform.getDefaultLocation(), "org.eclipse.pde", null); diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionPersistenceTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionPersistenceTests.java index 531cda038ae..2eec51c38dd 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionPersistenceTests.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionPersistenceTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2017 IBM Corporation and others. + * Copyright (c) 2008, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,47 +13,527 @@ *******************************************************************************/ package org.eclipse.pde.ui.tests.target; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileInputStream; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.pde.core.plugin.TargetPlatform; import org.eclipse.pde.core.target.ITargetDefinition; +import org.eclipse.pde.core.target.ITargetHandle; import org.eclipse.pde.core.target.ITargetLocation; +import org.eclipse.pde.core.target.ITargetPlatformService; import org.eclipse.pde.core.target.NameVersionDescriptor; +import org.eclipse.pde.internal.core.target.DirectoryBundleContainer; +import org.eclipse.pde.internal.core.target.FeatureBundleContainer; import org.eclipse.pde.internal.core.target.IUBundleContainer; +import org.eclipse.pde.internal.core.target.ProfileBundleContainer; +import org.eclipse.pde.internal.core.target.TargetDefinition; import org.eclipse.pde.internal.core.target.TargetDefinitionPersistenceHelper; +import org.eclipse.pde.ui.tests.PDETestCase; +import org.eclipse.pde.ui.tests.PDETestsPlugin; import org.junit.Test; +import org.osgi.framework.ServiceReference; /** - * Tests the persistence of target definitions. Tests memento creation, reading of old target files, and writing of the model. + * Tests the persistence of target definitions. Tests memento creation, reading + * of old target files, and writing of the model. * * @since 3.5 */ -public class TargetDefinitionPersistenceTests extends MinimalTargetDefinitionPersistenceTests { +public class TargetDefinitionPersistenceTests { + + /** Tests restoration of a handle to target definition in an IFile. */ + @Test + public void testWorkspaceTargetHandleMemento() throws CoreException { + ITargetPlatformService service = getTargetService(); + IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(IPath.fromOSString("does/not/exist")); + ITargetHandle handle = service.getTarget(file); + assertFalse("Target should not exist", handle.exists()); + String memento = handle.getMemento(); + assertNotNull("Missing memento", memento); + ITargetHandle handle2 = service.getTarget(memento); + assertEquals("Restore failed", handle, handle2); + IFile file2 = ResourcesPlugin.getWorkspace().getRoot().getFile(IPath.fromOSString("does/not/exist/either")); + ITargetHandle handle3 = service.getTarget(file2); + assertFalse("Should be different targets", handle.equals(handle3)); + } + + /** Tests restoration of a handle to target definition in local metadata. */ + @Test + public void testLocalTargetHandleMemento() throws CoreException { + ITargetPlatformService service = getTargetService(); + ITargetHandle handle = service.newTarget().getHandle(); + assertFalse("Target should not exist", handle.exists()); + String memento = handle.getMemento(); + assertNotNull("Missing memento", memento); + ITargetHandle handle2 = service.getTarget(memento); + assertEquals("Restore failed", handle, handle2); + ITargetHandle handle3 = service.newTarget().getHandle(); + assertFalse("Should be different targets", handle.equals(handle3)); + } + + /** Tests restoration of a handle to target definition in external URI. */ + @Test + public void testExternalFileTargetHandleMemento() throws CoreException { + ITargetPlatformService service = getTargetService(); + URI uri = null; + try { + uri = new URI("file:///does/not/exist"); + } catch (URISyntaxException e) { + } + // IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new + // Path("does/not/exist")); + ITargetHandle handle = service.getTarget(uri); + assertFalse("Target should not exist", handle.exists()); + String memento = handle.getMemento(); + assertNotNull("Missing memento", memento); + ITargetHandle handle2 = service.getTarget(memento); + assertEquals("Restore failed", handle, handle2); + // IFile file2 = ResourcesPlugin.getWorkspace().getRoot().getFile(new + // Path("does/not/exist/either")); + URI uri2 = null; + try { + uri2 = new URI("file://even/this/file/does/not/exist"); + } catch (URISyntaxException e) { + } + ITargetHandle handle3 = service.getTarget(uri2); + assertFalse("Should be different targets", handle.equals(handle3)); + } /** - * Tests that a complex metadata based target definition can be serialized to xml, - * then deserialized without any loss of data. - * - * @throws Exception + * Tests that an empty target definition can be serialized to xml, then + * deserialized without any loss of data. + */ + @Test + public void testPersistEmptyDefinition() throws Exception { + ITargetDefinition definitionA = getTargetService().newTarget(); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + TargetDefinitionPersistenceHelper.persistXML(definitionA, outputStream); + ITargetDefinition definitionB = getTargetService().newTarget(); + ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); + TargetDefinitionPersistenceHelper.initFromXML(definitionB, inputStream); + assertTargetDefinitionsEqual(definitionA, definitionB); + } + + /** + * Tests that we can de-serialize an old style target definition file + * (version 3.2) and retrieve the correct contents. + */ + @Test + public void testReadOldBasicTargetFile() throws Exception { + ITargetDefinition target = readOldTarget("basic"); + + assertEquals("Wrong name", "Basic", target.getName()); + assertNull(target.getArch()); + assertNull(target.getOS()); + assertNull(target.getNL()); + assertNull(target.getWS()); + assertNull(target.getProgramArguments()); + assertNull(target.getVMArguments()); + assertNull(target.getImplicitDependencies()); + assertNull(target.getJREContainer()); + + ITargetLocation[] containers = target.getTargetLocations(); + assertEquals("Wrong number of bundles", 1, containers.length); + assertTrue("Container should be a profile container", containers[0] instanceof ProfileBundleContainer); + assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()), + IPath.fromOSString(getResolvedLocation(containers[0]))); + } + + /** + * Tests that we can de-serialize an old style target definition file + * (version 3.2) and retrieve the correct contents. + */ + @Test + public void testReadOldBasicDirectoryTargetFile() throws Exception { + ITargetDefinition target = readOldTarget("directory"); + + assertEquals("Wrong name", "Directory", target.getName()); + assertNull(target.getArch()); + assertNull(target.getOS()); + assertNull(target.getNL()); + assertNull(target.getWS()); + assertNull(target.getProgramArguments()); + assertNull(target.getVMArguments()); + assertNull(target.getImplicitDependencies()); + assertNull(target.getJREContainer()); + + ITargetLocation[] containers = target.getTargetLocations(); + assertEquals("Wrong number of bundles", 1, containers.length); + assertTrue("Container should be a directory container", containers[0] instanceof DirectoryBundleContainer); + assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("plugins"), + IPath.fromOSString(getResolvedLocation(containers[0]))); + } + + /** + * Tests that we can de-serialize an old style target definition file + * (version 3.2) and retrieve the correct contents. + */ + @Test + public void testReadOldSpecificTargetFile() throws Exception { + ITargetDefinition target = readOldTarget("specific"); + + assertEquals("Wrong name", "Specific Settings", target.getName()); + assertEquals("x86", target.getArch()); + assertEquals("linux", target.getOS()); + assertEquals("en_US", target.getNL()); + assertEquals("gtk", target.getWS()); + assertEquals("pgm1 pgm2", target.getProgramArguments()); + assertEquals("-Dfoo=\"bar\"", target.getVMArguments()); + assertEquals( + JavaRuntime + .newJREContainerPath(JavaRuntime.getExecutionEnvironmentsManager().getEnvironment("J2SE-1.4")), + target.getJREContainer()); + + NameVersionDescriptor[] infos = target.getImplicitDependencies(); + assertEquals("Wrong number of implicit dependencies", 2, infos.length); + Set set = new HashSet<>(); + for (NameVersionDescriptor info : infos) { + set.add(info.getId()); + } + assertTrue("Missing ", set.remove("org.eclipse.jdt.debug")); + assertTrue("Missing ", set.remove("org.eclipse.debug.core")); + assertTrue(set.isEmpty()); + + ITargetLocation[] containers = target.getTargetLocations(); + assertEquals("Wrong number of bundles", 1, containers.length); + assertTrue("Container should be a directory container", containers[0] instanceof DirectoryBundleContainer); + assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("plugins"), + IPath.fromOSString(getResolvedLocation(containers[0]))); + } + + /** + * Tests that we can de-serialize an old style target definition file + * (version 3.2) and retrieve the correct contents. + */ + @Test + public void testReadOldAdditionLocationsTargetFile() throws Exception { + ITargetDefinition target = readOldTarget("additionalLocations"); + + assertEquals("Wrong name", "Additional Locations", target.getName()); + assertNull(target.getArch()); + assertNull(target.getOS()); + assertNull(target.getNL()); + assertNull(target.getWS()); + assertNull(target.getProgramArguments()); + assertNull(target.getVMArguments()); + assertNull(target.getJREContainer()); + assertNull(target.getImplicitDependencies()); + + ITargetLocation[] containers = target.getTargetLocations(); + assertEquals("Wrong number of bundles", 3, containers.length); + assertTrue(containers[0] instanceof ProfileBundleContainer); + assertTrue(containers[1] instanceof DirectoryBundleContainer); + assertTrue(containers[2] instanceof DirectoryBundleContainer); + + assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()), + IPath.fromOSString(getResolvedLocation(containers[0]))); + + String string = VariablesPlugin.getDefault().getStringVariableManager() + .performStringSubstitution("${workspace_loc}"); + assertEquals("Wrong 1st additional location", IPath.fromOSString(string).append("stuff"), + IPath.fromOSString(getResolvedLocation(containers[1]))); + + assertEquals("Wrong 2nd additional location", + IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("dropins"), + IPath.fromOSString(getResolvedLocation(containers[2]))); + } + + /** + * Tests that we can de-serialize an old style target definition file + * (version 3.2) and retrieve the correct contents. + */ + @Test + public void testReadOldFeaturesTargetFile() throws Exception { + ITargetDefinition target = readOldTarget("featureLocations"); + + assertEquals("Wrong name", "Features", target.getName()); + assertNull(target.getArch()); + assertNull(target.getOS()); + assertNull(target.getNL()); + assertNull(target.getWS()); + assertNull(target.getProgramArguments()); + assertNull(target.getVMArguments()); + assertNull(target.getJREContainer()); + assertNull(target.getImplicitDependencies()); + + ITargetLocation[] containers = target.getTargetLocations(); + assertEquals("Wrong number of bundles", 2, containers.length); + assertTrue(containers[0] instanceof FeatureBundleContainer); + assertTrue(containers[1] instanceof FeatureBundleContainer); + + assertEquals("Wrong feature location", "org.eclipse.jdt", + ((FeatureBundleContainer) containers[0]).getFeatureId()); + assertEquals("Wrong feature location", "org.eclipse.platform", + ((FeatureBundleContainer) containers[1]).getFeatureId()); + } + + /** + * Tests that we can de-serialize an old style target definition file + * (version 3.2) and retrieve the correct contents. + */ + @Test + public void testReadOldRestrictionsTargetFile() throws Exception { + ITargetDefinition target = readOldTarget("restrictions"); + + assertEquals("Wrong name", "Restrictions", target.getName()); + assertNull(target.getArch()); + assertNull(target.getOS()); + assertNull(target.getNL()); + assertNull(target.getWS()); + assertNull(target.getProgramArguments()); + assertNull(target.getVMArguments()); + assertNull(target.getJREContainer()); + assertNull(target.getImplicitDependencies()); + + ITargetLocation[] containers = target.getTargetLocations(); + assertEquals("Wrong number of containers", 3, containers.length); + assertTrue(containers[0] instanceof ProfileBundleContainer); + assertTrue(containers[1] instanceof FeatureBundleContainer); + assertTrue(containers[2] instanceof DirectoryBundleContainer); + + assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()), + IPath.fromOSString(getResolvedLocation(containers[0]))); + assertEquals("Wrong 1st additional location", "org.eclipse.jdt", + ((FeatureBundleContainer) containers[1]).getFeatureId()); + assertEquals("Wrong 2nd additional location", + IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("dropins"), + IPath.fromOSString(getResolvedLocation(containers[2]))); + + NameVersionDescriptor[] restrictions = new NameVersionDescriptor[] { + new NameVersionDescriptor("org.eclipse.debug.core", null), + new NameVersionDescriptor("org.eclipse.debug.ui", null), + new NameVersionDescriptor("org.eclipse.jdt.debug", null), + new NameVersionDescriptor("org.eclipse.jdt.debug.ui", null), + new NameVersionDescriptor("org.eclipse.jdt.launching", null) }; + + NameVersionDescriptor[] actual = target.getIncluded(); + assertNotNull(actual); + assertEquals("Wrong number of restrictions", restrictions.length, actual.length); + for (int j = 0; j < actual.length; j++) { + assertEquals("Wrong restriction", restrictions[j], actual[j]); + } + } + + /** + * Tests that we can de-serialize an old style target definition file + * (version 3.2) that has extra/unsupported tags and retrieve the correct + * contents. + */ + @Test + public void testReadOldTargetFileWithUnknownTags() throws Exception { + ITargetDefinition target = readOldTarget("extratags"); + + assertEquals("Wrong name", "Restrictions", target.getName()); + assertNull(target.getArch()); + assertNull(target.getOS()); + assertNull(target.getNL()); + assertNull(target.getWS()); + assertNull(target.getProgramArguments()); + assertNull(target.getVMArguments()); + assertNull(target.getJREContainer()); + assertNull(target.getImplicitDependencies()); + + ITargetLocation[] containers = target.getTargetLocations(); + assertEquals("Wrong number of bundles", 3, containers.length); + assertTrue(containers[0] instanceof ProfileBundleContainer); + assertTrue(containers[1] instanceof FeatureBundleContainer); + assertTrue(containers[2] instanceof DirectoryBundleContainer); + + assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()), + IPath.fromOSString(getResolvedLocation(containers[0]))); + assertEquals("Wrong 1st additional location", "org.eclipse.jdt", + ((FeatureBundleContainer) containers[1]).getFeatureId()); + assertEquals("Wrong 2nd additional location", + IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("dropins"), + IPath.fromOSString(getResolvedLocation(containers[2]))); + + NameVersionDescriptor[] restrictions = new NameVersionDescriptor[] { + new NameVersionDescriptor("org.eclipse.debug.core", null), + new NameVersionDescriptor("org.eclipse.debug.ui", null), + new NameVersionDescriptor("org.eclipse.jdt.debug", null), + new NameVersionDescriptor("org.eclipse.jdt.debug.ui", null), + new NameVersionDescriptor("org.eclipse.jdt.launching", null) }; + + NameVersionDescriptor[] actual = target.getIncluded(); + assertNotNull(actual); + assertEquals("Wrong number of restrictions", restrictions.length, actual.length); + for (int j = 0; j < actual.length; j++) { + assertEquals("Wrong restriction", restrictions[j], actual[j]); + } + } + + /** + * Tests that we can de-serialize an old style target definition file + * (version 3.2) and retrieve the correct contents with optional bundles. */ + @Test + public void testReadOldOptionalTargetFile() throws Exception { + ITargetDefinition target = readOldTarget("optional"); + assertEquals("Wrong name", "Optional", target.getName()); + assertNull(target.getArch()); + assertNull(target.getOS()); + assertNull(target.getNL()); + assertNull(target.getWS()); + assertNull(target.getProgramArguments()); + assertNull(target.getVMArguments()); + assertNull(target.getImplicitDependencies()); + assertNull(target.getJREContainer()); + + ITargetLocation[] containers = target.getTargetLocations(); + assertEquals("Wrong number of bundles", 2, containers.length); + assertTrue("Container should be a profile container", containers[0] instanceof ProfileBundleContainer); + assertTrue("Container should be a profile container", containers[1] instanceof FeatureBundleContainer); + assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()), + IPath.fromOSString(getResolvedLocation(containers[0]))); + assertEquals("Wrong feature location", "org.eclipse.jdt", + ((FeatureBundleContainer) containers[1]).getFeatureId()); + + // Old optional settings are added to includes + NameVersionDescriptor[] included = new NameVersionDescriptor[] { + new NameVersionDescriptor("org.eclipse.debug.core", null), + new NameVersionDescriptor("org.eclipse.debug.examples.core", null), + new NameVersionDescriptor("org.eclipse.debug.examples.ui", null), + new NameVersionDescriptor("org.eclipse.debug.ui", null), + new NameVersionDescriptor("org.eclipse.jdt.debug", null), + new NameVersionDescriptor("org.eclipse.jdt.debug.ui", null), + new NameVersionDescriptor("org.eclipse.jdt.launching", null) }; + + NameVersionDescriptor[] actual = target.getIncluded(); + assertNotNull(actual); + assertEquals("Wrong number of inclusions", included.length, actual.length); + for (int j = 0; j < actual.length; j++) { + assertEquals("Wrong restriction", included[j], actual[j]); + } + } + + /** + * Test for bug 268709, if the content section is included in the xml, but + * there are no specific plug-ins or features as well as no + * useAllPlugins=true setting, treat the file as though it did include all + * plug-ins from the directory. + */ + @Test + public void testEmptyContentSection() throws Exception { + ITargetDefinition target = readOldTarget("emptycontent"); + + ITargetLocation[] containers = target.getTargetLocations(); + assertEquals("Wrong number of bundles", 1, containers.length); + assertTrue("Container should be a directory container", containers[0] instanceof DirectoryBundleContainer); + assertEquals("Wrong home location", IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("plugins"), + IPath.fromOSString(getResolvedLocation(containers[0]))); + + target.resolve(null); + + assertTrue("Should have resolved bundles", target.getBundles().length > 0); + + } + + /** + * Test for bug 264139. Tests that when a target definition specifies + * "useAllPlugins=true" that we ignore specific plug-ins/features specified + * in the file during migration. + */ + @Test + public void testMigrationOfUseAllWithRestrictions() throws Exception { + ITargetDefinition target = readOldTarget("eclipse-serverside"); + ITargetLocation[] containers = target.getTargetLocations(); + assertEquals(6, containers.length); + validateTypeAndLocation(containers[0], ProfileBundleContainer.class, + "${resource_loc:/target-platforms/eclipse-equinox-SDK-3.5M5/eclipse}"); + validateTypeAndLocation(containers[1], DirectoryBundleContainer.class, + "${resource_loc:/target-platforms/eclipse-3.5M5-delta-pack/eclipse}"); + validateTypeAndLocation(containers[2], DirectoryBundleContainer.class, + "${resource_loc:/target-platforms/eclipse-pde-headless-3.5M5}"); + validateTypeAndLocation(containers[3], DirectoryBundleContainer.class, + "${resource_loc:/target-platforms/eclipse-test-framework-3.5M5/eclipse}"); + validateTypeAndLocation(containers[4], DirectoryBundleContainer.class, + "${resource_loc:/target-platforms/eclipse-core-plugins-3.5M5}"); + validateTypeAndLocation(containers[5], DirectoryBundleContainer.class, + "${resource_loc:/target-platforms/3rdparty-bundles}"); + } + + /** Validates the type and location of a bundle container. */ + private static void validateTypeAndLocation(ITargetLocation container, Class clazz, String rawLocation) + throws CoreException { + assertTrue(clazz.isInstance(container)); + assertEquals(rawLocation, container.getLocation(false)); + } + + /** + * Tests that we increment the sequence number correctly when target is + * modified contents. + */ + @Test + public void testSequenceNumberChange() throws Exception { + ITargetDefinition target = readOldTarget("featureLocations"); + + assertEquals("Wrong name", "Features", target.getName()); + TargetDefinition targetDef = (TargetDefinition) target; + int currentSeqNo = targetDef.getSequenceNumber(); + target.setArch("x86"); + asssertSequenceNumber("Arch", currentSeqNo, targetDef); + + currentSeqNo = targetDef.getSequenceNumber(); + target.setOS("win32"); + asssertSequenceNumber("OS", currentSeqNo, targetDef); + + currentSeqNo = targetDef.getSequenceNumber(); + target.setNL("hi_IN"); + asssertSequenceNumber("NL", currentSeqNo, targetDef); + + currentSeqNo = targetDef.getSequenceNumber(); + target.setWS("carbon"); + asssertSequenceNumber("WS", currentSeqNo, targetDef); + + ITargetLocation[] newContainers = new ITargetLocation[1]; + newContainers[0] = new DirectoryBundleContainer("Path"); + currentSeqNo = targetDef.getSequenceNumber(); + target.setTargetLocations(newContainers); + asssertSequenceNumber("Bundle Containers", currentSeqNo, targetDef); + } + + @Test + public void testIncludeSource() throws Exception { + ITargetDefinition target = readOldTarget("SoftwareSiteTarget"); + ITargetLocation[] containers = target.getTargetLocations(); + assertEquals(1, containers.length); + assertTrue(containers[0] instanceof IUBundleContainer); + IUBundleContainer iubc = (IUBundleContainer) containers[0]; + assertTrue(iubc.getIncludeSource()); + } + + /** + * Tests that a complex metadata based target definition can be serialized + * to xml, then deserialized without any loss of data. + */ @Test public void testPersistComplexMetadataDefinition() throws Exception { - // org.junit.Assume.assumeTrue(false); + PDETestCase.assumeRunningInStandaloneEclipseSDK(); + ITargetDefinition definitionA = getTargetService().newTarget(); initComplexDefiniton(definitionA); @@ -69,12 +549,11 @@ public void testPersistComplexMetadataDefinition() throws Exception { /** * Tests that a complex workspace file based target definition can be * serialized to xml, then deserialized without any loss of data. - * - * @throws Exception */ @Test public void testPersistComplexWorkspaceDefinition() throws Exception { - // org.junit.Assume.assumeTrue(false); + PDETestCase.assumeRunningInStandaloneEclipseSDK(); + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("TargetDefinitionPersistenceTests"); try { if (!project.exists()) { @@ -99,7 +578,62 @@ public void testPersistComplexWorkspaceDefinition() throws Exception { } } - protected void initComplexDefiniton(ITargetDefinition definition) throws URISyntaxException { + /** + * Returns the target platform service or null if none + * + * @return target platform service + */ + private ITargetPlatformService getTargetService() { + ServiceReference reference = PDETestsPlugin.getBundleContext() + .getServiceReference(ITargetPlatformService.class); + assertNotNull("Missing target platform service", reference); + return PDETestsPlugin.getBundleContext().getService(reference); + } + + /** + * Reads a target definition file from the tests/targets/target-files + * location with the given name. Note that ".target" will be appended. + */ + private ITargetDefinition readOldTarget(String name) throws Exception { + URL url = PDETestsPlugin.getBundleContext().getBundle() + .getEntry("/tests/targets/target-files/" + name + ".trgt"); + File file = new File(FileLocator.toFileURL(url).getFile()); + ITargetDefinition target = getTargetService().newTarget(); + try (FileInputStream stream = new FileInputStream(file)) { + TargetDefinitionPersistenceHelper.initFromXML(target, stream); + } + return target; + } + + /** Returns the resolved location of the specified bundle container. */ + private String getResolvedLocation(ITargetLocation container) throws CoreException { + return container.getLocation(true); + } + + /** + * Returns the location of the JDT feature in the running host as a path in + * the local file system. + * + * @return path to JDT feature + */ + private IPath getJdtFeatureLocation() { + IPath path = IPath.fromOSString(TargetPlatform.getDefaultLocation()); + path = path.append("features"); + File dir = path.toFile(); + assertTrue("Missing features directory", dir.exists() && !dir.isFile()); + String[] files = dir.list(); + String location = null; + for (String file : files) { + if (file.startsWith("org.eclipse.jdt_")) { + location = path.append(file).toOSString(); + break; + } + } + assertNotNull("Missing JDT feature", location); + return IPath.fromOSString(location); + } + + private void initComplexDefiniton(ITargetDefinition definition) throws URISyntaxException { definition.setName("name"); definition.setOS("os"); definition.setWS("ws"); @@ -148,5 +682,13 @@ protected void initComplexDefiniton(ITargetDefinition definition) throws URISynt restrictedProfileContainer, siteContainer, siteContainer2 }); } + private void assertTargetDefinitionsEqual(ITargetDefinition targetA, ITargetDefinition targetB) { + assertTrue("Target content not equal", ((TargetDefinition) targetA).isContentEqual(targetB)); + } + + private void asssertSequenceNumber(String name, int currentSeqNo, TargetDefinition targetDef) { + assertEquals("Sequence number did not increment after updating '" + name + "'", currentSeqNo + 1, + targetDef.getSequenceNumber()); + } } \ No newline at end of file diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionResolutionTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionResolutionTests.java index 76910c89f8a..ead5668e673 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionResolutionTests.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/TargetDefinitionResolutionTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2017 IBM Corporation and others. + * Copyright (c) 2009, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,22 +14,391 @@ package org.eclipse.pde.ui.tests.target; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.io.File; + +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.frameworkadmin.BundleInfo; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.jdt.launching.JavaRuntime; import org.eclipse.pde.core.plugin.TargetPlatform; import org.eclipse.pde.core.target.ITargetDefinition; import org.eclipse.pde.core.target.ITargetLocation; +import org.eclipse.pde.core.target.ITargetPlatformService; import org.eclipse.pde.core.target.NameVersionDescriptor; import org.eclipse.pde.core.target.TargetBundle; +import org.eclipse.pde.internal.core.target.IUBundleContainer; +import org.eclipse.pde.ui.tests.PDETestCase; import org.junit.Test; -public class TargetDefinitionResolutionTests extends MinimalTargetDefinitionResolutionTests { +public class TargetDefinitionResolutionTests extends AbstractTargetTest { + + @Test + public void testInvalidBundleContainers() throws Exception { + ITargetDefinition definition = getNewTarget(); + + ITargetLocation directoryContainer = getTargetService().newDirectoryLocation("***SHOULD NOT EXIST***"); + IStatus status = directoryContainer.resolve(definition, null); + assertEquals("Incorrect severity", IStatus.ERROR, status.getSeverity()); + + ITargetLocation profileContainer = getTargetService().newProfileLocation("***SHOULD NOT EXIST***", null); + status = directoryContainer.resolve(definition, null); + assertEquals("Incorrect severity", IStatus.ERROR, status.getSeverity()); + + ITargetLocation featureContainer = getTargetService().newFeatureLocation("***SHOULD NOT EXIST***", + "org.eclipse.jdt", ""); + status = directoryContainer.resolve(definition, null); + assertEquals("Incorrect severity", IStatus.ERROR, status.getSeverity()); + + definition.setTargetLocations(new ITargetLocation[] { directoryContainer, profileContainer, featureContainer }); + status = definition.resolve(null); + IStatus[] children = status.getChildren(); + assertEquals("Wrong number of children", 3, children.length); + for (IStatus element : children) { + assertEquals("Incorrect severity", IStatus.ERROR, element.getSeverity()); + assertFalse("Failed resolution should be single status", element.isMultiStatus()); + } + } + + /** + * Tests that if we find a bundle with a bad or missing manifest when + * resolving we create the correct status. + * + * @see TargetBundle.STATUS_INVALID_MANIFEST + * @throws Exception + */ + @Test + public void testInvalidManifest() throws Exception { + // TODO Should we have tests for this? + } + + @Test + public void testResolutionCaching() throws Exception { + ITargetDefinition definition = getNewTarget(); + assertTrue(definition.isResolved()); + assertNotNull("Bundles not available when resolved", definition.getBundles()); + assertEquals("Wrong number of bundles", 0, definition.getBundles().length); + + // Resolving with errors should stay resolved, solving a definition + // should resolve all targets + ITargetLocation brokenContainer = getTargetService().newDirectoryLocation("***SHOULD NOT EXIST***"); + assertFalse(brokenContainer.isResolved()); + assertNull("Bundles available when unresolved", brokenContainer.getBundles()); + definition.setTargetLocations(new ITargetLocation[] { brokenContainer }); + assertFalse(definition.isResolved()); + assertNull("Bundles available when unresolved", definition.getBundles()); + IStatus status = definition.resolve(null); + assertEquals("Incorrect Severity", IStatus.ERROR, status.getSeverity()); + assertTrue(brokenContainer.isResolved()); + assertNotNull("Bundles not available when resolved", brokenContainer.getBundles()); + assertTrue(definition.isResolved()); + assertNotNull("Bundles not available when resolved", definition.getBundles()); + + // Adding an unresolved container should make the target unresolved, + // resolving the container should resolve the target + ITargetLocation profileContainer = getTargetService().newProfileLocation(TargetPlatform.getDefaultLocation(), + null); + assertFalse(profileContainer.isResolved()); + assertNull("Bundles available when unresolved", profileContainer.getBundles()); + definition.setTargetLocations(new ITargetLocation[] { brokenContainer, profileContainer }); + assertFalse(definition.isResolved()); + assertNull("Bundles available when unresolved", definition.getBundles()); + status = profileContainer.resolve(definition, null); + assertEquals("Incorrect Severity", IStatus.OK, status.getSeverity()); + assertEquals("Incorrect Severity", IStatus.ERROR, definition.getStatus().getSeverity()); + assertTrue(profileContainer.isResolved()); + assertNotNull("Bundles not available when resolved", profileContainer.getBundles()); + assertTrue(definition.isResolved()); + assertNotNull("Bundles not available when resolved", definition.getBundles()); + + // Having a bundle status does not prevent the resolution, adding a + // resolved container should leave the target resolved + ITargetLocation includesContainer = getTargetService().newProfileLocation(TargetPlatform.getDefaultLocation(), + null); + assertFalse(includesContainer.isResolved()); + assertNull("Bundles available when unresolved", includesContainer.getBundles()); + status = includesContainer.resolve(definition, null); + assertTrue(includesContainer.isResolved()); + assertNotNull("Bundles not available when resolved", includesContainer.getBundles()); + assertEquals("Incorrect Severity", IStatus.OK, status.getSeverity()); + assertEquals("Incorrect Severity", IStatus.OK, includesContainer.getStatus().getSeverity()); + definition.setTargetLocations(new ITargetLocation[] { brokenContainer, profileContainer }); + definition.setIncluded(new NameVersionDescriptor[] { new NameVersionDescriptor("bogus", null), + new NameVersionDescriptor("org.eclipse.platform", "666.666.666") }); + assertTrue(definition.isResolved()); + assertEquals("Incorrect Severity", IStatus.ERROR, definition.getStatus().getSeverity()); + assertNotNull("Bundles not available when resolved", definition.getBundles()); + + // Setting includes, etc. should not unresolve the target + definition.setIncluded(null); + assertTrue(definition.isResolved()); + definition.setIncluded(new NameVersionDescriptor[] { new NameVersionDescriptor("bogus", null), + new NameVersionDescriptor("org.eclipse.platform", "666.666.666") }); + assertTrue(definition.isResolved()); + definition.setName("name"); + definition.setOS("os"); + definition.setWS("ws"); + definition.setArch("arch"); + definition.setNL("nl"); + definition.setProgramArguments("program\nargs"); + definition.setVMArguments("vm\nargs"); + definition.setJREContainer(JavaRuntime.newDefaultJREContainerPath()); + NameVersionDescriptor[] implicit = new NameVersionDescriptor[] { + new NameVersionDescriptor("org.eclipse.jdt.launching", null), + new NameVersionDescriptor("org.eclipse.jdt.debug", null) }; + definition.setImplicitDependencies(implicit); + assertTrue(definition.isResolved()); + definition.setName(null); + definition.setOS(null); + definition.setWS(null); + definition.setArch(null); + definition.setNL(null); + definition.setProgramArguments(null); + definition.setVMArguments(null); + definition.setJREContainer(null); + definition.setImplicitDependencies(null); + assertTrue(definition.isResolved()); + + definition.setTargetLocations(null); + assertTrue(definition.isResolved()); + assertNotNull("Bundles not available when resolved", definition.getBundles()); + + } + + /** + * Tests that a target definition is in synch with the target platform. + * + * @throws Exception + */ + @Test + public void testTargetInSynch() throws Exception { + IPath location = extractAbcdePlugins(); + IPath dirPath = location.append("plugins"); + ITargetDefinition definition = getNewTarget(); + ITargetLocation container = getTargetService().newDirectoryLocation(dirPath.toOSString()); + definition.setTargetLocations(new ITargetLocation[] { container }); + definition.resolve(null); + TargetBundle[] allBundles = definition.getAllBundles(); + assertEquals(10, allBundles.length); + + try { + setTargetPlatform(definition); + IStatus status = getTargetService().compareWithTargetPlatform(definition); + assertTrue(status.isOK()); + } finally { + resetTargetPlatform(); + } + } + + /** + * Tests that a target definition is in synch with the target platform when + * there are duplicates in the target definition (duplicates should be + * ignored). + * + * @throws Exception + */ + @Test + public void testTargetInSynchWithDuplicates() throws Exception { + IPath location = extractAbcdePlugins(); + IPath dirPath = location.append("plugins"); + ITargetDefinition definition = getNewTarget(); + ITargetLocation container = getTargetService().newDirectoryLocation(dirPath.toOSString()); + ITargetLocation container2 = getTargetService().newDirectoryLocation(dirPath.toOSString()); + definition.setTargetLocations(new ITargetLocation[] { container, container2 }); + definition.resolve(null); + TargetBundle[] allBundles = definition.getAllBundles(); + assertEquals(20, allBundles.length); + + try { + setTargetPlatform(definition); + IStatus status = getTargetService().compareWithTargetPlatform(definition); + assertTrue(status.isOK()); + } finally { + resetTargetPlatform(); + } + } + + /** + * Tests that a target definition is not in synch with the target platform + * when a bundle is deleted from the underlying files system (target + * platform). + * + * @throws Exception + */ + @Test + public void testTargetMissingBundle() throws Exception { + IPath location = extractAbcdePlugins(); + IPath dirPath = location.append("plugins"); + ITargetDefinition definition = getNewTarget(); + ITargetLocation container = getTargetService().newDirectoryLocation(dirPath.toOSString()); + definition.setTargetLocations(new ITargetLocation[] { container }); + + try { + setTargetPlatform(definition); + // delete a bundle + IPath bundle = dirPath.append("bundle.a_1.0.0.jar"); + assertTrue(bundle.toFile().exists()); + bundle.toFile().delete(); + // force definition to re-resolve + ITargetDefinition copy = getTargetService().newTarget(); + getTargetService().copyTargetDefinition(definition, copy); + copy.resolve(null); + IStatus status = getTargetService().compareWithTargetPlatform(copy); + assertNotNull(status); + assertFalse(status.isOK()); + IStatus[] children = status.getChildren(); + assertEquals(1, children.length); + assertEquals(ITargetPlatformService.STATUS_MISSING_FROM_TARGET_DEFINITION, children[0].getCode()); + assertEquals("bundle.a", children[0].getMessage()); + } finally { + resetTargetPlatform(); + } + } + + /** + * Tests that a target definition will warn if an expected bundle does not + * exist on the file system. + * + * @throws Exception + */ + @Test + public void testTargetPlatformMissingBundle() throws Exception { + IPath location = extractAbcdePlugins(); + IPath dirPath = location.append("plugins"); + // delete a bundle + IPath bundle = dirPath.append("bundle.a_1.0.0.jar"); + File jar = bundle.toFile(); + assertTrue(jar.exists()); + jar.delete(); + + ITargetDefinition definition = getTargetService().newTarget(); + ITargetLocation container = getTargetService().newDirectoryLocation(dirPath.toOSString()); + definition.setTargetLocations(new ITargetLocation[] { container }); + definition.resolve(null); + TargetBundle[] allBundles = definition.getAllBundles(); + assertEquals(9, allBundles.length); + + try { + setTargetPlatform(definition); + // force definition to re-resolve + ITargetDefinition copy = getTargetService().newTarget(); + getTargetService().copyTargetDefinition(definition, copy); + // add the bundle back to the file system + extractAbcdePlugins(); + + copy.resolve(null); + IStatus status = getTargetService().compareWithTargetPlatform(copy); + assertNotNull(status); + assertFalse(status.isOK()); + IStatus[] children = status.getChildren(); + assertEquals(1, children.length); + assertEquals(ITargetPlatformService.STATUS_MISSING_FROM_TARGET_PLATFORM, children[0].getCode()); + assertEquals("bundle.a", children[0].getMessage()); + } finally { + resetTargetPlatform(); + } + } + + /** + * Tests the two options on IU bundle containers for controlling how the + * site will be resolved + * + * @throws Exception + */ + @Test + public void testSiteContainerIncludeSettings() throws Exception { + ITargetDefinition target = getNewTarget(); + IUBundleContainer containerA = (IUBundleContainer) getTargetService().newIULocation(new IInstallableUnit[0], + null, IUBundleContainer.INCLUDE_REQUIRED); + IUBundleContainer containerB = (IUBundleContainer) getTargetService().newIULocation( + new String[] { "unit1", "unit2" }, new String[] { "1.0", "2.0" }, null, + IUBundleContainer.INCLUDE_REQUIRED); + target.setTargetLocations(new ITargetLocation[] { containerA, containerB }); + + // Check default settings + assertTrue(containerA.getIncludeAllRequired()); + assertFalse(containerA.getIncludeAllEnvironments()); + assertFalse(containerA.getIncludeSource()); + assertTrue(containerB.getIncludeAllRequired()); + assertFalse(containerB.getIncludeAllEnvironments()); + assertFalse(containerB.getIncludeSource()); + + // Check basic changes + int flags = IUBundleContainer.INCLUDE_ALL_ENVIRONMENTS | IUBundleContainer.INCLUDE_SOURCE; + containerA = (IUBundleContainer) getTargetService().newIULocation(new IInstallableUnit[0], null, flags); + containerB = (IUBundleContainer) getTargetService().newIULocation(new String[] { "unit1", "unit2" }, + new String[] { "1.0", "2.0" }, null, flags); + target.setTargetLocations(new ITargetLocation[] { containerA, containerB }); + assertFalse(containerA.getIncludeAllRequired()); + assertTrue(containerA.getIncludeAllEnvironments()); + assertTrue(containerA.getIncludeSource()); + + // Check that all containers are updated in the target if target is + // passed as argument + flags = IUBundleContainer.INCLUDE_ALL_ENVIRONMENTS | IUBundleContainer.INCLUDE_SOURCE; + containerA = (IUBundleContainer) getTargetService().newIULocation(new IInstallableUnit[0], null, flags); + flags = IUBundleContainer.INCLUDE_REQUIRED; + containerB = (IUBundleContainer) getTargetService().newIULocation(new String[] { "unit1", "unit2" }, + new String[] { "1.0", "2.0" }, null, flags); + + target.setTargetLocations(new ITargetLocation[] { containerA, containerB }); + assertTrue(containerA.getIncludeAllRequired()); + assertFalse(containerA.getIncludeAllEnvironments()); + assertFalse(containerA.getIncludeSource()); + assertTrue(containerB.getIncludeAllRequired()); + assertFalse(containerB.getIncludeAllEnvironments()); + assertFalse(containerB.getIncludeSource()); + + // now switch the order of A and B + target.setTargetLocations(new ITargetLocation[] { containerB, containerA }); + assertFalse(containerA.getIncludeAllRequired()); + assertTrue(containerA.getIncludeAllEnvironments()); + assertTrue(containerA.getIncludeSource()); + assertFalse(containerB.getIncludeAllRequired()); + assertTrue(containerB.getIncludeAllEnvironments()); + assertTrue(containerB.getIncludeSource()); + } + + @Test + public void testNameVersionDescriptor() { + NameVersionDescriptor d1 = new NameVersionDescriptor("a.b.c", "1.0.0"); + NameVersionDescriptor d2 = new NameVersionDescriptor("a.b.c", "1.0.0"); + assertEquals(d1, d2); + + d1 = new NameVersionDescriptor("a.b.c", "1.0.0"); + d2 = new NameVersionDescriptor("a.b.c", "1.0.1"); + assertFalse(d1.equals(d2)); + + d1 = new NameVersionDescriptor("a.b.c", "1.0.0"); + d2 = new NameVersionDescriptor("a.b.e", "1.0.0"); + assertFalse(d1.equals(d2)); + + d1 = new NameVersionDescriptor("a.b.c", null); + d2 = new NameVersionDescriptor("a.b.c", null); + assertEquals(d1, d2); + + d1 = new NameVersionDescriptor("a.b.c", null); + d2 = new NameVersionDescriptor("a.b.e", null); + assertFalse(d1.equals(d2)); + + d1 = new NameVersionDescriptor("a.b.c", null); + d2 = new NameVersionDescriptor("a.b.c", "1.0.0"); + assertFalse(d1.equals(d2)); + + d1 = new NameVersionDescriptor("a.b.c", "1.0.0"); + d2 = new NameVersionDescriptor("a.b.c", null); + assertFalse(d1.equals(d2)); + } + @Test public void testMissingBundles() throws Exception { + PDETestCase.assumeRunningInStandaloneEclipseSDK(); + ITargetDefinition definition = getNewTarget(); ITargetLocation directoryContainer = getTargetService().newDirectoryLocation(TargetPlatform.getDefaultLocation() + "/plugins"); @@ -68,6 +437,8 @@ public void testMissingBundles() throws Exception { */ @Test public void testSourceBundleRecognition() throws Exception { + PDETestCase.assumeRunningInStandaloneEclipseSDK(); + ITargetDefinition definition = getNewTarget(); ITargetLocation directoryContainer = getTargetService().newDirectoryLocation(TargetPlatform.getDefaultLocation() + "/plugins"); @@ -108,6 +479,4 @@ public void testSourceBundleRecognition() throws Exception { } } - - } \ No newline at end of file diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/wizards/AllNewProjectMinimalTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/wizards/AllNewProjectMinimalTests.java deleted file mode 100644 index a1937e8e5bf..00000000000 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/wizards/AllNewProjectMinimalTests.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016, 2017 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.pde.ui.tests.wizards; - -import org.eclipse.pde.ui.tests.ee.ExecutionEnvironmentTests; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * They run on minimal plugin bundles and dont require the whole SDK ( for - * hudson gerrit). This class is refactored out of AllNewProjectTests - * - */ -@RunWith(Suite.class) -@SuiteClasses({ NewFeatureProjectTestCase.class, NewSiteProjectTestCase.class, - // ConvertProjectToPluginTestCase.class, - ExecutionEnvironmentTests.class }) -public class AllNewProjectMinimalTests { - -}