Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2010-01-13 17:29:41 +0000
committerPascal Rapicault2010-01-13 17:29:41 +0000
commit18189f0d42f7375660762dc6c885cf31683ae562 (patch)
tree17775d847bed9a33f3c68b74db2df75a2139c0bc /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant
parentc363f2984a09b73c422e38f4556fd3b23eafe958 (diff)
downloadrt.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/ant')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/MirrorTaskTest.java107
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java43
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/RepoTasksTests.java15
4 files changed, 69 insertions, 108 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java
index 0127f5869..759155a62 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java
@@ -18,12 +18,12 @@ import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository;
import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper;
-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.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.repository.ICompositeRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.repository.ICompositeRepository;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractAntProvisioningTest;
public class CompositeRepositoryTaskTest extends AbstractAntProvisioningTest {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/MirrorTaskTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/MirrorTaskTest.java
index e01bb1e31..23af9407f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/MirrorTaskTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/MirrorTaskTest.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ant;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.*;
import java.net.URI;
@@ -21,13 +21,15 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.artifact.processors.md5.Messages;
import org.eclipse.equinox.internal.p2.director.PermissiveSlicer;
import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
-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.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
-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.internal.repository.comparator.MD5ArtifactComparator;
+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.*;
+import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractAntProvisioningTest;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
@@ -301,7 +303,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
AntTaskElement mirror = createMirrorTask(TYPE_METADATA);
@@ -315,7 +317,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
p.setProperty("org.eclipse.update.install.features", String.valueOf(true));
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, true, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
try {
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
@@ -331,7 +333,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
AntTaskElement mirror = createMirrorTask(TYPE_METADATA);
@@ -344,7 +346,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
PermissiveSlicer slicer = new PermissiveSlicer(repo, new Properties(), true, false, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
try {
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
} catch (ProvisionException e) {
@@ -359,7 +361,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
AntTaskElement mirror = createMirrorTask(TYPE_METADATA);
@@ -373,7 +375,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
p.setProperty("org.eclipse.update.install.features", String.valueOf(true));
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, false, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
try {
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
} catch (ProvisionException e) {
@@ -388,7 +390,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
AntTaskElement mirror = createMirrorTask(TYPE_METADATA);
@@ -401,7 +403,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
Properties p = getSliceProperties();
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
try {
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
} catch (ProvisionException e) {
@@ -419,7 +421,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
AntTaskElement mirror = createMirrorTask(TYPE_METADATA);
@@ -433,7 +435,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
p.setProperty("org.eclipse.update.install.features", String.valueOf(true));
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
try {
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
} catch (ProvisionException e) {
@@ -451,7 +453,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
// Create task
@@ -465,7 +467,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
Properties p = getSliceProperties();
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
try {
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
} catch (ProvisionException e) {
@@ -483,7 +485,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("test.feature.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("test.feature.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
// Create task
@@ -498,10 +500,10 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
- assertEquals("Different number of ArtifactKeys", getArtifactKeyCount(result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor())), getArtifactKeyCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
+ assertEquals("Different number of ArtifactKeys", getArtifactKeyCount(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getArtifactKeyCount(destinationRepo));
try {
- assertArtifactKeyContentEquals("Different ArtifactKeys", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()), destinationRepo);
+ assertArtifactKeyContentEquals("Different ArtifactKeys", result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()), destinationRepo);
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
} catch (ProvisionException e) {
fail("Failed to compare contents", e);
@@ -519,7 +521,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("test.feature.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("test.feature.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
// Create task
@@ -534,8 +536,8 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of ArtifactKeys", getArtifactKeyCount(result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor())), getArtifactKeyCount(destinationRepo));
- assertArtifactKeyContentEquals("Different ArtifactKeys", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()), destinationRepo);
+ assertEquals("Different number of ArtifactKeys", getArtifactKeyCount(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getArtifactKeyCount(destinationRepo));
+ assertArtifactKeyContentEquals("Different ArtifactKeys", result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()), destinationRepo);
}
/*
@@ -548,10 +550,10 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("test.feature.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("test.feature.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
- c = repo.query(new InstallableUnitQuery("RCP_Browser_Example.feature.group"), new Collector(), new NullProgressMonitor());
+ c = repo.query(new InstallableUnitQuery("RCP_Browser_Example.feature.group"), new NullProgressMonitor());
IInstallableUnit iu2 = (IInstallableUnit) c.iterator().next();
// Create task
@@ -567,8 +569,8 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu, iu2}, new NullProgressMonitor());
- assertEquals("Different number of ArtifactKeys", getArtifactKeyCount(result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor())), getArtifactKeyCount(destinationRepo));
- assertArtifactKeyContentEquals("Different ArtifactKeys", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()), destinationRepo);
+ assertEquals("Different number of ArtifactKeys", getArtifactKeyCount(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getArtifactKeyCount(destinationRepo));
+ assertArtifactKeyContentEquals("Different ArtifactKeys", result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()), destinationRepo);
}
/*
@@ -581,7 +583,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.ui.examples.readmetool"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.ui.examples.readmetool"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
// Create task
@@ -623,7 +625,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
*/
public void testBaselineCompareUsingMD5Comparator() {
//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/content.xml");
File artifact2 = getTestData("0.0", "/testData/mirror/mirrorSourceRepo2/content.xml");
@@ -677,6 +679,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
// Create a comparator element
AntTaskElement comparator = new AntTaskElement("comparator");
+ comparator.addAttribute("comparator", MD5ArtifactComparator.MD5_COMPARATOR_ID);
comparator.addElement(getRepositoryElement(baselineLocation.toURI(), null));
mirror.addElement(comparator);
@@ -750,38 +753,10 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
/*
* Get the number of ArtifactKeys in a repository
*/
- protected int getArtifactKeyCount(URI location) {
- try {
- return getArtifactRepositoryManager().loadRepository(location, null).getArtifactKeys().length;
- } catch (ProvisionException e) {
- fail("Failed to load repository " + URIUtil.toUnencodedString(location) + " for ArtifactDescriptor count");
- return -1;
- }
- }
-
- /*
- * Get the number of ArtifactKeys in a repository
- */
- protected int getArtifactKeyCount(Collector ius) {
+ protected int getArtifactKeyCount(IQueryResult ius) {
int count = 0;
for (Iterator iter = ius.iterator(); iter.hasNext();)
- count += ((InstallableUnit) iter.next()).getArtifacts().length;
- return count;
- }
-
- /*
- * Get the number of ArtifactDescriptors in a repository
- */
- protected int getArtifactDescriptorCount(URI location) {
- int count = 0;
- try {
- IArtifactRepository repo = getArtifactRepositoryManager().loadRepository(location, null);
- IArtifactKey[] keys = repo.getArtifactKeys();
- for (int i = 0; i < keys.length; i++)
- count += repo.getArtifactDescriptors(keys[i]).length;
- } catch (ProvisionException e) {
- fail("Failed to load repository " + URIUtil.toUnencodedString(location) + " for ArtifactDescriptor count");
- }
+ count += ((InstallableUnit) iter.next()).getArtifacts().size();
return count;
}
@@ -790,7 +765,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
*/
protected int getIUCount(URI location) {
try {
- return getMetadataRepositoryManager().loadRepository(location, null).query(InstallableUnitQuery.ANY, new Collector(), null).size();
+ return queryResultSize(getMetadataRepositoryManager().loadRepository(location, null).query(InstallableUnitQuery.ANY, null));
} catch (ProvisionException e) {
fail("Failed to load repository " + URIUtil.toUnencodedString(location) + " for ArtifactDescriptor count");
return -1;
@@ -801,9 +776,9 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
* Add all IUs to the parent element
*/
protected void addAllIUs(AntTaskElement parent, IMetadataRepository repo) {
- Collector collector = repo.query(InstallableUnitQuery.ANY, new Collector(), null);
+ IQueryResult queryResult = repo.query(InstallableUnitQuery.ANY, null);
- for (Iterator iter = collector.iterator(); iter.hasNext();) {
+ for (Iterator iter = queryResult.iterator(); iter.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iter.next();
parent.addElement(createIUElement(iu));
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java
index 93a0a334f..1fb74ff9b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java
@@ -12,16 +12,15 @@ package org.eclipse.equinox.p2.tests.ant;
import java.io.File;
import java.net.URI;
-import java.util.Collection;
+import java.util.Iterator;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-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.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.p2.core.ProvisionException;
+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.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.tests.AbstractAntProvisioningTest;
public class Repo2RunnableTaskTests extends AbstractAntProvisioningTest {
@@ -61,8 +60,8 @@ public class Repo2RunnableTaskTests extends AbstractAntProvisioningTest {
IInstallableUnit iu = null;
try {
IMetadataRepository repo = getMetadataRepositoryManager().loadRepository(source, new NullProgressMonitor());
- Collection ius = repo.query(new InstallableUnitQuery("helloworldfeature.feature.jar"), new Collector(), new NullProgressMonitor()).toCollection();
- assertEquals("Expected number of IUs", 1, ius.size());
+ IQueryResult ius = repo.query(new InstallableUnitQuery("helloworldfeature.feature.jar"), new NullProgressMonitor());
+ assertEquals("Expected number of IUs", 1, queryResultSize(ius));
iu = (IInstallableUnit) ius.iterator().next();
} catch (ProvisionException e) {
fail("Failed to obtain iu", e);
@@ -71,7 +70,7 @@ public class Repo2RunnableTaskTests extends AbstractAntProvisioningTest {
task.addElement(createIUElement(iu));
runAntTask();
- assertEquals("Number of artifact keys differs", iu.getArtifacts().length, getArtifactKeyCount(destination));
+ assertEquals("Number of artifact keys differs", iu.getArtifacts().size(), getArtifactKeyCount(destination));
assertTrue("Unexpected format", expectedFormat(destination));
}
@@ -117,9 +116,9 @@ public class Repo2RunnableTaskTests extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Failed to load repository", e);
}
- IArtifactKey[] keys = repo.getArtifactKeys();
- for (int i = 0; i < keys.length; i++) {
- IArtifactKey key = keys[i];
+ IQueryResult keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null);
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
+ IArtifactKey key = (IArtifactKey) iterator.next();
IArtifactDescriptor[] descriptors = repo.getArtifactDescriptors(key);
for (int n = 0; n < descriptors.length; n++) {
IArtifactDescriptor desc = descriptors[n];
@@ -130,25 +129,13 @@ public class Repo2RunnableTaskTests extends AbstractAntProvisioningTest {
else
assertFalse(desc + " is a folder", isFolder);
// Artifacts should not be packed
- assertTrue("Artifact is still packed", !"packed".equals(desc.getProperty("format")));
+ assertTrue("Artifact is still packed", !IArtifactDescriptor.FORMAT_PACKED.equals(desc.getProperty(IArtifactDescriptor.FORMAT)));
}
}
return true;
}
/*
- * Count the number of ArtifactKeys in the repository at the given location
- */
- protected int getArtifactKeyCount(URI location) {
- try {
- return getArtifactRepositoryManager().loadRepository(location, new NullProgressMonitor()).getArtifactKeys().length;
- } catch (ProvisionException e) {
- fail("Failed to count keys in repository", e);
- return -1;
- }
- }
-
- /*
* Create a simple AntTaskElement for the Repo2RunnableTask
*/
protected AntTaskElement createRepo2RunnableTaskElement() {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/RepoTasksTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/RepoTasksTests.java
index 9c274bab6..037c23683 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/RepoTasksTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/RepoTasksTests.java
@@ -12,10 +12,11 @@ package org.eclipse.equinox.p2.tests.ant;
import java.io.File;
import java.net.URI;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-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.repository.IMetadataRepository;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.tests.AbstractAntProvisioningTest;
public class RepoTasksTests extends AbstractAntProvisioningTest {
@@ -63,10 +64,8 @@ public class RepoTasksTests extends AbstractAntProvisioningTest {
assertNull(iu);
IArtifactRepository artifacts = getArtifactRepositoryManager().loadRepository(destinationRepo, null);
- IArtifactKey[] keys = artifacts.getArtifactKeys();
- for (int i = 0; i < keys.length; i++) {
- assertFalse(keys[i].getId().equals("anotherplugin"));
- }
+ IQueryResult keys = artifacts.query(new ArtifactKeyQuery(null, "anotherplugin", null), null);
+ assertTrue(keys.isEmpty());
assertFalse(new File(getTestFolder(getName()), "plugins/anotherplugin_1.0.0.jar").exists());
}
}

Back to the top