diff options
author | Pascal Rapicault | 2010-01-13 17:29:41 +0000 |
---|---|---|
committer | Pascal Rapicault | 2010-01-13 17:29:41 +0000 |
commit | 18189f0d42f7375660762dc6c885cf31683ae562 (patch) | |
tree | 17775d847bed9a33f3c68b74db2df75a2139c0bc /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository | |
parent | c363f2984a09b73c422e38f4556fd3b23eafe958 (diff) | |
download | rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.tar.gz rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.tar.xz rt.equinox.p2-18189f0d42f7375660762dc6c885cf31683ae562.zip |
Merging api branch back to HEADv20100113
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository')
18 files changed, 397 insertions, 257 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java index 141681015..2c431c266 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java @@ -11,7 +11,7 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.artifact.repository; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.*; import junit.framework.TestCase; @@ -19,11 +19,11 @@ import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository; import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.ArtifactOutputStream; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -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.artifact.repository.processing.ProcessingStep; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; import org.eclipse.equinox.internal.provisional.p2.repository.IStateful; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class ArtifactOutputStreamTest extends TestCase { @@ -44,7 +44,7 @@ public class ArtifactOutputStreamTest extends TestCase { tempWritableLocation.mkdirs(); sar = new SimpleArtifactRepository("name", tempWritableLocation.toURI(), null); destination = new Destination(); - ak = new ArtifactKey("classifier", "id", new Version("1.0")); + ak = new ArtifactKey("classifier", "id", Version.create("1.0")); ad = new ArtifactDescriptor(ak); temp = File.createTempFile("ArtifactOutputStreamTest", ".tmp"); temp.deleteOnExit(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java index 2db20ca3c..5493af202 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java @@ -19,11 +19,15 @@ import junit.framework.TestSuite; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.preferences.IPreferencesService; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.repository.*; +import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent; +import org.eclipse.equinox.p2.core.IAgentLocation; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; import org.eclipse.equinox.p2.tests.*; +import org.eclipse.equinox.security.storage.EncodingUtils; import org.osgi.framework.BundleException; import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.Preferences; @@ -60,7 +64,7 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - manager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.context, IArtifactRepositoryManager.class.getName()); + manager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.context, IArtifactRepositoryManager.SERVICE_NAME); } /** @@ -109,7 +113,9 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest { //bash the repository preference file (don't try this at home, kids) final String REPO_BUNDLE = "org.eclipse.equinox.p2.artifact.repository"; IPreferencesService prefService = (IPreferencesService) ServiceHelper.getService(TestActivator.getContext(), IPreferencesService.class.getName()); - Preferences prefs = prefService.getRootNode().node("/profile/_SELF_/" + REPO_BUNDLE + "/repositories"); //$NON-NLS-1$ //$NON-NLS-2$ + IAgentLocation agentLocation = (IAgentLocation) getAgent().getService(IAgentLocation.SERVICE_NAME); + String locationString = EncodingUtils.encodeSlashes(agentLocation.getRootLocation().toString()); + Preferences prefs = prefService.getRootNode().node("/profile/" + locationString + "_SELF_/" + REPO_BUNDLE + "/repositories"); //$NON-NLS-1$ //$NON-NLS-2$ try { String[] children = prefs.childrenNames(); for (int i = 0; i < children.length; i++) @@ -121,14 +127,13 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest { //stop and restart the artifact repository bundle (kids, if I ever catch you doing this I'm taking PackageAdmin away) try { - TestActivator.getBundle(REPO_BUNDLE).stop(); - TestActivator.getBundle(REPO_BUNDLE).start(); + restartBundle(TestActivator.getBundle(REPO_BUNDLE)); } catch (BundleException e) { fail("1.99", e); } //everybody's happy again - manager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.context, IArtifactRepositoryManager.class.getName()); + manager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.context, IArtifactRepositoryManager.SERVICE_NAME); assertTrue("1.0", manager.contains(location)); } @@ -157,12 +162,7 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest { public void testPathWithSpaces() { File site = getTestData("Repository", "/testData/artifactRepo/simple with spaces/"); URI location = site.toURI(); - try { - IArtifactRepository repository = manager.loadRepository(location, getMonitor()); - assertEquals("1.0", 2, repository.getArtifactKeys().length); - } catch (ProvisionException e) { - fail("=.99", e); - } + assertEquals("1.0", 2, getArtifactKeyCount(location)); } /** @@ -217,12 +217,7 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest { public void testUpdateSitePathWithSpaces() { File site = getTestData("Repository", "/testData/updatesite/site with spaces/"); URI location = site.toURI(); - try { - IArtifactRepository repository = manager.loadRepository(location, getMonitor()); - assertEquals("1.0", 3, repository.getArtifactKeys().length); - } catch (ProvisionException e) { - fail("=.99", e); - } + assertEquals("1.0", 3, getArtifactKeyCount(location)); } /** @@ -280,13 +275,8 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest { * Tests parsing a repository with a duplicate element. See bug 255401. */ public void testDuplicateElement() { - try { - File duplicateElementXML = getTestData("testDuplicateElement", "testData/artifactRepo/duplicateElement"); - IArtifactRepository repo = getArtifactRepositoryManager().loadRepository(duplicateElementXML.toURI(), null); - assertEquals("Ensure correct number of artifact keys exist", 2, repo.getArtifactKeys().length); - } catch (ProvisionException e) { - fail("Error occured while loading repository with duplicate elements", e); - } + File duplicateElementXML = getTestData("testDuplicateElement", "testData/artifactRepo/duplicateElement"); + assertEquals("Ensure correct number of artifact keys exist", 2, getArtifactKeyCount(duplicateElementXML.toURI())); } public void testEnablement() { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java index 14254436a..55a3045af 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java @@ -10,21 +10,23 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.artifact.repository; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.engine.phases.Sizing; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -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.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.internal.p2.engine.Phase; +import org.eclipse.equinox.internal.p2.engine.PhaseSet; +import org.eclipse.equinox.internal.p2.engine.phases.Sizing; +import org.eclipse.equinox.internal.provisional.p2.director.PlannerHelper; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; @@ -40,8 +42,8 @@ public class ArtifactRepositoryMissingSizeData extends AbstractProvisioningTest IMetadataRepositoryManager mmgr = getMetadataRepositoryManager(); metaRepo = mmgr.loadRepository((getTestData("MissingArtifact repo", testDataLocation).toURI()), null); - missingArtifactIU = (IInstallableUnit) metaRepo.query(new InstallableUnitQuery("javax.wsdl", new VersionRange("[1.5, 1.6)")), new Collector(), null).iterator().next(); - missingSizeIU = (IInstallableUnit) metaRepo.query(new InstallableUnitQuery("javax.wsdl", new VersionRange("[1.4, 1.5)")), new Collector(), null).iterator().next(); + missingArtifactIU = (IInstallableUnit) metaRepo.query(new InstallableUnitQuery("javax.wsdl", new VersionRange("[1.5, 1.6)")), null).iterator().next(); + missingSizeIU = (IInstallableUnit) metaRepo.query(new InstallableUnitQuery("javax.wsdl", new VersionRange("[1.4, 1.5)")), null).iterator().next(); IArtifactRepositoryManager mgr = getArtifactRepositoryManager(); source = mgr.loadRepository((getTestData("MissingArtifact repo", testDataLocation).toURI()), null); @@ -55,13 +57,13 @@ public class ArtifactRepositoryMissingSizeData extends AbstractProvisioningTest req.addInstallableUnits(new IInstallableUnit[] {missingArtifactIU}); req.setInstallableUnitInclusionRules(missingArtifactIU, PlannerHelper.createStrictInclusionRule(missingArtifactIU)); - ProvisioningPlan plan = createPlanner().getProvisioningPlan(req, null, null); + IProvisioningPlan plan = createPlanner().getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); Sizing sizing = new Sizing(100, ""); PhaseSet set = new SPhaseSet(sizing); - IStatus status = engine.perform(profile1, set, plan.getOperands(), null, new NullProgressMonitor()); + IStatus status = engine.perform(plan, set, new NullProgressMonitor()); if (!status.matches(IStatus.ERROR)) { fail("Incorrect status for missing artifact during Sizing."); } @@ -73,13 +75,13 @@ public class ArtifactRepositoryMissingSizeData extends AbstractProvisioningTest req.addInstallableUnits(new IInstallableUnit[] {missingSizeIU}); req.setInstallableUnitInclusionRules(missingSizeIU, PlannerHelper.createStrictInclusionRule(missingSizeIU)); - ProvisioningPlan plan = createPlanner().getProvisioningPlan(req, null, null); + IProvisioningPlan plan = createPlanner().getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); Sizing sizing = new Sizing(100, ""); PhaseSet set = new SPhaseSet(sizing); - IStatus status = engine.perform(profile1, set, plan.getOperands(), null, new NullProgressMonitor()); + IStatus status = engine.perform(plan, set, new NullProgressMonitor()); if (!status.matches(IStatus.WARNING) && status.getCode() != ProvisionException.ARTIFACT_INCOMPLETE_SIZING) { fail("Incorrect status for missing file size during Sizing"); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java index 99bf84bb4..59be6964a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java @@ -10,22 +10,22 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.artifact.repository; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.ByteArrayOutputStream; import java.io.File; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.ArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class ArtifactRepositoryWithReferenceDescriptors extends AbstractProvisioningTest { IArtifactRepository repo = null; - ArtifactDescriptor descriptor1 = null; - ArtifactDescriptor descriptor2 = null; + SimpleArtifactDescriptor descriptor1 = null; + SimpleArtifactDescriptor descriptor2 = null; // <artifact classifier='org.eclipse.update.feature' id='org.eclipse.datatools.sqldevtools.feature' version='1.6.0.v200805301340-7F7d-E8yz-SHrDBONwUwXwIyxYSZ'> // <repositoryProperties size='4'> @@ -40,14 +40,14 @@ public class ArtifactRepositoryWithReferenceDescriptors extends AbstractProvisio super.setUp(); repo = createArtifactRepository(getTempFolder().toURI(), null); File fileLocation = getTestData("Artifacts for repositor with references", "testData/referenceArtifactRepo/test1 Reference.jar"); - descriptor1 = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "test1Reference", new Version("1.0.0"))); - descriptor1.setProcessingSteps(new ProcessingStepDescriptor[0]); + descriptor1 = new SimpleArtifactDescriptor(new ArtifactKey("osgi.bundle", "test1Reference", Version.create("1.0.0"))); + descriptor1.setProcessingSteps(new IProcessingStepDescriptor[0]); descriptor1.setRepositoryProperty("artifact.reference", fileLocation.toURL().toExternalForm()); descriptor1.setRepositoryProperty("file.name", fileLocation.getAbsolutePath()); descriptor1.setRepositoryProperty("file.lastModified", Long.toString(fileLocation.lastModified())); - descriptor2 = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "test1Reference", new Version("1.0.0"))); - descriptor2.setProcessingSteps(new ProcessingStepDescriptor[0]); + descriptor2 = new SimpleArtifactDescriptor(new ArtifactKey("osgi.bundle", "test1Reference", Version.create("1.0.0"))); + descriptor2.setProcessingSteps(new IProcessingStepDescriptor[0]); descriptor2.setRepositoryProperty("artifact.reference", fileLocation.toURI().toString()); descriptor2.setRepositoryProperty("file.name", fileLocation.getAbsolutePath()); descriptor2.setRepositoryProperty("file.lastModified", Long.toString(fileLocation.lastModified())); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug252308.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug252308.java index 12e7ccef4..d93317b0b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug252308.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug252308.java @@ -10,15 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.artifact.repository; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.*; import java.lang.reflect.Method; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest; +import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** @@ -119,10 +121,10 @@ public class Bug252308 extends AbstractProvisioningTest { fail("failing setting up the tests", e); } - IArtifactDescriptor sourceDescriptor = getArtifactKeyFor(source, "osgi.bundle", "missingFromFileSystem", new Version(1, 0, 0))[0]; - ArtifactDescriptor targetDescriptor = new ArtifactDescriptor(sourceDescriptor); + IArtifactDescriptor sourceDescriptor = getArtifactKeyFor(source, "osgi.bundle", "missingFromFileSystem", Version.createOSGi(1, 0, 0))[0]; + SimpleArtifactDescriptor targetDescriptor = new SimpleArtifactDescriptor(sourceDescriptor); targetDescriptor.setRepositoryProperty("artifact.folder", "true"); - MirrorRequest request = new MirrorRequest(new ArtifactKey("osgi.bundle", "missingFromFileSystem", new Version(1, 0, 0)), target, null, null); + MirrorRequest request = new MirrorRequest(new ArtifactKey("osgi.bundle", "missingFromFileSystem", Version.createOSGi(1, 0, 0)), target, null, null); request.setSourceRepository(source); IStatus s = transferSingle(request, targetDescriptor, sourceDescriptor, new NullProgressMonitor()); assertTrue(s.toString(), s.getException().getClass() == FileNotFoundException.class); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java index b00bcd5cd..20c87ce50 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java @@ -14,15 +14,16 @@ import java.io.*; import java.net.URI; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -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.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.artifact.*; +import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; @@ -37,7 +38,7 @@ public class Bug265577 extends AbstractProvisioningTest { super.setUp(); profile = createProfile(Bug265577.class.getName()); - engine = (IEngine) ServiceHelper.getService(TestActivator.context, IEngine.class.getName()); + engine = (IEngine) ServiceHelper.getService(TestActivator.context, IEngine.SERVICE_NAME); // Load repositories File repoLocation = getTestData("Repository location", "/testData/bug265577/zipRepo.zip"); if (repoLocation == null) @@ -60,9 +61,9 @@ public class Bug265577 extends AbstractProvisioningTest { // Tests the response to a feature folder inside a jar public void testZippedRepoWithFolderFeature() { - Collector collector = metadataRepo.query(new InstallableUnitQuery("Field_Assist_Example.feature.jar"), new Collector(), null); - IInstallableUnit[] ius = (IInstallableUnit[]) collector.toArray(IInstallableUnit.class); - IArtifactKey key = (ius[0].getArtifacts())[0]; + IQueryResult queryResult = metadataRepo.query(new InstallableUnitQuery("Field_Assist_Example.feature.jar"), null); + IInstallableUnit[] ius = (IInstallableUnit[]) queryResult.toArray(IInstallableUnit.class); + IArtifactKey key = (ius[0].getArtifacts()).iterator().next(); IArtifactDescriptor[] descriptors = artifactRepo.getArtifactDescriptors(key); ArtifactDescriptor desc = (ArtifactDescriptor) descriptors[0]; @@ -84,9 +85,9 @@ public class Bug265577 extends AbstractProvisioningTest { // Test to retrieve a file from a zipped metadata & artifact repository public void testZippedRepo() { - Collector collector = metadataRepo.query(new InstallableUnitQuery("valid.feature.jar"), new Collector(), null); - IInstallableUnit[] ius = (IInstallableUnit[]) collector.toArray(IInstallableUnit.class); - IArtifactKey key = (ius[0].getArtifacts())[0]; + IQueryResult queryResult = metadataRepo.query(new InstallableUnitQuery("valid.feature.jar"), null); + IInstallableUnit[] ius = (IInstallableUnit[]) queryResult.toArray(IInstallableUnit.class); + IArtifactKey key = (ius[0].getArtifacts()).iterator().next(); IArtifactDescriptor[] descriptors = artifactRepo.getArtifactDescriptors(key); IArtifactDescriptor desc = descriptors[0]; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java index bc794e3a5..762e6590a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.artifact.repository; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.*; import java.lang.reflect.Field; @@ -18,16 +18,19 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.*; import org.eclipse.core.runtime.*; -import org.eclipse.equinox.internal.p2.artifact.processors.md5.MD5ArtifactComparator; import org.eclipse.equinox.internal.p2.artifact.repository.*; import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository; import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; import org.eclipse.equinox.internal.p2.persistence.CompositeRepositoryState; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.internal.repository.comparator.MD5ArtifactComparator; +import org.eclipse.equinox.p2.internal.repository.tools.ArtifactRepositoryValidator; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.artifact.*; +import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestArtifactRepository; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; @@ -101,7 +104,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { CompositeArtifactRepository compRepo = createRepo(false); //Setup create a descriptor - IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3")); + IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3")); IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, null); try { @@ -117,7 +120,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { CompositeArtifactRepository compRepo = createRepo(false); //Setup create a descriptor - IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3")); + IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3")); IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, null); //Setup: create an array of descriptors @@ -137,7 +140,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { CompositeArtifactRepository compRepo = createRepo(false); //Setup create a descriptor - IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3")); + IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3")); IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, null); try { @@ -153,7 +156,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { CompositeArtifactRepository compRepo = createRepo(false); //Setup create a key - IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3")); + IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3")); try { compRepo.removeDescriptor(key); @@ -307,7 +310,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { assertContains("Assert child2's content is in composite repo", repo2, compRepo); //checks that the destination has the correct number of keys (no extras) //FIXME will this work? - assertEquals("Assert Correct Number of Keys", repo1.getArtifactKeys().length + repo2.getArtifactKeys().length, compRepo.getArtifactKeys().length); + assertEquals("Assert Correct Number of Keys", getArtifactKeyCount(repo1) + getArtifactKeyCount(repo2), getArtifactKeyCount(compRepo)); } public void testRemoveNonexistantChild() { @@ -361,14 +364,14 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { } //get the keys - IArtifactKey[] keys = repo.getArtifactKeys(); - assertTrue("Error retreaiving artifact keys", keys.length > 0); + IQueryResult keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null); + assertTrue("Error retreaiving artifact keys", !keys.isEmpty()); //test for existing key - assertTrue("Asserting key is in composite repo", compRepo.contains(keys[0])); + assertTrue("Asserting key is in composite repo", compRepo.contains((IArtifactKey) keys.iterator().next())); //Create a new key, not found in the composite repo - IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3")); + IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3")); //test for a non existing key assertFalse("Asserting key is not in composite repo", compRepo.contains(key)); } @@ -389,16 +392,16 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { } //get the descriptors - IArtifactKey[] keys = repo.getArtifactKeys(); - assertTrue("Error retreaiving artifact keys", keys.length > 0); - IArtifactDescriptor[] descriptors = repo.getArtifactDescriptors(keys[0]); + IQueryResult keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null); + assertTrue("Error retreaiving artifact keys", !keys.isEmpty()); + IArtifactDescriptor[] descriptors = repo.getArtifactDescriptors((IArtifactKey) keys.iterator().next()); assertTrue("Error retreaiving artifact descriptors", descriptors.length > 0); //test for existing descriptor assertTrue("Asserting key is in composite repo", compRepo.contains(descriptors[0])); //Create a new descriptor, not found in the composite repo - IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3")); + IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3")); IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, null); //test for a non existing descriptor assertFalse("Asserting key is not in composite repo", compRepo.contains(descriptor)); @@ -420,12 +423,13 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { fail("Error creating destination", e1); } - IArtifactKey[] keys = compRepo.getArtifactKeys(); - assertTrue("Error retreaiving artifact keys", keys.length > 0); - IArtifactDescriptor[] descriptors = compRepo.getArtifactDescriptors(keys[0]); + IQueryResult keys = compRepo.query(ArtifactKeyQuery.ALL_KEYS, null); + assertTrue("Error retreaiving artifact keys", !keys.isEmpty()); + IArtifactKey key = (IArtifactKey) keys.iterator().next(); + IArtifactDescriptor[] descriptors = compRepo.getArtifactDescriptors(key); assertTrue("Error retreaiving artifact descriptors", descriptors.length > 0); - IArtifactDescriptor newDescriptor = new ArtifactDescriptor(keys[0]); + IArtifactDescriptor newDescriptor = new ArtifactDescriptor(key); Map properties = new OrderedProperties(); properties.putAll(descriptors[0].getProperties()); properties.remove(IArtifactDescriptor.FORMAT); @@ -448,7 +452,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { fail("Error while downloading artifact", e); } //corresponding key should now be in the destination - assertTrue("Expected Key is not in destination", destinationRepo.contains(keys[0])); + assertTrue("Expected Key is not in destination", destinationRepo.contains(key)); IArtifactRepository repo = null; try { @@ -457,7 +461,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { fail("Unable to load repository for verification", e); } - IArtifactDescriptor[] srcDescriptors = repo.getArtifactDescriptors(keys[0]); + IArtifactDescriptor[] srcDescriptors = repo.getArtifactDescriptors(key); if (srcDescriptors == null) fail("Error finding descriptors for validation"); @@ -503,32 +507,34 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { } //create a request for a descriptor from repo1 - IArtifactKey[] keys1 = repo1.getArtifactKeys(); - assertTrue("Error retreaiving artifact keys", keys1.length > 0); - IArtifactDescriptor[] descriptors1 = repo1.getArtifactDescriptors(keys1[0]); + IQueryResult keys1 = repo1.query(ArtifactKeyQuery.ALL_KEYS, null); + IArtifactKey key1 = (IArtifactKey) keys1.iterator().next(); + assertTrue("Error retreaiving artifact keys", !keys1.isEmpty()); + IArtifactDescriptor[] descriptors1 = repo1.getArtifactDescriptors(key1); assertTrue("Error retreaiving artifact descriptors", descriptors1.length > 0); assertTrue("Expected key not in composite repository", compRepo.contains(descriptors1[0])); - IArtifactDescriptor newDescriptor1 = new ArtifactDescriptor(keys1[0]); + IArtifactDescriptor newDescriptor1 = new ArtifactDescriptor(key1); Map properties1 = new OrderedProperties(); properties1.putAll(descriptors1[0].getProperties()); properties1.remove(IArtifactDescriptor.FORMAT); ((ArtifactDescriptor) newDescriptor1).addProperties(properties1); // IArtifactRequest request1 = ((ArtifactRepositoryManager) getArtifactRepositoryManager()).createMirrorRequest(keys1[0], destinationRepo, (Properties) newDescriptor1.getProperties(), (Properties) destinationRepo.getProperties()); - IArtifactRequest request1 = ((ArtifactRepositoryManager) getArtifactRepositoryManager()).createMirrorRequest(keys1[0], destinationRepo, null, null); + IArtifactRequest request1 = ((ArtifactRepositoryManager) getArtifactRepositoryManager()).createMirrorRequest(key1, destinationRepo, null, null); //create a request for a descriptor from repo2 - IArtifactKey[] keys2 = repo2.getArtifactKeys(); - assertTrue("Error retreaiving artifact keys", keys2.length > 0); - IArtifactDescriptor[] descriptors2 = repo2.getArtifactDescriptors(keys2[0]); + IQueryResult keys2 = repo2.query(ArtifactKeyQuery.ALL_KEYS, null); + IArtifactKey key2 = (IArtifactKey) keys2.iterator().next(); + assertTrue("Error retreaiving artifact keys", !keys2.isEmpty()); + IArtifactDescriptor[] descriptors2 = repo2.getArtifactDescriptors(key2); assertTrue("Error retreaiving artifact descriptors", descriptors2.length > 0); assertTrue("Expected key not in composite repository", compRepo.contains(descriptors2[0])); - IArtifactDescriptor newDescriptor2 = new ArtifactDescriptor(keys2[0]); + IArtifactDescriptor newDescriptor2 = new ArtifactDescriptor(key2); Map properties2 = new OrderedProperties(); properties2.putAll(descriptors2[0].getProperties()); properties2.remove(IArtifactDescriptor.FORMAT); ((ArtifactDescriptor) newDescriptor2).addProperties(properties2); // IArtifactRequest request2 = ((ArtifactRepositoryManager) getArtifactRepositoryManager()).createMirrorRequest(keys2[0], destinationRepo, (Properties) newDescriptor2.getProperties(), (Properties) destinationRepo.getProperties()); - IArtifactRequest request2 = ((ArtifactRepositoryManager) getArtifactRepositoryManager()).createMirrorRequest(keys2[0], destinationRepo, null, null); + IArtifactRequest request2 = ((ArtifactRepositoryManager) getArtifactRepositoryManager()).createMirrorRequest(key2, destinationRepo, null, null); IArtifactRequest[] requests = new IArtifactRequest[2]; requests[0] = request1; @@ -546,8 +552,8 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { fail("Error while downloading artifacts", e); } //corresponding keys should now be in the destination - assertTrue("Expected Key is not in destination", destinationRepo.contains(keys1[0])); - assertTrue("Expected Key is not in destination", destinationRepo.contains(keys2[0])); + assertTrue("Expected Key is not in destination", destinationRepo.contains(key1)); + assertTrue("Expected Key is not in destination", destinationRepo.contains(key2)); //verify the file from repo1 File repo1File = ((SimpleArtifactRepository) repo1).getArtifactFile(descriptors1[0]); @@ -664,9 +670,9 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { assertEquals("Repository should only have 1 child", 1, compRepo.getChildren().size()); } - public void testValidate() { + public void testValidate() throws Exception { //Setup create descriptors with different md5 values - IArtifactKey dupKey = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3")); + IArtifactKey dupKey = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3")); File artifact1 = getTestData("0.0", "/testData/mirror/mirrorSourceRepo1 with space/artifacts.xml"); File artifact2 = getTestData("0.0", "/testData/mirror/mirrorSourceRepo2/artifacts.xml"); IArtifactDescriptor descriptor1 = PublisherHelper.createArtifactDescriptor(dupKey, artifact1); @@ -699,12 +705,13 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { compRepo.addChild(repo2Location.toURI()); //validate using the MD5 Comparator - assertFalse("Running verify on invalid repository", compRepo.validate(MD5ArtifactComparator.MD5_COMPARATOR_ID)); + ArtifactRepositoryValidator validator = new ArtifactRepositoryValidator(MD5ArtifactComparator.MD5_COMPARATOR_ID); + assertFalse("Running verify on invalid repository", validator.validateComposite(compRepo).isOK()); } - public void testAddChildWithValidate() { + public void testAddChildWithValidate() throws ProvisionException { //Setup create descriptors with different md5 values - IArtifactKey dupKey = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3")); + IArtifactKey dupKey = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3")); File artifact1 = getTestData("0.0", "/testData/mirror/mirrorSourceRepo1 with space/artifacts.xml"); File artifact2 = getTestData("0.0", "/testData/mirror/mirrorSourceRepo2/artifacts.xml"); IArtifactDescriptor descriptor1 = PublisherHelper.createArtifactDescriptor(dupKey, artifact1); @@ -733,10 +740,10 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { } //Add conflicting repositories - assertTrue("Adding first child with validate", compRepo.addChild(repo1Location.toURI(), MD5ArtifactComparator.MD5_COMPARATOR_ID)); - assertFalse("Adding conflicting child with validate", compRepo.addChild(repo2Location.toURI(), MD5ArtifactComparator.MD5_COMPARATOR_ID)); - - assertEquals("Asserting Composite Repository only has 1 child", 1, compRepo.getChildren().size()); + ArtifactRepositoryValidator validator = new ArtifactRepositoryValidator(MD5ArtifactComparator.MD5_COMPARATOR_ID); + assertTrue(validator.validateComposite(compRepo, repo1).isOK()); + compRepo.addChild(repo1Location.toURI()); + assertFalse(validator.validateComposite(compRepo, repo2).isOK()); } public void testEnabledAndSystemValues() { @@ -759,7 +766,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { compRepo.addChild(repo2Location.toURI()); //force composite repository to load all children - compRepo.getArtifactKeys(); + compRepo.getArtifactDescriptors(new ArtifactKey("", "", Version.emptyVersion)); assertTrue("Ensuring previously loaded repo is enabled", getArtifactRepositoryManager().isEnabled(repo1Location.toURI())); String repo1System = getArtifactRepositoryManager().getRepositoryProperty(repo1Location.toURI(), IRepository.PROP_SYSTEM); @@ -811,7 +818,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { assertContains("Assert child2's content is in composite repo", repo2, compRepo); //checks that the destination has the correct number of keys (no extras) //FIXME will this work? - assertEquals("Assert Correct Number of Keys", repo1.getArtifactKeys().length + repo2.getArtifactKeys().length, compRepo.getArtifactKeys().length); + assertEquals("Assert Correct Number of Keys", getArtifactKeyCount(repo1) + getArtifactKeyCount(repo2), getArtifactKeyCount(compRepo)); } private CompositeArtifactRepository createRepo(boolean compressed) { @@ -844,7 +851,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { URI childOne = new URI("memory:/in/memory/one"); URI childTwo = new URI("memory:/in/memory/two"); URI childThree = new URI("memory:/in/memory/three"); - CompositeArtifactRepository repository = new CompositeArtifactRepository(location, "in memory test", null); + CompositeArtifactRepository repository = createRepository(location, "in memory test"); repository.addChild(childOne); repository.addChild(childTwo); repository.addChild(childThree); @@ -872,7 +879,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { // create the composite repository and add the children URI location = new File(temp, "comp").toURI(); - CompositeArtifactRepository repository = new CompositeArtifactRepository(location, "test", null); + CompositeArtifactRepository repository = createRepository(location, "test"); try { repository.addChild(new URI("../one")); repository.addChild(new URI("../two")); @@ -883,8 +890,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { // query the number of artifacts List children = repository.getChildren(); assertEquals("2.0", 2, children.size()); - IArtifactKey[] keys = repository.getArtifactKeys(); - assertEquals("2.1", 2, keys.length); + assertEquals("2.1", 2, getArtifactKeyCount(repository)); // ensure the child URIs are stored as relative CompositeRepositoryState state = repository.toState(); @@ -903,7 +909,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { URI location = new URI("memory:/in/memory"); URI one = new URI("one"); URI two = new URI("two"); - CompositeArtifactRepository repository = new CompositeArtifactRepository(location, "in memory test", null); + CompositeArtifactRepository repository = createRepository(location, "in memory test"); repository.addChild(one); repository.addChild(two); List children = repository.getChildren(); @@ -930,7 +936,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { destination = new File(getTempFolder(), getUniqueString()); out = new FileOutputStream(destination); - CompositeArtifactRepository repository = new CompositeArtifactRepository(new URI("memory:/in/memory"), "in memory test", null); + CompositeArtifactRepository repository = createRepository(new URI("memory:/in/memory"), "in memory test"); IArtifactRepository childOne = getArtifactRepositoryManager().loadRepository(childLocation, null); TestArtifactRepository childTwo = new TestArtifactRepository(new URI("memory:/in/memory/two")); @@ -940,7 +946,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { repository.addChild(childOne.getLocation()); repository.addChild(childTwo.getLocation()); - IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "missingSize.asdf", new Version("1.5.1.v200803061910"))); + IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "missingSize.asdf", Version.create("1.5.1.v200803061910"))); IStatus status = repository.getArtifact(descriptor, out, new NullProgressMonitor()); // We should have a failure @@ -996,11 +1002,11 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { IArtifactRepository destination = null; BadMirrorSite child = null; CompositeArtifactRepository source = null; - IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "missingSize.asdf", new Version("1.5.1.v200803061910"))); + IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "missingSize.asdf", Version.create("1.5.1.v200803061910"))); try { destination = super.createArtifactRepository(getTempFolder().toURI(), null); child = new BadMirrorSite(new URI("memory:/in/memory/child")); - source = new CompositeArtifactRepository(new URI("memory:/in/memory/source"), "in memory test", null); + source = createRepository(new URI("memory:/in/memory/source"), "in memory test"); source.addChild(child.getLocation()); // Create mirror request @@ -1026,6 +1032,12 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { } } + protected CompositeArtifactRepository createRepository(URI location, String name) { + CompositeArtifactRepositoryFactory factory = new CompositeArtifactRepositoryFactory(); + factory.setAgent(getAgent()); + return (CompositeArtifactRepository) factory.create(location, name, CompositeArtifactRepository.REPOSITORY_TYPE, null); + } + /* * Test a child returning different bytes */ @@ -1066,8 +1078,8 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { destination = new File(getTempFolder(), getUniqueString()); out = new FileOutputStream(destination); - source = new CompositeArtifactRepository(new URI("memory:/in/memory"), "in memory test", null); - IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "missingSize.asdf", new Version("1.5.1.v200803061910"))); + source = createRepository(new URI("memory:/in/memory"), "in memory test"); + IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "missingSize.asdf", Version.create("1.5.1.v200803061910"))); // Create 'bad' child which returns an error in transfer childOne = new BadSite(new URI("memory:/in/memory/one")); @@ -1125,8 +1137,8 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { IArtifactRepository childOne = null; IArtifactRepository childTwo = null; try { - IArtifactDescriptor desc = new ArtifactDescriptor(new ArtifactKey("osgi", "a", new Version("1.0.0"))); - source = new CompositeArtifactRepository(new URI("memory:/in/memory"), "in memory test", null); + IArtifactDescriptor desc = new ArtifactDescriptor(new ArtifactKey("osgi", "a", Version.create("1.0.0"))); + source = createRepository(new URI("memory:/in/memory"), "in memory test"); childOne = createChild(); source.addChild(childOne.getLocation()); @@ -1161,8 +1173,8 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { IArtifactRepository childOne = null; IArtifactRepository childTwo = null; try { - IArtifactKey desc = new ArtifactKey("osgi", "a", new Version("1.0.0")); - source = new CompositeArtifactRepository(new URI("memory:/in/memory"), "in memory test", null); + IArtifactKey desc = new ArtifactKey("osgi", "a", Version.create("1.0.0")); + source = createRepository(new URI("memory:/in/memory"), "in memory test"); childOne = createChild(); source.addChild(childOne.getLocation()); @@ -1198,22 +1210,22 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { IArtifactRepository childTwo = null; try { - source = new CompositeArtifactRepository(new URI("memory:/in/memory"), "in memory test", null); - IArtifactKey key = new ArtifactKey("classifier", "name", new Version("1.0.0")); + source = createRepository(new URI("memory:/in/memory"), "in memory test"); + IArtifactKey key = new ArtifactKey("classifier", "name", Version.create("1.0.0")); childOne = createChild(); ((TestArtifactRepository) childOne).addArtifact(key, new byte[] {}); source.addChild(childOne.getLocation()); - assertTrue("Composite repo does not contain key", Arrays.asList(source.getArtifactKeys()).contains(key)); + assertTrue("Composite repo does not contain key", source.contains(key)); markBad(source, childOne); - assertFalse("Composite repo contains key but child is marked bad", Arrays.asList(source.getArtifactKeys()).contains(key)); + assertFalse("Composite repo contains key but child is marked bad", source.contains(key)); childTwo = createChild(); ((TestArtifactRepository) childTwo).addArtifact(key, new byte[] {}); source.addChild(childTwo.getLocation()); - assertTrue("Composite repo does not contain key, but it is available", Arrays.asList(source.getArtifactKeys()).contains(key)); + assertTrue("Composite repo does not contain key, but it is available", source.contains(key)); } catch (Exception e) { fail(e.getMessage(), e); } finally { @@ -1235,8 +1247,8 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest { IArtifactRepository childTwo = null; try { - source = new CompositeArtifactRepository(new URI("memory:/in/memory"), "in memory test", null); - IArtifactKey key = new ArtifactKey("classifier", "name", new Version("1.0.0")); + source = createRepository(new URI("memory:/in/memory"), "in memory test"); + IArtifactKey key = new ArtifactKey("classifier", "name", Version.create("1.0.0")); IArtifactDescriptor desc = new ArtifactDescriptor(key); childOne = createChild(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java index b842f6242..cc5c9d171 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java @@ -15,9 +15,9 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest; import org.eclipse.equinox.internal.p2.engine.DownloadManager; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; +import org.eclipse.equinox.p2.engine.ProvisioningContext; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.repository.artifact.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class CorruptedJar extends AbstractProvisioningTest { @@ -45,8 +45,9 @@ public class CorruptedJar extends AbstractProvisioningTest { public void testDownloadCorruptedJar() { ProvisioningContext ctx = new ProvisioningContext(); ctx.setArtifactRepositories(new URI[] {getTestData("CorruptedJar repo", testDataLocation).toURI()}); - DownloadManager mgr = new DownloadManager(ctx); - mgr.add(new MirrorRequest(source.getArtifactKeys()[0], target, null, null)); + DownloadManager mgr = new DownloadManager(ctx, getArtifactRepositoryManager()); + IArtifactKey key = (IArtifactKey) source.query(ArtifactKeyQuery.ALL_KEYS, null).iterator().next(); + mgr.add(new MirrorRequest(key, target, null, null)); IStatus s = mgr.start(new NullProgressMonitor()); assertNotOK(s); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java index 5e822f3c3..c96ce06db 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java @@ -10,16 +10,19 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.artifact.repository; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.io.FileFilter; import java.net.URL; +import java.util.Iterator; import junit.framework.TestCase; import org.eclipse.core.runtime.FileLocator; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.artifact.*; +import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.ServiceReference; @@ -39,7 +42,7 @@ public class FoldersRepositoryTest extends TestCase { } protected void setUp() throws Exception { - managerRef = TestActivator.getContext().getServiceReference(IArtifactRepositoryManager.class.getName()); + managerRef = TestActivator.getContext().getServiceReference(IArtifactRepositoryManager.SERVICE_NAME); manager = (IArtifactRepositoryManager) TestActivator.getContext().getService(managerRef); } @@ -81,19 +84,22 @@ public class FoldersRepositoryTest extends TestCase { String identifier = fileName.substring(0, fileName.indexOf('_')); String version = fileName.substring(fileName.indexOf('_') + 1); - ArtifactKey key = new ArtifactKey("osgi.bundle", identifier, new Version(version)); + ArtifactKey key = new ArtifactKey("osgi.bundle", identifier, Version.create(version)); ArtifactDescriptor descriptor = new ArtifactDescriptor(key); if (file.isDirectory()) descriptor.setProperty("artifact.folder", "true"); repo.addDescriptor(descriptor); } - IArtifactKey[] keys = repo.getArtifactKeys(); - assertEquals(2, keys.length); - for (int i = 0; i < keys.length; i++) { - repo.removeDescriptor(keys[i]); + IQueryResult keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null); + assertEquals(2, AbstractProvisioningTest.queryResultSize(keys)); + for (Iterator iterator = keys.iterator(); iterator.hasNext();) { + IArtifactKey key = (IArtifactKey) iterator.next(); + repo.removeDescriptor(key); } - assertEquals(0, repo.getArtifactKeys().length); + + keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null); + assertTrue(keys.isEmpty()); assertEquals(0, pluginsFolder.listFiles(filter).length); manager.removeRepository(repo.getLocation()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java index e180583d9..99932a704 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java @@ -10,15 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.artifact.repository; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.net.*; import junit.framework.TestCase; import org.eclipse.core.runtime.URIUtil; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.ServiceReference; @@ -36,7 +36,7 @@ public class JarURLArtifactRepositoryTest extends TestCase { } protected void setUp() throws Exception { - managerRef = TestActivator.getContext().getServiceReference(IArtifactRepositoryManager.class.getName()); + managerRef = TestActivator.getContext().getServiceReference(IArtifactRepositoryManager.SERVICE_NAME); manager = (IArtifactRepositoryManager) TestActivator.getContext().getService(managerRef); } @@ -56,6 +56,6 @@ public class JarURLArtifactRepositoryTest extends TestCase { fail(e.getMessage()); } IArtifactRepository repo = manager.loadRepository(jarRepoLocation, null); - assertTrue(repo.contains(new ArtifactKey("osgi.bundle", "testdata", new Version("1.0.0.1")))); + assertTrue(repo.contains(new ArtifactKey("osgi.bundle", "testdata", Version.create("1.0.0.1")))); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java index 884fa123f..04e2db056 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java @@ -10,16 +10,18 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.artifact.repository; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.ByteArrayOutputStream; import java.io.File; +import java.util.Iterator; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.artifact.*; +import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MD5Tests extends AbstractProvisioningTest { @@ -34,25 +36,23 @@ public class MD5Tests extends AbstractProvisioningTest { } public void testCheckMD5() { - IArtifactKey[] keys = repo.getArtifactKeys(); - for (int i = 0; i < keys.length; i++) { - IArtifactDescriptor[] desc = repo.getArtifactDescriptors(keys[i]); - for (int j = 0; j < desc.length; j++) { - IStatus status = repo.getArtifact(desc[j], new ByteArrayOutputStream(500), new NullProgressMonitor()); - //All artifacts that are expected to fail MD5 check are those whose id starts with bogus - if (desc[j].getArtifactKey().getId().startsWith("bogus")) { - assertNotOK(status); - continue; - } - assertOK("2.1 " + desc[j], status); + IQueryResult<IArtifactDescriptor> descriptors = repo.descriptorQueryable().query(ArtifactDescriptorQuery.ALL_DESCRIPTORS, null); + for (Iterator<IArtifactDescriptor> iterator = descriptors.iterator(); iterator.hasNext();) { + IArtifactDescriptor desc = iterator.next(); + IStatus status = repo.getArtifact(desc, new ByteArrayOutputStream(500), new NullProgressMonitor()); + //All artifacts that are expected to fail MD5 check are those whose id starts with bogus + if (desc.getArtifactKey().getId().startsWith("bogus")) { + assertNotOK(status); + continue; } + assertOK("2.1 " + desc, status); } } public void testBug249035_ArtifactIdentity() { //MD5 sum should not affect the identity of the artifact - ArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", new Version("1.0.0"))); + ArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", Version.create("1.0.0"))); descriptor.setProperty(IArtifactDescriptor.DOWNLOAD_MD5, "42"); try { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java index 6c6bef325..f7e7b8017 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.artifact.repository; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.*; import java.lang.reflect.Field; @@ -24,12 +24,13 @@ import org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest; import org.eclipse.equinox.internal.p2.artifact.repository.MirrorSelector; import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; -import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.AbstractArtifactRepository; -import org.eclipse.equinox.internal.provisional.spi.p2.repository.AbstractRepository; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.query.*; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.artifact.*; +import org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository; +import org.eclipse.equinox.p2.repository.spi.AbstractRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.AbstractWrappedArtifactRepository; import org.w3c.dom.*; @@ -66,7 +67,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { public void testInvalidZipFileInTheSource() { IArtifactKey key = new ArtifactKey("org.eclipse.update.feature", "HelloWorldFeature", Version.createOSGi(1, 0, 0)); - Properties targetProperties = new Properties(); + Map<String, String> targetProperties = new HashMap<String, String>(); targetProperties.put("artifact.folder", "true"); MirrorRequest request = new MirrorRequest(key, targetRepository, null, targetProperties); request.setSourceRepository(sourceRepository); @@ -79,7 +80,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest { public void testMissingArtifact() { IArtifactKey key = new ArtifactKey("org.eclipse.update.feature", "Missing", Version.createOSGi(1, 0, 0)); - Properties targetProperties = new Properties(); + Map<String, String> targetProperties = new HashMap<String, String>(); targetProperties.put("artifact.folder", "true"); MirrorRequest request = new MirrorRequest(key, targetRepository, null, targetProperties); request.setSourceRepository(sourceRepository); @@ -134,10 +135,11 @@ public class MirrorRequestTest extends AbstractProvisioningTest { // Set status sequence, actual Statuses added later source.setSequence(seq); // Grab an ArtifactKey to mirror, doesn't matter which - IArtifactKey[] keys = source.getArtifactKeys(); - assertTrue("Unable to obtain artifact keys", keys != null && keys.length > 0); + IQueryResult keys = source.query(ArtifactKeyQuery.ALL_KEYS, null); + assertTrue("Unable to obtain artifact keys", keys != null && !keys.isEmpty()); - MirrorRequest req = new MirrorRequest(keys[0], targetRepository, null, null); + IArtifactKey key = (IArtifactKey) keys.iterator().next(); + MirrorRequest req = new MirrorRequest(key, targetRepository, null, null); req.setSourceRepository(source); // Set Status sequence seq.add(new Status(IStatus.ERROR, "Activator", "Message")); @@ -147,9 +149,9 @@ public class MirrorRequestTest extends AbstractProvisioningTest { assertEquals("Expected WARNING status", IStatus.WARNING, req.getResult().getSeverity()); // Remove key from repo so the same one can be used - targetRepository.removeDescriptor(keys[0]); + targetRepository.removeDescriptor(key); // Set Status sequence - req = new MirrorRequest(keys[0], targetRepository, null, null); + req = new MirrorRequest(key, targetRepository, null, null); req.setSourceRepository(source); seq.add(new Status(IStatus.WARNING, "Activator", "Message")); seq.add(new Status(IStatus.INFO, "Activator", "Message")); @@ -158,9 +160,9 @@ public class MirrorRequestTest extends AbstractProvisioningTest { assertEquals("Expected INFO status", IStatus.INFO, req.getResult().getSeverity()); // Remove key from repo so the same one can be used - targetRepository.removeDescriptor(keys[0]); + targetRepository.removeDescriptor(key); // Set Status sequence - req = new MirrorRequest(keys[0], targetRepository, null, null); + req = new MirrorRequest(key, targetRepository, null, null); req.setSourceRepository(source); seq.add(new Status(IStatus.INFO, "Activator", "Message")); req.perform(new NullProgressMonitor()); @@ -289,10 +291,6 @@ public class MirrorRequestTest extends AbstractProvisioningTest { return delegate.getArtifactDescriptors(key); } - public IArtifactKey[] getArtifactKeys() { - return delegate.getArtifactKeys(); - } - public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) { return delegate.getArtifacts(requests, monitor); } @@ -304,6 +302,14 @@ public class MirrorRequestTest extends AbstractProvisioningTest { public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { return delegate.getRawArtifact(descriptor, destination, monitor); } + + public IQueryable<IArtifactDescriptor> descriptorQueryable() { + return delegate.descriptorQueryable(); + } + + public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) { + return delegate.query(query, monitor); + } } /* diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java index c0173b5c9..ad1d357d1 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java @@ -12,23 +12,28 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.artifact.repository; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.io.*; import java.net.URI; import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository; +import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepositoryFactory; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.*; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager; -import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.SimpleArtifactRepositoryFactory; +import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep; +import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.query.IQueryable; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.repository.artifact.*; +import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; @@ -80,7 +85,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { assertEquals(base, SimpleArtifactRepository.getActualLocation(base, true)); } - public void testCompressedRepository() throws URISyntaxException, ProvisionException { + public void testCompressedRepository() throws ProvisionException { IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager(); String tempDir = System.getProperty("java.io.tmpdir"); repositoryFile = new File(tempDir, "SimpleArtifactRepositoryTest"); @@ -90,7 +95,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { properties.put(IRepository.PROP_COMPRESSED, "true"); IArtifactRepository repo = artifactRepositoryManager.createRepository(repositoryURI, "artifact name", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); - IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3")); + IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3")); IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, null); repo.addDescriptor(descriptor); @@ -113,7 +118,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { fail("Repository should not create artifact.xml"); } - public void testUncompressedRepository() throws URISyntaxException, ProvisionException { + public void testUncompressedRepository() throws ProvisionException { IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager(); String tempDir = System.getProperty("java.io.tmpdir"); repositoryFile = new File(tempDir, "SimpleArtifactRepositoryTest"); @@ -123,7 +128,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { properties.put(IRepository.PROP_COMPRESSED, "false"); IArtifactRepository repo = artifactRepositoryManager.createRepository(repositoryURI, "artifact name", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); - IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3")); + IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3")); IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, null); repo.addDescriptor(descriptor); @@ -158,6 +163,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { public void test_248772() { SimpleArtifactRepositoryFactory factory = new SimpleArtifactRepositoryFactory(); + factory.setAgent(getAgent()); URI location = null; location = new File(getTempFolder(), getUniqueString()).toURI(); factory.create(location, "test type", null, null); @@ -193,7 +199,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { } catch (ProvisionException e) { fail("Failed to create repository", e); } - IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", new Version("1.0.0"))); + IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", Version.create("1.0.0"))); OutputStream out = null; try { @@ -247,8 +253,8 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { // Create a descriptor for a packed repo ArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("org.eclipse.update.feature", "test", Version.parseVersion("1.0.0"))); - descriptor.setProperty(IArtifactDescriptor.FORMAT, "packed"); - descriptor.setProcessingSteps(new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}); + descriptor.setProperty(IArtifactDescriptor.FORMAT, IArtifactDescriptor.FORMAT_PACKED); + descriptor.setProcessingSteps(new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}); // Create repository Map properties = new HashMap(); @@ -262,4 +268,115 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest { fail("Test failed", e); } } + + private static class TestDescriptor implements IArtifactDescriptor { + private static final IProcessingStepDescriptor[] steps = new IProcessingStepDescriptor[0]; + private IArtifactKey artifactKey; + private Properties properties = new Properties(); + + public TestDescriptor(IArtifactKey key) { + this.artifactKey = key; + } + + public IArtifactKey getArtifactKey() { + return artifactKey; + } + + public IProcessingStepDescriptor[] getProcessingSteps() { + return steps; + } + + public Map getProperties() { + return properties; + } + + public String getProperty(String key) { + return properties.getProperty(key); + } + + public IArtifactRepository getRepository() { + return null; + } + + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (!(obj instanceof IArtifactDescriptor)) + return false; + + IArtifactDescriptor other = (IArtifactDescriptor) obj; + if (!artifactKey.equals(other.getArtifactKey())) + return false; + + if (!Arrays.equals(steps, other.getProcessingSteps())) + return false; + + String format = getProperty(FORMAT); + String otherFormat = other.getProperty(FORMAT); + if (format != null ? !format.equals(otherFormat) : otherFormat != null) + return false; + + return true; + } + + public int hashCode() { + String format = getProperty(FORMAT); + + final int prime = 31; + int result = 1; + result = prime * result + ((artifactKey == null) ? 0 : artifactKey.hashCode()); + result = prime * result + Arrays.asList(steps).hashCode(); + result = prime * result + (format != null ? format.hashCode() : 0); + return result; + } + } + + public void testAddContains() throws Exception { + File folder = getTestFolder("simple_AddContains"); + repositoryURI = folder.toURI(); + + Map properties = new HashMap(); + SimpleArtifactRepository repo = (SimpleArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); + + TestDescriptor descriptor = new TestDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", Version.create("1.0.0"))); + OutputStream stream = repo.getOutputStream(descriptor); + stream.write("I am an artifact\n".getBytes()); + stream.close(); + + assertTrue(repo.contains(descriptor)); + + assertTrue(repo.contains(new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", Version.create("1.0.0"))))); + + } + + public void testQuery() throws Exception { + File folder = getTestFolder("ArtifactRepository_testQuery"); + repositoryURI = folder.toURI(); + + IArtifactRepository repo = getArtifactRepositoryManager().createRepository(repositoryURI, "test", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, new HashMap()); + + ArtifactDescriptor d1 = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "a", Version.create("1.0.0"))); + ArtifactDescriptor d2 = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "a", Version.create("2.0.0"))); + ArtifactDescriptor d3 = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "a", Version.create("2.0.0"))); + d3.setProperty(IArtifactDescriptor.FORMAT, IArtifactDescriptor.FORMAT_PACKED); + + repo.addDescriptor(d1); + repo.addDescriptor(d2); + repo.addDescriptor(d3); + + IQueryable<IArtifactDescriptor> descQueryable = repo.descriptorQueryable(); + IQueryResult<IArtifactDescriptor> result = descQueryable.query(new ArtifactDescriptorQuery("a", null, null), null); + assertEquals(3, queryResultSize(result)); + + result = descQueryable.query(new ArtifactDescriptorQuery(null, new VersionRange("[2.0.0, 3.0.0)"), null), null); + assertEquals(2, queryResultSize(result)); + assertNotContains(result, d1); + + result = descQueryable.query(new ArtifactDescriptorQuery(null, null, IArtifactDescriptor.FORMAT_PACKED), null); + assertEquals(1, queryResultSize(result)); + IArtifactDescriptor resultDescriptor = result.iterator().next(); + assertEquals(d3.getArtifactKey(), resultDescriptor.getArtifactKey()); + } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java index 845d33de0..c3394503b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java @@ -15,9 +15,9 @@ import java.io.IOException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.p2.artifact.repository.Activator; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor; public class Adder extends ProcessingStep { @@ -32,7 +32,7 @@ public class Adder extends ProcessingStep { this.operand = operand; } - public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) { + public void initialize(IProcessingStepDescriptor descriptor, IArtifactDescriptor context) { super.initialize(descriptor, context); try { operand = Integer.valueOf(descriptor.getData()).intValue(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java index 38c6fbeb7..507d9283a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java @@ -15,9 +15,9 @@ import java.io.IOException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.p2.artifact.repository.Activator; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor; public class ByteShifter extends ProcessingStep { @@ -33,7 +33,7 @@ public class ByteShifter extends ProcessingStep { basicInitialize(null); } - private void basicInitialize(ProcessingStepDescriptor descriptor) { + private void basicInitialize(IProcessingStepDescriptor descriptor) { // if the status is already set to something that not ok, we've already found a problem. if (!getStatus().isOK()) return; @@ -51,7 +51,7 @@ public class ByteShifter extends ProcessingStep { setStatus(new Status(code, Activator.ID, "ByteShifter operand invalid: " + operand)); } - public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) { + public void initialize(IProcessingStepDescriptor descriptor, IArtifactDescriptor context) { super.initialize(descriptor, context); try { operand = Integer.valueOf(descriptor.getData()).intValue(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java index 008b05370..0a033464e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java @@ -14,9 +14,9 @@ import java.io.IOException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.p2.artifact.repository.Activator; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor; public class Counter extends ProcessingStep { @@ -33,7 +33,7 @@ public class Counter extends ProcessingStep { basicInitialize(null); } - private void basicInitialize(ProcessingStepDescriptor descriptor) { + private void basicInitialize(IProcessingStepDescriptor descriptor) { // if the status is already set to something that not ok, we've already found a problem. if (!getStatus().isOK()) return; @@ -51,7 +51,7 @@ public class Counter extends ProcessingStep { setStatus(new Status(code, Activator.ID, "Counter size not set")); } - public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) { + public void initialize(IProcessingStepDescriptor descriptor, IArtifactDescriptor context) { super.initialize(descriptor, context); String data = descriptor.getData(); if (data == null) diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java index 4b090422a..feb98171c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java @@ -15,9 +15,9 @@ import java.io.IOException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.p2.artifact.repository.Activator; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor; public class Multiplier extends ProcessingStep { @@ -32,7 +32,7 @@ public class Multiplier extends ProcessingStep { this.operand = operand; } - public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) { + public void initialize(IProcessingStepDescriptor descriptor, IArtifactDescriptor context) { super.initialize(descriptor, context); try { operand = Integer.valueOf(descriptor.getData()).intValue(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java index c3862a5a0..d22e509fc 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java @@ -18,7 +18,10 @@ import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.artifact.processors.pack200.Pack200ProcessorStep; import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; import org.eclipse.equinox.internal.p2.jarprocessor.PackStep; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.*; +import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep; +import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler; +import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor; +import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor; import org.eclipse.equinox.p2.tests.TestActivator; public class ProcessingStepHandlerTest extends TestCase { @@ -29,7 +32,7 @@ public class ProcessingStepHandlerTest extends TestCase { IProgressMonitor monitor = new NullProgressMonitor(); public void testExecuteNoPSs() throws IOException { - ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[0]; + IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[0]; OutputStream result = new ByteArrayOutputStream(10); OutputStream testStream = handler.createAndLink(descriptors, null, result, monitor); testStream.write("Test".getBytes()); @@ -125,7 +128,7 @@ public class ProcessingStepHandlerTest extends TestCase { //this test is only applicable if pack200 is available if (!PackStep.canPack()) return; - ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}; + IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}; ProcessingStep[] steps = handler.create(descriptors, null); ByteArrayOutputStream result = new ByteArrayOutputStream(100000); OutputStream testStream = handler.link(steps, result, monitor); @@ -137,7 +140,7 @@ public class ProcessingStepHandlerTest extends TestCase { } public void testCreateByteShifterPS() { - ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.ByteShifter", "1", true)}; + IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.ByteShifter", "1", true)}; ProcessingStep[] steps = handler.create(descriptors, null); assertNotNull(steps); assertEquals(1, steps.length); @@ -153,7 +156,7 @@ public class ProcessingStepHandlerTest extends TestCase { // } public void testCreateAdderPS() { - ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true)}; + IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true)}; ProcessingStep[] steps = handler.create(descriptors, null); assertNotNull(steps); assertEquals(1, steps.length); @@ -161,7 +164,7 @@ public class ProcessingStepHandlerTest extends TestCase { } public void testCreateMultiplierPS() { - ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true)}; + IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true)}; ProcessingStep[] steps = handler.create(descriptors, null); assertNotNull(steps); assertEquals(1, steps.length); @@ -169,7 +172,7 @@ public class ProcessingStepHandlerTest extends TestCase { } public void testCreatePack200UnpackerPS() { - ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}; + IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)}; ProcessingStep[] steps = handler.create(descriptors, null); assertNotNull(steps); assertEquals(1, steps.length); @@ -177,9 +180,9 @@ public class ProcessingStepHandlerTest extends TestCase { } public void testCreatePSsAndAssureOrderingOfPSs1() throws IOException { - ProcessingStepDescriptor adder = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true); - ProcessingStepDescriptor multiplier = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true); - ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {adder, multiplier}; + IProcessingStepDescriptor adder = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true); + IProcessingStepDescriptor multiplier = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true); + IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {adder, multiplier}; ProcessingStep[] steps = handler.create(descriptors, null); ByteArrayOutputStream result = new ByteArrayOutputStream(10); OutputStream testStream = handler.link(steps, result, monitor); @@ -189,9 +192,9 @@ public class ProcessingStepHandlerTest extends TestCase { } public void testCreatePSsAndAssureOrderingOfPSs2() throws IOException { - ProcessingStepDescriptor adder = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true); - ProcessingStepDescriptor multiplier = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true); - ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {multiplier, adder}; + IProcessingStepDescriptor adder = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true); + IProcessingStepDescriptor multiplier = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true); + IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {multiplier, adder}; ProcessingStep[] steps = handler.create(descriptors, null); ByteArrayOutputStream result = new ByteArrayOutputStream(10); OutputStream testStream = handler.link(steps, result, monitor); @@ -201,9 +204,9 @@ public class ProcessingStepHandlerTest extends TestCase { } public void testLinkPSs() throws IOException { - ProcessingStepDescriptor adder = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true); - ProcessingStepDescriptor multiplier = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true); - ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {adder, multiplier}; + IProcessingStepDescriptor adder = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true); + IProcessingStepDescriptor multiplier = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true); + IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {adder, multiplier}; ByteArrayOutputStream result = new ByteArrayOutputStream(10); OutputStream testStream = handler.createAndLink(descriptors, null, result, monitor); testStream.write(new byte[] {1, 2, 3, 4, 5}); |