diff options
author | Simon Kaegi | 2008-04-15 14:25:28 +0000 |
---|---|---|
committer | Simon Kaegi | 2008-04-15 14:25:28 +0000 |
commit | 4cac7c2500e742760ae3a788c29c9ad5d1755710 (patch) | |
tree | 2563badccec03e79050bb6b70a13f6ee392a6fcf /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse | |
parent | e0fa70dfe0cb05935b3d076d78a07b716fccc9d1 (diff) | |
download | rt.equinox.p2-4cac7c2500e742760ae3a788c29c9ad5d1755710.tar.gz rt.equinox.p2-4cac7c2500e742760ae3a788c29c9ad5d1755710.tar.xz rt.equinox.p2-4cac7c2500e742760ae3a788c29c9ad5d1755710.zip |
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse')
4 files changed, 79 insertions, 17 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java index 56dbf8f74..dbdeadf16 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java @@ -662,7 +662,10 @@ public abstract class AbstractProvisioningTest extends TestCase { if (base == null) fail(message + " entry not found in bundle: " + entry); try { - return new File(FileLocator.toFileURL(base).getPath()); + File result = new File(FileLocator.toFileURL(base).getPath()); + if (!result.getCanonicalFile().getPath().equals(result.getPath())) + fail(message + " result path: " + result.getPath() + " does not match canonical path: " + result.getCanonicalFile().getPath()); + return result; } catch (IOException e) { fail(message, e); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java index 66f57adce..d7f549f59 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java @@ -13,7 +13,9 @@ package org.eclipse.equinox.p2.tests.directorywatcher; import java.io.File; import junit.framework.Test; import junit.framework.TestSuite; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; +import org.eclipse.equinox.internal.provisional.p2.artifact.repository.ArtifactDescriptor; +import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; +import org.eclipse.equinox.internal.provisional.p2.metadata.*; public class RepositoryListenerTest extends AbstractDirectoryWatcherTest { @@ -31,6 +33,16 @@ public class RepositoryListenerTest extends AbstractDirectoryWatcherTest { return new TestSuite(RepositoryListenerTest.class); } + public static boolean isZipped(TouchpointData[] data) { + if (data == null || data.length == 0) + return false; + for (int i = 0; i < data.length; i++) { + if (data[i].getInstructions("zipped") != null) //$NON-NLS-1$ + return true; + } + return false; + } + /* * Remove the files from the target, if they exist in the source. */ @@ -53,6 +65,7 @@ public class RepositoryListenerTest extends AbstractDirectoryWatcherTest { // create the watcher TestRepositoryWatcher watcher = TestRepositoryWatcher.createWatcher(folder); + watcher.poll(); // We should have an empty repository because we haven't done anything yet assertEquals("1.0", 0, watcher.getInstallableUnits().length); @@ -82,6 +95,59 @@ public class RepositoryListenerTest extends AbstractDirectoryWatcherTest { assertEquals("6.1", 1, watcher.getArtifactKeys().length); } + public void testBundleShape() { + + // make sure we remove this file after we finish running the tests + File folder = getTempFolder(); + toRemove.add(folder); + + // create the watcher + TestRepositoryWatcher watcher = TestRepositoryWatcher.createWatcher(folder); + + // this folder contains a jared plugin and a directory plugin + File baseFolder = getTestData("0.99", "/testData/directorywatcher1"); + copy("2.0", baseFolder, folder); + watcher.poll(); + + // verify metadata + IInstallableUnit jaredIU = null; + IInstallableUnit directoryIU = null; + IInstallableUnit[] ius = watcher.getInstallableUnits(); + assertEquals("3.0", 2, ius.length); + for (int i = 0; i < ius.length; i++) { + IInstallableUnit iu = ius[i]; + if (isZipped(iu.getTouchpointData())) { + assertNull("4.0", jaredIU); + jaredIU = iu; + } else { + assertNull("5.0", directoryIU); + directoryIU = iu; + } + } + assertTrue("6.0", directoryIU != null && jaredIU != null); + + // verify artifact descriptors + IArtifactDescriptor jaredDescriptor = null; + IArtifactDescriptor directoryDescriptor = null; + IArtifactKey[] keys = watcher.getArtifactKeys(); + assertEquals("7.0", 2, keys.length); + for (int i = 0; i < keys.length; i++) { + IArtifactKey key = keys[i]; + IArtifactDescriptor[] descriptors = watcher.getArtifactDescriptors(key); + assertEquals("8.0", 1, descriptors.length); + ArtifactDescriptor descriptor = (ArtifactDescriptor) descriptors[0]; + String isFolder = descriptor.getRepositoryProperty("artifact.folder"); + if (Boolean.valueOf(isFolder).booleanValue()) { + assertNull("9.0", directoryDescriptor); + directoryDescriptor = descriptors[0]; + } else { + assertNull("10.0", jaredDescriptor); + jaredDescriptor = descriptors[0]; + } + } + assertTrue("11.0", jaredDescriptor != null && directoryDescriptor != null); + } + /* * Test to ensure that we convert bundles with Eclipse 2.x-style plugin.xml files into * proper OSGi manifest files so the bundle can be installed diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java index 2d7d1f373..f6ddc69e0 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java @@ -164,7 +164,7 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv public void testNormalFeaturesandPluginsDirectory() throws IOException { File directory = new File(tempDirectory, "exists"); directory.mkdirs(); - copy("1.0", getFile("/testdata/extensionlocation"), directory); + copy("1.0", getTestData("1.1", "/testData/extensionlocation"), directory); IArtifactRepository repo = null; try { repo = factory.load(directory.toURL(), null); @@ -180,7 +180,7 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv directory.mkdirs(); File features = new File(directory, "features"); features.mkdir(); - copy("1.0", getFile("/testdata/extensionlocation/features"), features); + copy("1.0", getTestData("1.1", "/testData/extensionlocation/features"), features); IArtifactRepository repo = null; try { repo = factory.load(directory.toURL(), null); @@ -196,7 +196,7 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv directory.mkdirs(); File plugins = new File(directory, "plugins"); plugins.mkdir(); - copy("1.0", getFile("/testdata/extensionlocation/plugins"), plugins); + copy("1.0", getTestData("1.1", "/testData/extensionlocation/plugins"), plugins); IArtifactRepository repo = null; try { repo = factory.load(directory.toURL(), null); @@ -211,7 +211,7 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv File directory = new File(tempDirectory, "exists"); directory.mkdirs(); File eclipseDirectory = new File(directory, "eclipse"); - copy("1.0", getFile("/testdata/extensionlocation"), eclipseDirectory); + copy("1.0", getTestData("1.1", "/testData/extensionlocation"), eclipseDirectory); IArtifactRepository repo = null; try { repo = factory.load(directory.toURL(), null); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java index de32f33de..113bd4852 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java @@ -14,14 +14,12 @@ import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; -import org.eclipse.core.runtime.FileLocator; import org.eclipse.equinox.internal.p2.extensionlocation.ExtensionLocationMetadataRepositoryFactory; import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; import org.eclipse.equinox.internal.provisional.p2.query.Collector; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestActivator; public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProvisioningTest { @@ -46,11 +44,6 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv factory = new ExtensionLocationMetadataRepositoryFactory(); } - public static File getFile(String path) throws IOException { - URL fileURL = TestActivator.getContext().getBundle().getEntry(path); - return new File(FileLocator.toFileURL(fileURL).getPath()); - } - public void testNonFileURL() throws MalformedURLException { URL nonFileURL = new URL("http://www.eclipse.org"); try { @@ -165,7 +158,7 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv public void testNormalFeaturesandPluginsDirectory() throws IOException { File directory = new File(tempDirectory, "exists"); directory.mkdirs(); - copy("1.0", getFile("/testdata/extensionlocation"), directory); + copy("1.0", getTestData("1.1", "/testData/extensionlocation"), directory); IMetadataRepository repo = null; try { repo = factory.load(directory.toURL(), null); @@ -181,7 +174,7 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv directory.mkdirs(); File features = new File(directory, "features"); features.mkdir(); - copy("1.0", getFile("/testdata/extensionlocation/features"), features); + copy("1.0", getTestData("1.1", "/testData/extensionlocation/features"), features); IMetadataRepository repo = null; try { repo = factory.load(directory.toURL(), null); @@ -197,7 +190,7 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv directory.mkdirs(); File plugins = new File(directory, "plugins"); plugins.mkdir(); - copy("1.0", getFile("/testdata/extensionlocation/plugins"), plugins); + copy("1.0", getTestData("1.1", "/testData/extensionlocation/plugins"), plugins); IMetadataRepository repo = null; try { repo = factory.load(directory.toURL(), null); @@ -212,7 +205,7 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv File directory = new File(tempDirectory, "exists"); directory.mkdirs(); File eclipseDirectory = new File(directory, "eclipse"); - copy("1.0", getFile("/testdata/extensionlocation"), eclipseDirectory); + copy("1.0", getTestData("1.1", "/testData/extensionlocation"), eclipseDirectory); IMetadataRepository repo = null; try { repo = factory.load(directory.toURL(), null); |