From 912012e163a96f7b6cf06ec7136e611e93dc01a2 Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Sun, 17 Sep 2023 14:32:48 +0200 Subject: [PATCH] Combine BaseImportTestCase subclasses into a parameterized test and make it work in verification tests and fix source-attachment assertion. Add Plug-ins to import from the runtime as dependencies of the Test-Plugin in order to ensure they are available in the test-runtime. --- .../META-INF/MANIFEST.MF | 12 +- .../pde/ui/tests/imports/AllImportTests.java | 6 +- .../ui/tests/imports/BaseImportTestCase.java | 191 +++++++++++------- .../tests/imports/ImportAsBinaryTestCase.java | 88 -------- .../tests/imports/ImportAsSourceTestCase.java | 62 ------ .../imports/ImportWithLinksTestCase.java | 81 -------- 6 files changed, 136 insertions(+), 304 deletions(-) delete mode 100644 ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/ImportAsBinaryTestCase.java delete mode 100644 ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/ImportAsSourceTestCase.java delete mode 100644 ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/ImportWithLinksTestCase.java diff --git a/ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF index 8db8519d83..f023ede4b2 100644 --- a/ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.ui.tests/META-INF/MANIFEST.MF @@ -41,7 +41,17 @@ Require-Bundle: org.eclipse.pde.ui, org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="2.1.300", org.eclipse.platform, org.eclipse.ui.ide.application, - org.eclipse.pde.api.tools + org.eclipse.pde.api.tools, + org.eclipse.jsch.core, + org.eclipse.jdt.doc.user, + org.junit.source;resolution:=optional, + org.eclipse.pde.ui.source;resolution:=optional, + org.apache.ant.source;resolution:=optional, + org.eclipse.jdt.debug.source;resolution:=optional, + org.eclipse.jsch.core.source;resolution:=optional, + org.eclipse.core.filebuffers.source;resolution:=optional, + org.eclipse.jdt.doc.user;resolution:=optional, + org.eclipse.pde.build.source;resolution:=optional Import-Package: javax.annotation;version="[1.3.0,2.0.0)", javax.inject;version="[1.0.0,2.0.0)", org.assertj.core.api;version="3.14.0", diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/AllImportTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/AllImportTests.java index a993febdda..e799cca22b 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/AllImportTests.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/AllImportTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2017 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 @@ -17,9 +17,9 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; - @RunWith(Suite.class) -@SuiteClasses({ ImportWithLinksTestCase.class, ImportAsBinaryTestCase.class, ImportAsSourceTestCase.class, +@SuiteClasses({ // + BaseImportTestCase.class, // // Temporarily disabled until git migration is complete and we have access to a // stable cvs repo (bug 355873) diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/BaseImportTestCase.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/BaseImportTestCase.java index ac774834fe..6927a270dd 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/BaseImportTestCase.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/BaseImportTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 IBM Corporation and others. + * Copyright (c) 2006, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,74 +10,122 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Hannes Wellmann - Combine BaseImportTestCase subclasses into a parameterized test and make it succeed in verifiation builds *******************************************************************************/ package org.eclipse.pde.ui.tests.imports; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; + +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragmentRoot; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; import org.eclipse.pde.core.plugin.IPluginModelBase; import org.eclipse.pde.core.plugin.ModelEntry; import org.eclipse.pde.core.plugin.PluginRegistry; +import org.eclipse.pde.internal.core.BinaryRepositoryProvider; import org.eclipse.pde.internal.core.PDECore; +import org.eclipse.pde.internal.core.natures.PDE; import org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation; import org.eclipse.pde.ui.tests.PDETestCase; +import org.eclipse.team.core.RepositoryProvider; +import org.junit.Assume; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; +import org.osgi.framework.FrameworkUtil; import org.osgi.framework.Version; -public abstract class BaseImportTestCase extends PDETestCase { +@RunWith(Parameterized.class) +public class BaseImportTestCase extends PDETestCase { + + @Parameters(name = "{0}") + public static Object[][] importTypes() { + return new Object[][] { // + { "Import binary", PluginImportOperation.IMPORT_BINARY }, // + { "Import with source", PluginImportOperation.IMPORT_WITH_SOURCE }, // + { "Import with links", PluginImportOperation.IMPORT_BINARY_WITH_LINKS }, // + }; + } - protected abstract int getType(); - protected abstract void verifyProject(String projectName, boolean isJava); + @Parameter(0) + public String importTypeName; + @Parameter(1) + public int importType; @Test - public void testImportJAR() { + public void testImportJAR() throws Exception { doSingleImport("org.eclipse.jsch.core", true); } @Test - public void testImportFlat() { + public void testImportFlat() throws Exception { doSingleImport("org.eclipse.jdt.debug", true); } @Test - public void testImportNotJavaFlat() { + public void testImportNotJavaFlat() throws Exception { doSingleImport("org.junit.source", false); } @Test - public void testImportNotJavaJARd() { + public void testImportNotJavaJARd() throws Exception { doSingleImport("org.eclipse.jdt.doc.user", false); doSingleImport("org.eclipse.pde.ui.source", false); } @Test - public void testImportJUnit4() { + public void testImportAnt() throws Exception { + Assume.assumeFalse(importType == PluginImportOperation.IMPORT_WITH_SOURCE); + // Note: Ant is exempt from importing as source + doSingleImport("org.apache.ant", true); + } + + @Test + public void testImportJUnit4() throws Exception { doSingleImport("org.junit", 4, true); } @Test - public void testImportLinksMultiple() { - IPluginModelBase[] modelsToImport = getModels(new String[] {"org.eclipse.core.filebuffers", "org.eclipse.jdt.doc.user", "org.eclipse.pde.build"}); - runOperation(modelsToImport, getType()); - for (int i = 0; i < modelsToImport.length; i++) { - verifyProject(modelsToImport[i], i != 1); + public void testImportLinksMultiple() throws Exception { + List modelsToImport = Stream + .of("org.eclipse.core.filebuffers", "org.eclipse.jdt.doc.user", "org.eclipse.pde.build").map(name -> { + IPluginModelBase model = PluginRegistry.findModel(name); + assertNotNull("No model found with name'" + name + "'", model); + assertNull("Workspace resource already exists for: " + name, model.getUnderlyingResource()); + return model; + }).toList(); + runOperation(modelsToImport, importType); + for (int i = 0; i < modelsToImport.size(); i++) { + verifyProject(modelsToImport.get(i), i != 1); } } - protected void doSingleImport(String bundleSymbolicName, boolean isJava) { + protected void doSingleImport(String bundleSymbolicName, boolean isJava) throws Exception { IPluginModelBase modelToImport = PluginRegistry.findModel(bundleSymbolicName); + assertNotNull("No model found with name'" + name + "'", modelToImport); assertNull(modelToImport.getUnderlyingResource()); - runOperation(new IPluginModelBase[] {modelToImport}, getType()); + runOperation(List.of(modelToImport), importType); verifyProject(modelToImport, isJava); } @@ -90,73 +138,78 @@ protected void doSingleImport(String bundleSymbolicName, boolean isJava) { * @param majorVersion the major version that the imported plug-in must have * @param isJava whether the imported plug-in should have a java nature */ - protected void doSingleImport(String bundleSymbolicName, int majorVersion, boolean isJava) { + protected void doSingleImport(String bundleSymbolicName, int majorVersion, boolean isJava) throws Exception { ModelEntry entry = PluginRegistry.findEntry(bundleSymbolicName); IPluginModelBase models[] = entry.getExternalModels(); - assertTrue("No models for " + bundleSymbolicName + " could be found", models.length > 0); - IPluginModelBase modelToImport = null; - - for (IPluginModelBase model : models) { - Version version = new Version(model.getPluginBase().getVersion()); - if (version.getMajor() == majorVersion){ - modelToImport = model; - break; - } - } - - assertNull("Model with correct major version " + majorVersion + " could not be found", modelToImport.getUnderlyingResource()); - runOperation(new IPluginModelBase[] {modelToImport}, getType()); + assertTrue("No external models for with name '" + bundleSymbolicName + "'", models.length > 0); + IPluginModelBase modelToImport = Arrays.stream(models) + .filter(m -> new Version(m.getPluginBase().getVersion()).getMajor() == majorVersion).findFirst() + .orElse(null); + + assertNull("Model for " + bundleSymbolicName + " with major version " + majorVersion + " not be found", + modelToImport.getUnderlyingResource()); + runOperation(List.of(modelToImport), importType); verifyProject(modelToImport, isJava); } - protected void runOperation(IPluginModelBase[] models, int type) { - PluginImportOperation job = new PluginImportOperation(models, type, false); + protected void runOperation(List models, int type) throws InterruptedException { + PluginImportOperation job = new PluginImportOperation(models.toArray(IPluginModelBase[]::new), type, false); job.setRule(ResourcesPlugin.getWorkspace().getRoot()); job.setSystem(true); job.schedule(); - try{ - job.join(); - } catch (InterruptedException e){ - fail("Job interupted: " + e.getMessage()); - } + job.join(); IStatus status = job.getResult(); - if (!status.isOK()){ - fail("Import Operation failed: " + status.toString()); - } + assertTrue("Import Operation failed: " + status.toString(), status.isOK()); } - protected IPluginModelBase[] getModels(String[] symbolicNames) { - IPluginModelBase[] models = new IPluginModelBase[symbolicNames.length]; - for (int i = 0; i < symbolicNames.length; i++) { - IPluginModelBase model = PluginRegistry.findModel(symbolicNames[i]); - assertNull(model.getUnderlyingResource()); - models[i] = model; - } - return models; - } - - protected void verifyProject(IPluginModelBase modelImported, boolean isJava) { + private void verifyProject(IPluginModelBase modelImported, boolean isJava) throws CoreException { String id = modelImported.getPluginBase().getId(); - verifyProject(id, isJava); - } - - protected IProject verifyProject(String projectName) { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IProject project = root.getProject(projectName); - assertTrue("Project " + projectName + " does not exist", project.exists()); - return project; + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(id); + assertTrue("Project " + id + " does not exist", project.exists()); + + // When self hosting the tests, import tests may fail if you have the + // imported project in the host + boolean isFromSelfHostedTestRuntime = Platform.inDevelopmentMode() + && Path.of(modelImported.getInstallLocation()).getParent().getParent() + .equals(FileLocator.getBundleFileLocation(FrameworkUtil.getBundle(BaseImportTestCase.class)) + .get().toPath().getParent().getParent()); + + if (!isFromSelfHostedTestRuntime) { + if (importType == PluginImportOperation.IMPORT_BINARY_WITH_LINKS) { + assertThat(RepositoryProvider.getProvider(project), is(instanceOf(BinaryRepositoryProvider.class))); + } else if (importType == PluginImportOperation.IMPORT_BINARY) { + assertEquals(PDECore.BINARY_PROJECT_VALUE, + project.getPersistentProperty(PDECore.EXTERNAL_PROJECT_PROPERTY)); + } + } + assertTrue(project.hasNature(PDE.PLUGIN_NATURE)); + assertEquals(isJava, project.hasNature(JavaCore.NATURE_ID)); + if (isJava) { + IJavaProject jProject = JavaCore.create(project); + assertSourceAttached(jProject); + if (importType == PluginImportOperation.IMPORT_WITH_SOURCE) { + assertAnyClasspathEntryOfKind(jProject, IClasspathEntry.CPE_SOURCE); + } else { + if (!isFromSelfHostedTestRuntime) { + assertAnyClasspathEntryOfKind(jProject, IClasspathEntry.CPE_LIBRARY); + } + } + } } - protected boolean checkSourceAttached(IJavaProject jProject) throws CoreException { - IPackageFragmentRoot[] roots = jProject.getPackageFragmentRoots(); - for (IPackageFragmentRoot root : roots) { + private void assertSourceAttached(IJavaProject jProject) throws CoreException { + for (IPackageFragmentRoot root : jProject.getPackageFragmentRoots()) { IClasspathEntry entry = root.getRawClasspathEntry(); - if (entry.getEntryKind() != IClasspathEntry.CPE_LIBRARY || entry.getEntryKind() != IClasspathEntry.CPE_CONTAINER || !entry.getPath().equals(PDECore.REQUIRED_PLUGINS_CONTAINER_PATH)) - continue; - if (root.getSourceAttachmentPath() == null) - return false; + if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY + || (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) + && !entry.getPath().equals(PDECore.REQUIRED_PLUGINS_CONTAINER_PATH)) { + assertNotNull("Missing source attachement for entry " + entry, root.getSourceAttachmentPath()); + } } - return true; + } + + private static void assertAnyClasspathEntryOfKind(IJavaProject project, int entryKind) throws JavaModelException { + assertTrue(Arrays.stream(project.getRawClasspath()).anyMatch(e -> e.getEntryKind() == entryKind)); } } diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/ImportAsBinaryTestCase.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/ImportAsBinaryTestCase.java deleted file mode 100644 index 1042931215..0000000000 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/ImportAsBinaryTestCase.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.imports; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.pde.internal.core.PDECore; -import org.eclipse.pde.internal.core.natures.PDE; -import org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation; -import org.junit.Test; - -public class ImportAsBinaryTestCase extends BaseImportTestCase { - - private static int TYPE = PluginImportOperation.IMPORT_BINARY; - - @Override - protected int getType() { - return TYPE; - } - - @Test - public void testImportAnt() { - // Note: Ant is exempt from importing as source - doSingleImport("org.apache.ant", true); - } - - @Override - @Test - public void testImportJUnit4() { - // Note: JUnit 4 does not have source but it is a java project - doSingleImport("org.junit", 4, true); - } - - @Override - protected void verifyProject(String projectName, boolean isJava) { - try { - IProject project = verifyProject(projectName); - // When self hosting the tests, import tests may fail if you have the imported project in the host - if (!Platform.inDevelopmentMode()) { - assertEquals(PDECore.BINARY_PROJECT_VALUE, project.getPersistentProperty(PDECore.EXTERNAL_PROJECT_PROPERTY)); - } - assertTrue(project.hasNature(PDE.PLUGIN_NATURE)); - assertEquals(isJava, project.hasNature(JavaCore.NATURE_ID)); - if (isJava) { - IJavaProject jProject = JavaCore.create(project); - assertTrue(checkSourceAttached(jProject)); - assertTrue(checkLibraryEntry(jProject)); - } - } catch (CoreException e) { - fail(e.getMessage()); - } - } - - private boolean checkLibraryEntry(IJavaProject jProject) throws JavaModelException { - // When self hosting the tests, import tests may fail if you have the imported project in the host - if (Platform.inDevelopmentMode()) { - return true; - } - - IClasspathEntry[] entries = jProject.getRawClasspath(); - for (IClasspathEntry entry : entries) { - if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) - return true; - } - return false; - } - -} diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/ImportAsSourceTestCase.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/ImportAsSourceTestCase.java deleted file mode 100644 index 5bb7ee2a21..0000000000 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/ImportAsSourceTestCase.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.imports; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.pde.internal.core.natures.PDE; -import org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation; - -public class ImportAsSourceTestCase extends BaseImportTestCase { - - private static int TYPE = PluginImportOperation.IMPORT_WITH_SOURCE; - - @Override - protected int getType() { - return TYPE; - } - - @Override - protected void verifyProject(String projectName, boolean isJava) { - try { - IProject project = verifyProject(projectName); - assertTrue(project.hasNature(PDE.PLUGIN_NATURE)); - assertEquals(isJava, project.hasNature(JavaCore.NATURE_ID)); - if (isJava) { - IJavaProject jProject = JavaCore.create(project); - assertTrue(checkSourceAttached(jProject)); - assertTrue(checkSourceFolder(jProject)); - } - } catch (CoreException e) { - fail(e.getMessage()); - } - } - - private boolean checkSourceFolder(IJavaProject jProject) throws JavaModelException { - IClasspathEntry[] entries = jProject.getRawClasspath(); - for (IClasspathEntry entry : entries) { - if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) - return true; - } - return false; - } -} diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/ImportWithLinksTestCase.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/ImportWithLinksTestCase.java deleted file mode 100644 index 1b2050a768..0000000000 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/imports/ImportWithLinksTestCase.java +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 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.imports; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.pde.internal.core.BinaryRepositoryProvider; -import org.eclipse.pde.internal.core.natures.PDE; -import org.eclipse.pde.internal.ui.wizards.imports.PluginImportOperation; -import org.eclipse.team.core.RepositoryProvider; - -public class ImportWithLinksTestCase extends BaseImportTestCase { - - private static int TYPE = PluginImportOperation.IMPORT_BINARY_WITH_LINKS; - - @Override - protected int getType() { - return TYPE; - } - - public void testImportAnt() { - // Note: Ant is exempt from importing as source - doSingleImport("org.apache.ant", true); - } - - @Override - protected void verifyProject(String projectName, boolean isJava) { - try { - IProject project = verifyProject(projectName); - RepositoryProvider provider = RepositoryProvider.getProvider(project); - // When self hosting the tests, import tests may fail if you have the imported project in the host - if (!Platform.inDevelopmentMode()) { - assertTrue(provider instanceof BinaryRepositoryProvider); - } - assertTrue(project.hasNature(PDE.PLUGIN_NATURE)); - assertEquals(isJava, project.hasNature(JavaCore.NATURE_ID)); - if (isJava) { - IJavaProject jProject = JavaCore.create(project); - assertTrue(checkSourceAttached(jProject)); - assertTrue(checkLibraryEntry(jProject)); - } - } catch (CoreException e) { - fail(e.getMessage()); - } - } - - private boolean checkLibraryEntry(IJavaProject jProject) throws JavaModelException { - // When self hosting the tests, import tests may fail if you have the imported project in the host - if (Platform.inDevelopmentMode()) { - return true; - } - - IClasspathEntry[] entries = jProject.getRawClasspath(); - for (IClasspathEntry entry : entries) { - if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) - return true; - } - return false; - } - -}