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 | |
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')
321 files changed, 7438 insertions, 6032 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractAntProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractAntProvisioningTest.java index e72c223e8..0a82e05d9 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractAntProvisioningTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractAntProvisioningTest.java @@ -17,12 +17,14 @@ import java.util.*; import org.eclipse.ant.core.AntRunner; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.URIUtil; -import org.eclipse.equinox.internal.p2.metadata.InstallableUnit; import org.eclipse.equinox.internal.p2.persistence.XMLWriter; -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.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; +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.query.IQueryResult; +import org.eclipse.equinox.p2.query.IQueryable; +import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; public class AbstractAntProvisioningTest extends AbstractProvisioningTest { protected static final String TYPE_ARTIFACT = "A"; @@ -246,11 +248,11 @@ public class AbstractAntProvisioningTest extends AbstractProvisioningTest { assertContains(message, destination, source); } - protected static void assertArtifactKeyContentEquals(String message, Collector ius, URI artifactRepositoryLocation) { + protected void assertArtifactKeyContentEquals(String message, IQueryResult ius, URI artifactRepositoryLocation) { try { IArtifactRepository repo = getArtifactRepositoryManager().loadRepository(artifactRepositoryLocation, null); List fromIUs = getArtifactKeys(ius); - List fromRepo = Arrays.asList(repo.getArtifactKeys()); + Iterator fromRepo = repo.query(ArtifactKeyQuery.ALL_KEYS, null).iterator(); assertContains(message, fromIUs, fromRepo); assertContains(message, fromRepo, fromIUs); } catch (ProvisionException e) { @@ -259,28 +261,11 @@ public class AbstractAntProvisioningTest extends AbstractProvisioningTest { } - protected static void assertContains(String message, IQueryable source, IQueryable destination) { - Collector sourceCollector = source.query(InstallableUnitQuery.ANY, new Collector(), null); - Iterator it = sourceCollector.iterator(); + protected static List getArtifactKeys(IQueryResult<IInstallableUnit> ius) { + List<IArtifactKey> keys = new ArrayList<IArtifactKey>(); - while (it.hasNext()) { - IInstallableUnit sourceIU = (IInstallableUnit) it.next(); - Collector destinationCollector = destination.query(new InstallableUnitQuery(sourceIU), new Collector(), null); - assertEquals(message, 1, destinationCollector.size()); - assertTrue(message, sourceIU.equals(destinationCollector.iterator().next())); - } - } - - protected static void assertContains(String message, List fromIUs, List fromRepo) { - for (Iterator iter = fromIUs.iterator(); iter.hasNext();) - assertTrue(message, fromRepo.contains(iter.next())); - } - - protected static List getArtifactKeys(Collector ius) { - List keys = new ArrayList(ius.size()); - - for (Iterator iter = ius.iterator(); iter.hasNext();) - keys.addAll(Arrays.asList(((InstallableUnit) iter.next()).getArtifacts())); + for (Iterator<IInstallableUnit> iter = ius.iterator(); iter.hasNext();) + keys.addAll(iter.next().getArtifacts()); return keys; } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java index 76f090a7d..1b6ef6158 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java @@ -19,23 +19,29 @@ import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.core.helpers.URLUtil; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager; -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.core.eventbus.IProvisioningEventBus; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.*; -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.provisional.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.core.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil; +import org.eclipse.equinox.p2.metadata.query.FragmentQuery; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.publisher.PublisherInfo; import org.eclipse.equinox.p2.publisher.eclipse.*; +import org.eclipse.equinox.p2.query.*; +import org.eclipse.equinox.p2.repository.IRepositoryManager; +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.osgi.service.datalocation.Location; import org.eclipse.osgi.service.resolver.BundleDescription; +import org.osgi.framework.*; /** * Base class for provisioning tests with convenience methods used by multiple tests. @@ -71,6 +77,7 @@ public abstract class AbstractProvisioningTest extends TestCase { protected List profilesToRemove = new ArrayList(); private File testFolder = null; + protected Object previousSelfValue = null; public static void assertEmptyProfile(IProfile profile) { assertNotNull("The profile should not be null", profile); @@ -199,7 +206,7 @@ public abstract class AbstractProvisioningTest extends TestCase { InstallableUnitFragmentDescription fragment = new InstallableUnitFragmentDescription(); fragment.setId(name); fragment.setVersion(DEFAULT_VERSION); - fragment.setProperty(IInstallableUnit.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString()); + fragment.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString()); fragment.setTouchpointType(TOUCHPOINT_OSGI); fragment.addTouchpointData(NO_TP_DATA); fragment.setHost(BUNDLE_REQUIREMENT); @@ -225,7 +232,7 @@ public abstract class AbstractProvisioningTest extends TestCase { } public static IDirector createDirector() { - return (IDirector) ServiceHelper.getService(TestActivator.getContext(), IDirector.class.getName()); + return (IDirector) ServiceHelper.getService(TestActivator.getContext(), IDirector.SERVICE_NAME); } /** @@ -263,8 +270,8 @@ public abstract class AbstractProvisioningTest extends TestCase { /** * Creates and returns a correctly formatted LDAP filter with the given key and value. */ - protected static String createFilter(String filterKey, String filterValue) { - return "(" + filterKey + '=' + filterValue + ')'; + protected static Filter createFilter(String filterKey, String filterValue) { + return ExpressionUtil.parseLDAP("(" + filterKey + '=' + filterValue + ')'); } /** @@ -304,6 +311,10 @@ public abstract class AbstractProvisioningTest extends TestCase { * assume default values, and the default self capability is also added to the IU. */ public static IInstallableUnit createIU(String name, String filter, IProvidedCapability[] additionalProvides) { + return createIU(name, ExpressionUtil.parseLDAP(filter), additionalProvides); + } + + public static IInstallableUnit createIU(String name, Filter filter, IProvidedCapability[] additionalProvides) { return createIU(name, DEFAULT_VERSION, filter, NO_REQUIRES, additionalProvides, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false); } @@ -356,6 +367,10 @@ public abstract class AbstractProvisioningTest extends TestCase { * assume default values, and the default self capability is also added to the IU. */ public static IInstallableUnit createIU(String name, Version version, String filter, IProvidedCapability[] additionalProvides) { + return createIU(name, version, ExpressionUtil.parseLDAP(filter), additionalProvides); + } + + public static IInstallableUnit createIU(String name, Version version, Filter filter, IProvidedCapability[] additionalProvides) { return createIU(name, version, filter, NO_REQUIRES, additionalProvides, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false); } @@ -363,7 +378,7 @@ public abstract class AbstractProvisioningTest extends TestCase { * Create a basic InstallableUnit with the given attributes. All other attributes * assume default values, and the default self capability is also added to the IU. */ - public static IInstallableUnit createIU(String name, Version version, String filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton) { + public static IInstallableUnit createIU(String name, Version version, Filter filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton) { return createIU(name, version, filter, required, additionalProvides, properties, tpType, tpData, singleton, null, null); } @@ -371,7 +386,7 @@ public abstract class AbstractProvisioningTest extends TestCase { return createIUPatch(name, version, null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, singleton, null, changes, scope, lifeCycle, NO_REQUIRES); } - public static IInstallableUnitPatch createIUPatch(String name, Version version, String filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton, IUpdateDescriptor update, IRequirementChange[] reqChanges, IRequiredCapability[][] scope, IRequiredCapability lifeCycle, IRequiredCapability[] metaRequirements) { + public static IInstallableUnitPatch createIUPatch(String name, Version version, Filter filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton, IUpdateDescriptor update, IRequirementChange[] reqChanges, IRequiredCapability[][] scope, IRequiredCapability lifeCycle, IRequiredCapability[] metaRequirements) { InstallableUnitPatchDescription iu = new MetadataFactory.InstallableUnitPatchDescription(); iu.setId(name); iu.setVersion(version); @@ -400,7 +415,7 @@ public abstract class AbstractProvisioningTest extends TestCase { return MetadataFactory.createInstallableUnitPatch(iu); } - public static IInstallableUnit createIU(String name, Version version, String filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton, IUpdateDescriptor update, IRequiredCapability[] metaRequirements) { + public static IInstallableUnit createIU(String name, Version version, Filter filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton, IUpdateDescriptor update, IRequiredCapability[] metaRequirements) { InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription(); iu.setId(name); iu.setVersion(version); @@ -444,47 +459,45 @@ public abstract class AbstractProvisioningTest extends TestCase { InstallableUnitFragmentDescription fragment = new InstallableUnitFragmentDescription(); fragment.setId(name); fragment.setVersion(version); - fragment.setProperty(IInstallableUnit.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString()); + fragment.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString()); fragment.setRequiredCapabilities(required); fragment.setTouchpointType(tpType); if (tpData != null) fragment.addTouchpointData(tpData); if (host != null) { VersionRange hostRange = new VersionRange(host.getVersion(), true, host.getVersion(), true); - fragment.setHost(new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, host.getId(), hostRange, null, false, false)}); + fragment.setHost(new IRequirement[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, host.getId(), hostRange, null, false, false)}); } fragment.setCapabilities(new IProvidedCapability[] {getSelfCapability(name, version)}); return MetadataFactory.createInstallableUnitFragment(fragment); } public static void changeVersion(InstallableUnitDescription desc, Version newVersion) { - IProvidedCapability[] capabilities = desc.getProvidedCapabilities(); - for (int i = 0; i < capabilities.length; i++) { - if (desc.getVersion().equals(capabilities[i].getVersion())) - capabilities[i] = MetadataFactory.createProvidedCapability(capabilities[i].getNamespace(), capabilities[i].getName(), newVersion); + List<IProvidedCapability> capabilities = new ArrayList(desc.getProvidedCapabilities()); + for (int i = 0; i < capabilities.size(); i++) { + IProvidedCapability pc = capabilities.get(i); + if (desc.getVersion().equals(pc.getVersion())) + capabilities.set(i, MetadataFactory.createProvidedCapability(pc.getNamespace(), pc.getName(), newVersion)); } desc.setVersion(newVersion); + desc.setCapabilities(capabilities.toArray(new IProvidedCapability[capabilities.size()])); } public static MetadataFactory.InstallableUnitDescription createIUDescriptor(IInstallableUnit prototype) { InstallableUnitDescription desc = new MetadataFactory.InstallableUnitDescription(); - desc.setArtifacts(prototype.getArtifacts()); - IProvidedCapability originalCapabilities[] = prototype.getProvidedCapabilities(); - IProvidedCapability newCapabilities[] = new IProvidedCapability[originalCapabilities.length]; - for (int i = 0; i < originalCapabilities.length; i++) { - newCapabilities[i] = MetadataFactory.createProvidedCapability(originalCapabilities[i].getNamespace(), originalCapabilities[i].getName(), originalCapabilities[i].getVersion()); - } - desc.setCapabilities(newCapabilities); + Collection<IArtifactKey> originalArtifacts = prototype.getArtifacts(); + desc.setArtifacts(originalArtifacts.toArray(new IArtifactKey[originalArtifacts.size()])); + Collection<IProvidedCapability> originalCapabilities = prototype.getProvidedCapabilities(); + desc.setCapabilities(originalCapabilities.toArray(new IProvidedCapability[originalCapabilities.size()])); desc.setCopyright(prototype.getCopyright()); desc.setFilter(prototype.getFilter()); desc.setId(prototype.getId()); - desc.setLicense(prototype.getLicense()); - IRequiredCapability[] originalRequirements = prototype.getRequiredCapabilities(); - IRequiredCapability[] newRequirements = new IRequiredCapability[originalRequirements.length]; - for (int i = 0; i < newRequirements.length; i++) { - newRequirements[i] = MetadataFactory.createRequiredCapability(originalRequirements[i].getNamespace(), originalRequirements[i].getName(), originalRequirements[i].getRange(), originalRequirements[i].getFilter(), originalRequirements[i].isOptional(), originalRequirements[i].isMultiple(), originalRequirements[i].isGreedy()); - } - desc.setRequiredCapabilities(prototype.getRequiredCapabilities()); + Collection<ILicense> originalLicenses = prototype.getLicenses(); + desc.setLicenses(originalLicenses.toArray(new ILicense[originalLicenses.size()])); + Collection<IRequirement> originalRequirements = prototype.getRequiredCapabilities(); + desc.setRequiredCapabilities(originalRequirements.toArray(new IRequirement[originalRequirements.size()])); + originalRequirements = prototype.getMetaRequiredCapabilities(); + desc.setMetaRequiredCapabilities(originalRequirements.toArray(new IRequirement[originalRequirements.size()])); desc.setSingleton(prototype.isSingleton()); desc.setTouchpointType(MetadataFactory.createTouchpointType(prototype.getTouchpointType().getId(), prototype.getTouchpointType().getVersion())); desc.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor(prototype.getUpdateDescriptor().getId(), prototype.getUpdateDescriptor().getRange(), prototype.getUpdateDescriptor().getSeverity(), prototype.getUpdateDescriptor().getDescription())); @@ -499,20 +512,29 @@ public abstract class AbstractProvisioningTest extends TestCase { } public static IPlanner createPlanner() { - return (IPlanner) ServiceHelper.getService(TestActivator.getContext(), IPlanner.class.getName()); + return (IPlanner) ServiceHelper.getService(TestActivator.getContext(), IPlanner.SERVICE_NAME); } /** * Creates and returns a required capability with the provided attributes. */ + protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name) { + return createRequiredCapabilities(namespace, name, ANY_VERSION, (Filter) null); + } + protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name, String filter) { return createRequiredCapabilities(namespace, name, ANY_VERSION, filter); } - /** - * Creates and returns a required capability with the provided attributes. - */ + protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name, VersionRange range) { + return createRequiredCapabilities(namespace, name, range, (Filter) null); + } + protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name, VersionRange range, String filter) { + return createRequiredCapabilities(namespace, name, range, ExpressionUtil.parseLDAP(filter)); + } + + protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name, VersionRange range, Filter filter) { return new IRequiredCapability[] {MetadataFactory.createRequiredCapability(namespace, name, range, filter, false, false)}; } @@ -568,7 +590,7 @@ public abstract class AbstractProvisioningTest extends TestCase { } public static Iterator getInstallableUnits(IProfile profile2) { - return profile2.query(InstallableUnitQuery.ANY, new Collector(), null).iterator(); + return profile2.query(InstallableUnitQuery.ANY, null).iterator(); } /** @@ -581,7 +603,7 @@ public abstract class AbstractProvisioningTest extends TestCase { /** * Get the 'self' capability for an installable unit with the give id and version. */ - private static IProvidedCapability getSelfCapability(String installableUnitId, Version installableUnitVersion) { + protected static IProvidedCapability getSelfCapability(String installableUnitId, Version installableUnitVersion) { return MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, installableUnitId, installableUnitVersion); } @@ -618,6 +640,41 @@ public abstract class AbstractProvisioningTest extends TestCase { } } + public static int queryResultSize(IQueryResult queryResult) { + if (queryResult instanceof Collector) + return ((Collector) queryResult).size(); + + int cnt = 0; + Iterator itor = queryResult.iterator(); + while (itor.hasNext()) { + itor.next(); + ++cnt; + } + return cnt; + } + + public static int queryResultUniqueSize(IQueryResult queryResult) { + int cnt = 0; + Iterator itor = queryResult.iterator(); + HashSet uniqueTracker = new HashSet(); + while (itor.hasNext()) { + if (uniqueTracker.add(itor.next())) + ++cnt; + } + return cnt; + } + + public static void restartBundle(final Bundle bundle) throws BundleException { + bundle.stop(Bundle.STOP_TRANSIENT); + startBundle(bundle); + } + + public static void startBundle(final Bundle bundle) throws BundleException { + //see http://dev.eclipse.org/mhonarc/lists/equinox-dev/msg05917.html + bundle.start(Bundle.START_ACTIVATION_POLICY); + bundle.start(Bundle.START_TRANSIENT); + } + private static void write(IStatus status, int indent, PrintStream output) { indent(output, indent); output.println("Severity: " + status.getSeverity()); @@ -684,7 +741,7 @@ public abstract class AbstractProvisioningTest extends TestCase { * in the tearDown method. */ protected IProfile createProfile(String name) { - return createProfile(name, null, null); + return createProfile(name, null); } /** @@ -692,18 +749,14 @@ public abstract class AbstractProvisioningTest extends TestCase { * already exists. The returned profile will be removed automatically * in the tearDown method. */ - protected IProfile createProfile(String name, String parentId) { - return createProfile(name, parentId, null); - } - - protected IProfile createProfile(String name, String parentId, Map properties) { + protected IProfile createProfile(String name, Map properties) { //remove any existing profile with the same name - IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry profileRegistry = getProfileRegistry(); profileRegistry.removeProfile(name); profilesToRemove.add(name); //create and return a new profile try { - return profileRegistry.addProfile(name, properties, parentId); + return profileRegistry.addProfile(name, properties); } catch (ProvisionException e) { throw new IllegalArgumentException(e.getMessage()); } @@ -714,9 +767,7 @@ public abstract class AbstractProvisioningTest extends TestCase { } protected IProfile getProfile(String profileId) { - //remove any existing profile with the same name - IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); - return profileRegistry.getProfile(profileId); + return getProfileRegistry().getProfile(profileId); } /** @@ -732,7 +783,7 @@ public abstract class AbstractProvisioningTest extends TestCase { */ protected IMetadataRepository createTestMetdataRepository(IInstallableUnit[] units) { IMetadataRepository repo = new TestMetadataRepository(units); - MetadataRepositoryManager repoMan = (MetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + MetadataRepositoryManager repoMan = (MetadataRepositoryManager) getMetadataRepositoryManager(); assertNotNull(repoMan); repoMan.addRepository(repo); metadataRepos.add(repo); @@ -746,8 +797,22 @@ public abstract class AbstractProvisioningTest extends TestCase { return repo; } + protected static IProvisioningAgent getAgent() { + //get the global agent for the currently running system + return (IProvisioningAgent) ServiceHelper.getService(TestActivator.getContext(), IProvisioningAgent.SERVICE_NAME); + } + + protected static IAgentLocation getAgentLocation() { + //get the location of the currently running system + return (IAgentLocation) getAgent().getService(IAgentLocation.SERVICE_NAME); + } + protected static IArtifactRepositoryManager getArtifactRepositoryManager() { - return (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.class.getName()); + return (IArtifactRepositoryManager) getAgent().getService(IArtifactRepositoryManager.SERVICE_NAME); + } + + protected IProfileRegistry getProfileRegistry() { + return (IProfileRegistry) getAgent().getService(IProfileRegistry.SERVICE_NAME); } protected IMetadataRepository createMetadataRepository(URI location, Map properties) throws ProvisionException { @@ -765,17 +830,17 @@ public abstract class AbstractProvisioningTest extends TestCase { } protected IInstallableUnit getIU(IMetadataRepository repository, String name) { - Collector collector = repository.query(new InstallableUnitQuery(name), new Collector(), null); + IQueryResult queryResult = repository.query(new InstallableUnitQuery(name), null); IInstallableUnit unit = null; - if (collector.size() > 0) - unit = (IInstallableUnit) collector.iterator().next(); + if (!queryResult.isEmpty()) + unit = (IInstallableUnit) queryResult.iterator().next(); return unit; } protected static IMetadataRepositoryManager getMetadataRepositoryManager() { - return (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + return (IMetadataRepositoryManager) getAgent().getService(IMetadataRepositoryManager.SERVICE_NAME); } public static String getUniqueString() { @@ -819,7 +884,7 @@ public abstract class AbstractProvisioningTest extends TestCase { protected void tearDown() throws Exception { super.tearDown(); //remove all metadata repositories created by this test - IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + IMetadataRepositoryManager repoMan = getMetadataRepositoryManager(); if (!metadataRepos.isEmpty()) { for (Iterator it = metadataRepos.iterator(); it.hasNext();) { IMetadataRepository repo = (IMetadataRepository) it.next(); @@ -837,7 +902,7 @@ public abstract class AbstractProvisioningTest extends TestCase { } } //remove all profiles created by this test - IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry profileRegistry = getProfileRegistry(); for (Iterator it = profilesToRemove.iterator(); it.hasNext();) { String toRemove = (String) it.next(); profileRegistry.removeProfile(toRemove); @@ -867,46 +932,24 @@ public abstract class AbstractProvisioningTest extends TestCase { return null; } - protected static void assertInstallOperand(ProvisioningPlan plan, IInstallableUnit iu) { - Operand[] ops = plan.getOperands(); - for (int i = 0; i < ops.length; i++) { - if (ops[i] instanceof InstallableUnitOperand) { - InstallableUnitOperand iuOp = (InstallableUnitOperand) ops[i]; - if (iu.equals(iuOp.second())) - return; - } - } - fail("Can't find " + iu + " in the plan"); + protected static void assertInstallOperand(IProvisioningPlan plan, IInstallableUnit iu) { + if (plan.getAdditions().query(new InstallableUnitQuery(iu), null).isEmpty()) + fail("Can't find " + iu + " in the plan"); } - protected static void assertUninstallOperand(ProvisioningPlan plan, IInstallableUnit iu) { - Operand[] ops = plan.getOperands(); - for (int i = 0; i < ops.length; i++) { - if (ops[i] instanceof InstallableUnitOperand) { - InstallableUnitOperand iuOp = (InstallableUnitOperand) ops[i]; - if (iu.equals(iuOp.first())) - return; - } - } - fail("Can't find " + iu + " in the plan"); - } - - protected static void assertNoOperand(ProvisioningPlan plan, IInstallableUnit iu) { - Operand[] ops = plan.getOperands(); - for (int i = 0; i < ops.length; i++) { - if (ops[i] instanceof InstallableUnitOperand) { - InstallableUnitOperand iuOp = (InstallableUnitOperand) ops[i]; - if (iuOp.second() != null && iuOp.second().equals(iu)) - fail(iu + " should not be present in this plan."); - if (iuOp.first() != null && iuOp.first().equals(iu)) - fail(iu + " should not be present in this plan."); - } - } + protected static void assertUninstallOperand(IProvisioningPlan plan, IInstallableUnit iu) { + if (plan.getRemovals().query(new InstallableUnitQuery(iu), null).isEmpty()) + fail("Can't find " + iu + " in the plan"); + } + + protected static void assertNoOperand(IProvisioningPlan plan, IInstallableUnit iu) { + if (!(plan.getRemovals().query(new InstallableUnitQuery(iu), null).isEmpty() && plan.getAdditions().query(new InstallableUnitQuery(iu), null).isEmpty())) + fail(iu + " should not be present in this plan."); } protected void setUp() throws Exception { super.setUp(); - MetadataRepositoryManager repoMan = (MetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + IMetadataRepositoryManager repoMan = getMetadataRepositoryManager(); URI[] repos = repoMan.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL); for (int i = 0; i < repos.length; i++) { repoMan.removeRepository(repos[i]); @@ -920,18 +963,18 @@ public abstract class AbstractProvisioningTest extends TestCase { req.setInstallableUnitInclusionRules(ius[i], strict ? PlannerHelper.createStrictInclusionRule(ius[i]) : PlannerHelper.createOptionalInclusionRule(ius[i])); } - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); if (plan.getStatus().getSeverity() == IStatus.ERROR || plan.getStatus().getSeverity() == IStatus.CANCEL) return plan.getStatus(); - return engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), null, null); + return engine.perform(plan, null); } protected IStatus uninstall(IProfile profile, IInstallableUnit[] ius, IPlanner planner, IEngine engine) { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.removeInstallableUnits(ius); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); - return engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + return engine.perform(plan, null); } protected static void assertEquals(String message, Object[] expected, Object[] actual, boolean orderImportant) { @@ -1002,15 +1045,15 @@ public abstract class AbstractProvisioningTest extends TestCase { if (!iu1.equals(iu2)) fail(message + " " + iu1 + " is not equal to " + iu2); - if (iu1.isFragment()) { - if (!iu2.isFragment()) + if (FragmentQuery.isFragment(iu1)) { + if (!FragmentQuery.isFragment(iu2)) fail(message + " " + iu1 + " is not a fragment."); try { assertEquals(message, ((IInstallableUnitFragment) iu1).getHost(), ((IInstallableUnitFragment) iu2).getHost()); } catch (AssertionFailedError failure) { fail(message + " Unequal hosts: " + failure.getMessage()); } - } else if (iu2.isFragment()) { + } else if (FragmentQuery.isFragment(iu2)) { fail(message + " " + iu2 + " is a fragment."); } @@ -1027,7 +1070,7 @@ public abstract class AbstractProvisioningTest extends TestCase { assertEquals(message, iu1.getTouchpointType(), iu2.getTouchpointType()); assertEquals(message, iu1.getTouchpointData(), iu2.getTouchpointData()); assertEquals(message, iu1.getProperties(), iu2.getProperties()); - assertEquals(message, iu1.getLicense(), iu2.getLicense()); + assertEquals(message, iu1.getLicenses(), iu2.getLicenses()); assertEquals(message, iu1.getCopyright(), iu2.getCopyright()); assertEquals(message, iu1.getUpdateDescriptor(), iu2.getUpdateDescriptor()); assertEquals(message, iu1.getFilter(), iu2.getFilter()); @@ -1136,15 +1179,15 @@ public abstract class AbstractProvisioningTest extends TestCase { * Note: NOT BICONDITIONAL! assertContains(A, B) is NOT the same as assertContains(B, A) */ protected static void assertContains(String message, IArtifactRepository sourceRepo, IArtifactRepository destinationRepo) { - IArtifactKey[] sourceKeys = sourceRepo.getArtifactKeys(); - - for (int i = 0; i < sourceKeys.length; i++) { - IArtifactDescriptor[] destinationDescriptors = destinationRepo.getArtifactDescriptors(sourceKeys[i]); + IQueryResult sourceKeys = sourceRepo.query(ArtifactKeyQuery.ALL_KEYS, null); + for (Iterator iterator = sourceKeys.iterator(); iterator.hasNext();) { + IArtifactKey key = (IArtifactKey) iterator.next(); + IArtifactDescriptor[] destinationDescriptors = destinationRepo.getArtifactDescriptors(key); if (destinationDescriptors == null || destinationDescriptors.length == 0) - fail(message + ": unmatched key: " + sourceKeys[i].toString()); + fail(message + ": unmatched key: " + key.toString()); //this implicitly verifies the keys are present - IArtifactDescriptor[] sourceDescriptors = sourceRepo.getArtifactDescriptors(sourceKeys[i]); + IArtifactDescriptor[] sourceDescriptors = sourceRepo.getArtifactDescriptors(key); assertEquals(message, sourceDescriptors, destinationDescriptors, false); //order doesn't matter } @@ -1164,13 +1207,13 @@ public abstract class AbstractProvisioningTest extends TestCase { * Note: NOT BICONDITIONAL! assertContains(A, B) is NOT the same as assertContains(B, A) */ protected static void assertContains(String message, IMetadataRepository sourceRepo, IMetadataRepository destinationRepo) { - Collector sourceCollector = sourceRepo.query(InstallableUnitQuery.ANY, new Collector(), null); + IQueryResult sourceCollector = sourceRepo.query(InstallableUnitQuery.ANY, null); Iterator it = sourceCollector.iterator(); while (it.hasNext()) { IInstallableUnit sourceIU = (IInstallableUnit) it.next(); - Collector destinationCollector = destinationRepo.query(new InstallableUnitQuery(sourceIU), new Collector(), null); - assertEquals(message, 1, destinationCollector.size()); + IQueryResult destinationCollector = destinationRepo.query(new InstallableUnitQuery(sourceIU), null); + assertEquals(message, 1, queryResultSize(destinationCollector)); assertEquals(message, sourceIU, (IInstallableUnit) destinationCollector.iterator().next()); } } @@ -1184,6 +1227,61 @@ public abstract class AbstractProvisioningTest extends TestCase { assertContains(message, repo2, repo1); } + public static void assertContains(String message, IQueryable source, IQueryable destination) { + IQueryResult sourceCollector = source.query(InstallableUnitQuery.ANY, null); + Iterator it = sourceCollector.iterator(); + + while (it.hasNext()) { + IInstallableUnit sourceIU = (IInstallableUnit) it.next(); + IQueryResult destinationCollector = destination.query(new InstallableUnitQuery(sourceIU), null); + assertEquals(message, 1, queryResultSize(destinationCollector)); + assertTrue(message, sourceIU.equals(destinationCollector.iterator().next())); + } + } + + public static void assertContains(String message, IQueryResult result, IQueryResult mustHave) { + assertContains(message, result.iterator(), mustHave.iterator()); + } + + public static void assertContains(String message, Iterator result, Iterator mustHave) { + HashSet repoSet = new HashSet(); + while (mustHave.hasNext()) + repoSet.add(mustHave.next()); + assertContains(message, result, repoSet); + } + + public static void assertContains(String message, Iterator result, Collection mustHave) { + while (result.hasNext()) + assertTrue(message, mustHave.contains(result.next())); + } + + public static void assertContains(IQueryResult result, Object value) { + assertContains(null, result, value); + } + + public static void assertNotContains(IQueryResult result, Object value) { + assertNotContains(null, result, value); + } + + public static void assertContains(String message, IQueryResult result, Object value) { + Iterator itor = result.iterator(); + while (itor.hasNext()) + if (itor.next().equals(value)) + return; + fail(message); + } + + public static void assertNotContains(String message, IQueryResult result, Object value) { + Iterator itor = result.iterator(); + while (itor.hasNext()) + if (itor.next().equals(value)) + fail(message); + } + + public static void assertContains(String message, Collection fromIUs, Iterator fromRepo) { + assertContains(message, fromIUs.iterator(), fromRepo); + } + /* * Return a boolean value indicating whether or not the given installable units * are considered to be equal. @@ -1327,4 +1425,76 @@ public abstract class AbstractProvisioningTest extends TestCase { fail(); } } + + protected int getArtifactKeyCount(URI location) { + try { + return getArtifactKeyCount(getArtifactRepositoryManager().loadRepository(location, null)); + } catch (ProvisionException e) { + fail("Failed to load repository " + URIUtil.toUnencodedString(location) + " for ArtifactDescriptor count"); + return -1; + } + } + + protected int getArtifactKeyCount(IArtifactRepository repo) { + return queryResultSize(repo.query(ArtifactKeyQuery.ALL_KEYS, null)); + } + + protected int getArtifactDescriptorCount(URI location) { + int count = 0; + try { + IArtifactRepository repo = getArtifactRepositoryManager().loadRepository(location, null); + IQueryResult descriptors = repo.descriptorQueryable().query(ArtifactDescriptorQuery.ALL_DESCRIPTORS, null); + return queryResultSize(descriptors); + } catch (ProvisionException e) { + fail("Failed to load repository " + URIUtil.toUnencodedString(location) + " for ArtifactDescriptor count"); + } + return count; + } + + public int countPlanElements(IProvisioningPlan plan) { + return queryResultSize(new CompoundQueryable(plan.getAdditions(), plan.getRemovals()).query(InstallableUnitQuery.ANY, null)); + } + + /** + * This method is used by tests that require access to the "self" profile. It spoofs + * up a fake self profile is none is already available. Tests should invoke this method + * from their {@link #setUp()} method, and invoke {@link #tearDownSelfProfile()} + * from their {@link #tearDown()} method. + */ + protected void setUpSelfProfile() { + if (System.getProperty("eclipse.p2.profile") == null) { + SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) getProfileRegistry(); + try { + Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$ + selfField.setAccessible(true); + previousSelfValue = selfField.get(profileRegistry); + if (previousSelfValue == null) + selfField.set(profileRegistry, "agent"); + } catch (Throwable t) { + fail(); + } + } + createProfile("agent"); + } + + /** + * This method is used by tests that require access to the "self" profile. It cleans up + * a fake self profile is none is already available. Tests should invoke this method + * from their {@link #tearDown()} method, and invoke {@link #setUpSelfProfile()} + * from their {@link #setUp()} method. + */ + protected void tearDownSelfProfile() { + if (System.getProperty("eclipse.p2.profile") == null) { + SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) getProfileRegistry(); + try { + Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$ + selfField.setAccessible(true); + Object self = selfField.get(profileRegistry); + if (self.equals("agent")) + selfField.set(profileRegistry, previousSelfValue); + } catch (Throwable t) { + // ignore as we still want to continue tidying up + } + } + } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractWrappedArtifactRepository.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractWrappedArtifactRepository.java index 81beb03d8..0343fb74b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractWrappedArtifactRepository.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractWrappedArtifactRepository.java @@ -15,9 +15,10 @@ import java.net.URI; import java.util.Map; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -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.metadata.IArtifactKey; +import org.eclipse.equinox.p2.query.*; +import org.eclipse.equinox.p2.repository.artifact.*; public class AbstractWrappedArtifactRepository implements IArtifactRepository { @@ -51,10 +52,6 @@ public class AbstractWrappedArtifactRepository implements IArtifactRepository { return delegate.getArtifactDescriptors(key); } - public IArtifactKey[] getArtifactKeys() { - return delegate.getArtifactKeys(); - } - public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) { return delegate.getArtifacts(requests, monitor); } @@ -130,4 +127,16 @@ public class AbstractWrappedArtifactRepository implements IArtifactRepository { public Object getAdapter(Class adapter) { return delegate.getAdapter(adapter); } + + public IArtifactDescriptor createArtifactDescriptor(IArtifactKey key) { + return delegate.createArtifactDescriptor(key); + } + + 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/AutomatedTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java index 513bbeaa1..da38e98f9 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java @@ -35,11 +35,13 @@ public class AutomatedTests extends TestCase { suite.addTest(org.eclipse.equinox.p2.tests.installer.AllTests.suite()); suite.addTest(org.eclipse.equinox.p2.tests.jarprocessor.AllTests.suite()); suite.addTest(org.eclipse.equinox.p2.tests.metadata.AllTests.suite()); + suite.addTest(org.eclipse.equinox.p2.tests.metadata.expression.AllTests.suite()); suite.addTest(org.eclipse.equinox.p2.tests.metadata.repository.AllTests.suite()); suite.addTest(org.eclipse.equinox.p2.tests.mirror.AllTests.suite()); suite.addTest(org.eclipse.equinox.p2.tests.omniVersion.AllTests.suite()); suite.addTest(org.eclipse.equinox.p2.tests.planner.AllTests.suite()); suite.addTest(org.eclipse.equinox.p2.tests.publisher.AllTests.suite()); + suite.addTest(org.eclipse.equinox.p2.tests.ql.AllTests.suite()); suite.addTest(org.eclipse.equinox.p2.tests.repository.AllTests.suite()); suite.addTest(org.eclipse.equinox.p2.tests.simpleconfigurator.SimpleConfiguratorTests.suite()); suite.addTest(org.eclipse.equinox.p2.tests.simpleconfigurator.manipulator.AllTests.suite()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/FailingMetadataRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/FailingMetadataRepositoryFactory.java index 5126261be..6eb7adacb 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/FailingMetadataRepositoryFactory.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/FailingMetadataRepositoryFactory.java @@ -13,9 +13,9 @@ package org.eclipse.equinox.p2.tests; import java.net.URI; import java.util.Map; import org.eclipse.core.runtime.*; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; -import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.MetadataRepositoryFactory; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory; /** * A repository factory that always throws exceptions. The "fail" flag must be set to diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java deleted file mode 100644 index f0efa0f3c..000000000 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java +++ /dev/null @@ -1,231 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008-2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * EclipseSource - ongoing development - *******************************************************************************/ -package org.eclipse.equinox.p2.tests; - -import java.lang.ref.SoftReference; -import java.util.*; -import org.eclipse.equinox.internal.p2.metadata.InstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; - -public class IUPropertyUtils { - - IQueryable queryable; - - /** - * - */ - public IUPropertyUtils(IQueryable queryable) { - this.queryable = queryable; - } - - // TODO: these constants should come from API, eg. IInstallableUnit or ??? - final Locale DEFAULT_LOCALE = new Locale("df", "LT"); //$NON-NLS-1$//$NON-NLS-2$ - final String NAMESPACE_IU_LOCALIZATION = "org.eclipse.equinox.p2.localization"; //$NON-NLS-1$ - - // Cache the IU fragments that provide localizations for a given locale. - // map: locale => soft reference to a collector - private Map LocaleCollectorCache = new HashMap(2); - - // Get the license in the default locale. - public ILicense getLicense(IInstallableUnit iu) { - return getLicense(iu, getCurrentLocale()); - } - - // Get the copyright in the default locale. - public ICopyright getCopyright(IInstallableUnit iu) { - return getCopyright(iu, getCurrentLocale()); - } - - // Get a property in the default locale - public String getIUProperty(IInstallableUnit iu, String propertyKey) { - return getIUProperty(iu, propertyKey, getCurrentLocale()); - } - - public ILicense getLicense(IInstallableUnit iu, Locale locale) { - ILicense license = iu.getLicense(); - String body = (license != null ? license.getBody() : null); - if (body == null || body.length() <= 1 || body.charAt(0) != '%') - return license; - final String actualKey = body.substring(1); // Strip off the % - body = getLocalizedIUProperty(iu, actualKey, locale); - return MetadataFactory.createLicense(license.getLocation(), body); - } - - public ICopyright getCopyright(IInstallableUnit iu, Locale locale) { - ICopyright copyright = iu.getCopyright(); - String body = (copyright != null ? copyright.getBody() : null); - if (body == null || body.length() <= 1 || body.charAt(0) != '%') - return copyright; - final String actualKey = body.substring(1); // Strip off the % - body = getLocalizedIUProperty(iu, actualKey, locale); - return MetadataFactory.createCopyright(copyright.getLocation(), body); - } - - public String getIUProperty(IInstallableUnit iu, String propertyKey, Locale locale) { - String value = iu.getProperty(propertyKey); - if (value == null || value.length() <= 1 || value.charAt(0) != '%') - return value; - // else have a localizable property - final String actualKey = value.substring(1); // Strip off the % - return getLocalizedIUProperty(iu, actualKey, locale); - } - - private String getLocalizedIUProperty(IInstallableUnit iu, String actualKey, Locale locale) { - String localizedKey = makeLocalizedKey(actualKey, locale.toString()); - String localizedValue = null; - - //first check for a cached localized value - if (iu instanceof InstallableUnit) - localizedValue = ((InstallableUnit) iu).getLocalizedProperty(localizedKey); - //next check if the localized value is stored in the same IU (common case) - if (localizedValue == null) - localizedValue = iu.getProperty(localizedKey); - if (localizedValue != null) - return localizedValue; - - final List locales = buildLocaleVariants(locale); - final IInstallableUnit theUnit = iu; - - Collector localizationFragments = getLocalizationFragments(locale, locales); - - Collector hostLocalizationCollector = new Collector() { - public boolean accept(Object object) { - boolean haveHost = false; - if (object instanceof IInstallableUnitFragment) { - IInstallableUnitFragment fragment = (IInstallableUnitFragment) object; - IRequiredCapability[] hosts = fragment.getHost(); - for (int i = 0; i < hosts.length; i++) { - IRequiredCapability nextHost = hosts[i]; - if (IInstallableUnit.NAMESPACE_IU_ID.equals(nextHost.getNamespace()) && // - theUnit.getId().equals(nextHost.getName()) && // - nextHost.getRange() != null && // - nextHost.getRange().isIncluded(theUnit.getVersion())) { - haveHost = true; - break; - } - } - } - return (haveHost ? super.accept(object) : true); - } - }; - - IUPropertyQuery iuQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_FRAGMENT, "true"); //$NON-NLS-1$ - Collector collected = iuQuery.perform(localizationFragments.iterator(), hostLocalizationCollector); - - if (!collected.isEmpty()) { - String translation = null; - for (Iterator iter = collected.iterator(); iter.hasNext() && translation == null;) { - IInstallableUnit localizationIU = (IInstallableUnit) iter.next(); - for (Iterator jter = locales.iterator(); jter.hasNext();) { - String localeKey = makeLocalizedKey(actualKey, (String) jter.next()); - translation = localizationIU.getProperty(localeKey); - if (translation != null) - return cacheResult(iu, localizedKey, translation); - } - } - } - - for (Iterator iter = locales.iterator(); iter.hasNext();) { - String nextLocale = (String) iter.next(); - String localeKey = makeLocalizedKey(actualKey, nextLocale); - String nextValue = iu.getProperty(localeKey); - if (nextValue != null) - return cacheResult(iu, localizedKey, nextValue); - } - - return cacheResult(iu, localizedKey, actualKey); - } - - /** - * Cache the translated property value to optimize future retrieval of the same value. - * Currently we just cache on the installable unit object in memory. In future - * we should push support for localized property retrieval into IInstallableUnit - * so we aren't required to reach around the API here. - */ - private String cacheResult(IInstallableUnit iu, String localizedKey, String localizedValue) { - if (iu instanceof InstallableUnit) - ((InstallableUnit) iu).setLocalizedProperty(localizedKey, localizedValue); - return localizedValue; - } - - /** - * Collects the installable unit fragments that contain locale data for the given locales. - */ - private synchronized Collector getLocalizationFragments(Locale locale, List localeVariants) { - SoftReference collectorRef = (SoftReference) LocaleCollectorCache.get(locale); - if (collectorRef != null) { - Collector cached = (Collector) collectorRef.get(); - if (cached != null) - return cached; - } - - final List locales = localeVariants; - - Collector localeFragmentCollector = new Collector() { - public boolean accept(Object object) { - boolean haveLocale = false; - if (object instanceof IInstallableUnitFragment) { - IInstallableUnitFragment fragment = (IInstallableUnitFragment) object; - IProvidedCapability[] provides = fragment.getProvidedCapabilities(); - for (int j = 0; j < provides.length && !haveLocale; j++) { - IProvidedCapability nextProvide = provides[j]; - if (NAMESPACE_IU_LOCALIZATION.equals(nextProvide.getNamespace())) { - String providedLocale = nextProvide.getName(); - if (providedLocale != null) { - for (Iterator iter = locales.iterator(); iter.hasNext();) { - if (providedLocale.equals(iter.next())) { - haveLocale = true; - break; - } - } - } - } - } - } - return (haveLocale ? super.accept(object) : true); - } - }; - - IUPropertyQuery iuQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_FRAGMENT, "true"); //$NON-NLS-1$ - Collector collected = queryable.query(iuQuery, localeFragmentCollector, null); - LocaleCollectorCache.put(locale, new SoftReference(collected)); - return collected; - } - - /** - */ - private List buildLocaleVariants(Locale locale) { - String nl = locale.toString(); - ArrayList result = new ArrayList(4); - int lastSeparator; - while (true) { - result.add(nl); - lastSeparator = nl.lastIndexOf('_'); - if (lastSeparator == -1) - break; - nl = nl.substring(0, lastSeparator); - } - // Add the default locale (most general) - result.add(DEFAULT_LOCALE.toString()); - return result; - } - - private String makeLocalizedKey(String actualKey, String localeImage) { - return localeImage + '.' + actualKey; - } - - private Locale getCurrentLocale() { - return Locale.getDefault(); - } - -} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/MockQueryable.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/MockQueryable.java index 1f09bab10..dfe6b5d6f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/MockQueryable.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/MockQueryable.java @@ -13,7 +13,7 @@ package org.eclipse.equinox.p2.tests; import java.util.ArrayList; import java.util.Collection; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; +import org.eclipse.equinox.p2.query.*; /** * A test queryable that contains a simple collection of objects. @@ -35,8 +35,8 @@ public class MockQueryable implements IQueryable { } - public Collector query(Query query, Collector collector, IProgressMonitor monitor) { - return query.perform(items.iterator(), collector); + public IQueryResult query(IQuery query, IProgressMonitor monitor) { + return query.perform(items.iterator()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java index 7c51861c8..310fa1b57 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java @@ -44,9 +44,9 @@ public class TestActivator implements BundleActivator { packageAdmin = (PackageAdmin) context.getService(packageAdminRef); //This is a hack because the junit plugin launch config do not allow to start bundles - getBundle("org.eclipse.equinox.p2.exemplarysetup").start(); - getBundle("org.eclipse.equinox.frameworkadmin.equinox").start(); - getBundle("org.eclipse.equinox.simpleconfigurator.manipulator").start(); + AbstractProvisioningTest.startBundle(getBundle("org.eclipse.equinox.p2.exemplarysetup")); + AbstractProvisioningTest.startBundle(getBundle("org.eclipse.equinox.frameworkadmin.equinox")); + AbstractProvisioningTest.startBundle(getBundle("org.eclipse.equinox.simpleconfigurator.manipulator")); } public void stop(BundleContext context) throws Exception { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java index 6ec898f2a..aa3d7f5a1 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java @@ -20,12 +20,14 @@ import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.artifact.repository.ArtifactRequest; import org.eclipse.equinox.internal.p2.repository.Transport; import org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler; -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.RepositoryCreationException; -import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.AbstractArtifactRepository; +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.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest; +import org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository; +import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; /** * A simple artifact repository implementation used for testing purposes. @@ -107,10 +109,6 @@ public class TestArtifactRepository extends AbstractArtifactRepository { return keysToLocations.get(key); } - public IArtifactKey[] getArtifactKeys() { - return keysToLocations.keySet().toArray(new IArtifactKey[keysToLocations.keySet().size()]); - } - private IStatus getArtifact(ArtifactRequest request, IProgressMonitor monitor) { request.setSourceRepository(this); request.perform(monitor); @@ -130,7 +128,7 @@ public class TestArtifactRepository extends AbstractArtifactRepository { } } - public void initialize(URI repoURL, InputStream descriptorFile) throws RepositoryCreationException { + public void initialize(URI repoURL, InputStream descriptorFile) { location = repoURL; } @@ -194,4 +192,14 @@ public class TestArtifactRepository extends AbstractArtifactRepository { public OutputStream getOutputStream(IArtifactDescriptor descriptor) { throw new UnsupportedOperationException("Method is not implemented by this repository"); } + + public IQueryable<IArtifactDescriptor> descriptorQueryable() { + // TODO Auto-generated method stub + return null; + } + + public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) { + // TODO Auto-generated method stub + return null; + } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java index 8cc075fbb..05130d887 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java @@ -10,19 +10,21 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.net.URI; import java.net.URISyntaxException; import java.util.*; import junit.framework.Assert; import org.eclipse.core.runtime.IProgressMonitor; -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.repository.IRepository; -import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository; -import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.RepositoryReference; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository; +import org.eclipse.equinox.p2.repository.spi.RepositoryReference; /** * A simple metadata repository used for testing purposes. All metadata @@ -58,7 +60,7 @@ public class TestMetadataRepository extends AbstractMetadataRepository { } public IInstallableUnit find(String id, String versionString) { - Iterator result = query(new InstallableUnitQuery(id, new Version(versionString)), new Collector(), null).iterator(); + Iterator result = query(new InstallableUnitQuery(id, Version.create(versionString)), null).iterator(); return (IInstallableUnit) (result.hasNext() ? result.next() : null); } @@ -69,8 +71,8 @@ public class TestMetadataRepository extends AbstractMetadataRepository { return null; } - public Collector query(Query query, Collector collector, IProgressMonitor monitor) { - return query.perform(units.iterator(), collector); + public IQueryResult query(IQuery query, IProgressMonitor monitor) { + return query.perform(units.iterator()); } public void removeAll() { 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()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java index 3a65650b1..a0ab65372 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java @@ -14,8 +14,8 @@ import java.io.*; import java.lang.reflect.*; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; import org.eclipse.equinox.p2.tests.TestActivator; /** 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}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/AggregateQueryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/AggregateQueryTest.java index ddf8fca34..bea6a9cdc 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/AggregateQueryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/AggregateQueryTest.java @@ -11,7 +11,8 @@ package org.eclipse.equinox.p2.tests.core; import java.util.*; import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; +import org.eclipse.equinox.p2.query.*; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** * This tests both Compound and Composite queries @@ -28,16 +29,17 @@ public class AggregateQueryTest extends TestCase { } public void testEmptyCompositeQuery() { - CompositeQuery query = new CompositeQuery(new Query[0]); - query.perform(getABCDE().iterator(), new Collector()); + PipedQuery query = new PipedQuery(new IQuery[0]); + query.perform(getABCDE().iterator()); // We should not throw an exception. No guarantee on what perform // will return in this case } public void testSymmetry() { - Query getLatest = new ContextQuery() { + IQuery getLatest = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + public Collector perform(Iterator iterator) { + Collector result = new Collector(); List list = new ArrayList(); while (iterator.hasNext()) { list.add(iterator.next()); @@ -48,9 +50,10 @@ public class AggregateQueryTest extends TestCase { } }; - Query getAllBut3 = new ContextQuery() { + IQuery getAllBut3 = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + public Collector perform(Iterator iterator) { + Collector result = new Collector(); while (iterator.hasNext()) { Object o = iterator.next(); if (!o.equals("3")) @@ -60,21 +63,21 @@ public class AggregateQueryTest extends TestCase { } }; - CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {getLatest, getAllBut3}, true); - Collector result = compoundQuery.perform(get123().iterator(), new Collector()); - assertEquals(0, result.size()); + CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {getLatest, getAllBut3}, true); + IQueryResult result = compoundQuery.perform(get123().iterator()); + assertEquals(0, AbstractProvisioningTest.queryResultSize(result)); - compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {getAllBut3, getLatest}, true); - result = compoundQuery.perform(get123().iterator(), new Collector()); - assertEquals(0, result.size()); + compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {getAllBut3, getLatest}, true); + result = compoundQuery.perform(get123().iterator()); + assertEquals(0, AbstractProvisioningTest.queryResultSize(result)); - compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {getLatest, getAllBut3}, false); - result = compoundQuery.perform(get123().iterator(), new Collector()); - assertEquals(3, result.size()); + compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {getLatest, getAllBut3}, false); + result = compoundQuery.perform(get123().iterator()); + assertEquals(3, AbstractProvisioningTest.queryResultSize(result)); - compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {getAllBut3, getLatest}, false); - result = compoundQuery.perform(get123().iterator(), new Collector()); - assertEquals(3, result.size()); + compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {getAllBut3, getLatest}, false); + result = compoundQuery.perform(get123().iterator()); + assertEquals(3, AbstractProvisioningTest.queryResultSize(result)); } @@ -83,9 +86,10 @@ public class AggregateQueryTest extends TestCase { * This method tests that */ public void testNonSymmetry() { - Query getLatest = new ContextQuery() { + IQuery getLatest = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + public Collector perform(Iterator iterator) { + Collector result = new Collector(); List list = new ArrayList(); while (iterator.hasNext()) { list.add(iterator.next()); @@ -96,9 +100,11 @@ public class AggregateQueryTest extends TestCase { } }; - Query getAllBut3 = new ContextQuery() { + IQuery getAllBut3 = new ContextQuery() { + + public Collector perform(Iterator iterator) { + Collector result = new Collector(); - public Collector perform(Iterator iterator, Collector result) { while (iterator.hasNext()) { Object o = iterator.next(); if (!o.equals("3")) @@ -108,95 +114,95 @@ public class AggregateQueryTest extends TestCase { } }; - CompositeQuery compoundQuery = new CompositeQuery(new Query[] {getLatest, getAllBut3}); - Collector result = compoundQuery.perform(get123().iterator(), new Collector()); - assertEquals(0, result.size()); + PipedQuery compoundQuery = new PipedQuery(getLatest, getAllBut3); + IQueryResult result = compoundQuery.perform(get123().iterator()); + assertEquals(0, AbstractProvisioningTest.queryResultSize(result)); - compoundQuery = new CompositeQuery(new Query[] {getAllBut3, getLatest}); - result = compoundQuery.perform(get123().iterator(), new Collector()); - assertEquals(1, result.size()); - assertEquals("2", result.toCollection().iterator().next()); + compoundQuery = new PipedQuery(getAllBut3, getLatest); + result = compoundQuery.perform(get123().iterator()); + assertEquals(1, AbstractProvisioningTest.queryResultSize(result)); + assertEquals("2", result.iterator().next()); } public void testCompoundAllMatchQueries() { - Query A = new MatchQuery() { + IQuery A = new MatchQuery() { public boolean isMatch(Object candidate) { return false; } }; - Query B = new MatchQuery() { + IQuery B = new MatchQuery() { public boolean isMatch(Object candidate) { return false; } }; - Query C = new MatchQuery() { + IQuery C = new MatchQuery() { public boolean isMatch(Object candidate) { return false; } }; - CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {A, B, C}, true); + CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {A, B, C}, true); assertTrue("1.0", compoundQuery instanceof IMatchQuery); - assertEquals("1.1", 3, compoundQuery.getQueries().length); - assertEquals("1.2", A, compoundQuery.getQueries()[0]); - assertEquals("1.3", B, compoundQuery.getQueries()[1]); - assertEquals("1.4", C, compoundQuery.getQueries()[2]); + assertEquals("1.1", 3, compoundQuery.getQueries().size()); + assertEquals("1.2", A, compoundQuery.getQueries().get(0)); + assertEquals("1.3", B, compoundQuery.getQueries().get(1)); + assertEquals("1.4", C, compoundQuery.getQueries().get(2)); } public void testCompoundSomeMatchQueries() { - Query A = new MatchQuery() { + IQuery A = new MatchQuery() { public boolean isMatch(Object candidate) { return false; } }; - Query B = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + IQuery B = new ContextQuery() { + public Collector perform(Iterator iterator) { // TODO Auto-generated method stub return null; } }; - Query C = new MatchQuery() { + IQuery C = new MatchQuery() { public boolean isMatch(Object candidate) { return false; } }; - CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {A, B, C}, true); + CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {A, B, C}, true); assertTrue("1.0", !(compoundQuery instanceof IMatchQuery)); - assertEquals("1.1", 3, compoundQuery.getQueries().length); - assertEquals("1.2", A, compoundQuery.getQueries()[0]); - assertEquals("1.3", B, compoundQuery.getQueries()[1]); - assertEquals("1.4", C, compoundQuery.getQueries()[2]); + assertEquals("1.1", 3, compoundQuery.getQueries().size()); + assertEquals("1.2", A, compoundQuery.getQueries().get(0)); + assertEquals("1.3", B, compoundQuery.getQueries().get(1)); + assertEquals("1.4", C, compoundQuery.getQueries().get(2)); } public void testCompoundNoMatchQueries() { - Query A = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + IQuery A = new ContextQuery() { + public Collector perform(Iterator iterator) { // TODO Auto-generated method stub return null; } }; - Query B = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + IQuery B = new ContextQuery() { + public Collector perform(Iterator iterator) { // TODO Auto-generated method stub return null; } }; - Query C = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + IQuery C = new ContextQuery() { + public Collector perform(Iterator iterator) { // TODO Auto-generated method stub return null; } }; - CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {A, B, C}, true); + CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {A, B, C}, true); assertTrue("1.0", !(compoundQuery instanceof IMatchQuery)); - assertEquals("1.1", 3, compoundQuery.getQueries().length); - assertEquals("1.2", A, compoundQuery.getQueries()[0]); - assertEquals("1.3", B, compoundQuery.getQueries()[1]); - assertEquals("1.4", C, compoundQuery.getQueries()[2]); + assertEquals("1.1", 3, compoundQuery.getQueries().size()); + assertEquals("1.2", A, compoundQuery.getQueries().get(0)); + assertEquals("1.3", B, compoundQuery.getQueries().get(1)); + assertEquals("1.4", C, compoundQuery.getQueries().get(2)); } public void testIntersection() { - Query ABC = new MatchQuery() { + IQuery ABC = new MatchQuery() { public boolean isMatch(Object candidate) { if (candidate.equals("A") || candidate.equals("B") || candidate.equals("C")) return true; @@ -204,7 +210,7 @@ public class AggregateQueryTest extends TestCase { } }; - Query BCDE = new MatchQuery() { + IQuery BCDE = new MatchQuery() { public boolean isMatch(Object candidate) { if (candidate.equals("B") || candidate.equals("C") || candidate.equals("D") || candidate.equals("E")) return true; @@ -212,16 +218,17 @@ public class AggregateQueryTest extends TestCase { } }; - CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {ABC, BCDE}, true); - Collector result = compoundQuery.perform(getABCDE().iterator(), new Collector()); - assertEquals("1.0", result.size(), 2); - assertTrue("1.1", result.toCollection().contains("B")); - assertTrue("1.2", result.toCollection().contains("C")); + CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {ABC, BCDE}, true); + IQueryResult result = compoundQuery.perform(getABCDE().iterator()); + assertEquals("1.0", AbstractProvisioningTest.queryResultSize(result), 2); + AbstractProvisioningTest.assertContains("1.1", result, "B"); + AbstractProvisioningTest.assertContains("1.2", result, "C"); } public void testIntersection2() { - Query ABC = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + IQuery ABC = new ContextQuery() { + public Collector perform(Iterator iterator) { + Collector result = new Collector(); while (iterator.hasNext()) { Object o = iterator.next(); if (o.equals("A") || o.equals("B") || o.equals("C")) @@ -231,8 +238,9 @@ public class AggregateQueryTest extends TestCase { } }; - Query BCDE = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + IQuery BCDE = new ContextQuery() { + public Collector perform(Iterator iterator) { + Collector result = new Collector(); while (iterator.hasNext()) { Object o = iterator.next(); if (o.equals("B") || o.equals("C") || o.equals("D") || o.equals("E")) @@ -242,15 +250,15 @@ public class AggregateQueryTest extends TestCase { } }; - CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {ABC, BCDE}, true); - Collector result = compoundQuery.perform(getABCDE().iterator(), new Collector()); - assertEquals("1.0", result.size(), 2); - assertTrue("1.1", result.toCollection().contains("B")); - assertTrue("1.2", result.toCollection().contains("C")); + CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {ABC, BCDE}, true); + IQueryResult result = compoundQuery.perform(getABCDE().iterator()); + assertEquals("1.0", AbstractProvisioningTest.queryResultSize(result), 2); + AbstractProvisioningTest.assertContains("1.1", result, "B"); + AbstractProvisioningTest.assertContains("1.2", result, "C"); } public void testUnion() { - Query ABC = new MatchQuery() { + IQuery ABC = new MatchQuery() { public boolean isMatch(Object candidate) { if (candidate.equals("A") || candidate.equals("B") || candidate.equals("C")) return true; @@ -258,7 +266,7 @@ public class AggregateQueryTest extends TestCase { } }; - Query BCDE = new MatchQuery() { + IQuery BCDE = new MatchQuery() { public boolean isMatch(Object candidate) { if (candidate.equals("B") || candidate.equals("C") || candidate.equals("D") || candidate.equals("E")) return true; @@ -266,19 +274,20 @@ public class AggregateQueryTest extends TestCase { } }; - CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {ABC, BCDE}, false); - Collector result = compoundQuery.perform(getABCDE().iterator(), new Collector()); - assertEquals("1.0", result.size(), 5); - assertTrue("1.1", result.toCollection().contains("A")); - assertTrue("1.2", result.toCollection().contains("B")); - assertTrue("1.3", result.toCollection().contains("C")); - assertTrue("1.4", result.toCollection().contains("D")); - assertTrue("1.5", result.toCollection().contains("E")); + CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {ABC, BCDE}, false); + IQueryResult result = compoundQuery.perform(getABCDE().iterator()); + assertEquals("1.0", AbstractProvisioningTest.queryResultSize(result), 5); + AbstractProvisioningTest.assertContains("1.1", result, "A"); + AbstractProvisioningTest.assertContains("1.2", result, "B"); + AbstractProvisioningTest.assertContains("1.3", result, "C"); + AbstractProvisioningTest.assertContains("1.4", result, "D"); + AbstractProvisioningTest.assertContains("1.5", result, "E"); } public void testUnion2() { - Query ABC = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + IQuery ABC = new ContextQuery() { + public Collector perform(Iterator iterator) { + Collector result = new Collector(); while (iterator.hasNext()) { Object o = iterator.next(); if (o.equals("A") || o.equals("B") || o.equals("C")) @@ -288,8 +297,9 @@ public class AggregateQueryTest extends TestCase { } }; - Query BCDE = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + IQuery BCDE = new ContextQuery() { + public Collector perform(Iterator iterator) { + Collector result = new Collector(); while (iterator.hasNext()) { Object o = iterator.next(); if (o.equals("B") || o.equals("C") || o.equals("D") || o.equals("E")) @@ -299,13 +309,13 @@ public class AggregateQueryTest extends TestCase { } }; - CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {ABC, BCDE}, false); - Collector result = compoundQuery.perform(getABCDE().iterator(), new Collector()); - assertEquals("1.0", result.size(), 5); - assertTrue("1.1", result.toCollection().contains("A")); - assertTrue("1.2", result.toCollection().contains("B")); - assertTrue("1.3", result.toCollection().contains("C")); - assertTrue("1.4", result.toCollection().contains("D")); - assertTrue("1.5", result.toCollection().contains("E")); + CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {ABC, BCDE}, false); + IQueryResult result = compoundQuery.perform(getABCDE().iterator()); + assertEquals("1.0", AbstractProvisioningTest.queryResultSize(result), 5); + AbstractProvisioningTest.assertContains("1.1", result, "A"); + AbstractProvisioningTest.assertContains("1.2", result, "B"); + AbstractProvisioningTest.assertContains("1.3", result, "C"); + AbstractProvisioningTest.assertContains("1.4", result, "D"); + AbstractProvisioningTest.assertContains("1.5", result, "E"); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CollectorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CollectorTest.java index 7e12817bc..8b2760129 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CollectorTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CollectorTest.java @@ -12,7 +12,7 @@ package org.eclipse.equinox.p2.tests.core; import java.util.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; +import org.eclipse.equinox.p2.query.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** @@ -47,7 +47,7 @@ public class CollectorTest extends AbstractProvisioningTest { public void testCompositeCollectors() { String[] s = new String[] {"A", "B", "C", "D", "E", "F", "G", "1", "2", "3", "4", "5", "6", "7"}; List list = Arrays.asList(s); - Query numeric = new MatchQuery() { + IQuery numeric = new MatchQuery() { public boolean isMatch(Object candidate) { if (((String) candidate).compareTo("0") > 0 && ((String) candidate).compareTo("8") < 0) { @@ -57,7 +57,7 @@ public class CollectorTest extends AbstractProvisioningTest { } }; - Query fourOrFiveOrABC = new MatchQuery() { + IQuery fourOrFiveOrABC = new MatchQuery() { public boolean isMatch(Object candidate) { if (((String) candidate).equals("4") || ((String) candidate).equals("5") || ((String) candidate).equals("A") || ((String) candidate).equals("B") || ((String) candidate).equals("C")) { return true; @@ -65,20 +65,19 @@ public class CollectorTest extends AbstractProvisioningTest { return false; } }; - Collector collector = numeric.perform(list.iterator(), new Collector()); - assertEquals("1.0", 7, collector.toCollection().size()); - - collector = collector.query(fourOrFiveOrABC, new Collector(), null); - Collection collection = collector.toCollection(); - assertEquals("2.0", 2, collection.size()); - assertTrue("2.1", collection.contains("4")); - assertTrue("2.2", collection.contains("5")); + IQueryResult queryResult = numeric.perform(list.iterator()); + assertEquals("1.0", 7, queryResultSize(queryResult)); + + queryResult = queryResult.query(fourOrFiveOrABC, null); + assertEquals("2.0", 2, queryResultSize(queryResult)); + assertContains("2.1", queryResult, "4"); + assertContains("2.2", queryResult, "5"); } public void testSameCollector() { String[] s = new String[] {"A", "B", "C", "D", "E", "F", "G", "1", "2", "3", "4", "5", "6", "7"}; List list = Arrays.asList(s); - Query numeric = new MatchQuery() { + IQuery numeric = new MatchQuery() { public boolean isMatch(Object candidate) { if (((String) candidate).compareTo("0") > 0 && ((String) candidate).compareTo("8") < 0) { @@ -88,7 +87,7 @@ public class CollectorTest extends AbstractProvisioningTest { } }; - Query fourOrFiveOrABC = new MatchQuery() { + IQuery fourOrFiveOrABC = new MatchQuery() { public boolean isMatch(Object candidate) { if (((String) candidate).equals("4") || ((String) candidate).equals("5") || ((String) candidate).equals("A") || ((String) candidate).equals("B") || ((String) candidate).equals("C")) { return true; @@ -96,11 +95,12 @@ public class CollectorTest extends AbstractProvisioningTest { return false; } }; - Collector collector = numeric.perform(list.iterator(), new Collector()); - assertEquals("1.0", 7, collector.toCollection().size()); + Collector collector = new Collector(); + collector.addAll(numeric.perform(list.iterator())); + assertEquals("1.0", 7, collector.unmodifiableSet().size()); - collector = collector.query(fourOrFiveOrABC, collector, null); - Collection collection = collector.toCollection(); + collector.addAll(collector.query(fourOrFiveOrABC, null)); + Collection collection = collector.unmodifiableSet(); assertEquals("2.0", 7, collection.size()); } @@ -110,7 +110,7 @@ public class CollectorTest extends AbstractProvisioningTest { public void testEmptyCompositeCollectors() { String[] s = new String[] {"A", "B", "C", "D", "E", "F", "G", "1", "2", "3", "4", "5", "6", "7"}; List list = Arrays.asList(s); - Query eightOrNine = new MatchQuery() { + IQuery eightOrNine = new MatchQuery() { public boolean isMatch(Object candidate) { if (((String) candidate).compareTo("8") > 0 && ((String) candidate).compareTo("9") < 0) { @@ -120,7 +120,7 @@ public class CollectorTest extends AbstractProvisioningTest { } }; - Query fourOrFiveOrABC = new MatchQuery() { + IQuery fourOrFiveOrABC = new MatchQuery() { public boolean isMatch(Object candidate) { if (((String) candidate).equals("4") || ((String) candidate).equals("5") || ((String) candidate).equals("A") || ((String) candidate).equals("B") || ((String) candidate).equals("C")) { return true; @@ -128,17 +128,16 @@ public class CollectorTest extends AbstractProvisioningTest { return false; } }; - Collector collector = eightOrNine.perform(list.iterator(), new Collector()); - assertEquals("1.0", 0, collector.toCollection().size()); + IQueryResult queryResult = eightOrNine.perform(list.iterator()); + assertTrue("1.0", queryResult.isEmpty()); - collector = collector.query(fourOrFiveOrABC, new Collector(), null); - Collection collection = collector.toCollection(); - assertEquals("2.0", 0, collection.size()); + queryResult = queryResult.query(fourOrFiveOrABC, null); + assertTrue("2.0", queryResult.isEmpty()); } public void testToCollection() { Collector collector = new Collector(); - Collection result = collector.toCollection(); + Collection result = collector.unmodifiableSet(); assertEquals("1.0", 0, result.size()); //collection should be immutable try { @@ -150,7 +149,7 @@ public class CollectorTest extends AbstractProvisioningTest { String value = "value"; collector.accept(value); - result = collector.toCollection(); + result = collector.unmodifiableSet(); assertEquals("2.0", 1, result.size()); assertEquals("2.1", value, result.iterator().next()); //collection should be immutable diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java index 16783c3f7..c05dd804a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java @@ -9,11 +9,13 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.core; -import java.util.*; +import java.util.Arrays; +import java.util.Iterator; import junit.framework.TestCase; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.tests.harness.TestProgressMonitor; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; +import org.eclipse.equinox.p2.query.*; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** * Tests the compound queryable @@ -56,10 +58,11 @@ public class CompoundQueryableTest extends TestCase { IQueryable queryable1 = new IQueryable() { Integer[] elements = new Integer[] {1, 2, 3, 4, 5}; - public Collector query(Query query, Collector collector, IProgressMonitor monitor) { + public IQueryResult query(IQuery query, IProgressMonitor monitor) { + IQueryResult collector; try { monitor.beginTask("", 10); - collector = query.perform(createIterator(elements), collector); + collector = query.perform(createIterator(elements)); monitor.worked(10); } finally { monitor.done(); @@ -71,10 +74,11 @@ public class CompoundQueryableTest extends TestCase { IQueryable queryable2 = new IQueryable() { Integer[] elements = new Integer[] {4, 6, 8, 10, 12}; - public Collector query(Query query, Collector collector, IProgressMonitor monitor) { + public IQueryResult query(IQuery query, IProgressMonitor monitor) { + IQueryResult collector; try { monitor.beginTask("", 10); - collector = query.perform(createIterator(elements), collector); + collector = query.perform(createIterator(elements)); monitor.worked(10); } finally { monitor.done(); @@ -86,10 +90,11 @@ public class CompoundQueryableTest extends TestCase { IQueryable queryable3 = new IQueryable() { Integer[] elements = new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; - public Collector query(Query query, Collector collector, IProgressMonitor monitor) { + public IQueryResult query(IQuery query, IProgressMonitor monitor) { + IQueryResult collector; try { monitor.beginTask("", 10); - collector = query.perform(createIterator(elements), collector); + collector = query.perform(createIterator(elements)); monitor.worked(10); } finally { monitor.done(); @@ -98,7 +103,7 @@ public class CompoundQueryableTest extends TestCase { } }; - Query matchQuery = new MatchQuery() { + IQuery matchQuery = new MatchQuery() { public boolean isMatch(Object candidate) { if (candidate instanceof Integer) { @@ -110,7 +115,7 @@ public class CompoundQueryableTest extends TestCase { } }; - Query matchMod4query = new MatchQuery() { + IQuery matchMod4query = new MatchQuery() { public boolean isMatch(Object candidate) { if (candidate instanceof Integer) { int x = ((Integer) candidate).intValue(); @@ -121,9 +126,10 @@ public class CompoundQueryableTest extends TestCase { } }; - Query contextQuery = new ContextQuery() { + IQuery contextQuery = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + public Collector perform(Iterator iterator) { + Collector result = new Collector(); while (iterator.hasNext()) { Object o = iterator.next(); if (o instanceof Integer && ((Integer) o).intValue() % 2 == 0) { @@ -135,8 +141,9 @@ public class CompoundQueryableTest extends TestCase { }; - Query greatestNumberQuery = new ContextQuery() { - public Collector perform(Iterator iterator, Collector result) { + IQuery greatestNumberQuery = new ContextQuery() { + public Collector perform(Iterator iterator) { + Collector result = new Collector(); int greatest = Integer.MIN_VALUE; while (iterator.hasNext()) { int item = ((Integer) iterator.next()).intValue(); @@ -151,208 +158,129 @@ public class CompoundQueryableTest extends TestCase { }; public void testMatchQuery() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2}); + CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2); CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - Collector collector = cQueryable.query(matchQuery, new Collector(), monitor); - assertEquals("1.0", 6, collector.size()); - Collection collection = collector.toCollection(); - assertTrue("1.1", collection.contains(2)); - assertTrue("1.2", collection.contains(4)); - assertTrue("1.3", collection.contains(6)); - assertTrue("1.4", collection.contains(8)); - assertTrue("1.5", collection.contains(10)); - assertTrue("1.6", collection.contains(12)); + IQueryResult queryResult = cQueryable.query(matchQuery, monitor); + assertEquals("1.0", 6, AbstractProvisioningTest.queryResultSize(queryResult)); + AbstractProvisioningTest.assertContains("1.1", queryResult, 2); + AbstractProvisioningTest.assertContains("1.2", queryResult, 4); + AbstractProvisioningTest.assertContains("1.3", queryResult, 6); + AbstractProvisioningTest.assertContains("1.4", queryResult, 8); + AbstractProvisioningTest.assertContains("1.5", queryResult, 10); + AbstractProvisioningTest.assertContains("1.6", queryResult, 12); } public void testSingleQueryable() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1}); + CompoundQueryable cQueryable = new CompoundQueryable(queryable1); CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - Collector collector = cQueryable.query(matchQuery, new Collector(), monitor); - assertEquals("1.0", 2, collector.size()); - Collection collection = collector.toCollection(); - assertTrue("1.1", collection.contains(2)); - assertTrue("1.2", collection.contains(4)); + IQueryResult queryResult = cQueryable.query(matchQuery, monitor); + assertEquals("1.0", 2, AbstractProvisioningTest.queryResultSize(queryResult)); + AbstractProvisioningTest.assertContains("1.1", queryResult, 2); + AbstractProvisioningTest.assertContains("1.2", queryResult, 4); } public void testSingleContextQuery() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1}); + CompoundQueryable cQueryable = new CompoundQueryable(queryable1); CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - Collector collector = cQueryable.query(greatestNumberQuery, new Collector(), monitor); - assertEquals("1.0", 1, collector.size()); - Collection collection = collector.toCollection(); - assertTrue("1.1", collection.contains(5)); + IQueryResult queryResult = cQueryable.query(greatestNumberQuery, monitor); + assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(queryResult)); + AbstractProvisioningTest.assertContains("1.1", queryResult, 5); } public void testMultipleContextQueries() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2}); + CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2); CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - Collector collector = cQueryable.query(greatestNumberQuery, new Collector(), monitor); - assertEquals("1.0", 1, collector.size()); - Collection collection = collector.toCollection(); - assertTrue("1.1", collection.contains(12)); - } - - public void testListCollector1() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2}); - CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - Collector collector = cQueryable.query(contextQuery, cQueryable.new ListCollector(), monitor); - - // We use a list so there should be 7 elements (4 is there twice) - assertEquals("1.0", 7, collector.size()); - Collection collection = collector.toCollection(); - assertTrue("1.1", collection.contains(2)); - assertTrue("1.2", collection.contains(4)); - assertTrue("1.3", collection.contains(6)); - assertTrue("1.4", collection.contains(8)); - assertTrue("1.5", collection.contains(10)); - assertTrue("1.6", collection.contains(12)); - } - - public void testListCollector_isEmpty() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2}); - CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - Collector collector = cQueryable.new ListCollector(); - assertTrue("1.0", collector.isEmpty()); - collector = cQueryable.query(contextQuery, cQueryable.new ListCollector(), monitor); - assertFalse("1.0", collector.isEmpty()); - } - - public void testListCollector_getCollection() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2}); - CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - - Collector collector = cQueryable.query(contextQuery, cQueryable.new ListCollector(), monitor); - - // We use a list so there should be 7 elements (4 is there twice) - assertEquals("1.0", 7, collector.size()); - Integer[] array = (Integer[]) collector.toArray(Integer.class); - Collection collection = Arrays.asList(array); - assertTrue("1.1", collection.contains(2)); - assertTrue("1.2", collection.contains(4)); - assertTrue("1.3", collection.contains(6)); - assertTrue("1.4", collection.contains(8)); - assertTrue("1.5", collection.contains(10)); - assertTrue("1.6", collection.contains(12)); - } - - public void testListCollector_toArray() { - final CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2}); - CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - - class CustomListCollector extends CompoundQueryable.ListCollector { - - public CustomListCollector() { - cQueryable.super(); - } - - public Collection getCollection() { - return super.getCollection(); - } - } - - CustomListCollector collector = (CustomListCollector) cQueryable.query(contextQuery, new CustomListCollector(), monitor); - - // We use a list so there should be 7 elements (4 is there twice) - assertEquals("1.0", 7, collector.size()); - Collection collection = collector.getCollection(); - assertTrue("1.1", collection.contains(2)); - assertTrue("1.2", collection.contains(4)); - assertTrue("1.3", collection.contains(6)); - assertTrue("1.4", collection.contains(8)); - assertTrue("1.5", collection.contains(10)); - assertTrue("1.6", collection.contains(12)); + IQueryResult queryResult = cQueryable.query(greatestNumberQuery, monitor); + assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(queryResult)); + AbstractProvisioningTest.assertContains("1.1", queryResult, 12); } public void testCompoundMatchAndQuery() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2}); + CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2); CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - Collector collector = cQueryable.query(CompoundQuery.createCompoundQuery(new Query[] {matchQuery, matchMod4query}, true), new Collector(), monitor); - assertEquals("1.0", 3, collector.size()); - Collection collection = collector.toCollection(); - assertTrue("1.2", collection.contains(4)); - assertTrue("1.4", collection.contains(8)); - assertTrue("1.6", collection.contains(12)); + IQueryResult queryResult = cQueryable.query(CompoundQuery.createCompoundQuery(new IQuery[] {matchQuery, matchMod4query}, true), monitor); + assertEquals("1.0", 3, AbstractProvisioningTest.queryResultSize(queryResult)); + AbstractProvisioningTest.assertContains("1.2", queryResult, 4); + AbstractProvisioningTest.assertContains("1.4", queryResult, 8); + AbstractProvisioningTest.assertContains("1.6", queryResult, 12); } public void testCompoundMatchOrQuery() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2}); + CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2); CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - Collector collector = cQueryable.query(CompoundQuery.createCompoundQuery(new Query[] {matchQuery, matchMod4query}, false), new Collector(), monitor); - assertEquals("1.0", 6, collector.size()); - Collection collection = collector.toCollection(); - assertTrue("1.2", collection.contains(2)); - assertTrue("1.2", collection.contains(4)); - assertTrue("1.2", collection.contains(6)); - assertTrue("1.4", collection.contains(8)); - assertTrue("1.2", collection.contains(10)); - assertTrue("1.6", collection.contains(12)); + IQueryResult queryResult = cQueryable.query(CompoundQuery.createCompoundQuery(new IQuery[] {matchQuery, matchMod4query}, false), monitor); + assertEquals("1.0", 6, AbstractProvisioningTest.queryResultSize(queryResult)); + AbstractProvisioningTest.assertContains("1.2", queryResult, 2); + AbstractProvisioningTest.assertContains("1.2", queryResult, 4); + AbstractProvisioningTest.assertContains("1.2", queryResult, 6); + AbstractProvisioningTest.assertContains("1.4", queryResult, 8); + AbstractProvisioningTest.assertContains("1.2", queryResult, 10); + AbstractProvisioningTest.assertContains("1.6", queryResult, 12); } public void testMatchQueryProgressMonitor() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2}); + CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2); CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - cQueryable.query(matchQuery, new Collector(), monitor); + cQueryable.query(matchQuery, monitor); assertTrue("1.0", monitor.isDone()); assertTrue("1.1", monitor.isWorkDone()); } public void testSingleQueryableProgressMonitor() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1}); + CompoundQueryable cQueryable = new CompoundQueryable(queryable1); CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - cQueryable.query(matchQuery, new Collector(), monitor); + cQueryable.query(matchQuery, monitor); assertTrue("1.0", monitor.isDone()); assertTrue("1.1", monitor.isWorkDone()); } public void testSingleContextQueryProgressMonitor() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1}); + CompoundQueryable cQueryable = new CompoundQueryable(queryable1); CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - cQueryable.query(greatestNumberQuery, new Collector(), monitor); + cQueryable.query(greatestNumberQuery, monitor); assertTrue("1.0", monitor.isDone()); assertTrue("1.1", monitor.isWorkDone()); } public void testMultipleContextQueriesProgressMonitor() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2}); + CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2); CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - cQueryable.query(greatestNumberQuery, new Collector(), monitor); + cQueryable.query(greatestNumberQuery, monitor); assertTrue("1.0", monitor.isDone()); assertTrue("1.1", monitor.isWorkDone()); } public void testNullProgressMonitor() { - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2}); - cQueryable.query(greatestNumberQuery, new Collector(), null); + CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2); + cQueryable.query(greatestNumberQuery, null); // this is the same as above will null passed in, this should not throw any exceptions } public void testDoubleCompoundContextOrQuery() { - CompoundQueryable cQueryable1 = new CompoundQueryable(new IQueryable[] {queryable3, queryable2}); - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {cQueryable1, queryable1}); + CompoundQueryable cQueryable1 = new CompoundQueryable(queryable3, queryable2); + CompoundQueryable cQueryable = new CompoundQueryable(cQueryable1, queryable1); CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - Collector collector = cQueryable.query(CompoundQuery.createCompoundQuery(new Query[] {contextQuery, greatestNumberQuery}, false), new Collector(), monitor); - assertEquals("1.0", 7, collector.size()); - Collection collection = collector.toCollection(); - assertTrue("1.2", collection.contains(2)); - assertTrue("1.2", collection.contains(4)); - assertTrue("1.2", collection.contains(6)); - assertTrue("1.4", collection.contains(8)); - assertTrue("1.2", collection.contains(10)); - assertTrue("1.6", collection.contains(12)); - assertTrue("1.6", collection.contains(13)); + IQueryResult queryResult = cQueryable.query(CompoundQuery.createCompoundQuery(new IQuery[] {contextQuery, greatestNumberQuery}, false), monitor); + assertEquals("1.0", 7, AbstractProvisioningTest.queryResultSize(queryResult)); + AbstractProvisioningTest.assertContains("1.2", queryResult, 2); + AbstractProvisioningTest.assertContains("1.2", queryResult, 4); + AbstractProvisioningTest.assertContains("1.2", queryResult, 6); + AbstractProvisioningTest.assertContains("1.4", queryResult, 8); + AbstractProvisioningTest.assertContains("1.2", queryResult, 10); + AbstractProvisioningTest.assertContains("1.6", queryResult, 12); + AbstractProvisioningTest.assertContains("1.6", queryResult, 13); assertTrue("1.0", monitor.isDone()); assertTrue("1.1", monitor.isWorkDone()); } public void testDoubleCompositeQuery() { - CompoundQueryable cQueryable1 = new CompoundQueryable(new IQueryable[] {queryable3, queryable2}); - CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {cQueryable1, queryable1}); + CompoundQueryable cQueryable1 = new CompoundQueryable(queryable3, queryable2); + CompoundQueryable cQueryable = new CompoundQueryable(cQueryable1, queryable1); CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor(); - Collector collector = cQueryable.query(new CompositeQuery(new Query[] {contextQuery, greatestNumberQuery}), new Collector(), monitor); - assertEquals("1.0", 1, collector.size()); - Collection collection = collector.toCollection(); - assertTrue("1.2", collection.contains(12)); + IQueryResult queryResult = cQueryable.query(new PipedQuery(contextQuery, greatestNumberQuery), monitor); + assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(queryResult)); + AbstractProvisioningTest.assertContains("1.2", queryResult, 12); assertTrue("1.0", monitor.isDone()); assertTrue("1.1", monitor.isWorkDone()); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery1.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery1.java index 22d98ddbc..b212c8c28 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery1.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery1.java @@ -9,7 +9,7 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.core; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.MatchQuery; +import org.eclipse.equinox.p2.query.MatchQuery; public class PropertyLookupQuery1 extends MatchQuery { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery2.java index 7564cc633..e7e45457a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery2.java @@ -10,8 +10,8 @@ package org.eclipse.equinox.p2.tests.core; import java.util.Iterator; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.ContextQuery; +import org.eclipse.equinox.p2.query.Collector; +import org.eclipse.equinox.p2.query.ContextQuery; public class PropertyLookupQuery2 extends ContextQuery { @@ -19,7 +19,7 @@ public class PropertyLookupQuery2 extends ContextQuery { return "bar"; } - public Collector perform(Iterator iterator, Collector result) { + public Collector perform(Iterator iterator) { return null; } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/QueryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/QueryTest.java index 81c2d9ca6..e05b16f25 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/QueryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/QueryTest.java @@ -10,9 +10,11 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.core; -import java.util.*; +import java.util.Arrays; +import java.util.List; import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; +import org.eclipse.equinox.p2.query.*; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** * Tests for the {@link org.eclipse.equinox.internal.provisional.p2.query.Query} class. @@ -63,29 +65,16 @@ public class QueryTest extends TestCase { } /** - * A collector that only accepts the first element and then short-circuits. - */ - static class ShortCircuitCollector extends Collector { - @Override - public boolean accept(Object object) { - super.accept(object); - return false; - } - } - - /** - * Tests a simple perform where all items match. - */ + * Tests a simple perform where all items match. + */ public void testPerformSimple() { List items = Arrays.asList("red", "green", "blue"); - Query query = new AnyStringQuery(); - Collector collector = new Collector(); - query.perform(items.iterator(), collector); - Collection result = collector.toCollection(); - assertEquals("1.0", 3, result.size()); - assertTrue("1.1", result.contains("red")); - assertTrue("1.2", result.contains("green")); - assertTrue("1.3", result.contains("blue")); + IQuery query = new AnyStringQuery(); + IQueryResult collector = query.perform(items.iterator()); + assertEquals("1.0", 3, AbstractProvisioningTest.queryResultSize(collector)); + AbstractProvisioningTest.assertContains("1.1", collector, "red"); + AbstractProvisioningTest.assertContains("1.2", collector, "green"); + AbstractProvisioningTest.assertContains("1.3", collector, "blue"); } /** @@ -93,53 +82,50 @@ public class QueryTest extends TestCase { */ public void testPerformSomeMatches() { List items = Arrays.asList(new Object(), "green", new Object()); - Query query = new AnyStringQuery(); - Collector collector = new Collector(); - query.perform(items.iterator(), collector); - Collection result = collector.toCollection(); - assertEquals("1.0", 1, result.size()); - assertTrue("1.1", result.contains("green")); + IQuery query = new AnyStringQuery(); + IQueryResult collector = query.perform(items.iterator()); + assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(collector)); + AbstractProvisioningTest.assertContains("1.1", collector, "green"); } public void testPerformHooks() { List items = Arrays.asList("red", "green", "blue"); PerformHookQuery query = new PerformHookQuery(); - Collector collector = new Collector(); assertFalse("1.0", query.isComplete()); assertFalse("1.1", query.isPrepared()); - query.perform(items.iterator(), collector); + query.perform(items.iterator()); assertTrue("1.2", query.isComplete()); assertTrue("1.3", query.isPrepared()); assertTrue("1.4", query.areHooksExecutedProperly()); } public void testPropertyLookupMatchQuery() { - Query query1 = new PropertyLookupQuery1(); + IQuery query1 = new PropertyLookupQuery1(); Object property = query1.getProperty("SomeProperty"); assertEquals("1.0", "foo", property); } public void testPropertyLookupContextQuery() { - Query query1 = new PropertyLookupQuery2(); + IQuery query1 = new PropertyLookupQuery2(); Object property = query1.getProperty("SomeOtherProperty"); assertEquals("1.0", "bar", property); } public void testPropertyLookupInvalidProperty1() { - Query query1 = new PropertyLookupQuery1(); + IQuery query1 = new PropertyLookupQuery1(); Object property = query1.getProperty("ThisProperty"); assertEquals("1.0", null, property); } public void testPropertyLookupInvalidProperty2() { - Query query1 = new PropertyLookupQuery1(); + IQuery query1 = new PropertyLookupQuery1(); Object property = query1.getProperty("SomeOtherProperty"); assertEquals("1.0", null, property); } public void testIDLookup() { - Query query1 = new PropertyLookupQuery1(); - Query query2 = new PropertyLookupQuery2(); + IQuery query1 = new PropertyLookupQuery1(); + IQuery query2 = new PropertyLookupQuery2(); assertEquals("1.0", "org.eclipse.equinox.p2.tests.core.PropertyLookupQuery1", query1.getId()); assertEquals("1.0", "org.eclipse.equinox.p2.tests.core.PropertyLookupQuery2", query2.getId()); } @@ -147,11 +133,10 @@ public class QueryTest extends TestCase { public void testPerformHooksOnQueryFail() { List items = Arrays.asList("red", new Object()); PerformHookQuery query = new PerformHookQuery(); - Collector collector = new Collector(); assertFalse("1.0", query.isComplete()); assertFalse("1.1", query.isPrepared()); try { - query.perform(items.iterator(), collector); + query.perform(items.iterator()); } catch (RuntimeException e) { // expected } @@ -162,15 +147,14 @@ public class QueryTest extends TestCase { public void testPreAndPostCompoundANDQuery() { List items = Arrays.asList("red", "green", "blue"); - Collector collector = new Collector(); PerformHookQuery query1 = new PerformHookQuery(); PerformHookQuery query2 = new PerformHookQuery(); - CompoundQuery cQuery = CompoundQuery.createCompoundQuery(new Query[] {query1, query2}, true); + CompoundQuery cQuery = CompoundQuery.createCompoundQuery(new IQuery[] {query1, query2}, true); assertFalse("1.0", query1.isComplete()); assertFalse("1.1", query1.isPrepared()); assertFalse("1.2", query2.isComplete()); assertFalse("1.3", query2.isPrepared()); - cQuery.perform(items.iterator(), collector); + cQuery.perform(items.iterator()); assertTrue("1.4", query1.isComplete()); assertTrue("1.5", query1.isPrepared()); assertTrue("1.6", query2.isComplete()); @@ -181,15 +165,14 @@ public class QueryTest extends TestCase { public void testPreAndPostCompoundOrQuery() { List items = Arrays.asList("red", "green", "blue"); - Collector collector = new Collector(); PerformHookQuery query1 = new PerformHookQuery(); PerformHookQuery query2 = new PerformHookQuery(); - CompoundQuery cQuery = CompoundQuery.createCompoundQuery(new Query[] {query1, query2}, false); + CompoundQuery cQuery = CompoundQuery.createCompoundQuery(new IQuery[] {query1, query2}, false); assertFalse("1.0", query1.isComplete()); assertFalse("1.1", query1.isPrepared()); assertFalse("1.2", query2.isComplete()); assertFalse("1.3", query2.isPrepared()); - cQuery.perform(items.iterator(), collector); + cQuery.perform(items.iterator()); assertTrue("1.4", query1.isComplete()); assertTrue("1.5", query1.isPrepared()); assertTrue("1.6", query2.isComplete()); @@ -200,15 +183,14 @@ public class QueryTest extends TestCase { public void testPreAndPostCompositeQuery() { List items = Arrays.asList("red", "green", "blue"); - Collector collector = new Collector(); PerformHookQuery query1 = new PerformHookQuery(); PerformHookQuery query2 = new PerformHookQuery(); - CompositeQuery cQuery = new CompositeQuery(new Query[] {query1, query2}); + PipedQuery cQuery = new PipedQuery(query1, query2); assertFalse("1.0", query1.isComplete()); assertFalse("1.1", query1.isPrepared()); assertFalse("1.2", query2.isComplete()); assertFalse("1.3", query2.isPrepared()); - cQuery.perform(items.iterator(), collector); + cQuery.perform(items.iterator()); assertTrue("1.4", query1.isComplete()); assertTrue("1.5", query1.isPrepared()); assertTrue("1.6", query2.isComplete()); @@ -219,16 +201,15 @@ public class QueryTest extends TestCase { public void testPreAndPostCompoundQueryFail() { List items = Arrays.asList("red", new Object()); - Collector collector = new Collector(); PerformHookQuery query1 = new PerformHookQuery(); PerformHookQuery query2 = new PerformHookQuery(); - CompoundQuery cQuery = CompoundQuery.createCompoundQuery(new Query[] {query1, query2}, true); + CompoundQuery cQuery = CompoundQuery.createCompoundQuery(new IQuery[] {query1, query2}, true); assertFalse("1.0", query1.isComplete()); assertFalse("1.1", query1.isPrepared()); assertFalse("1.2", query2.isComplete()); assertFalse("1.3", query2.isPrepared()); try { - cQuery.perform(items.iterator(), collector); + cQuery.perform(items.iterator()); fail("This query is expected to fail"); } catch (RuntimeException e) { // expected @@ -243,16 +224,15 @@ public class QueryTest extends TestCase { public void testPreAndPostCompositeQueryFail() { List items = Arrays.asList("red", new Object()); - Collector collector = new Collector(); PerformHookQuery query1 = new PerformHookQuery(); PerformHookQuery query2 = new PerformHookQuery(); - CompositeQuery cQuery = new CompositeQuery(new Query[] {query1, query2}); + PipedQuery cQuery = new PipedQuery(query1, query2); assertFalse("1.0", query1.isComplete()); assertFalse("1.1", query1.isPrepared()); assertFalse("1.2", query2.isComplete()); assertFalse("1.3", query2.isPrepared()); try { - cQuery.perform(items.iterator(), collector); + cQuery.perform(items.iterator()); fail("This query is expected to fail"); } catch (RuntimeException e) { // expected @@ -265,17 +245,59 @@ public class QueryTest extends TestCase { assertTrue("1.9", query2.areHooksExecutedProperly()); } - /** - * Tests a perform where the collector decides to short-circuit the query. - */ - public void testShortCircuit() { + public void testLimitQuery() { List items = Arrays.asList("red", "green", "blue"); - Query query = new AnyStringQuery(); - Collector collector = new ShortCircuitCollector(); - query.perform(items.iterator(), collector); - Collection result = collector.toCollection(); - assertEquals("1.0", 1, result.size()); - assertTrue("1.1", result.contains("red")); + IQuery query = new AnyStringQuery(); + IQuery limitQuery = new LimitQuery(query, 1); + IQueryResult collector = limitQuery.perform(items.iterator()); + assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(collector)); + AbstractProvisioningTest.assertContains("1.1", collector, "red"); } + public void testLimitQuery2() { + List items = Arrays.asList("red", "green", "blue"); + IQuery query = new AnyStringQuery(); + IQuery limitQuery = new LimitQuery(query, 2); + IQueryResult collector = limitQuery.perform(items.iterator()); + assertEquals("1.0", 2, AbstractProvisioningTest.queryResultSize(collector)); + AbstractProvisioningTest.assertContains("1.1", collector, "red"); + AbstractProvisioningTest.assertContains("1.2", collector, "green"); + } + + public void testLimitQuery3() { + List items = Arrays.asList("red", "green", "blue"); + IQuery query = new AnyStringQuery(); + IQuery limitQuery = new LimitQuery(query, 3); + IQueryResult collector = limitQuery.perform(items.iterator()); + assertEquals("1.0", 3, AbstractProvisioningTest.queryResultSize(collector)); + AbstractProvisioningTest.assertContains("1.1", collector, "red"); + AbstractProvisioningTest.assertContains("1.2", collector, "green"); + AbstractProvisioningTest.assertContains("1.3", collector, "blue"); + } + + public void testLimitQuery0() { + List items = Arrays.asList("red", "green", "blue"); + IQuery query = new AnyStringQuery(); + IQuery limitQuery = new LimitQuery(query, 0); + IQueryResult collector = limitQuery.perform(items.iterator()); + assertEquals("1.0", 0, AbstractProvisioningTest.queryResultSize(collector)); + } + + // public void testPipedLimitQuery() { + // List items = Arrays.asList("pink", "red", "green", "pink"); + // IQuery anyString = new AnyStringQuery(); + // IQuery containsI = new MatchQuery() { + // + // public boolean isMatch(Object candidate) { + // return ((String) candidate).contains("e"); + // } + // }; + // IQuery pipedQuery = new PipedQuery(new IQuery[] {anyString, containsI}); + // IQuery limitQuery = new LimitQuery(pipedQuery, 1); + // Collector collector = limitQuery.perform(items.iterator(), new Collector()); + // Collection result = collector.toCollection(); + // assertEquals("1.0", 1, result.size()); + // assertTrue("1.1", result.contains("red")); + // } + } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java index a18084e7f..cabde3bcb 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java @@ -14,17 +14,21 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IProvidedCapability; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; +import org.osgi.framework.Filter; /** * Various automated tests of the {@link IDirector} API. */ public class AutomatedDirectorTest extends AbstractProvisioningTest { - //private static Version version = new Version(1, 0, 0); + //private static Version version = Version.createOSGi(1, 0, 0); public static Test suite() { return new TestSuite(AutomatedDirectorTest.class); @@ -49,8 +53,8 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest { IInstallableUnit requiredIU = createIU("required." + getName()); // The IU to be installed - String filter = createFilter("FilterKey", "true"); - IRequiredCapability capability = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), ANY_VERSION, filter, false, false); + Filter filter = createFilter("FilterKey", "true"); + IRequiredCapability capability = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), ANY_VERSION, filter, false, false); IInstallableUnit toInstallIU = createIU("toInstall." + getName(), new IRequiredCapability[] {capability}); IInstallableUnit[] allUnits = new IInstallableUnit[] {requiredIU, toInstallIU}; @@ -61,7 +65,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest { //Install into a profile in which the filter is satisfied Map properties = new HashMap(); properties.put(IProfile.PROP_ENVIRONMENTS, "FilterKey=true"); - IProfile satisfied = createProfile("Satisfied." + getName(), null, properties); + IProfile satisfied = createProfile("Satisfied." + getName(), properties); ProfileChangeRequest request = new ProfileChangeRequest(satisfied); request.addInstallableUnits(toInstallArray); IStatus result = director.provision(request, null, null); @@ -78,7 +82,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest { IInstallableUnit requiredIU = createIU("required." + getName(), new IProvidedCapability[] {MetadataFactory.createProvidedCapability("test.capability", capabilityId, DEFAULT_VERSION)}); //The IU that optionally requires the capability - IRequiredCapability required = MetadataFactory.createRequiredCapability("test.capability", capabilityId, ANY_VERSION, null, /* optional=> */true, /* multiple=> */false, /* greedy=>*/false); + IRequiredCapability required = (IRequiredCapability) MetadataFactory.createRequiredCapability("test.capability", capabilityId, ANY_VERSION, null, /* optional=> */true, /* multiple=> */false, /* greedy=>*/false); IInstallableUnit toInstallIU = createIU("toInstall." + getName(), new IRequiredCapability[] {required}); IInstallableUnit[] allUnits = new IInstallableUnit[] {toInstallIU, requiredIU}; @@ -102,7 +106,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest { public void testInstallOptionalUnavailable() { String capabilityId = "test." + getName(); //no IU will be available that exports this capability - IRequiredCapability required = MetadataFactory.createRequiredCapability("test.capability", capabilityId, ANY_VERSION, null, true, false); + IRequiredCapability required = (IRequiredCapability) MetadataFactory.createRequiredCapability("test.capability", capabilityId, ANY_VERSION, null, true, false); IInstallableUnit toInstallIU = createIU("toInstall." + getName(), new IRequiredCapability[] {required}); IInstallableUnit[] allUnits = new IInstallableUnit[] {toInstallIU}; @@ -129,7 +133,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest { IProvidedCapability[] provides = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("test.capability", capabilityId, DEFAULT_VERSION)}; IInstallableUnit requiredIU = createIU("required." + getName(), createFilter("osgi.os", "blort"), provides); - IInstallableUnit toInstallIU = createIU("toInstall." + getName(), createRequiredCapabilities("test.capability", capabilityId, ANY_VERSION, null)); + IInstallableUnit toInstallIU = createIU("toInstall." + getName(), createRequiredCapabilities("test.capability", capabilityId, ANY_VERSION, (Filter) null)); IInstallableUnit[] allUnits = new IInstallableUnit[] {requiredIU, toInstallIU}; IInstallableUnit[] toInstallArray = new IInstallableUnit[] {toInstallIU}; @@ -145,7 +149,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest { //try again with the filter satisfied Map properties = new HashMap(); properties.put(IProfile.PROP_ENVIRONMENTS, "osgi.os=blort"); - IProfile profile2 = createProfile("TestProfile2." + getName(), null, properties); + IProfile profile2 = createProfile("TestProfile2." + getName(), properties); request = new ProfileChangeRequest(profile2); request.addInstallableUnits(toInstallArray); result = director.provision(request, null, null); @@ -172,7 +176,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest { //try again with the filter satisfied Map properties = new HashMap(); properties.put(IProfile.PROP_ENVIRONMENTS, "osgi.os=blort"); - IProfile profile2 = createProfile("TestProfile2." + getName(), null, properties); + IProfile profile2 = createProfile("TestProfile2." + getName(), properties); request = new ProfileChangeRequest(profile2); request.addInstallableUnits(toInstallArray); result = director.provision(request, null, null); @@ -188,7 +192,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest { //The IU that exports the capability IInstallableUnit requiredIU = createIU("required." + getName(), new IProvidedCapability[] {MetadataFactory.createProvidedCapability("test.capability", capabilityId, DEFAULT_VERSION)}); - IInstallableUnit toInstallIU = createIU("toInstall." + getName(), createRequiredCapabilities("test.capability", capabilityId, ANY_VERSION, null)); + IInstallableUnit toInstallIU = createIU("toInstall." + getName(), createRequiredCapabilities("test.capability", capabilityId, ANY_VERSION, (Filter) null)); IInstallableUnit[] allUnits = new IInstallableUnit[] {requiredIU, toInstallIU}; IInstallableUnit[] toInstallArray = new IInstallableUnit[] {toInstallIU}; @@ -214,7 +218,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest { //The IU that is needed IInstallableUnit requiredIU = createIU("required." + getName()); - IRequiredCapability capability = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), null, null, false, false); + IRequiredCapability capability = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), null, null, false, false); IInstallableUnit toInstallIU = createIU("toInstall." + getName(), new IRequiredCapability[] {capability}); IInstallableUnit[] allUnits = new IInstallableUnit[] {requiredIU, toInstallIU}; @@ -242,7 +246,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest { //The IU that exports the capability IInstallableUnit requiredIU = createIU("required." + getName()); - IRequiredCapability capability = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), ANY_VERSION, null, false, false); + IRequiredCapability capability = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), ANY_VERSION, null, false, false); IInstallableUnit toInstallIU = createIU("toInstall." + getName(), new IRequiredCapability[] {capability}); IInstallableUnit[] allUnits = new IInstallableUnit[] {requiredIU, toInstallIU}; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/Bug203637.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/Bug203637.java index c087e00b9..08e3f6fdd 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/Bug203637.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/Bug203637.java @@ -10,19 +10,19 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.director; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class Bug203637 extends AbstractProvisioningTest { public void test() { IDirector d = createDirector(); IProfile profile = createProfile("TestProfile." + getName()); - IInstallableUnit a1 = createIU("A", new Version(1, 0, 0), true); + IInstallableUnit a1 = createIU("A", Version.createOSGi(1, 0, 0), true); ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a1}); request.removeInstallableUnits(new IInstallableUnit[0]); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java index 2cf543da7..d39a38c6c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java @@ -22,12 +22,12 @@ import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.director.app.Activator; import org.eclipse.equinox.internal.p2.director.app.Application; -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.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.query.*; +import org.eclipse.equinox.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.osgi.framework.Bundle; @@ -473,10 +473,10 @@ public class DirectorAppTest extends AbstractProvisioningTest { URI metadataRepo1 = getTestData("10.1", "/testData/metadataRepo/good").toURI(); URI metadataRepo2 = getTestData("10.1", "/testData/metadataRepo/multipleversions1").toURI(); Application application = new Application(); - Method method = application.getClass().getDeclaredMethod("collectRootIUs", URI[].class, Query.class, Collector.class); + Method method = application.getClass().getDeclaredMethod("collectRootIUs", URI[].class, IQuery.class); method.setAccessible(true); URI[] uris = new URI[] {metadataRepo1, metadataRepo2}; - Query query = new MatchQuery() { + IQuery query = new MatchQuery() { public boolean isMatch(Object candidate) { if (candidate instanceof IInstallableUnit) { IInstallableUnit iu = (IInstallableUnit) candidate; @@ -486,8 +486,7 @@ public class DirectorAppTest extends AbstractProvisioningTest { return false; } }; - Collector collector = new Collector(); - Collector result = (Collector) method.invoke(application, uris, query, collector); + Collector result = (Collector) method.invoke(application, uris, query); assertEquals("1.0", 1, result.size()); } @@ -572,8 +571,8 @@ public class DirectorAppTest extends AbstractProvisioningTest { File artifactRepo1 = getTestData("12.0", "/testData/mirror/mirrorSourceRepo3"); File metadataRepo1 = getTestData("12.1", "/testData/mirror/mirrorSourceRepo3"); - IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); - IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName()); + IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME); + IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); assertNotNull(artifactManager); assertNotNull(metadataManager); @@ -619,8 +618,8 @@ public class DirectorAppTest extends AbstractProvisioningTest { File artifactRepo1 = getTestData("13.0", "/testData/mirror/mirrorSourceRepo4"); File metadataRepo1 = getTestData("13.1", "/testData/mirror/mirrorSourceRepo4"); - IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); - IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName()); + IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME); + IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); assertNotNull(artifactManager); assertNotNull(metadataManager); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorApplicationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorApplicationTest.java index a88c991f6..336011ab3 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorApplicationTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorApplicationTest.java @@ -22,12 +22,12 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.director.app.*; -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.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.query.*; +import org.eclipse.equinox.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.osgi.framework.Bundle; @@ -526,10 +526,10 @@ public class DirectorApplicationTest extends AbstractProvisioningTest { URI metadataRepo1 = getTestData("10.1", "/testData/metadataRepo/good").toURI(); URI metadataRepo2 = getTestData("10.1", "/testData/metadataRepo/multipleversions1").toURI(); Application application = new Application(); - Method method = application.getClass().getDeclaredMethod("collectRootIUs", URI[].class, Query.class, Collector.class); + Method method = application.getClass().getDeclaredMethod("collectRootIUs", URI[].class, IQuery.class); method.setAccessible(true); URI[] uris = new URI[] {metadataRepo1, metadataRepo2}; - Query query = new MatchQuery() { + IQuery query = new MatchQuery() { public boolean isMatch(Object candidate) { if (candidate instanceof IInstallableUnit) { IInstallableUnit iu = (IInstallableUnit) candidate; @@ -539,8 +539,7 @@ public class DirectorApplicationTest extends AbstractProvisioningTest { return false; } }; - Collector collector = new Collector(); - Collector result = (Collector) method.invoke(application, uris, query, collector); + Collector result = (Collector) method.invoke(application, uris, query); assertEquals("1.0", 1, result.size()); } @@ -633,8 +632,8 @@ public class DirectorApplicationTest extends AbstractProvisioningTest { File artifactRepo1 = getTestData("12.0", "/testData/mirror/mirrorSourceRepo3"); File metadataRepo1 = getTestData("12.1", "/testData/mirror/mirrorSourceRepo3"); - IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); - IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName()); + IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME); + IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); assertNotNull(artifactManager); assertNotNull(metadataManager); @@ -683,8 +682,8 @@ public class DirectorApplicationTest extends AbstractProvisioningTest { File artifactRepo1 = getTestData("13.0", "/testData/mirror/mirrorSourceRepo4"); File metadataRepo1 = getTestData("13.1", "/testData/mirror/mirrorSourceRepo4"); - IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); - IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName()); + IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME); + IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); assertNotNull(artifactManager); assertNotNull(metadataManager); @@ -724,8 +723,8 @@ public class DirectorApplicationTest extends AbstractProvisioningTest { public void testUninstallIgnoresPassedInRepos() throws Exception { File srcRepo = getTestData("14.0", "/testData/mirror/mirrorSourceRepo4"); - IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName()); - IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName()); + IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME); + IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); assertNotNull(artifactManager); assertNotNull(metadataManager); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java index 416a37a18..a1c451d32 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java @@ -10,23 +10,23 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.director; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; -import java.util.ArrayList; -import java.util.Collection; +import java.util.*; import org.eclipse.equinox.internal.p2.director.OperationGenerator; import org.eclipse.equinox.internal.p2.metadata.ResolvedInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; import org.eclipse.equinox.internal.provisional.p2.metadata.*; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class OperationGenerationTest extends AbstractProvisioningTest { public void testInstallUninstall() { - IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false); - IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false); - IInstallableUnit a3 = createIU("a", new Version(3, 0, 0), false); + IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false); + IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false); + IInstallableUnit a3 = createIU("a", Version.createOSGi(3, 0, 0), false); Collection from; from = new ArrayList(); @@ -38,16 +38,16 @@ public class OperationGenerationTest extends AbstractProvisioningTest { to.add(a1); to.add(a3); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); // 1 x install // 1 x uninstall - assertEquals(2, operands.length); + assertEquals(2, operands.size()); } public void test1() { - IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false); - IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false); - IInstallableUnit a3 = createIU("a", new Version(3, 0, 0), false); + IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false); + IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false); + IInstallableUnit a3 = createIU("a", Version.createOSGi(3, 0, 0), false); Collection from; from = new ArrayList(); @@ -60,15 +60,15 @@ public class OperationGenerationTest extends AbstractProvisioningTest { to.add(a3); to.add(a2); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); // 1 x install - assertEquals(1, operands.length); + assertEquals(1, operands.size()); } public void test2() { - IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false); - IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false); - IInstallableUnit a3 = createIU("a", new Version(3, 0, 0), false); + IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false); + IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false); + IInstallableUnit a3 = createIU("a", Version.createOSGi(3, 0, 0), false); Collection from; from = new ArrayList(); @@ -81,17 +81,17 @@ public class OperationGenerationTest extends AbstractProvisioningTest { to.add(a1); to.add(a3); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); // 1 x uninstall - assertEquals(1, operands.length); + assertEquals(1, operands.size()); } public void testUpdate1() { - IInstallableUnit a = createIU("a", new Version(1, 0, 0), false); + IInstallableUnit a = createIU("a", Version.createOSGi(1, 0, 0), false); InstallableUnitDescription b = new MetadataFactory.InstallableUnitDescription(); b.setId("b"); - b.setVersion(new Version(1, 0, 0)); + b.setVersion(Version.createOSGi(1, 0, 0)); b.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("a", new VersionRange("[1.0.0, 2.0.0)"), IUpdateDescriptor.NORMAL, null)); Collection from; @@ -102,18 +102,18 @@ public class OperationGenerationTest extends AbstractProvisioningTest { to = new ArrayList(); to.add(MetadataFactory.createInstallableUnit(b)); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); // 1 x upgrade - assertEquals(1, operands.length); + assertEquals(1, operands.size()); } public void testUpdate2() { - IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false); - IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false); + IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false); + IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false); InstallableUnitDescription b = new MetadataFactory.InstallableUnitDescription(); b.setId("b"); - b.setVersion(new Version(1, 0, 0)); + b.setVersion(Version.createOSGi(1, 0, 0)); b.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("a", new VersionRange("[1.0.0, 3.0.0)"), IUpdateDescriptor.NORMAL, null)); Collection from; @@ -125,24 +125,24 @@ public class OperationGenerationTest extends AbstractProvisioningTest { to = new ArrayList(); to.add(MetadataFactory.createInstallableUnit(b)); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); // 1 x install // 2 x uninstall - assertEquals(3, operands.length); + assertEquals(3, operands.size()); } public void testUpdate3() { - IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false); - IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false); + IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false); + IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false); InstallableUnitDescription b = new MetadataFactory.InstallableUnitDescription(); b.setId("b"); - b.setVersion(new Version(1, 0, 0)); + b.setVersion(Version.createOSGi(1, 0, 0)); b.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("a", new VersionRange("[1.0.0, 2.0.0)"), IUpdateDescriptor.NORMAL, null)); InstallableUnitDescription c = new MetadataFactory.InstallableUnitDescription(); c.setId("c"); - c.setVersion(new Version(1, 0, 0)); + c.setVersion(Version.createOSGi(1, 0, 0)); c.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("a", new VersionRange("[2.0.0, 2.3.0)"), IUpdateDescriptor.NORMAL, null)); Collection from; @@ -155,19 +155,19 @@ public class OperationGenerationTest extends AbstractProvisioningTest { to.add(MetadataFactory.createInstallableUnit(b)); to.add(MetadataFactory.createInstallableUnit(c)); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); // 2 x update - assertEquals(2, operands.length); + assertEquals(2, operands.size()); } public void testUpdate4() { - IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false); - IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false); - IInstallableUnit b1 = createIU("b", new Version(1, 0, 0), false); + IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false); + IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false); + IInstallableUnit b1 = createIU("b", Version.createOSGi(1, 0, 0), false); InstallableUnitDescription b2 = new MetadataFactory.InstallableUnitDescription(); b2.setId("b"); - b2.setVersion(new Version(2, 0, 0)); + b2.setVersion(Version.createOSGi(2, 0, 0)); b2.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("b", new VersionRange("[1.0.0, 2.0.0)"), IUpdateDescriptor.NORMAL, null)); Collection from; @@ -182,19 +182,19 @@ public class OperationGenerationTest extends AbstractProvisioningTest { to.add(a2); to.add(MetadataFactory.createInstallableUnit(b2)); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); // 1 x update - assertEquals(1, operands.length); + assertEquals(1, operands.size()); } public void testUpdate5() { - IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false); - IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false); - IInstallableUnit b1 = createIU("b", new Version(1, 0, 0), false); + IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false); + IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false); + IInstallableUnit b1 = createIU("b", Version.createOSGi(1, 0, 0), false); InstallableUnitDescription b2 = new MetadataFactory.InstallableUnitDescription(); b2.setId("b"); - b2.setVersion(new Version(2, 0, 0)); + b2.setVersion(Version.createOSGi(2, 0, 0)); b2.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("b", new VersionRange("[1.0.0, 2.0.0)"), IUpdateDescriptor.NORMAL, null)); Collection from; @@ -208,21 +208,21 @@ public class OperationGenerationTest extends AbstractProvisioningTest { to.add(a1); to.add(MetadataFactory.createInstallableUnit(b2)); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); // 1 x update // 1 x uninstall - assertEquals(2, operands.length); + assertEquals(2, operands.size()); } public void test248468b() { String id = "myBundle"; - IUpdateDescriptor update = createUpdateDescriptor(id, new Version("1.0.0")); - IInstallableUnit one = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); - IUpdateDescriptor update2 = createUpdateDescriptor(id, new Version("2.0.0")); - IInstallableUnit two = createIU(id, new Version("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update2, null); + IUpdateDescriptor update = createUpdateDescriptor(id, Version.create("1.0.0")); + IInstallableUnit one = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); + IUpdateDescriptor update2 = createUpdateDescriptor(id, Version.create("2.0.0")); + IInstallableUnit two = createIU(id, Version.create("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update2, null); - IUpdateDescriptor update3 = createUpdateDescriptor(id, new Version("3.0.0")); - IInstallableUnit three = createIU(id, new Version("3.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update3, null); + IUpdateDescriptor update3 = createUpdateDescriptor(id, Version.create("3.0.0")); + IInstallableUnit three = createIU(id, Version.create("3.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update3, null); Collection from = new ArrayList(); from.add(MetadataFactory.createResolvedInstallableUnit(one, new IInstallableUnitFragment[0])); @@ -232,27 +232,27 @@ public class OperationGenerationTest extends AbstractProvisioningTest { Collection to = new ArrayList(); to.add(MetadataFactory.createResolvedInstallableUnit(three, new IInstallableUnitFragment[0])); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); //We are uninstalling myBundle 1.0 and 2.0. 3.0 stays unchanged. - for (int i = 0; i < operands.length; i++) { - assertNotSame("3.0", three, operands[i].first()); - assertNotSame("3.0.1", three, operands[i].second()); + for (int i = 0; i < operands.size(); i++) { + assertNotSame("3.0", three, operands.get(i).first()); + assertNotSame("3.0.1", three, operands.get(i).second()); } - assertEquals("3.1", one, operands[0].first()); - assertNull("3.2", operands[0].second()); - assertEquals("3.3", two, operands[1].first()); - assertNull("3.4", operands[1].second()); + assertEquals("3.1", one, operands.get(0).first()); + assertNull("3.2", operands.get(0).second()); + assertEquals("3.3", two, operands.get(1).first()); + assertNull("3.4", operands.get(1).second()); } public void test248468d() { String id = "myBundle"; - IUpdateDescriptor update = createUpdateDescriptor(id, new Version("1.0.0")); - IInstallableUnit one = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); - update = createUpdateDescriptor(id, new Version("2.0.0")); - IInstallableUnit two = createIU(id, new Version("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); + IUpdateDescriptor update = createUpdateDescriptor(id, Version.create("1.0.0")); + IInstallableUnit one = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); + update = createUpdateDescriptor(id, Version.create("2.0.0")); + IInstallableUnit two = createIU(id, Version.create("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); - IUpdateDescriptor update3 = createUpdateDescriptor(id, new Version("3.0.0")); - IInstallableUnit three = createIU("anotherBundle", new Version("3.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update3, null); + IUpdateDescriptor update3 = createUpdateDescriptor(id, Version.create("3.0.0")); + IInstallableUnit three = createIU("anotherBundle", Version.create("3.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update3, null); Collection from = new ArrayList(); from.add(MetadataFactory.createResolvedInstallableUnit(one, new IInstallableUnitFragment[0])); @@ -262,28 +262,28 @@ public class OperationGenerationTest extends AbstractProvisioningTest { to.add(MetadataFactory.createResolvedInstallableUnit(two, new IInstallableUnitFragment[0])); to.add(MetadataFactory.createResolvedInstallableUnit(three, new IInstallableUnitFragment[0])); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); //Two is already in the system therefore it will not be in the operands - for (int i = 0; i < operands.length; i++) { - assertNotSame("2.0", two, operands[i].first()); - assertNotSame("2.1", two, operands[i].second()); + for (int i = 0; i < operands.size(); i++) { + assertNotSame("2.0", two, operands.get(i).first()); + assertNotSame("2.1", two, operands.get(i).second()); } //three is an update of one - assertEquals("2.2", 1, operands.length); - assertEquals("2.4", one, operands[0].first()); - assertEquals("2.5", three, operands[0].second()); + assertEquals("2.2", 1, operands.size()); + assertEquals("2.4", one, operands.get(0).first()); + assertEquals("2.5", three, operands.get(0).second()); } public void test248468c() { String id = "myBundle"; - IUpdateDescriptor update = createUpdateDescriptor(id, new Version("1.0.0")); - IInstallableUnit one = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); - update = createUpdateDescriptor(id, new Version("2.0.0")); - IInstallableUnit two = createIU(id, new Version("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); + IUpdateDescriptor update = createUpdateDescriptor(id, Version.create("1.0.0")); + IInstallableUnit one = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); + update = createUpdateDescriptor(id, Version.create("2.0.0")); + IInstallableUnit two = createIU(id, Version.create("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); - IUpdateDescriptor update3 = MetadataFactory.createUpdateDescriptor(id, new VersionRange(new Version(2, 0, 0), true, new Version(3, 0, 0), false), IUpdateDescriptor.HIGH, "desc"); - // IUpdateDescriptor update3 = createUpdateDescriptor(id, new Version("3.0.0")); - IInstallableUnit three = createIU("anotherBundle", new Version("3.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update3, null); + IUpdateDescriptor update3 = MetadataFactory.createUpdateDescriptor(id, new VersionRange(Version.createOSGi(2, 0, 0), true, Version.createOSGi(3, 0, 0), false), IUpdateDescriptor.HIGH, "desc"); + // IUpdateDescriptor update3 = createUpdateDescriptor(id, Version.create("3.0.0")); + IInstallableUnit three = createIU("anotherBundle", Version.create("3.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update3, null); Collection from = new ArrayList(); from.add(MetadataFactory.createResolvedInstallableUnit(one, new IInstallableUnitFragment[0])); @@ -293,26 +293,26 @@ public class OperationGenerationTest extends AbstractProvisioningTest { to.add(MetadataFactory.createResolvedInstallableUnit(two, new IInstallableUnitFragment[0])); to.add(MetadataFactory.createResolvedInstallableUnit(three, new IInstallableUnitFragment[0])); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); //Two is already in the system therefore it will not be in the operands - for (int i = 0; i < operands.length; i++) { - assertNotSame("2.0", two, operands[i].first()); - assertNotSame("2.1", two, operands[i].second()); + for (int i = 0; i < operands.size(); i++) { + assertNotSame("2.0", two, operands.get(i).first()); + assertNotSame("2.1", two, operands.get(i).second()); } //We install three and uninstall one - assertEquals("2.2", 2, operands.length); - assertNull("2.3", operands[0].first()); - assertEquals("2.4", three, operands[0].second()); - assertEquals("2.5", one, operands[1].first()); - assertNull("2.6", operands[1].second()); + assertEquals("2.2", 2, operands.size()); + assertNull("2.3", operands.get(0).first()); + assertEquals("2.4", three, operands.get(0).second()); + assertEquals("2.5", one, operands.get(1).first()); + assertNull("2.6", operands.get(1).second()); } public void test248468() { String id = "myBundle"; - IUpdateDescriptor update = createUpdateDescriptor(id, new Version("1.0.0")); - IInstallableUnit one = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); - update = createUpdateDescriptor(id, new Version("2.0.0")); - IInstallableUnit two = createIU(id, new Version("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); + IUpdateDescriptor update = createUpdateDescriptor(id, Version.create("1.0.0")); + IInstallableUnit one = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); + update = createUpdateDescriptor(id, Version.create("2.0.0")); + IInstallableUnit two = createIU(id, Version.create("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null); Collection from = new ArrayList(); from.add(MetadataFactory.createResolvedInstallableUnit(one, new IInstallableUnitFragment[0])); @@ -321,20 +321,20 @@ public class OperationGenerationTest extends AbstractProvisioningTest { Collection to = new ArrayList(); to.add(MetadataFactory.createResolvedInstallableUnit(two, new IInstallableUnitFragment[0])); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); - assertEquals("1.0", 1, operands.length); - assertEquals("1.1", one, operands[0].first()); - assertNull("1.2", operands[0].second()); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); + assertEquals("1.0", 1, operands.size()); + assertEquals("1.1", one, operands.get(0).first()); + assertNull("1.2", operands.get(0).second()); } public void testConfigurationChange1() { String id = "myBundle"; String cuId = "cu"; - IInstallableUnit anIU = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); - IInstallableUnit anotherIU = createIU("misc", new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); - IInstallableUnit anotherIU2 = createIU("misc2", new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); - IInstallableUnitFragment cu1 = createIUFragment(anIU, cuId, new Version("1.0.0")); - IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, new Version("2.0.0")); + IInstallableUnit anIU = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); + IInstallableUnit anotherIU = createIU("misc", Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); + IInstallableUnit anotherIU2 = createIU("misc2", Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); + IInstallableUnitFragment cu1 = createIUFragment(anIU, cuId, Version.create("1.0.0")); + IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, Version.create("2.0.0")); Collection from = new ArrayList(); ResolvedInstallableUnit fromResolved = (ResolvedInstallableUnit) MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu1}); @@ -346,16 +346,17 @@ public class OperationGenerationTest extends AbstractProvisioningTest { to.add(toResolved); to.add(MetadataFactory.createResolvedInstallableUnit(anotherIU2, new IInstallableUnitFragment[0])); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); - assertEquals("1.0", 3, operands.length); + assertEquals("1.0", 3, operands.size()); assertContainsConfigurationChange("2.0", operands); assertContainsInstallableUnitOperand("3.0", operands, new InstallableUnitOperand(fromResolved, toResolved)); } - private void assertContainsInstallableUnitOperand(String message, InstallableUnitOperand[] operands, InstallableUnitOperand operand) { - for (int i = 0; i < operands.length; i++) { - if (operands[i].first() != null && operands[i].first().equals(operand.first()) && operands[i].second() != null && operands[i].second().equals(operand.second())) + private void assertContainsInstallableUnitOperand(String message, List<InstallableUnitOperand> operands, InstallableUnitOperand operand) { + for (int i = 0; i < operands.size(); i++) { + InstallableUnitOperand cmp = operands.get(i); + if (cmp.first() != null && cmp.first().equals(operand.first()) && cmp.second() != null && cmp.second().equals(operand.second())) return; } fail(message); @@ -364,8 +365,8 @@ public class OperationGenerationTest extends AbstractProvisioningTest { public void testConfigurationChange2() { String id = "myBundle"; String cuId = "cu"; - IInstallableUnit anIU = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); - IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, new Version("2.0.0")); + IInstallableUnit anIU = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); + IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, Version.create("2.0.0")); Collection from = new ArrayList(); ResolvedInstallableUnit fromResolved = (ResolvedInstallableUnit) MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[0]); @@ -375,17 +376,17 @@ public class OperationGenerationTest extends AbstractProvisioningTest { IInstallableUnit toResolved = MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu2}); to.add(toResolved); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); - assertEquals("1.0", 1, operands.length); + assertEquals("1.0", 1, operands.size()); assertContainsInstallableUnitOperand("3.0", operands, new InstallableUnitOperand(fromResolved, toResolved)); } public void testConfigurationChange3() { String id = "myBundle"; String cuId = "cu"; - IInstallableUnit anIU = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); - IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, new Version("2.0.0")); + IInstallableUnit anIU = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); + IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, Version.create("2.0.0")); Collection from = new ArrayList(); ResolvedInstallableUnit fromResolved = (ResolvedInstallableUnit) MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu2}); @@ -395,17 +396,17 @@ public class OperationGenerationTest extends AbstractProvisioningTest { IInstallableUnit toResolved = MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[0]); to.add(toResolved); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); - assertEquals("1.0", 1, operands.length); + assertEquals("1.0", 1, operands.size()); assertContainsInstallableUnitOperand("3.0", operands, new InstallableUnitOperand(fromResolved, toResolved)); } public void testConfigurationChange4() { String id = "myBundle"; String cuId = "cu"; - IInstallableUnit anIU = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); - IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, new Version("2.0.0")); + IInstallableUnit anIU = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); + IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, Version.create("2.0.0")); Collection from = new ArrayList(); ResolvedInstallableUnit fromResolved = (ResolvedInstallableUnit) MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu2}); @@ -415,17 +416,17 @@ public class OperationGenerationTest extends AbstractProvisioningTest { IInstallableUnit toResolved = MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu2}); to.add(toResolved); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); - assertEquals("1.0", 0, operands.length); + assertEquals("1.0", 0, operands.size()); } public void testConfigurationChange5() { String id = "myBundle"; String cuId = "cu"; - IInstallableUnit anIU = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); - IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, new Version("2.0.0")); - IInstallableUnitFragment cu1 = createIUFragment(anIU, cuId, new Version("1.0.0")); + IInstallableUnit anIU = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); + IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, Version.create("2.0.0")); + IInstallableUnitFragment cu1 = createIUFragment(anIU, cuId, Version.create("1.0.0")); Collection from = new ArrayList(); ResolvedInstallableUnit fromResolved = (ResolvedInstallableUnit) MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu1, cu2}); @@ -435,18 +436,18 @@ public class OperationGenerationTest extends AbstractProvisioningTest { IInstallableUnit toResolved = MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu2, cu1}); to.add(toResolved); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); - assertEquals("1.0", 0, operands.length); + assertEquals("1.0", 0, operands.size()); } public void testConfigurationChange6() { String id = "myBundle"; String cuId = "cu"; - IInstallableUnit anIU = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); - IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, new Version("2.0.0")); - IInstallableUnitFragment cu1 = createIUFragment(anIU, cuId, new Version("1.0.0")); - IInstallableUnitFragment cu3 = createIUFragment(anIU, cuId, new Version("3.0.0")); + IInstallableUnit anIU = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); + IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, Version.create("2.0.0")); + IInstallableUnitFragment cu1 = createIUFragment(anIU, cuId, Version.create("1.0.0")); + IInstallableUnitFragment cu3 = createIUFragment(anIU, cuId, Version.create("3.0.0")); Collection from = new ArrayList(); ResolvedInstallableUnit fromResolved = (ResolvedInstallableUnit) MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu1, cu2}); @@ -456,9 +457,9 @@ public class OperationGenerationTest extends AbstractProvisioningTest { IInstallableUnit toResolved = MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu1, cu3}); to.add(toResolved); - InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to); + List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to); - assertEquals("1.0", 1, operands.length); + assertEquals("1.0", 1, operands.size()); assertContainsInstallableUnitOperand("3.0", operands, new InstallableUnitOperand(fromResolved, toResolved)); } @@ -470,9 +471,10 @@ public class OperationGenerationTest extends AbstractProvisioningTest { fail(message + "Can't find " + expected); } - public void assertContainsConfigurationChange(String message, InstallableUnitOperand[] ops) { - for (int i = 0; i < ops.length; i++) { - if (ops[i].first() != null && ops[i].first().equals(ops[i].second())) { + public void assertContainsConfigurationChange(String message, List<InstallableUnitOperand> ops) { + for (int i = 0; i < ops.size(); i++) { + InstallableUnitOperand op = ops.get(i); + if (op.first() != null && op.first().equals(op.second())) { return; } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java index a947717e6..40088c1a0 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java @@ -8,15 +8,15 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.director; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class OracleTest extends AbstractProvisioningTest { @@ -31,18 +31,18 @@ public class OracleTest extends AbstractProvisioningTest { IProfile profile; protected void setUp() throws Exception { - IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)"), null); + IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)")); a1 = createIU("A", requires, true); - requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.0.0, 3.0.0)"), null); + requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.0.0, 3.0.0)")); c1 = createIU("C", requires, true); d1 = createIU("D", DEFAULT_VERSION, true); - requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[2.0.0, 3.0.0)"), null); + requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[2.0.0, 3.0.0)")); b1 = createIU("B", requires, true); - d2 = createIU("D", new Version(2, 0, 0), true); + d2 = createIU("D", Version.createOSGi(2, 0, 0), true); createTestMetdataRepository(new IInstallableUnit[] {a1, c1, d1, b1}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java index 430fadc9b..11aeff973 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java @@ -8,15 +8,18 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.director; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IUpdateDescriptor; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class OracleTest2 extends AbstractProvisioningTest { @@ -30,16 +33,16 @@ public class OracleTest2 extends AbstractProvisioningTest { IProfile profile; protected void setUp() throws Exception { - IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)"), null); + IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)")); a1 = createIU("A", requires, true); c1 = createIU("C", DEFAULT_VERSION, true); - requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[2.0.0, 3.0.0)"), null); + requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[2.0.0, 3.0.0)")); InstallableUnitDescription desc = new MetadataFactory.InstallableUnitDescription(); desc.setRequiredCapabilities(requires); desc.setId("A"); - desc.setVersion(new Version(2, 0, 0)); + desc.setVersion(Version.createOSGi(2, 0, 0)); desc.setSingleton(true); desc.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("A", new VersionRange("[1.0.0, 2.3.0)"), IUpdateDescriptor.NORMAL, null)); @@ -49,7 +52,7 @@ public class OracleTest2 extends AbstractProvisioningTest { InstallableUnitDescription desc2 = new MetadataFactory.InstallableUnitDescription(); desc2.setId("C"); - desc2.setVersion(new Version(2, 0, 0)); + desc2.setVersion(Version.createOSGi(2, 0, 0)); desc2.setSingleton(true); desc2.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("C", new VersionRange("[1.0.0, 2.3.0)"), IUpdateDescriptor.NORMAL, null)); c2 = MetadataFactory.createInstallableUnit(desc2); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java index ed6f1d617..9efa4f8e3 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java @@ -10,14 +10,14 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.director; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** @@ -40,8 +40,8 @@ public class ReplacePlanTest extends AbstractProvisioningTest { protected void setUp() throws Exception { //base IU that others require f1 = createIU("f1", DEFAULT_VERSION, true); - f1_1 = createIU("f1", new Version(1, 1, 0), true); - f1_4 = createIU("f1", new Version(1, 4, 0), true); + f1_1 = createIU("f1", Version.createOSGi(1, 1, 0), true); + f1_4 = createIU("f1", Version.createOSGi(1, 4, 0), true); //fragments of base IU frag1 = createIUFragment(f1, "frag1", f1.getVersion()); @@ -49,10 +49,10 @@ public class ReplacePlanTest extends AbstractProvisioningTest { frag1_4 = createIUFragment(f1, "frag1", f1_4.getVersion()); //IUs that require base IU - IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "f1", new VersionRange("[1.0.0, 1.3.0)"), null); + IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "f1", new VersionRange("[1.0.0, 1.3.0)")); fa = createIU("fa", requires, false); - requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "f1", new VersionRange("[1.0.0, 1.4.0)"), null); - fap = createIU("fa", new Version(1, 1, 0), requires, NO_PROPERTIES, false); + requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "f1", new VersionRange("[1.0.0, 1.4.0)")); + fap = createIU("fa", Version.createOSGi(1, 1, 0), requires, NO_PROPERTIES, false); createTestMetdataRepository(new IInstallableUnit[] {f1, fa, frag1}); @@ -73,10 +73,10 @@ public class ReplacePlanTest extends AbstractProvisioningTest { ProfileChangeRequest request = new ProfileChangeRequest(profile); request.removeInstallableUnits(oldUnits); request.addInstallableUnits(newUnits); - ProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), null); + IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), null); assertTrue("1.0", plan.getStatus().isOK()); assertProfileContainsAll("1.1", profile, oldUnits); - IStatus result = createEngine().perform(profile, new DefaultPhaseSet(), plan.getOperands(), null, null); + IStatus result = createEngine().perform(plan, null); assertTrue("1.2", result.isOK()); assertProfileContainsAll("1.3", profile, newUnits); } @@ -86,7 +86,7 @@ public class ReplacePlanTest extends AbstractProvisioningTest { ProfileChangeRequest request = new ProfileChangeRequest(profile); request.removeInstallableUnits(new IInstallableUnit[] {frag1}); request.addInstallableUnits(new IInstallableUnit[] {frag1_4}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), null); + IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), null); assertTrue("1.0", plan.getStatus().isOK()); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java index 98cd52f53..5fdd4e937 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java @@ -10,25 +10,25 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.director; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; -import java.net.*; -import java.util.ArrayList; -import java.util.List; +import java.net.URI; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.director.DirectorActivator; -import org.eclipse.equinox.internal.provisional.p2.core.*; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.IAgentLocation; +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.query.IQueryResult; +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; @@ -49,8 +49,8 @@ public class RollbackTest extends AbstractProvisioningTest { c1 = createIU("C", DEFAULT_VERSION, true); IRequiredCapability[] req = new IRequiredCapability[1]; - req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true); - d1 = createIU("D", new Version("1.0.0"), req); + req[0] = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true); + d1 = createIU("D", Version.create("1.0.0"), req); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, c1, d1}); @@ -67,21 +67,13 @@ public class RollbackTest extends AbstractProvisioningTest { } private IMetadataRepository getRollbackRepository() throws ProvisionException { - try { - IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); - URL location = ((AgentLocation) ServiceHelper.getService(DirectorActivator.context, AgentLocation.class.getName())).getDataArea(DirectorActivator.PI_DIRECTOR); - return repoMan.loadRepository(URIUtil.toURI(new URL(location, "rollback")), null); - } catch (MalformedURLException e) { - fail("0.02", e); - return null; - } catch (URISyntaxException e) { - fail("0.03", e); - return null; - } + IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); + URI location = ((IAgentLocation) ServiceHelper.getService(DirectorActivator.context, IAgentLocation.class.getName())).getDataArea(DirectorActivator.PI_DIRECTOR); + return repoMan.loadRepository(URIUtil.append(location, "rollback"), null); } public void testRollbackProfileProperties() { - IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry profileRegistry = getProfileRegistry(); assertEquals(1, profileRegistry.listProfileTimestamps(profile.getProfileId()).length); ProfileChangeRequest request1 = new ProfileChangeRequest(profile); @@ -115,7 +107,7 @@ public class RollbackTest extends AbstractProvisioningTest { } public void testRollbackIUs() { - IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry profileRegistry = getProfileRegistry(); assertEquals(1, profileRegistry.listProfileTimestamps(profile.getProfileId()).length); ProfileChangeRequest request1 = new ProfileChangeRequest(profile); @@ -124,9 +116,9 @@ public class RollbackTest extends AbstractProvisioningTest { IStatus status = director.provision(request1, null, new NullProgressMonitor()); assertEquals("1.0", IStatus.OK, status.getCode()); - List profileIUs = new ArrayList(profile.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection()); - assertTrue("2.0", profileIUs.contains(a1)); - assertTrue("3.0", profileIUs.contains(b1)); + IQueryResult profileIUs = profile.query(InstallableUnitQuery.ANY, null); + assertContains("2.0", profileIUs, a1); + assertContains("3.0", profileIUs, b1); assertEquals(2, profileRegistry.listProfileTimestamps(profile.getProfileId()).length); @@ -136,10 +128,10 @@ public class RollbackTest extends AbstractProvisioningTest { status = director.provision(request2, null, new NullProgressMonitor()); assertEquals("5.0", IStatus.OK, status.getCode()); - profileIUs = new ArrayList(profile.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection()); - assertFalse("6.0", profileIUs.contains(a1)); - assertTrue("7.0", profileIUs.contains(b1)); - assertTrue("8.0", profileIUs.contains(c1)); + profileIUs = profile.query(InstallableUnitQuery.ANY, null); + assertNotContains("6.0", profileIUs, a1); + assertContains("7.0", profileIUs, b1); + assertContains("8.0", profileIUs, c1); assertEquals(3, profileRegistry.listProfileTimestamps(profile.getProfileId()).length); IProfile revertProfile = profileRegistry.getProfile(profile.getProfileId(), profileRegistry.listProfileTimestamps(profile.getProfileId())[1]); @@ -147,14 +139,14 @@ public class RollbackTest extends AbstractProvisioningTest { status = director.revert(profile, revertProfile, new ProvisioningContext(), new NullProgressMonitor()); assertEquals("10.0", IStatus.OK, status.getCode()); - profileIUs = new ArrayList(profile.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection()); - assertTrue("11.0", profileIUs.contains(a1)); - assertTrue("12.0", profileIUs.contains(b1)); - assertFalse("13.0", profileIUs.contains(c1)); + profileIUs = profile.query(InstallableUnitQuery.ANY, null); + assertContains("11.0", profileIUs, a1); + assertContains("12.0", profileIUs, b1); + assertNotContains("13.0", profileIUs, c1); } public void testRollbackIUProfileProperties() { - IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry profileRegistry = getProfileRegistry(); assertEquals(1, profileRegistry.listProfileTimestamps(profile.getProfileId()).length); ProfileChangeRequest request1 = new ProfileChangeRequest(profile); @@ -189,7 +181,7 @@ public class RollbackTest extends AbstractProvisioningTest { } public void testRollbackDependentIUProfileProperties() { - IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry profileRegistry = getProfileRegistry(); assertEquals(1, profileRegistry.listProfileTimestamps(profile.getProfileId()).length); ProfileChangeRequest request1 = new ProfileChangeRequest(profile); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java index a21e834de..d066a3d16 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java @@ -10,14 +10,14 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.director; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SingletonTest extends AbstractProvisioningTest { @@ -34,17 +34,17 @@ public class SingletonTest extends AbstractProvisioningTest { IProfile profile; protected void setUp() throws Exception { - f1 = createIU("f1", new Version(1, 0, 0), true); + f1 = createIU("f1", Version.createOSGi(1, 0, 0), true); - f1_1 = createIU("f1", new Version(1, 1, 0), true); + f1_1 = createIU("f1", Version.createOSGi(1, 1, 0), true); - f2 = createIU("f2", new Version(1, 0, 0), true); + f2 = createIU("f2", Version.createOSGi(1, 0, 0), true); - f2_1 = createIU("f2", new Version(1, 0, 1)); + f2_1 = createIU("f2", Version.createOSGi(1, 0, 1)); - junit38 = createIU("junit", new Version(3, 8, 1)); + junit38 = createIU("junit", Version.createOSGi(3, 8, 1)); - junit40 = createIU("junit", new Version(4, 0, 1)); + junit40 = createIU("junit", Version.createOSGi(4, 0, 1)); createTestMetdataRepository(new IInstallableUnit[] {f1, f1_1, junit38, junit40, f2, f2_1}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java index 8360cd9ae..4758f3614 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java @@ -12,8 +12,8 @@ package org.eclipse.equinox.p2.tests.director; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class UninstallTest extends AbstractProvisioningTest { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java index f2d224097..cb08ac8f5 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java @@ -8,16 +8,15 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.director; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class UpdateTest extends AbstractProvisioningTest { @@ -34,15 +33,15 @@ public class UpdateTest extends AbstractProvisioningTest { protected void setUp() throws Exception { String f1Id = getName() + "f1"; f1 = createIU(f1Id, DEFAULT_VERSION, true); - f1_1 = createIU(f1Id, new Version(1, 1, 0), true); - f1_4 = createIU(f1Id, new Version(1, 4, 0), true); + f1_1 = createIU(f1Id, Version.createOSGi(1, 1, 0), true); + f1_4 = createIU(f1Id, Version.createOSGi(1, 4, 0), true); - IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, f1Id, new VersionRange("[1.0.0, 1.3.0)"), null); + IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, f1Id, new VersionRange("[1.0.0, 1.3.0)")); String faId = getName() + ".fa"; fa = createIU(faId, requires, false); - requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, f1Id, new VersionRange("[1.0.0, 1.4.0)"), null); - fap = createIU(faId, new Version(1, 1, 0), requires, NO_PROPERTIES, false); + requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, f1Id, new VersionRange("[1.0.0, 1.4.0)")); + fap = createIU(faId, Version.createOSGi(1, 1, 0), requires, NO_PROPERTIES, false); createTestMetdataRepository(new IInstallableUnit[] {f1, fa}); @@ -59,7 +58,7 @@ public class UpdateTest extends AbstractProvisioningTest { public void testInstall() { ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {f1_1}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), new NullProgressMonitor()); assertOK("1.0", plan.getStatus()); assertOK("1.1", director.provision(request, null, null)); request = new ProfileChangeRequest(profile); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java index 7df459def..a77f39e67 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java @@ -10,14 +10,14 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.directorywatcher; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.util.*; import junit.framework.Test; import junit.framework.TestSuite; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; /** * @since 1.0 @@ -113,7 +113,7 @@ public class ProfileSynchronizerTest extends AbstractDirectoryWatcherTest { IArtifactKey[] artifacts = watcher.getArtifactKeys(); assertEquals("3.0", 1, ius.length); assertEquals("3.1", "ccc", ius[0].getId()); - assertEquals("3.2", new Version("2.0.0"), ius[0].getVersion()); + assertEquals("3.2", Version.create("2.0.0"), ius[0].getVersion()); assertEquals("4.0", 1, artifacts.length); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java index 1f8dd7d7b..bf2e0a86b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java @@ -11,11 +11,12 @@ package org.eclipse.equinox.p2.tests.directorywatcher; import java.io.File; +import java.util.List; import junit.framework.Test; import junit.framework.TestSuite; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.ArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; public class RepositoryListenerTest extends AbstractDirectoryWatcherTest { @@ -33,11 +34,11 @@ public class RepositoryListenerTest extends AbstractDirectoryWatcherTest { return new TestSuite(RepositoryListenerTest.class); } - public static boolean isZipped(ITouchpointData[] data) { - if (data == null || data.length == 0) + public static boolean isZipped(List<ITouchpointData> data) { + if (data == null || data.size() == 0) return false; - for (int i = 0; i < data.length; i++) { - if (data[i].getInstruction("zipped") != null) //$NON-NLS-1$ + for (int i = 0; i < data.size(); i++) { + if (data.get(i).getInstruction("zipped") != null) //$NON-NLS-1$ return true; } return false; @@ -135,7 +136,7 @@ public class RepositoryListenerTest extends AbstractDirectoryWatcherTest { IArtifactKey key = keys[i]; IArtifactDescriptor[] descriptors = watcher.getArtifactDescriptors(key); assertEquals("8.0", 1, descriptors.length); - ArtifactDescriptor descriptor = (ArtifactDescriptor) descriptors[0]; + SimpleArtifactDescriptor descriptor = (SimpleArtifactDescriptor) descriptors[0]; String isFolder = descriptor.getRepositoryProperty("artifact.folder"); if (Boolean.valueOf(isFolder).booleanValue()) { assertNull("9.0", directoryDescriptor); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/TestRepositoryWatcher.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/TestRepositoryWatcher.java index d9cfbb081..19f92dfbd 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/TestRepositoryWatcher.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/TestRepositoryWatcher.java @@ -11,16 +11,15 @@ package org.eclipse.equinox.p2.tests.directorywatcher; import java.io.File; -import java.util.Dictionary; import java.util.Hashtable; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; +import java.util.Map; import org.eclipse.equinox.internal.provisional.p2.directorywatcher.DirectoryWatcher; import org.eclipse.equinox.internal.provisional.p2.directorywatcher.RepositoryListener; -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.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.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.BundleContext; @@ -37,7 +36,7 @@ class TestRepositoryWatcher extends DirectoryWatcher { */ public static TestRepositoryWatcher createWatcher(File folder) { RepositoryListener listener = new RepositoryListener(AbstractProvisioningTest.getUniqueString(), false); - Dictionary props = new Hashtable(); + Map<String, String> props = new Hashtable<String, String>(); props.put(DirectoryWatcher.DIR, folder.getAbsolutePath()); props.put(DirectoryWatcher.POLL, "500"); TestRepositoryWatcher result = new TestRepositoryWatcher(props, TestActivator.getContext()); @@ -48,7 +47,7 @@ class TestRepositoryWatcher extends DirectoryWatcher { /* * Constructor for the class. */ - private TestRepositoryWatcher(Dictionary props, BundleContext context) { + private TestRepositoryWatcher(Map<String, String> props, BundleContext context) { super(props, context); } @@ -64,14 +63,15 @@ class TestRepositoryWatcher extends DirectoryWatcher { * Return the list of all the IUs known to the metadata repository this watcher's listener. */ public IInstallableUnit[] getInstallableUnits() { - return (IInstallableUnit[]) listener.getMetadataRepository().query(InstallableUnitQuery.ANY, new Collector(), null).toArray(IInstallableUnit.class); + return listener.getMetadataRepository().query(InstallableUnitQuery.ANY, null).toArray(IInstallableUnit.class); } /* * Return the list of artifact keys known to this listener's repository. */ public IArtifactKey[] getArtifactKeys() { - return listener.getArtifactRepository().getArtifactKeys(); + IQueryResult keys = listener.getArtifactRepository().query(ArtifactKeyQuery.ALL_KEYS, null); + return (IArtifactKey[]) keys.toArray(IArtifactKey.class); } /* diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ActionManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ActionManagerTest.java index 09a62ed29..2bdf4694d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ActionManagerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ActionManagerTest.java @@ -10,13 +10,13 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.engine; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.io.File; import java.net.MalformedURLException; import org.eclipse.equinox.internal.p2.engine.ActionManager; -import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.internal.provisional.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.Bundle; @@ -37,7 +37,7 @@ public class ActionManagerTest extends AbstractProvisioningTest { public void testGetTouchpointQualifiedActionId() { ActionManager manager = new ActionManager(); - assertNotNull(manager.getTouchpointQualifiedActionId("test", MetadataFactory.createTouchpointType("phaseTest", new Version("1")))); + assertNotNull(manager.getTouchpointQualifiedActionId("test", MetadataFactory.createTouchpointType("phaseTest", Version.create("1")))); } public void testGetActionWithVersion() { @@ -50,7 +50,8 @@ public class ActionManagerTest extends AbstractProvisioningTest { assertNotNull(manager.getAction("test1.test", null)); } - public void testDynamicAction() throws MalformedURLException, BundleException, InterruptedException { + // temporarily disabling this test until API is done + public void DISABLED_testDynamicAction() throws MalformedURLException, BundleException, InterruptedException { ActionManager manager = new ActionManager(); assertNull(manager.getAction("dummy.touchpointAndAction.dummy", new VersionRange("1.0.0"))); File dummy = getTestData("0.1", "/testData/engineTest/dummy.touchpointAndAction_1.0.0.jar"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java index 5e3d14e6f..466da3497 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java @@ -13,14 +13,12 @@ package org.eclipse.equinox.p2.tests.engine; import java.io.File; import java.io.IOException; import java.security.cert.Certificate; -import java.util.Hashtable; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.core.ProvisioningAgent; import org.eclipse.equinox.internal.p2.engine.EngineActivator; +import org.eclipse.equinox.internal.p2.engine.phases.CertificateChecker; import org.eclipse.equinox.internal.provisional.p2.core.IServiceUI; -import org.eclipse.equinox.internal.provisional.p2.engine.CertificateChecker; -import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestData; -import org.osgi.framework.ServiceRegistration; +import org.eclipse.equinox.p2.tests.*; /** * Tests for {@link CertificateChecker}. @@ -46,12 +44,16 @@ public class CertificateCheckerTest extends AbstractProvisioningTest { } CertificateChecker checker; - ServiceRegistration serviceReg; CertificateTestService serviceUI; File unsigned; + private ProvisioningAgent testAgent; protected void setUp() throws Exception { - checker = new CertificateChecker(); + serviceUI = new CertificateTestService(); + testAgent = new ProvisioningAgent(); + testAgent.registerService(IServiceUI.SERVICE_NAME, serviceUI); + testAgent.setBundleContext(TestActivator.getContext()); + checker = new CertificateChecker(testAgent); try { unsigned = TestData.getFile("CertificateChecker", "unsigned.jar"); } catch (IOException e) { @@ -59,17 +61,6 @@ public class CertificateCheckerTest extends AbstractProvisioningTest { } assertTrue("1.0", unsigned != null); assertTrue("1.0", unsigned.exists()); - // We need to ensure the test service has a higher ranking than - // anything registered by the SDK via DS. - serviceUI = new CertificateTestService(); - Hashtable properties = new Hashtable(1); - properties.put(org.osgi.framework.Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE)); - serviceReg = EngineActivator.getContext().registerService(IServiceUI.class.getName(), serviceUI, properties); - } - - protected void tearDown() throws Exception { - if (serviceReg != null) - serviceReg.unregister(); } /** @@ -154,16 +145,10 @@ public class CertificateCheckerTest extends AbstractProvisioningTest { */ public void testBug291049() { try { - - // Intentionally unregister our service so that we get whatever the default (or null) service is - // in an SDK configuration. - if (serviceReg != null) { - serviceReg.unregister(); - serviceReg = null; - } + // Intentionally replace our service with a null service + testAgent.registerService(IServiceUI.SERVICE_NAME, null); checker.add(unsigned); // TODO need to add some untrusted files here, too. To prove that we treated them as trusted temporarily - System.getProperties().setProperty(EngineActivator.PROP_UNSIGNED_POLICY, EngineActivator.UNSIGNED_PROMPT); IStatus result = checker.start(); assertTrue("1.0", result.isOK()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java index 37fde9fd3..cc89dbf17 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java @@ -17,9 +17,9 @@ import junit.framework.TestSuite; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.p2.engine.DownloadManager; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.engine.ProvisioningContext; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** @@ -34,7 +34,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest { * Tests invocation of DownloadManager when there is nothing to download. */ public void testEmpty() { - DownloadManager manager = new DownloadManager(null); + DownloadManager manager = createDownloadManager(null); IStatus result = manager.start(null); assertTrue("1.0", result.isOK()); } @@ -44,7 +44,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest { */ public void testEmptyWithContext() { ProvisioningContext context = new ProvisioningContext(); - DownloadManager manager = new DownloadManager(context); + DownloadManager manager = createDownloadManager(context); IStatus result = manager.start(null); assertTrue("1.0", result.isOK()); } @@ -54,7 +54,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest { */ public void testAddNullArtifactRequest() { ProvisioningContext context = new ProvisioningContext(); - DownloadManager manager = new DownloadManager(context); + DownloadManager manager = createDownloadManager(context); try { manager.add((IArtifactRequest) null); } catch (RuntimeException e) { @@ -65,7 +65,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest { public void testAddNullArtifactRequestArray() { ProvisioningContext context = new ProvisioningContext(); - DownloadManager manager = new DownloadManager(context); + DownloadManager manager = createDownloadManager(context); try { manager.add((IArtifactRequest[]) null); } catch (RuntimeException e) { @@ -76,7 +76,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest { public void testAddEmptyArtifactRequestArray() { ProvisioningContext context = new ProvisioningContext(); - DownloadManager manager = new DownloadManager(context); + DownloadManager manager = createDownloadManager(context); manager.add(new IArtifactRequest[0]); IStatus result = manager.start(null); assertTrue("1.0", result.isOK()); @@ -84,7 +84,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest { public void testAddArtifactRequestArrayContainingNull() { ProvisioningContext context = new ProvisioningContext(); - DownloadManager manager = new DownloadManager(context); + DownloadManager manager = createDownloadManager(context); try { IArtifactRequest[] requests = new IArtifactRequest[] {null}; manager.add(requests); @@ -96,7 +96,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest { public void testAddArtifactRequest() { ProvisioningContext context = new ProvisioningContext(); - DownloadManager manager = new DownloadManager(context); + DownloadManager manager = createDownloadManager(context); IArtifactRequest request = createArtifactRequest(); manager.add(request); @@ -108,7 +108,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest { public void testContext() { ProvisioningContext context = new ProvisioningContext(); context.setArtifactRepositories(new URI[0]); - DownloadManager manager = new DownloadManager(context); + DownloadManager manager = createDownloadManager(context); IArtifactRequest request = createArtifactRequest(); manager.add(request); @@ -119,7 +119,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest { public void testAddArtifactRequestArray() { ProvisioningContext context = new ProvisioningContext(); - DownloadManager manager = new DownloadManager(context); + DownloadManager manager = createDownloadManager(context); IArtifactRequest[] requests = new IArtifactRequest[] {createArtifactRequest()}; manager.add(requests); @@ -144,7 +144,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest { public void testEmptyArtifactRepositoryListContext() { ProvisioningContext context = new ProvisioningContext(); context.setArtifactRepositories(new URI[0]); - DownloadManager manager = new DownloadManager(context); + DownloadManager manager = createDownloadManager(context); IArtifactRequest[] requests = new IArtifactRequest[] {createArtifactRequest()}; manager.add(requests); @@ -163,7 +163,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest { } context.setArtifactRepositories(artifactRepos); - DownloadManager manager = new DownloadManager(context); + DownloadManager manager = createDownloadManager(context); IArtifactRequest[] requests = new IArtifactRequest[] {createArtifactRequest()}; manager.add(requests); @@ -182,7 +182,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest { } context.setArtifactRepositories(artifactRepos); - DownloadManager manager = new DownloadManager(context); + DownloadManager manager = createDownloadManager(context); IArtifactRequest[] requests = new IArtifactRequest[] {createArtifactRequest()}; manager.add(requests); @@ -201,11 +201,15 @@ public class DownloadManagerTest extends AbstractProvisioningTest { } context.setArtifactRepositories(artifactRepos); - DownloadManager manager = new DownloadManager(context); + DownloadManager manager = createDownloadManager(context); IArtifactRequest[] requests = new IArtifactRequest[] {createArtifactRequest()}; manager.add(requests); IStatus result = manager.start(null); assertTrue("1.0", result.isOK()); } + + private DownloadManager createDownloadManager(ProvisioningContext context) { + return new DownloadManager(context, getArtifactRepositoryManager()); + } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java index b82177bb7..96349ca5e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java @@ -10,15 +10,23 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.engine; +import org.eclipse.equinox.p2.metadata.Version; + import java.io.File; import java.util.*; import org.eclipse.core.runtime.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.engine.phases.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.p2.engine.*; +import org.eclipse.equinox.internal.p2.engine.phases.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.engine.spi.ProvisioningAction; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.Collector; +import org.eclipse.equinox.p2.query.IQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.ServiceReference; @@ -64,7 +72,7 @@ public class EngineTest extends AbstractProvisioningTest { return super.initializePhase(monitor, profile, parameters); } - protected ProvisioningAction[] getActions(Operand operand) { + protected List<ProvisioningAction> getActions(Operand operand) { return null; } @@ -83,7 +91,7 @@ public class EngineTest extends AbstractProvisioningTest { throw new NullPointerException(); } - protected ProvisioningAction[] getActions(Operand operand) { + protected List<ProvisioningAction> getActions(Operand operand) { return null; } } @@ -97,7 +105,7 @@ public class EngineTest extends AbstractProvisioningTest { this(false); } - protected ProvisioningAction[] getActions(Operand operand) { + protected List<ProvisioningAction> getActions(Operand operand) { ProvisioningAction action = new ProvisioningAction() { public IStatus undo(Map parameters) { @@ -108,7 +116,7 @@ public class EngineTest extends AbstractProvisioningTest { throw new NullPointerException(); } }; - return new ProvisioningAction[] {action}; + return Collections.singletonList(action); } } @@ -165,10 +173,9 @@ public class EngineTest extends AbstractProvisioningTest { public void testNullProfile() { IProfile profile = null; - PhaseSet phaseSet = new DefaultPhaseSet(); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {}; try { - engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); } catch (IllegalArgumentException expected) { return; } @@ -181,32 +188,89 @@ public class EngineTest extends AbstractProvisioningTest { PhaseSet phaseSet = null; InstallableUnitOperand[] operands = new InstallableUnitOperand[] {}; try { - engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); } catch (IllegalArgumentException expected) { return; } fail(); } - public void testNullOperands() { + public void testNullPlan() { - IProfile profile = createProfile("test"); - PhaseSet phaseSet = new DefaultPhaseSet(); - InstallableUnitOperand[] operands = null; try { - engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + engine.perform(null, new NullProgressMonitor()); fail(); - } catch (IllegalArgumentException expected) { + } catch (RuntimeException expected) { + //expected + } + } + + /* + * Tests for {@link IEngine#createPhaseSetExcluding}. + */ + public void testCreatePhaseSetExcluding() { + //null argument + IPhaseSet set = engine.createPhaseSetExcluding(null); + assertEquals("1.0", 7, set.getPhaseIds().length); + + //empty argument + set = engine.createPhaseSetExcluding(new String[0]); + assertEquals("2.0", 7, set.getPhaseIds().length); + + //bogus argument + set = engine.createPhaseSetExcluding(new String[] {"blort"}); + assertEquals("3.0", 7, set.getPhaseIds().length); + + //valid argument + set = engine.createPhaseSetExcluding(new String[] {IPhaseSet.PHASE_CHECK_TRUST}); + final String[] phases = set.getPhaseIds(); + assertEquals("4.0", 6, phases.length); + for (int i = 0; i < phases.length; i++) + if (phases[i].equals(IPhaseSet.PHASE_CHECK_TRUST)) + fail("4.1." + i); + + } + + /* + * Tests for {@link IEngine#createPhaseSetIncluding}. + */ + public void testCreatePhaseSetIncluding() { + //null argument + try { + engine.createPhaseSetIncluding(null); + fail("1.0"); + } catch (RuntimeException e) { //expected } + //empty argument + IPhaseSet set = engine.createPhaseSetIncluding(new String[0]); + assertNotNull("2.0", set); + assertEquals("2.1", 0, set.getPhaseIds().length); + + //unknown argument + set = engine.createPhaseSetIncluding(new String[] {"blort", "not a phase", "bad input"}); + assertNotNull("3.0", set); + assertEquals("3.1", 0, set.getPhaseIds().length); + + //one valid phase + set = engine.createPhaseSetIncluding(new String[] {IPhaseSet.PHASE_COLLECT}); + assertNotNull("4.0", set); + assertEquals("4.1", 1, set.getPhaseIds().length); + assertEquals("4.2", IPhaseSet.PHASE_COLLECT, set.getPhaseIds()[0]); + + //one valid phase and one bogus + set = engine.createPhaseSetIncluding(new String[] {IPhaseSet.PHASE_COLLECT, "bogus"}); + assertNotNull("4.0", set); + assertEquals("4.1", 1, set.getPhaseIds().length); + assertEquals("4.2", IPhaseSet.PHASE_COLLECT, set.getPhaseIds()[0]); + } public void testEmptyOperands() { IProfile profile = createProfile("test"); - PhaseSet phaseSet = new DefaultPhaseSet(); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertTrue(result.isOK()); } @@ -219,7 +283,7 @@ public class EngineTest extends AbstractProvisioningTest { InstallableUnitOperand op = new InstallableUnitOperand(createResolvedIU(createIU("name")), null); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {op}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); assertTrue(result.isOK()); } @@ -235,7 +299,6 @@ public class EngineTest extends AbstractProvisioningTest { public void testPerformPropertyInstallUninstall() { IProfile profile = createProfile("testPerformPropertyInstallUninstall"); - PhaseSet phaseSet = new DefaultPhaseSet(); PropertyOperand propOp = new PropertyOperand("test", null, "test"); IInstallableUnit testIU = createResolvedIU(createIU("test")); @@ -243,7 +306,7 @@ public class EngineTest extends AbstractProvisioningTest { InstallableUnitPropertyOperand iuPropOp = new InstallableUnitPropertyOperand(testIU, "test", null, "test"); Operand[] operands = new Operand[] {propOp, iuOp, iuPropOp}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertTrue(result.isOK()); assertEquals("test", profile.getProperty("test")); assertEquals("test", profile.getInstallableUnitProperty(testIU, "test")); @@ -251,7 +314,7 @@ public class EngineTest extends AbstractProvisioningTest { PropertyOperand uninstallPropOp = new PropertyOperand("test", "test", null); InstallableUnitPropertyOperand uninstallIuPropOp = new InstallableUnitPropertyOperand(testIU, "test", "test", null); operands = new Operand[] {uninstallPropOp, uninstallIuPropOp}; - result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertTrue(result.isOK()); assertNull("test", profile.getProperty("test")); assertNull("test", profile.getInstallableUnitProperty(testIU, "test")); @@ -262,18 +325,17 @@ public class EngineTest extends AbstractProvisioningTest { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformSizing", null, properties); + IProfile profile = createProfile("testPerformSizing", properties); for (Iterator it = getInstallableUnits(profile); it.hasNext();) { - PhaseSet phaseSet = new DefaultPhaseSet(); IInstallableUnit doomed = (IInstallableUnit) it.next(); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(createResolvedIU(doomed), null)}; - engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); } final Sizing sizingPhase = new Sizing(100, "sizing"); PhaseSet phaseSet = new PhaseSet(new Phase[] {sizingPhase}) {}; InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU())}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); assertTrue(result.isOK()); assertTrue(sizingPhase.getDiskSize() == 0); assertTrue(sizingPhase.getDlSize() == 0); @@ -283,17 +345,15 @@ public class EngineTest extends AbstractProvisioningTest { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformInstallOSGiFramework", null, properties); + IProfile profile = createProfile("testPerformInstallOSGiFramework", properties); for (Iterator it = getInstallableUnits(profile); it.hasNext();) { - PhaseSet phaseSet = new DefaultPhaseSet(); IInstallableUnit doomed = (IInstallableUnit) it.next(); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(createResolvedIU(doomed), null)}; - engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); } PhaseSet phaseSet = new DefaultPhaseSet(); - InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU())}; - IStatus result = engine.validate(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = ((Engine) engine).validate(profile, phaseSet, operands, null, new NullProgressMonitor()); assertTrue(result.isOK()); } @@ -301,17 +361,14 @@ public class EngineTest extends AbstractProvisioningTest { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformInstallOSGiFramework", null, properties); + IProfile profile = createProfile("testPerformInstallOSGiFramework", properties); for (Iterator it = getInstallableUnits(profile); it.hasNext();) { - PhaseSet phaseSet = new DefaultPhaseSet(); IInstallableUnit doomed = (IInstallableUnit) it.next(); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(createResolvedIU(doomed), null)}; - engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); } - PhaseSet phaseSet = new DefaultPhaseSet(); - InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU())}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertTrue(result.isOK()); Iterator ius = getInstallableUnits(profile); assertTrue(ius.hasNext()); @@ -320,22 +377,21 @@ public class EngineTest extends AbstractProvisioningTest { public void testPerformUpdateOSGiFramework() { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformUpdateOSGiFramework", null, properties); - PhaseSet phaseSet = new DefaultPhaseSet(); + IProfile profile = createProfile("testPerformUpdateOSGiFramework", properties); IInstallableUnit iu33 = createOSGiIU("3.3"); IInstallableUnit iu34 = createOSGiIU("3.4"); InstallableUnitOperand[] installOperands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, iu33)}; - IStatus result = engine.perform(profile, phaseSet, installOperands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, installOperands, null), new NullProgressMonitor()); assertTrue(result.isOK()); - Iterator ius = profile.query(new InstallableUnitQuery(iu33), new Collector(), null).iterator(); + Iterator ius = profile.query(new InstallableUnitQuery(iu33), null).iterator(); assertTrue(ius.hasNext()); InstallableUnitOperand[] updateOperands = new InstallableUnitOperand[] {new InstallableUnitOperand(iu33, iu34)}; - result = engine.perform(profile, phaseSet, updateOperands, null, new NullProgressMonitor()); + result = engine.perform(engine.createCustomPlan(profile, updateOperands, null), new NullProgressMonitor()); assertTrue(result.isOK()); - ius = profile.query(new InstallableUnitQuery(iu34), new Collector(), null).iterator(); + ius = profile.query(new InstallableUnitQuery(iu34), null).iterator(); assertTrue(ius.hasNext()); } @@ -344,10 +400,9 @@ public class EngineTest extends AbstractProvisioningTest { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformUninstallOSGiFramework", null, properties); - PhaseSet phaseSet = new DefaultPhaseSet(); + IProfile profile = createProfile("testPerformUninstallOSGiFramework", properties); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(createOSGiIU(), null)}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertTrue(result.isOK()); assertEmptyProfile(profile); } @@ -356,14 +411,13 @@ public class EngineTest extends AbstractProvisioningTest { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformRollback", null, properties); - PhaseSet phaseSet = new DefaultPhaseSet(); + IProfile profile = createProfile("testPerformRollback", properties); Iterator ius = getInstallableUnits(profile); assertFalse(ius.hasNext()); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU()), new InstallableUnitOperand(null, createBadIU())}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertFalse(result.isOK()); ius = getInstallableUnits(profile); @@ -374,14 +428,14 @@ public class EngineTest extends AbstractProvisioningTest { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformRollback", null, properties); + IProfile profile = createProfile("testPerformRollback", properties); PhaseSet phaseSet = new DefaultPhaseSet(); Iterator ius = getInstallableUnits(profile); assertFalse(ius.hasNext()); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU()), new InstallableUnitOperand(null, createMissingActionIU())}; - IStatus result = engine.validate(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = ((Engine) engine).validate(profile, phaseSet, operands, null, new NullProgressMonitor()); assertFalse(result.isOK()); Throwable t = result.getException(); @@ -394,14 +448,13 @@ public class EngineTest extends AbstractProvisioningTest { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformMissingAction", null, properties); - PhaseSet phaseSet = new DefaultPhaseSet(); + IProfile profile = createProfile("testPerformMissingAction", properties); Iterator ius = getInstallableUnits(profile); assertFalse(ius.hasNext()); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU()), new InstallableUnitOperand(null, createMissingActionIU())}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertFalse(result.isOK()); ius = getInstallableUnits(profile); assertFalse(ius.hasNext()); @@ -411,7 +464,7 @@ public class EngineTest extends AbstractProvisioningTest { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformRollbackOnError", null, properties); + IProfile profile = createProfile("testPerformRollbackOnError", properties); NPEPhase phase = new NPEPhase(); PhaseSet phaseSet = new TestPhaseSet(phase); @@ -419,7 +472,7 @@ public class EngineTest extends AbstractProvisioningTest { assertFalse(ius.hasNext()); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU())}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); assertFalse(result.isOK()); ius = getInstallableUnits(profile); assertFalse(ius.hasNext()); @@ -430,7 +483,7 @@ public class EngineTest extends AbstractProvisioningTest { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformRollbackOnError", null, properties); + IProfile profile = createProfile("testPerformRollbackOnError", properties); ActionNPEPhase phase = new ActionNPEPhase(); PhaseSet phaseSet = new TestPhaseSet(phase); @@ -438,7 +491,7 @@ public class EngineTest extends AbstractProvisioningTest { assertFalse(ius.hasNext()); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU())}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); assertFalse(result.isOK()); ius = getInstallableUnits(profile); assertFalse(ius.hasNext()); @@ -448,7 +501,7 @@ public class EngineTest extends AbstractProvisioningTest { public void testPerformForcedPhaseWithActionError() { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformForceWithActionError", null, properties); + IProfile profile = createProfile("testPerformForceWithActionError", properties); ActionNPEPhase phase = new ActionNPEPhase(true); PhaseSet phaseSet = new TestPhaseSet(phase); @@ -456,7 +509,7 @@ public class EngineTest extends AbstractProvisioningTest { assertFalse(ius.hasNext()); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU())}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); assertTrue(result.isOK()); ius = getInstallableUnits(profile); assertTrue(ius.hasNext()); @@ -466,7 +519,7 @@ public class EngineTest extends AbstractProvisioningTest { public void testPerformForcedUninstallWithBadUninstallIUActionThrowsException() { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformForcedUninstallWithBadUninstallIUActionThrowsException", null, properties); + IProfile profile = createProfile("testPerformForcedUninstallWithBadUninstallIUActionThrowsException", properties); // forcedUninstall is false by default PhaseSet phaseSet = new DefaultPhaseSet(); @@ -476,20 +529,20 @@ public class EngineTest extends AbstractProvisioningTest { IInstallableUnit badUninstallIU = createBadUninstallIUThrowsException(); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, badUninstallIU)}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertTrue(result.isOK()); ius = getInstallableUnits(profile); assertTrue(ius.hasNext()); operands = new InstallableUnitOperand[] {new InstallableUnitOperand(badUninstallIU, null)}; - result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertFalse(result.isOK()); ius = getInstallableUnits(profile); assertTrue(ius.hasNext()); // this simulates a DefaultPhaseSet with forcedUninstall set phaseSet = new TestPhaseSet(true); - result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); assertTrue(result.isOK()); ius = getInstallableUnits(profile); assertFalse(ius.hasNext()); @@ -498,30 +551,29 @@ public class EngineTest extends AbstractProvisioningTest { public void testPerformForcedUninstallWithBadUninstallIUActionReturnsError() { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath()); - IProfile profile = createProfile("testPerformForcedUninstallWithBadUninstallIUActionReturnsError", null, properties); + IProfile profile = createProfile("testPerformForcedUninstallWithBadUninstallIUActionReturnsError", properties); // forcedUninstall is false by default - PhaseSet phaseSet = new DefaultPhaseSet(); Iterator ius = getInstallableUnits(profile); assertFalse(ius.hasNext()); IInstallableUnit badUninstallIU = createBadUninstallIUReturnsError(); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, badUninstallIU)}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertTrue(result.isOK()); ius = getInstallableUnits(profile); assertTrue(ius.hasNext()); operands = new InstallableUnitOperand[] {new InstallableUnitOperand(badUninstallIU, null)}; - result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertFalse(result.isOK()); ius = getInstallableUnits(profile); assertTrue(ius.hasNext()); // this simulates a DefaultPhaseSet with forcedUninstall set - phaseSet = new TestPhaseSet(true); - result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IPhaseSet phaseSet = new TestPhaseSet(true); + result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); assertTrue(result.isOK()); ius = getInstallableUnits(profile); assertFalse(ius.hasNext()); @@ -529,15 +581,14 @@ public class EngineTest extends AbstractProvisioningTest { public void testOrphanedIUProperty() { IProfile profile = createProfile("testOrphanedIUProperty"); - PhaseSet phaseSet = new DefaultPhaseSet(); IInstallableUnit iu = createIU("someIU"); Operand[] operands = new InstallableUnitPropertyOperand[] {new InstallableUnitPropertyOperand(iu, "key", null, "value")}; - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertTrue(result.isOK()); assertFalse(profile.getInstallableUnitProperties(iu).containsKey("key")); operands = new Operand[] {new InstallableUnitOperand(null, iu), new InstallableUnitPropertyOperand(iu, "adifferentkey", null, "value")}; - result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertTrue(result.isOK()); assertTrue(profile.getInstallableUnitProperties(iu).containsKey("adifferentkey")); assertFalse(profile.getInstallableUnitProperties(iu).containsKey("key")); @@ -550,7 +601,7 @@ public class EngineTest extends AbstractProvisioningTest { private IInstallableUnit createOSGiIU(String version) { InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription(); description.setId("org.eclipse.osgi"); - description.setVersion(new Version(version)); + description.setVersion(Version.create(version)); description.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI); Map touchpointData = new HashMap(); String manifest = "Manifest-Version: 1.0\r\n" + "Bundle-Activator: org.eclipse.osgi.framework.internal.core.SystemBundl\r\n" + " eActivator\r\n" + "Bundle-RequiredExecutionEnvironment: J2SE-1.4,OSGi/Minimum-1.0\r\n" + "Export-Package: org.eclipse.osgi.event;version=\"1.0\",org.eclipse.osgi.\r\n" + " framework.console;version=\"1.0\",org.eclipse.osgi.framework.eventmgr;v\r\n" + " ersion=\"1.0\",org.eclipse.osgi.framework.log;version=\"1.0\",org.eclipse\r\n" + " .osgi.service.datalocation;version=\"1.0\",org.eclipse.osgi.service.deb\r\n" + " ug;version=\"1.0\",org.eclipse.osgi.service.environment;version=\"1.0\",o\r\n" + " rg.eclipse.osgi.service.localization;version=\"1.0\",org.eclipse.osgi.s\r\n" + " ervice.pluginconversion;version=\"1.0\",org.eclipse.osgi.service.resolv\r\n" @@ -568,7 +619,7 @@ public class EngineTest extends AbstractProvisioningTest { IInstallableUnitFragment fragment = MetadataFactory.createInstallableUnitFragment(desc); cus[0] = fragment; - //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", new Version("3.3.1.R33x_v20070828")); + //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", Version.create("3.3.1.R33x_v20070828")); //iu.setArtifacts(new IArtifactKey[] {key}); IInstallableUnit iu = MetadataFactory.createInstallableUnit(description); @@ -578,7 +629,7 @@ public class EngineTest extends AbstractProvisioningTest { private IInstallableUnit createBadIU() { InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription(); description.setId("org.eclipse.osgi.bad"); - description.setVersion(new Version("3.3.1.R33x_v20070828")); + description.setVersion(Version.create("3.3.1.R33x_v20070828")); description.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI); Map touchpointData = new HashMap(); String manifest = "Manifest-Version: 1.0\r\n" + "Bundle-Activator: org.eclipse.osgi.framework.internal.core.SystemBundl\r\n" + " eActivator\r\n" + "Bundle-RequiredExecutionEnvironment: J2SE-1.4,OSGi/Minimum-1.0\r\n" + "Export-Package: org.eclipse.osgi.event;version=\"1.0\",org.eclipse.osgi.\r\n" + " framework.console;version=\"1.0\",org.eclipse.osgi.framework.eventmgr;v\r\n" + " ersion=\"1.0\",org.eclipse.osgi.framework.log;version=\"1.0\",org.eclipse\r\n" + " .osgi.service.datalocation;version=\"1.0\",org.eclipse.osgi.service.deb\r\n" + " ug;version=\"1.0\",org.eclipse.osgi.service.environment;version=\"1.0\",o\r\n" + " rg.eclipse.osgi.service.localization;version=\"1.0\",org.eclipse.osgi.s\r\n" + " ervice.pluginconversion;version=\"1.0\",org.eclipse.osgi.service.resolv\r\n" @@ -594,7 +645,7 @@ public class EngineTest extends AbstractProvisioningTest { desc.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData)); cus[0] = MetadataFactory.createInstallableUnitFragment(desc); - //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", new Version("3.3.1.R33x_v20070828")); + //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", Version.create("3.3.1.R33x_v20070828")); //iu.setArtifacts(new IArtifactKey[] {key}); IInstallableUnit iu = MetadataFactory.createInstallableUnit(description); @@ -604,7 +655,7 @@ public class EngineTest extends AbstractProvisioningTest { private IInstallableUnit createBadUninstallIUReturnsError() { InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription(); description.setId("org.eclipse.osgi.bad"); - description.setVersion(new Version("3.3.1.R33x_v20070828")); + description.setVersion(Version.create("3.3.1.R33x_v20070828")); description.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI); Map touchpointData = new HashMap(); String manifest = "Manifest-Version: 1.0\r\n" + "Bundle-Activator: org.eclipse.osgi.framework.internal.core.SystemBundl\r\n" + " eActivator\r\n" + "Bundle-RequiredExecutionEnvironment: J2SE-1.4,OSGi/Minimum-1.0\r\n" + "Export-Package: org.eclipse.osgi.event;version=\"1.0\",org.eclipse.osgi.\r\n" + " framework.console;version=\"1.0\",org.eclipse.osgi.framework.eventmgr;v\r\n" + " ersion=\"1.0\",org.eclipse.osgi.framework.log;version=\"1.0\",org.eclipse\r\n" + " .osgi.service.datalocation;version=\"1.0\",org.eclipse.osgi.service.deb\r\n" + " ug;version=\"1.0\",org.eclipse.osgi.service.environment;version=\"1.0\",o\r\n" + " rg.eclipse.osgi.service.localization;version=\"1.0\",org.eclipse.osgi.s\r\n" + " ervice.pluginconversion;version=\"1.0\",org.eclipse.osgi.service.resolv\r\n" @@ -620,7 +671,7 @@ public class EngineTest extends AbstractProvisioningTest { desc.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData)); cus[0] = MetadataFactory.createInstallableUnitFragment(desc); - //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", new Version("3.3.1.R33x_v20070828")); + //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", Version.create("3.3.1.R33x_v20070828")); //iu.setArtifacts(new IArtifactKey[] {key}); IInstallableUnit iu = MetadataFactory.createInstallableUnit(description); @@ -630,7 +681,7 @@ public class EngineTest extends AbstractProvisioningTest { private IInstallableUnit createBadUninstallIUThrowsException() { InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription(); description.setId("org.eclipse.osgi.bad"); - description.setVersion(new Version("3.3.1.R33x_v20070828")); + description.setVersion(Version.create("3.3.1.R33x_v20070828")); description.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI); Map touchpointData = new HashMap(); String manifest = "Manifest-Version: 1.0\r\n" + "Bundle-Activator: org.eclipse.osgi.framework.internal.core.SystemBundl\r\n" + " eActivator\r\n" + "Bundle-RequiredExecutionEnvironment: J2SE-1.4,OSGi/Minimum-1.0\r\n" + "Export-Package: org.eclipse.osgi.event;version=\"1.0\",org.eclipse.osgi.\r\n" + " framework.console;version=\"1.0\",org.eclipse.osgi.framework.eventmgr;v\r\n" + " ersion=\"1.0\",org.eclipse.osgi.framework.log;version=\"1.0\",org.eclipse\r\n" + " .osgi.service.datalocation;version=\"1.0\",org.eclipse.osgi.service.deb\r\n" + " ug;version=\"1.0\",org.eclipse.osgi.service.environment;version=\"1.0\",o\r\n" + " rg.eclipse.osgi.service.localization;version=\"1.0\",org.eclipse.osgi.s\r\n" + " ervice.pluginconversion;version=\"1.0\",org.eclipse.osgi.service.resolv\r\n" @@ -646,7 +697,7 @@ public class EngineTest extends AbstractProvisioningTest { desc.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData)); cus[0] = MetadataFactory.createInstallableUnitFragment(desc); - //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", new Version("3.3.1.R33x_v20070828")); + //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", Version.create("3.3.1.R33x_v20070828")); //iu.setArtifacts(new IArtifactKey[] {key}); IInstallableUnit iu = MetadataFactory.createInstallableUnit(description); @@ -656,7 +707,7 @@ public class EngineTest extends AbstractProvisioningTest { private IInstallableUnit createMissingActionIU() { InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription(); description.setId("org.eclipse.osgi.bad"); - description.setVersion(new Version("3.3.1.R33x_v20070828")); + description.setVersion(Version.create("3.3.1.R33x_v20070828")); description.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI); Map touchpointData = new HashMap(); String manifest = "Manifest-Version: 1.0\r\n" + "Bundle-Activator: org.eclipse.osgi.framework.internal.core.SystemBundl\r\n" + " eActivator\r\n" + "Bundle-RequiredExecutionEnvironment: J2SE-1.4,OSGi/Minimum-1.0\r\n" + "Export-Package: org.eclipse.osgi.event;version=\"1.0\",org.eclipse.osgi.\r\n" + " framework.console;version=\"1.0\",org.eclipse.osgi.framework.eventmgr;v\r\n" + " ersion=\"1.0\",org.eclipse.osgi.framework.log;version=\"1.0\",org.eclipse\r\n" + " .osgi.service.datalocation;version=\"1.0\",org.eclipse.osgi.service.deb\r\n" + " ug;version=\"1.0\",org.eclipse.osgi.service.environment;version=\"1.0\",o\r\n" + " rg.eclipse.osgi.service.localization;version=\"1.0\",org.eclipse.osgi.s\r\n" + " ervice.pluginconversion;version=\"1.0\",org.eclipse.osgi.service.resolv\r\n" @@ -672,7 +723,7 @@ public class EngineTest extends AbstractProvisioningTest { desc.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData)); cus[0] = MetadataFactory.createInstallableUnitFragment(desc); - //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", new Version("3.3.1.R33x_v20070828")); + //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", Version.create("3.3.1.R33x_v20070828")); //iu.setArtifacts(new IArtifactKey[] {key}); IInstallableUnit iu = MetadataFactory.createInstallableUnit(description); @@ -682,8 +733,8 @@ public class EngineTest extends AbstractProvisioningTest { public void testIncompatibleProfile() { IProfile profile = new IProfile() { - public Collector available(Query query, Collector collector, IProgressMonitor monitor) { - return null; + public Collector available(IQuery query, IProgressMonitor monitor) { + return new Collector(); } public Map getInstallableUnitProperties(IInstallableUnit iu) { @@ -694,18 +745,6 @@ public class EngineTest extends AbstractProvisioningTest { return null; } - public Map getLocalProperties() { - return null; - } - - public String getLocalProperty(String key) { - return null; - } - - public IProfile getParentProfile() { - return null; - } - public String getProfileId() { return null; } @@ -718,30 +757,17 @@ public class EngineTest extends AbstractProvisioningTest { return null; } - public String[] getSubProfileIds() { - return null; - } - public long getTimestamp() { return 0; } - public boolean hasSubProfiles() { - return false; - } - - public boolean isRootProfile() { - return false; - } - - public Collector query(Query query, Collector collector, IProgressMonitor monitor) { - return null; + public Collector query(IQuery query, IProgressMonitor monitor) { + return new Collector(); } }; - PhaseSet phaseSet = new DefaultPhaseSet(); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {}; try { - engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); } catch (IllegalArgumentException expected) { return; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java index ec2f10ea2..c37eabce8 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java @@ -10,23 +10,24 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.engine; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; +import java.util.List; import java.util.Map; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.engine.ActionManager; import org.eclipse.equinox.internal.p2.engine.InstructionParser; -import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction; -import org.eclipse.equinox.internal.provisional.p2.engine.Touchpoint; -import org.eclipse.equinox.internal.provisional.p2.metadata.ITouchpointType; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.engine.spi.ProvisioningAction; +import org.eclipse.equinox.p2.engine.spi.Touchpoint; +import org.eclipse.equinox.p2.metadata.ITouchpointType; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class InstructionParserTest extends AbstractProvisioningTest { - public static final ITouchpointType TOUCHPOINT_TYPE = MetadataFactory.createTouchpointType("InstructionParserTestTouchpoint", new Version("1.0")); //$NON-NLS-1$ //$NON-NLS-2$ + public static final ITouchpointType TOUCHPOINT_TYPE = MetadataFactory.createTouchpointType("InstructionParserTestTouchpoint", Version.create("1.0")); //$NON-NLS-1$ //$NON-NLS-2$ public static class InstructionParserTestTouchpoint extends Touchpoint { @@ -65,21 +66,21 @@ public class InstructionParserTest extends AbstractProvisioningTest { public void testGoodAction() { InstructionParser parser = new InstructionParser(new ActionManager()); - ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction()", null), TOUCHPOINT_TYPE); - assertEquals(1, actions.length); + List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction()", null), TOUCHPOINT_TYPE); + assertEquals(1, actions.size()); } public void testGoodActionFullyQualified() { InstructionParser parser = new InstructionParser(new ActionManager()); - ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("instructionparsertest.goodAction()", null), null); - assertEquals(1, actions.length); + List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("instructionparsertest.goodAction()", null), null); + assertEquals(1, actions.size()); } public void testBadActionFullyQualified() { InstructionParser parser = new InstructionParser(new ActionManager()); try { - ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("instructionparsertest.badAction()", null), null); - actions[0].execute(null); + List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("instructionparsertest.badAction()", null), null); + actions.get(0).execute(null); } catch (IllegalArgumentException e) { return; } @@ -88,21 +89,21 @@ public class InstructionParserTest extends AbstractProvisioningTest { public void testGoodActionFromImport() { InstructionParser parser = new InstructionParser(new ActionManager()); - ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction()", "instructionparsertest.goodAction"), null); - assertEquals(1, actions.length); + List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction()", "instructionparsertest.goodAction"), null); + assertEquals(1, actions.size()); } public void testGoodActionFromImportWithVersionRange() { InstructionParser parser = new InstructionParser(new ActionManager()); - ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction()", "instructionparsertest.goodAction;version=[1.0,2.0)"), null); - assertEquals(1, actions.length); + List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction()", "instructionparsertest.goodAction;version=[1.0,2.0)"), null); + assertEquals(1, actions.size()); } public void testBadActionFromImport() { InstructionParser parser = new InstructionParser(new ActionManager()); try { - ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("badAction()", "instructionparsertest.badAction"), null); - actions[0].execute(null); + List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("badAction()", "instructionparsertest.badAction"), null); + actions.get(0).execute(null); } catch (IllegalArgumentException e) { return; } @@ -111,20 +112,20 @@ public class InstructionParserTest extends AbstractProvisioningTest { public void testGoodActions() { InstructionParser parser = new InstructionParser(new ActionManager()); - ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(); goodAction()", null), TOUCHPOINT_TYPE); - assertEquals(2, actions.length); + List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(); goodAction()", null), TOUCHPOINT_TYPE); + assertEquals(2, actions.size()); } public void testGoodParameter() { InstructionParser parser = new InstructionParser(new ActionManager()); - ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(a:1)", null), TOUCHPOINT_TYPE); - assertEquals(1, actions.length); + List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(a:1)", null), TOUCHPOINT_TYPE); + assertEquals(1, actions.size()); } public void testGoodParameters() { InstructionParser parser = new InstructionParser(new ActionManager()); - ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(a:1, b:2)", null), TOUCHPOINT_TYPE); - assertEquals(1, actions.length); + List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(a:1, b:2)", null), TOUCHPOINT_TYPE); + assertEquals(1, actions.size()); } public void testBadParameter() { @@ -160,8 +161,8 @@ public class InstructionParserTest extends AbstractProvisioningTest { public void testGoodActionBadAction() { InstructionParser parser = new InstructionParser(new ActionManager()); try { - ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(); badAction()", null), TOUCHPOINT_TYPE); - actions[1].execute(null); + List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(); badAction()", null), TOUCHPOINT_TYPE); + actions.get(1).execute(null); } catch (IllegalArgumentException e) { return; } @@ -171,8 +172,8 @@ public class InstructionParserTest extends AbstractProvisioningTest { public void testNoActionFound() { InstructionParser parser = new InstructionParser(new ActionManager()); try { - ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("notfoundaction()", null), TOUCHPOINT_TYPE); - actions[0].execute(null); + List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("notfoundaction()", null), TOUCHPOINT_TYPE); + actions.get(0).execute(null); } catch (IllegalArgumentException e) { return; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java index 10ad1b8a7..e0069225f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.Map; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.engine.ParameterizedProvisioningAction; -import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction; +import org.eclipse.equinox.p2.engine.spi.ProvisioningAction; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class ParameterizedProvisioningActionTest extends AbstractProvisioningTest { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java index c8da12b6e..a717ac609 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java @@ -10,11 +10,11 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.engine; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.engine.phases.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.p2.engine.phases.*; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** @@ -32,8 +32,8 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest { public void testCollectPhase() { - IInstallableUnit iuXv1 = createIU("iuX", new Version("1.0.0")); - IInstallableUnit iuXv2 = createIU("iuX", new Version("2.0.0")); + IInstallableUnit iuXv1 = createIU("iuX", Version.create("1.0.0")); + IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0")); Collect collectPhase = new Collect(1) { protected boolean isApplicable(InstallableUnitOperand op) { @@ -48,8 +48,8 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest { public void testSizingPhase() { - IInstallableUnit iuXv1 = createIU("iuX", new Version("1.0.0")); - IInstallableUnit iuXv2 = createIU("iuX", new Version("2.0.0")); + IInstallableUnit iuXv1 = createIU("iuX", Version.create("1.0.0")); + IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0")); Sizing sizingPhase = new Sizing(1, "collect") { protected boolean isApplicable(InstallableUnitOperand op) { @@ -64,8 +64,8 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest { public void testUnconfigurePhase() { - IInstallableUnit iuXv1 = createIU("iuX", new Version("1.0.0")); - IInstallableUnit iuXv2 = createIU("iuX", new Version("2.0.0")); + IInstallableUnit iuXv1 = createIU("iuX", Version.create("1.0.0")); + IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0")); Unconfigure unconfigurePhase = new Unconfigure(1) { protected boolean isApplicable(InstallableUnitOperand op) { @@ -80,8 +80,8 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest { public void testUninstallPhase() { - IInstallableUnit iuXv1 = createIU("iuX", new Version("1.0.0")); - IInstallableUnit iuXv2 = createIU("iuX", new Version("2.0.0")); + IInstallableUnit iuXv1 = createIU("iuX", Version.create("1.0.0")); + IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0")); Uninstall uninstallPhase = new Uninstall(1) { protected boolean isApplicable(InstallableUnitOperand op) { @@ -96,8 +96,8 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest { public void testInstallPhase() { - IInstallableUnit iuXv1 = createIU("iuX", new Version("1.0.0")); - IInstallableUnit iuXv2 = createIU("iuX", new Version("2.0.0")); + IInstallableUnit iuXv1 = createIU("iuX", Version.create("1.0.0")); + IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0")); Install installPhase = new Install(1) { protected boolean isApplicable(InstallableUnitOperand op) { @@ -112,8 +112,8 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest { public void testConfigurePhase() { - IInstallableUnit iuXv1 = createIU("iuX", new Version("1.0.0")); - IInstallableUnit iuXv2 = createIU("iuX", new Version("2.0.0")); + IInstallableUnit iuXv1 = createIU("iuX", Version.create("1.0.0")); + IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0")); Configure configurePhase = new Configure(1) { protected boolean isApplicable(InstallableUnitOperand op) { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java index 7f714321b..2faad7acf 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java @@ -12,7 +12,8 @@ package org.eclipse.equinox.p2.tests.engine; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.internal.provisional.p2.engine.*; +import org.eclipse.equinox.internal.p2.engine.*; +import org.eclipse.equinox.p2.engine.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** @@ -53,7 +54,7 @@ public class PhaseSetTest extends AbstractProvisioningTest { InstallableUnitOperand[] operands = new InstallableUnitOperand[] {op}; ProvisioningContext context = new ProvisioningContext(); - IStatus result = phaseSet.perform(null, new EngineSession(profile, null, context), profile, operands, context, new NullProgressMonitor()); + IStatus result = phaseSet.perform(new EngineSession(null, profile, context), operands, new NullProgressMonitor()); assertTrue(result.isOK()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java index 5f26f5e68..30b6b1d8c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java @@ -10,15 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.engine; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.io.IOException; import java.util.*; import org.eclipse.core.runtime.*; -import org.eclipse.equinox.internal.p2.engine.ParameterizedProvisioningAction; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.p2.engine.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.engine.spi.ProvisioningAction; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.ServiceReference; @@ -79,9 +81,9 @@ public class PhaseTest extends AbstractProvisioningTest { return super.initializePhase(monitor, profile, parameters); } - protected ProvisioningAction[] getActions(InstallableUnitOperand operand) { + protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) { IInstallableUnit unit = operand.second(); - ProvisioningAction[] parsedActions = getActions(unit, phaseId); + List<ProvisioningAction> parsedActions = getActions(unit, phaseId); if (parsedActions != null) return parsedActions; @@ -94,7 +96,7 @@ public class PhaseTest extends AbstractProvisioningTest { if (action == null) { throw new IllegalArgumentException("action not found: " + phaseId); } - return new ProvisioningAction[] {action}; + return Collections.singletonList(action); } } @@ -160,7 +162,8 @@ public class PhaseTest extends AbstractProvisioningTest { PhaseSet phaseSet = new TestPhaseSet(new TestPhase()); IProfile profile = createProfile("PhaseTest"); - engine.perform(profile, phaseSet, new InstallableUnitOperand[0], null, new NullProgressMonitor()); + final InstallableUnitOperand[] operands = new InstallableUnitOperand[0]; + engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); } public void testInitCompletePhase() { @@ -186,7 +189,8 @@ public class PhaseTest extends AbstractProvisioningTest { PhaseSet phaseSet = new TestPhaseSet(phase); IProfile profile = createProfile("PhaseTest"); IInstallableUnit unit = createIU("unit"); - engine.perform(profile, phaseSet, new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)}, null, new NullProgressMonitor()); + final InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)}; + engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); assertTrue(phase.initializePhase); assertTrue(phase.completePhase); } @@ -215,7 +219,8 @@ public class PhaseTest extends AbstractProvisioningTest { IProfile profile = createProfile("PhaseTest"); IInstallableUnit unit = createIU("testInitCompleteOperand"); - engine.perform(profile, phaseSet, new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)}, null, new NullProgressMonitor()); + final InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)}; + engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); assertTrue(phase.initializeOperand); assertTrue(phase.completeOperand); } @@ -250,7 +255,8 @@ public class PhaseTest extends AbstractProvisioningTest { IProfile profile = createProfile("PhaseTest"); IInstallableUnit unit = createIU("testGetProfileDataArea"); - engine.perform(profile, phaseSet, new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)}, null, new NullProgressMonitor()); + final InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)}; + engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); assertTrue(phase.initializePhase); assertTrue(phase.completePhase); } @@ -269,17 +275,17 @@ public class PhaseTest extends AbstractProvisioningTest { public void testGetAction() { final ArrayList actionsList1 = new ArrayList(); InstallableUnitPhase phase1 = new InstallableUnitPhase("test", 1) { - protected ProvisioningAction[] getActions(InstallableUnitOperand operand) { - ProvisioningAction[] actions = getActions(operand.second(), "test1"); - actionsList1.addAll(Arrays.asList(actions)); + protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) { + List<ProvisioningAction> actions = getActions(operand.second(), "test1"); + actionsList1.addAll(actions); return actions; } }; final ArrayList actionsList2 = new ArrayList(); InstallableUnitPhase phase2 = new InstallableUnitPhase("test", 1) { - protected ProvisioningAction[] getActions(InstallableUnitOperand operand) { - ProvisioningAction[] actions = getActions(operand.second(), "test2"); - actionsList2.addAll(Arrays.asList(actions)); + protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) { + List<ProvisioningAction> actions = getActions(operand.second(), "test2"); + actionsList2.addAll(actions); return actions; } }; @@ -291,8 +297,9 @@ public class PhaseTest extends AbstractProvisioningTest { instructions.put("test1", MetadataFactory.createTouchpointInstruction("test1.test()", null)); instructions.put("test2", MetadataFactory.createTouchpointInstruction("test2.test()", null)); ITouchpointData touchpointData = MetadataFactory.createTouchpointData(instructions); - IInstallableUnit unit = createIU("test", new Version("1.0.0"), null, NO_REQUIRES, new IProvidedCapability[0], NO_PROPERTIES, ITouchpointType.NONE, touchpointData, false); - IStatus status = engine.perform(profile, phaseSet, new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)}, null, new NullProgressMonitor()); + IInstallableUnit unit = createIU("test", Version.create("1.0.0"), null, NO_REQUIRES, new IProvidedCapability[0], NO_PROPERTIES, ITouchpointType.NONE, touchpointData, false); + final InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)}; + IStatus status = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); if (!status.isOK()) { fail(status.toString()); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileMetadataRepositoryTest.java index 6b5bcc5b8..40b612f58 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileMetadataRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileMetadataRepositoryTest.java @@ -12,16 +12,14 @@ package org.eclipse.equinox.p2.tests.engine; import java.io.File; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; +import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepositoryFactory; import org.eclipse.equinox.internal.p2.engine.*; -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.engine.IProfile; -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.spi.p2.artifact.repository.SimpleArtifactRepositoryFactory; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestActivator; /** * Simple test of the engine API. @@ -73,7 +71,7 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest { IProfile profile = registry.getProfile("SDKPatchingTest"); assertNotNull("0.3", profile); - Collector profileCollector = profile.query(InstallableUnitQuery.ANY, new Collector(), getMonitor()); + IQueryResult profileCollector = profile.query(InstallableUnitQuery.ANY, getMonitor()); assertFalse("0.4", profileCollector.isEmpty()); File simpleProfileFolder = new File(tempFolder, "SDKPatchingTest.profile"); @@ -87,9 +85,9 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest { fail("0.99", e1); } - Collector repoCollector = repo.query(InstallableUnitQuery.ANY, new Collector(), getMonitor()); + IQueryResult repoCollector = repo.query(InstallableUnitQuery.ANY, getMonitor()); assertFalse("1.0", repoCollector.isEmpty()); - assertTrue("1.1", repoCollector.toCollection().containsAll(profileCollector.toCollection())); + assertContains("1.1", repoCollector, profileCollector); } public void testLoadTimestampedProfile() { @@ -101,7 +99,7 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest { IProfile profile = registry.getProfile("SDKPatchingTest"); assertNotNull("0.3", profile); - Collector profileCollector = profile.query(InstallableUnitQuery.ANY, new Collector(), getMonitor()); + IQueryResult profileCollector = profile.query(InstallableUnitQuery.ANY, getMonitor()); assertFalse("0.4", profileCollector.isEmpty()); File simpleProfileFolder = new File(tempFolder, "SDKPatchingTest.profile"); @@ -118,9 +116,9 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest { fail("0.99", e1); } - Collector repoCollector = repo.query(InstallableUnitQuery.ANY, new Collector(), getMonitor()); + IQueryResult repoCollector = repo.query(InstallableUnitQuery.ANY, getMonitor()); assertFalse("1.0", repoCollector.isEmpty()); - assertTrue("1.1", repoCollector.toCollection().containsAll(profileCollector.toCollection())); + assertContains("1.1", repoCollector, profileCollector); } public void DISABLED_testDefaultAgentRepoAndBundlePoolFromProfileRepo() throws InterruptedException { @@ -128,17 +126,19 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest { // /p2/org.eclipse.equinox.p2.engine/profileRegistry"); File tempFolder = getTempFolder(); copy("0.2", testData, tempFolder); - new SimpleArtifactRepositoryFactory().create(tempFolder.toURI(), "", "", null); + final SimpleArtifactRepositoryFactory simpleFactory = new SimpleArtifactRepositoryFactory(); + simpleFactory.setAgent(getAgent()); + simpleFactory.create(tempFolder.toURI(), "", "", null); File defaultAgenRepositoryDirectory = new File(tempFolder, "p2/org.eclipse.equinox.p2.core/cache"); - new SimpleArtifactRepositoryFactory().create(defaultAgenRepositoryDirectory.toURI(), "", "", null); + simpleFactory.create(defaultAgenRepositoryDirectory.toURI(), "", "", null); File profileRegistryFolder = new File(tempFolder, "p2/org.eclipse.equinox.p2.engine/profileRegistry"); SimpleProfileRegistry registry = new SimpleProfileRegistry(profileRegistryFolder, null, false); IProfile profile = registry.getProfile("SDKPatchingTest"); assertNotNull("1.0", profile); - Collector profileCollector = profile.query(InstallableUnitQuery.ANY, new Collector(), getMonitor()); + IQueryResult profileCollector = profile.query(InstallableUnitQuery.ANY, getMonitor()); assertFalse("1.1", profileCollector.isEmpty()); File simpleProfileFolder = new File(profileRegistryFolder, "SDKPatchingTest.profile"); @@ -147,7 +147,7 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest { File timeStampedProfile = new File(simpleProfileFolder, "" + profile.getTimestamp() + ".profile"); assertTrue("1.3", timeStampedProfile.exists()); - IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.context, IArtifactRepositoryManager.class.getName()); + IArtifactRepositoryManager manager = getArtifactRepositoryManager(); assertNotNull("2.0", manager); assertFalse("2.1", manager.contains(tempFolder.toURI())); @@ -159,9 +159,9 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest { fail("2.99", e1); } - Collector repoCollector = repo.query(InstallableUnitQuery.ANY, new Collector(), getMonitor()); + IQueryResult repoCollector = repo.query(InstallableUnitQuery.ANY, getMonitor()); assertFalse("3.0", repoCollector.isEmpty()); - assertTrue("3.1", repoCollector.toCollection().containsAll(profileCollector.toCollection())); + assertContains("3.1", repoCollector, profileCollector); int maxTries = 20; int current = 0; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java index 6f9c50874..81b4a6be3 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java @@ -10,12 +10,21 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.engine; +import java.io.File; +import java.net.URI; +import java.util.Hashtable; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.preferences.IPreferencesService; +import org.eclipse.equinox.internal.p2.core.ProvisioningAgent; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.engine.ProfilePreferences; +import org.eclipse.equinox.p2.core.IAgentLocation; +import org.eclipse.equinox.p2.core.IProvisioningAgent; +import org.eclipse.equinox.p2.engine.ProfileScope; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; +import org.eclipse.equinox.security.storage.EncodingUtils; +import org.osgi.framework.ServiceRegistration; import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.Preferences; @@ -34,20 +43,47 @@ public class ProfilePreferencesTest extends AbstractProvisioningTest { public void testInvalidProfile() { try { //reading and storing for a non-existent profile shouldn't cause any errors - Preferences node = prefServ.getRootNode().node("/profile/NonExistantProfile/testing"); + IAgentLocation agentLocation = (IAgentLocation) getAgent().getService(IAgentLocation.SERVICE_NAME); + String locationString = EncodingUtils.encodeSlashes(agentLocation.getRootLocation().toString()); + Preferences node = prefServ.getRootNode().node("/profile/" + locationString + "/NonExistantProfile/testing"); node.sync(); } catch (BackingStoreException e) { fail("1.0", e); } } + /** + * Profile preferences looks up the agent location using an LDAP filter. Make + * sure it can handle an agent location that contains characters that are not valid in an LDAP filter + */ + public void testInvalidFilterChars() { + File folder = getTestData("Prefs", "/testData/ProfilePreferencesTest/with(invalid)chars/"); + URI location = folder.toURI(); + ProvisioningAgent agent = new ProvisioningAgent(); + agent.setLocation(location); + agent.setBundleContext(TestActivator.getContext()); + IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME); + Hashtable props = new Hashtable(); + props.put("locationURI", location.toString()); + ServiceRegistration reg = TestActivator.getContext().registerService(IProvisioningAgent.SERVICE_NAME, agent, props); + try { + Preferences prefs = new ProfileScope(agentLocation, "TestProfile").getNode("org.eclipse.equinox.p2.ui.sdk"); + assertEquals("1.0", "always", prefs.get("allowNonOKPlan", "")); + } finally { + reg.unregister(); + } + + } + public void testProfilePreference() { Preferences pref = null; String key = "Test"; String value = "Value"; + IAgentLocation agentLocation = (IAgentLocation) getAgent().getService(IAgentLocation.SERVICE_NAME); + String locationString = EncodingUtils.encodeSlashes(agentLocation.getRootLocation().toString()); try { - pref = prefServ.getRootNode().node("/profile/_SELF_/testing"); + pref = prefServ.getRootNode().node("/profile/" + locationString + "/_SELF_/testing"); } catch (IllegalArgumentException e) { fail("IllegalArgumentException when accessing preferences for self profile"); } @@ -68,7 +104,7 @@ public class ProfilePreferencesTest extends AbstractProvisioningTest { // } waitForSave(); - pref = prefServ.getRootNode().node("/profile/_SELF_/testing"); + pref = prefServ.getRootNode().node("/profile/" + locationString + "/_SELF_/testing"); assertEquals("Value not present after load", value, pref.get(key, null)); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java index 7d4af1791..70014395b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java @@ -10,25 +10,21 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.engine; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.*; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.Properties; +import java.util.HashMap; +import java.util.Map; import org.eclipse.core.runtime.FileLocator; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.engine.*; -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.core.eventbus.IProvisioningEventBus; -import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; -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.p2.core.IAgentLocation; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProfileRegistry; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.ServiceReference; @@ -50,7 +46,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { } protected void getServices() { - registryRef = TestActivator.getContext().getServiceReference(IProfileRegistry.class.getName()); + registryRef = TestActivator.getContext().getServiceReference(IProfileRegistry.SERVICE_NAME); registry = (IProfileRegistry) TestActivator.getContext().getService(registryRef); } @@ -75,12 +71,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { private void restart() { try { ungetServices(); - TestActivator.getBundle("org.eclipse.equinox.p2.exemplarysetup").stop(); - TestActivator.getBundle("org.eclipse.equinox.p2.exemplarysetup").start(); - //ensure artifact repository manager is registered with event bus. See bug 247584 - IProvisioningEventBus bus = (IProvisioningEventBus) ServiceHelper.getService(TestActivator.getContext(), IProvisioningEventBus.SERVICE_NAME); - IArtifactRepositoryManager repoMan = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.class.getName()); - bus.addListener((ProvisioningListener) repoMan); + restartBundle(TestActivator.getBundle("org.eclipse.equinox.p2.exemplarysetup")); getServices(); } catch (Exception e) { fail(); @@ -123,7 +114,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { public void testPropertyPeristence() throws ProvisionException { assertNull(registry.getProfile(PROFILE_NAME)); - Properties properties = new Properties(); + Map<String, String> properties = new HashMap<String, String>(); properties.put("test", "test"); Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties); assertTrue(profile.getProperties().containsKey("test")); @@ -148,28 +139,28 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { public void testIUPeristence() throws ProvisionException { assertNull(registry.getProfile(PROFILE_NAME)); Profile profile = (Profile) registry.addProfile(PROFILE_NAME); - assertEquals(0, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty()); profile.addInstallableUnit(createIU("test")); - assertEquals(1, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null))); saveProfile(registry, profile); restart(); profile = (Profile) registry.getProfile(PROFILE_NAME); - assertEquals(1, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null))); profile.removeInstallableUnit(createIU("test")); - assertEquals(0, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty()); saveProfile(registry, profile); restart(); profile = (Profile) registry.getProfile(PROFILE_NAME); - assertEquals(0, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty()); registry.removeProfile(PROFILE_NAME); restart(); assertNull(registry.getProfile(PROFILE_NAME)); } public void testIUPropertyPeristence() throws ProvisionException { - Properties properties = new Properties(); + Map<String, String> properties = new HashMap<String, String>(); properties.put("test", "test"); assertNull(registry.getProfile(PROFILE_NAME)); Profile profile = (Profile) registry.addProfile(PROFILE_NAME); @@ -202,7 +193,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { public void testTimestampedProfiles() throws ProvisionException { assertNull(registry.getProfile(PROFILE_NAME)); - Properties properties = new Properties(); + Map<String, String> properties = new HashMap<String, String>(); properties.put("test", "test"); Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties); long oldtimestamp = profile.getTimestamp(); @@ -229,7 +220,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { public void testIsCurrent() throws Exception { assertNull(registry.getProfile(PROFILE_NAME)); - Properties properties = new Properties(); + Map<String, String> properties = new HashMap<String, String>(); properties.put("test", "test"); Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties); @@ -255,7 +246,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { profile = (Profile) registry.getProfile(PROFILE_NAME); assertTrue(registry.isCurrent(profile)); - AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(TestActivator.getContext(), AgentLocation.SERVICE_NAME); + IAgentLocation agentLocation = getAgentLocation(); SimpleProfileRegistry simpleRegistry2 = new SimpleProfileRegistry(SimpleProfileRegistry.getDefaultRegistryDirectory(agentLocation)); profile2 = (Profile) simpleRegistry2.getProfile(PROFILE_NAME); simpleRegistry2.lockProfile(profile2); @@ -672,7 +663,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest { public void testRemoveProfileTimestamps() throws ProvisionException { assertNull(registry.getProfile(PROFILE_NAME)); - Properties properties = new Properties(); + Map<String, String> properties = new HashMap<String, String>(); properties.put("test", "test"); Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties); assertTrue(profile.getProperties().containsKey("test")); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java index 914d5c89b..e6a70f064 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java @@ -10,21 +10,20 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.engine; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.*; import java.util.*; import java.util.Map.Entry; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.engine.*; -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.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; +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.query.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.BundleContext; import org.xml.sax.*; @@ -62,9 +61,9 @@ public class ProfileTest extends AbstractProvisioningTest { } public void testAddRemoveProperty() throws ProvisionException { - IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry registry = getProfileRegistry(); assertNull(registry.getProfile(PROFILE_NAME)); - Properties properties = new Properties(); + Map<String, String> properties = new HashMap<String, String>(); properties.put("test", "test"); Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties); assertTrue(profile.getProperties().containsKey("test")); @@ -80,57 +79,57 @@ public class ProfileTest extends AbstractProvisioningTest { } public void testAddRemoveIU() throws ProvisionException { - IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry registry = getProfileRegistry(); assertNull(registry.getProfile(PROFILE_NAME)); Profile profile = (Profile) registry.addProfile(PROFILE_NAME); - assertTrue(profile.query(InstallableUnitQuery.ANY, new Collector(), null).isEmpty()); + assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty()); profile.addInstallableUnit(createIU("test")); - assertEquals(1, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null))); profile.removeInstallableUnit(createIU("test")); - assertTrue(profile.query(InstallableUnitQuery.ANY, new Collector(), null).isEmpty()); + assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty()); registry.removeProfile(PROFILE_NAME); assertNull(registry.getProfile(PROFILE_NAME)); } public void testAddIUTwice() throws ProvisionException { - IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry registry = getProfileRegistry(); assertNull(registry.getProfile(PROFILE_NAME)); Profile profile = (Profile) registry.addProfile(PROFILE_NAME); - assertTrue(profile.query(InstallableUnitQuery.ANY, new Collector(), null).isEmpty()); + assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty()); profile.addInstallableUnit(createIU("test")); - assertEquals(1, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null))); profile.addInstallableUnit(createIU("test")); - assertEquals(1, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null))); registry.removeProfile(PROFILE_NAME); assertNull(registry.getProfile(PROFILE_NAME)); } public void testAddRemoveIUProperty() throws ProvisionException { - IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry registry = getProfileRegistry(); assertNull(registry.getProfile(PROFILE_NAME)); Profile profile = (Profile) registry.addProfile(PROFILE_NAME); - assertTrue(profile.query(InstallableUnitQuery.ANY, new Collector(), null).isEmpty()); + assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty()); profile.addInstallableUnit(createIU("test")); assertNull(profile.getInstallableUnitProperty(createIU("test"), "test")); assertNull(profile.removeInstallableUnitProperty(createIU("test"), "test")); - Properties iuProperties = new Properties(); + Map<String, String> iuProperties = new HashMap<String, String>(); iuProperties.put("test", "test"); profile.addInstallableUnitProperties(createIU("test"), iuProperties); assertEquals("test", profile.getInstallableUnitProperty(createIU("test"), "test")); profile.removeInstallableUnitProperty(createIU("test"), "test"); assertNull(profile.getInstallableUnitProperty(createIU("test"), "test")); - assertEquals(1, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null))); registry.removeProfile(PROFILE_NAME); assertNull(registry.getProfile(PROFILE_NAME)); } public void testAvailable() throws ProvisionException { - IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry registry = getProfileRegistry(); assertNull(registry.getProfile(PROFILE_NAME)); Profile profile = (Profile) registry.addProfile(PROFILE_NAME); - assertTrue(profile.available(InstallableUnitQuery.ANY, new Collector(), null).isEmpty()); + assertTrue(profile.available(InstallableUnitQuery.ANY, null).isEmpty()); profile.addInstallableUnit(createIU("test")); - assertEquals(1, profile.available(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(profile.available(InstallableUnitQuery.ANY, null))); profile.setSurrogateProfileHandler(new ISurrogateProfileHandler() { public IProfile createProfile(String id) { return null; @@ -140,200 +139,22 @@ public class ProfileTest extends AbstractProvisioningTest { return false; } - public Collector queryProfile(IProfile profile, Query query, Collector collector, IProgressMonitor monitor) { - return collector; + public IQueryResult queryProfile(IProfile profile, IQuery query, IProgressMonitor monitor) { + return new Collector(); } public boolean updateProfile(IProfile selfProfile) { return false; } }); - assertTrue(profile.available(InstallableUnitQuery.ANY, new Collector(), null).isEmpty()); - assertTrue(profile.snapshot().available(InstallableUnitQuery.ANY, new Collector(), null).isEmpty()); + assertTrue(profile.available(InstallableUnitQuery.ANY, null).isEmpty()); + assertTrue(profile.snapshot().available(InstallableUnitQuery.ANY, null).isEmpty()); registry.removeProfile(PROFILE_NAME); assertNull(registry.getProfile(PROFILE_NAME)); } - public void testNestedProfileStructure() { - Properties properties = new Properties(); - properties.put("test", "test"); - IProfile parent = createProfile("parent", null, properties); - IProfile child = createProfile("child", "parent"); - parent = getProfile("parent"); - assertTrue(parent.hasSubProfiles()); - assertFalse(child.hasSubProfiles()); - assertNotNull(parent.getLocalProperty("test")); - assertNotNull(child.getProperty("test")); - assertNotNull(child.getProperties().get("test")); - assertNull(child.getLocalProperty("test")); - assertNull(child.getLocalProperties().get("test")); - - assertTrue("Parentless profile should be a root.", parent.isRootProfile()); - assertFalse("Child profile should not be a root.", child.isRootProfile()); - assertTrue("Parent should be parent of child", child.getParentProfile().getProfileId().equals(parent.getProfileId())); - assertTrue("Parent should have one child.", parent.getSubProfileIds().length == 1); - assertTrue("Child should have no children.", child.getSubProfileIds().length == 0); - - IProfile grandchild = createProfile("grand", "child"); - child = getProfile("child"); - assertFalse("Grandchild profile should not be a root.", grandchild.isRootProfile()); - assertTrue("Parent should have one child.", parent.getSubProfileIds().length == 1); - assertTrue("Child should have one child.", child.getSubProfileIds().length == 1); - assertTrue("Grandparent of grandchild should be parent of child.", grandchild.getParentProfile().getParentProfile().getProfileId().equals(parent.getProfileId())); - } - - /* The test profile has the following structure and properties where - * id{x,y} indicates a profile with id "id" and properties defined - * with keys "x" and "y" - * - * grandchild00{foo} - * / - * / - * child0{foo} | --- grandchild01{} - * / \ - * / \ - * / grandchild01{bar} - * parent{foo,bar} | - * \ grandchild10{foo} - * \ / - * child1{} | - * \ - * grandchild11{} - * - */ - private static String parentId = "parent"; - private static String child0Id = "child0"; - private static String grandchild00Id = "grand00"; - private static String grandchild01Id = "grand01"; - private static String grandchild02Id = "grand02"; - private static String child1Id = "child1"; - private static String grandchild10Id = "grand10"; - private static String grandchild11Id = "grand11"; - - private static String key = "org.eclipse.p2.foo"; - private static String parentValue = "parent"; - private static String child0Value = "child0"; - private static String grandchild00Value = "grandchild00"; - private static String grandchild02Value = "grandchild02"; - private static String grandchild10Value = "grandchild10"; - private static String otherKey = "org.eclipse.p2.bar"; - private static String otherValue = "other"; - - // Create the profiles and test get after set - // for associated properties. - private IProfile[] createTestProfiles() { - - Map properties = new HashMap(); - - properties.put(key, parentValue); - properties.put(otherKey, otherValue); - IProfile parent = createProfile(parentId, null, properties); - properties.clear(); - assertTrue(parentValue.equals(parent.getProperty(key))); - assertTrue(otherValue.equals(parent.getProperty(otherKey))); - - properties.put(key, child0Value); - IProfile child0 = createProfile(child0Id, parentId, properties); - properties.clear(); - assertTrue(child0Value.equals(child0.getProperty(key))); - - IProfile child1 = createProfile(child1Id, parentId, properties); - // no value in child1 - - properties.put(key, grandchild00Value); - IProfile grandchild00 = createProfile(grandchild00Id, child0Id, properties); - properties.clear(); - assertTrue(grandchild00Value.equals(grandchild00.getProperty(key))); - - IProfile grandchild01 = createProfile(grandchild01Id, child0Id); - // no value in grandchild01 - - properties.put(otherKey, grandchild02Value); - IProfile grandchild02 = createProfile(grandchild02Id, child0Id, properties); - properties.clear(); - assertTrue(grandchild02Value.equals(grandchild02.getProperty(otherKey))); - - properties.put(key, grandchild10Value); - IProfile grandchild10 = createProfile(grandchild10Id, child1Id, properties); - properties.clear(); - assertTrue(grandchild10Value.equals(grandchild10.getProperty(key))); - - IProfile grandchild11 = createProfile(grandchild11Id, child1Id); - // no value in grandchild11 - - parent = getProfile(parentId); - child0 = getProfile(child0Id); - child1 = getProfile(child1Id); - grandchild00 = getProfile(grandchild00Id); - grandchild01 = getProfile(grandchild01Id); - grandchild02 = getProfile(grandchild02Id); - grandchild10 = getProfile(grandchild10Id); - grandchild11 = getProfile(grandchild11Id); - - IProfile[] profiles = {parent, child0, child1, grandchild00, grandchild01, grandchild02, grandchild10, grandchild11}; - return profiles; - } - - public void testNestedProfileProperties() { - validateProfiles(createTestProfiles()); - } - - public void validateProfiles(IProfile[] profiles) { - IProfile parent = profiles[0]; - IProfile child0 = profiles[1]; - IProfile child1 = profiles[2]; - IProfile grandchild00 = profiles[3]; - IProfile grandchild01 = profiles[4]; - IProfile grandchild02 = profiles[5]; - IProfile grandchild10 = profiles[6]; - IProfile grandchild11 = profiles[7]; - - assertTrue(parentId.equals(parent.getProfileId())); - assertTrue("Profile should have 3 local properties", parent.getLocalProperties().size() == 2); - assertTrue(parentValue.equals(parent.getProperty(key))); - assertTrue(otherValue.equals(parent.getProperty(otherKey))); - assertTrue("Parent should have 2 children.", parent.getSubProfileIds().length == 2); - - assertTrue(child0Id.equals(child0.getProfileId())); - assertTrue("First Child should have 1 local properties.", child0.getLocalProperties().size() == 1); - assertTrue(child0Value.equals(child0.getProperty(key))); - assertTrue(otherValue.equals(child0.getProperty(otherKey))); - assertTrue("First Child should have 3 children.", child0.getSubProfileIds().length == 3); - - assertTrue(child1Id.equals(child1.getProfileId())); - assertTrue("Second Child should have 0 local properties.", child1.getLocalProperties().size() == 0); - assertTrue(parentValue.equals(child1.getProperty(key))); - assertTrue(otherValue.equals(child1.getProperty(otherKey))); - assertTrue("Second Child should have 2 children.", child1.getSubProfileIds().length == 2); - - assertTrue(grandchild00Id.equals(grandchild00.getProfileId())); - assertTrue("First Grandchild of first Child should have 1 property.", grandchild00.getLocalProperties().size() == 1); - assertTrue(grandchild00Value.equals(grandchild00.getProperty(key))); - assertTrue(otherValue.equals(grandchild00.getProperty(otherKey))); - - assertTrue(grandchild01Id.equals(grandchild01.getProfileId())); - assertTrue("Second Grandchild of first Child should have 0 properties.", grandchild01.getLocalProperties().size() == 0); - assertTrue(child0Value.equals(grandchild01.getProperty(key))); - assertTrue(otherValue.equals(grandchild01.getProperty(otherKey))); - - assertTrue(grandchild02Id.equals(grandchild02.getProfileId())); - assertTrue("Third Grandchild of first Child should have 1 property.", grandchild02.getLocalProperties().size() == 1); - assertTrue(child0Value.equals(grandchild02.getProperty(key))); - assertTrue(grandchild02Value.equals(grandchild02.getProperty(otherKey))); - - assertTrue(grandchild10Id.equals(grandchild10.getProfileId())); - assertTrue("First Grandchild of second Child should have 1 property.", grandchild10.getLocalProperties().size() == 1); - assertTrue(grandchild10Value.equals(grandchild10.getProperty(key))); - assertTrue(otherValue.equals(grandchild10.getProperty(otherKey))); - - assertTrue(grandchild11Id.equals(grandchild11.getProfileId())); - assertTrue("Second Grandchild of second Child should have 0 properties.", grandchild11.getLocalProperties().size() == 0); - assertTrue(parentValue.equals(grandchild11.getProperty(key))); - assertTrue(otherValue.equals(grandchild11.getProperty(otherKey))); - } - private static String PROFILE_TEST_TARGET = "profileTest"; - private static Version PROFILE_TEST_VERSION = new Version("0.0.1"); + private static Version PROFILE_TEST_VERSION = Version.create("0.0.1"); private static String PROFILE_TEST_ELEMENT = "test"; public static final String PROFILES_ELEMENT = "profiles"; //$NON-NLS-1$ @@ -529,35 +350,4 @@ public class ProfileTest extends AbstractProvisioningTest { return result; } } - - public void testProfilePersistence() throws IOException { - IProfile[] testProfiles = createTestProfiles(); - ByteArrayOutputStream output0 = new ByteArrayOutputStream(1492); - ProfileStringWriter writer0 = new ProfileStringWriter(output0); - writer0.writeTest(testProfiles); - String profileText0 = output0.toString(); - output0.close(); - - ProfileStringParser parser = new ProfileStringParser(TestActivator.context, TestActivator.PI_PROV_TESTS); - parser.parse(profileText0); - assertTrue("Error parsing test profile: " + parser.getStatus().getMessage(), parser.getStatus().isOK()); - Map profileMap = (Map) parser.getRootObject(); - IProfile parent = (IProfile) profileMap.get(parentId); - IProfile child0 = (IProfile) profileMap.get(child0Id); - IProfile child1 = (IProfile) profileMap.get(child1Id); - IProfile grandchild00 = (IProfile) profileMap.get(grandchild00Id); - IProfile grandchild01 = (IProfile) profileMap.get(grandchild01Id); - IProfile grandchild02 = (IProfile) profileMap.get(grandchild02Id); - IProfile grandchild10 = (IProfile) profileMap.get(grandchild10Id); - IProfile grandchild11 = (IProfile) profileMap.get(grandchild11Id); - IProfile[] profiles = {parent, child0, child1, grandchild00, grandchild01, grandchild02, grandchild10, grandchild11}; - validateProfiles(profiles); - ByteArrayOutputStream output1 = new ByteArrayOutputStream(1492); - ProfileStringWriter writer = new ProfileStringWriter(output1); - - writer.writeTest(profiles); - String profileText1 = output1.toString(); - output1.close(); - assertTrue("Profile write after read after write produced different XML", profileText1.equals(profileText0)); - } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java index bb172d214..26784f4a6 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java @@ -11,18 +11,14 @@ package org.eclipse.equinox.p2.tests.engine; import java.lang.reflect.Field; -import java.util.HashSet; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.equinox.internal.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProfileRegistry; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestActivator; -import org.osgi.framework.ServiceReference; public class SurrogateProfileHandlerTest extends AbstractProvisioningTest { private static final String PROFILE_NAME = "profile.SurrogateProfileHandlerTest"; @@ -33,7 +29,6 @@ public class SurrogateProfileHandlerTest extends AbstractProvisioningTest { return new TestSuite(SurrogateProfileHandlerTest.class); } - private ServiceReference registryRef; private IProfileRegistry registry; private SurrogateProfileHandler handler; @@ -51,13 +46,11 @@ public class SurrogateProfileHandlerTest extends AbstractProvisioningTest { } protected void getServices() { - registryRef = TestActivator.getContext().getServiceReference(IProfileRegistry.class.getName()); - registry = (IProfileRegistry) TestActivator.getContext().getService(registryRef); + registry = getProfileRegistry(); } private void ungetServices() { registry = null; - TestActivator.getContext().ungetService(registryRef); } protected void setUp() throws Exception { @@ -89,8 +82,8 @@ public class SurrogateProfileHandlerTest extends AbstractProvisioningTest { saveProfile(registry, profile); IProfile surrogateProfile = handler.createProfile(PROFILE_NAME); assertTrue(handler.isSurrogate(surrogateProfile)); - assertEquals(0, surrogateProfile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); - assertEquals(1, surrogateProfile.available(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(0, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null))); + assertEquals(1, queryResultSize(surrogateProfile.available(InstallableUnitQuery.ANY, null))); } public void testUpdateProfile() throws ProvisionException { @@ -99,34 +92,34 @@ public class SurrogateProfileHandlerTest extends AbstractProvisioningTest { profile.setInstallableUnitProperty(createIU("test"), PROP_TYPE_ROOT, Boolean.TRUE.toString()); saveProfile(registry, profile); IProfile surrogateProfile = handler.createProfile(PROFILE_NAME); - assertEquals(1, surrogateProfile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null))); // HashSet used here to eliminate duplicates - assertEquals(1, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, new Collector(), null).toCollection()).size()); + assertEquals(1, queryResultUniqueSize(surrogateProfile.available(InstallableUnitQuery.ANY, null))); handler.updateProfile(surrogateProfile); - assertEquals(1, surrogateProfile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null))); // HashSet used here to eliminate duplicates - assertEquals(1, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, new Collector(), null).toCollection()).size()); + assertEquals(1, queryResultUniqueSize(surrogateProfile.available(InstallableUnitQuery.ANY, null))); Profile writeableSurrogateProfile = (Profile) surrogateProfile; writeableSurrogateProfile.addInstallableUnit(createIU("surrogate.test")); writeableSurrogateProfile.setInstallableUnitProperty(createIU("surrogate.test"), PROP_TYPE_ROOT, Boolean.TRUE.toString()); - assertEquals(2, surrogateProfile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(2, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null))); // HashSet used here to eliminate duplicates - assertEquals(2, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, new Collector(), null).toCollection()).size()); + assertEquals(2, queryResultUniqueSize(surrogateProfile.available(InstallableUnitQuery.ANY, null))); profile.addInstallableUnit(createIU("test2")); profile.setInstallableUnitProperty(createIU("test2"), PROP_TYPE_ROOT, Boolean.TRUE.toString()); saveProfile(registry, profile); - assertEquals(2, surrogateProfile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(2, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null))); // HashSet used here to eliminate duplicates - assertEquals(3, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, new Collector(), null).toCollection()).size()); + assertEquals(3, queryResultUniqueSize(surrogateProfile.available(InstallableUnitQuery.ANY, null))); //Strictly speaking this should not be necessary however without resetting the timestamp this test will sometimes fail writeableSurrogateProfile.setProperty(PROP_SHARED_TIMESTAMP, null); handler.updateProfile(surrogateProfile); - assertEquals(3, surrogateProfile.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(3, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null))); // HashSet used here to eliminate duplicates - assertEquals(3, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, new Collector(), null).toCollection()).size()); + assertEquals(3, queryResultUniqueSize(surrogateProfile.available(InstallableUnitQuery.ANY, null))); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointManagerTest.java index c296e822c..762e0912e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointManagerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointManagerTest.java @@ -46,7 +46,8 @@ public class TouchpointManagerTest extends AbstractProvisioningTest { assertNotNull(manager.getTouchpoint("phaseTest", null)); } - public void testDynamicTouchpoint() throws MalformedURLException, BundleException, InterruptedException { + // temporarily disabling this test until API is done + public void DISABLED_testDynamicTouchpoint() throws MalformedURLException, BundleException, InterruptedException { TouchpointManager manager = new TouchpointManager(); assertNull(manager.getTouchpoint("dummy", "1.0.0")); File dummy = getTestData("0.1", "/testData/engineTest/dummy.touchpointAndAction_1.0.0.jar"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java index b386d6953..8bee0b3ce 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.engine; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.util.Map; import org.eclipse.core.runtime.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.p2.engine.PhaseSet; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.engine.spi.Touchpoint; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.eclipse.equinox.p2.tests.engine.PhaseTest.TestPhaseSet; @@ -144,7 +146,8 @@ public class TouchpointTest extends AbstractProvisioningTest { testTouchpoint.resetCounters(); PhaseSet phaseSet = new TestPhaseSet(); IProfile profile = createProfile("testProfile"); - engine.perform(profile, phaseSet, new InstallableUnitOperand[] {new InstallableUnitOperand(null, createTestIU("operandTest"))}, null, new NullProgressMonitor()); + final InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createTestIU("operandTest"))}; + engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); assertEquals(1, testTouchpoint.initializeOperand); assertEquals(1, testTouchpoint.completeOperand); } @@ -154,7 +157,8 @@ public class TouchpointTest extends AbstractProvisioningTest { testTouchpoint.resetCounters(); PhaseSet phaseSet = new TestPhaseSet(); IProfile profile = createProfile("testProfile"); - engine.perform(profile, phaseSet, new InstallableUnitOperand[] {new InstallableUnitOperand(null, createTestIU("phaseTest"))}, null, new NullProgressMonitor()); + final InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createTestIU("phaseTest"))}; + engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor()); assertEquals(1, testTouchpoint.initializePhase); assertEquals(1, testTouchpoint.completePhase); } @@ -162,8 +166,8 @@ public class TouchpointTest extends AbstractProvisioningTest { private IInstallableUnit createTestIU(String touchpointName) { InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription(); description.setId("org.eclipse.test"); - description.setVersion(new Version("1.0.0")); - description.setTouchpointType(MetadataFactory.createTouchpointType(touchpointName, new Version("1.0.0"))); + description.setVersion(Version.create("1.0.0")); + description.setTouchpointType(MetadataFactory.createTouchpointType(touchpointName, Version.create("1.0.0"))); IInstallableUnit unit = MetadataFactory.createInstallableUnit(description); return createResolvedIU(unit); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java index b304bdca0..7df721d5c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java @@ -16,9 +16,9 @@ import java.net.*; import org.eclipse.core.runtime.FileLocator; import org.eclipse.equinox.internal.p2.extensionlocation.Constants; import org.eclipse.equinox.internal.p2.extensionlocation.ExtensionLocationArtifactRepositoryFactory; -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.repository.IRepositoryManager; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; @@ -172,7 +172,7 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv URI location = directory.toURI(); try { IArtifactRepository repo = factory.load(location, 0, getMonitor()); - if (repo.getArtifactKeys().length != 2) + if (getArtifactKeyCount(repo) != 2) fail("2.1"); } catch (ProvisionException ex) { fail("2.0"); @@ -188,7 +188,7 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv URI location = directory.toURI(); try { IArtifactRepository repo = factory.load(location, 0, getMonitor()); - if (repo.getArtifactKeys().length != 1) + if (getArtifactKeyCount(repo) != 1) fail("2.1"); } catch (ProvisionException ex) { fail("2.0"); @@ -204,7 +204,7 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv URI location = directory.toURI(); try { IArtifactRepository repo = factory.load(location, 0, getMonitor()); - if (repo.getArtifactKeys().length != 1) + if (getArtifactKeyCount(repo) != 1) fail("2.1"); } catch (ProvisionException ex) { fail("2.0"); @@ -218,7 +218,7 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv copy("1.1", getTestData("1.1", "/testData/extensionlocation"), eclipseDirectory); try { IArtifactRepository repo = factory.load(directory.toURI(), 0, getMonitor()); - if (repo.getArtifactKeys().length != 2) + if (getArtifactKeyCount(repo) != 2) fail("1.0"); } catch (ProvisionException e) { fail("0.5", e); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java index 82af17cd1..0049f8def 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java @@ -15,11 +15,10 @@ import java.io.IOException; import java.net.*; import org.eclipse.equinox.internal.p2.extensionlocation.Constants; import org.eclipse.equinox.internal.p2.extensionlocation.ExtensionLocationMetadataRepositoryFactory; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.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.repository.IRepositoryManager; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProvisioningTest { @@ -164,7 +163,7 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv URI location = directory.toURI(); try { IMetadataRepository repo = factory.load(location, 0, getMonitor()); - if (repo.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().size() != 3) + if (queryResultSize(repo.query(InstallableUnitQuery.ANY, null)) != 3) fail("2.99"); } catch (ProvisionException ex) { fail("2.0"); @@ -180,7 +179,7 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv URI location = directory.toURI(); try { IMetadataRepository repo = factory.load(location, 0, getMonitor()); - if (repo.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().size() != 2) + if (queryResultSize(repo.query(InstallableUnitQuery.ANY, null)) != 2) fail("3.0"); } catch (ProvisionException ex) { fail("2.0"); @@ -196,7 +195,7 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv URI location = directory.toURI(); try { IMetadataRepository repo = factory.load(location, 0, getMonitor()); - if (repo.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().size() != 1) + if (queryResultSize(repo.query(InstallableUnitQuery.ANY, null)) != 1) fail("3.0"); } catch (ProvisionException ex) { fail("2.0"); @@ -210,7 +209,7 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv copy("1.0", getTestData("1.1", "/testData/extensionlocation"), eclipseDirectory); try { IMetadataRepository repo = factory.load(directory.toURI(), 0, getMonitor()); - if (repo.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().size() != 3) + if (queryResultSize(repo.query(InstallableUnitQuery.ANY, null)) != 3) fail("3.0"); } catch (ProvisionException e) { fail("2.0"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java index 7add26707..00f1b472e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java @@ -20,8 +20,8 @@ public class AllTests extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(AllTests.class.getName()); suite.addTestSuite(End2EndTest.class); - // suite.addTest(From35to36.suite()); - // suite.addTest(Install36from35.suite()); + suite.addTest(From35to36.suite()); + suite.addTest(Install36from35.suite()); return suite; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java index b5413b610..7dc4ddb89 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java @@ -10,23 +10,22 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.full; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.VersionRange; -import java.util.*; +import java.util.HashMap; +import java.util.Map; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry; -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.IProfile; +import org.eclipse.equinox.p2.engine.IProfileRegistry; +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.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.eclipse.osgi.service.environment.EnvironmentInfo; @@ -39,7 +38,7 @@ import org.osgi.framework.ServiceReference; public class DirectorTest extends AbstractProvisioningTest { public void testInstallIU() throws ProvisionException { - ServiceReference sr = TestActivator.context.getServiceReference(IDirector.class.getName()); + ServiceReference sr = TestActivator.context.getServiceReference(IDirector.SERVICE_NAME); if (sr == null) { throw new RuntimeException("Director service not available"); } @@ -48,23 +47,21 @@ public class DirectorTest extends AbstractProvisioningTest { throw new RuntimeException("Director could not be loaded"); } - ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.class.getName()); + ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.SERVICE_NAME); IMetadataRepositoryManager mgr = (IMetadataRepositoryManager) TestActivator.context.getService(sr2); if (mgr == null) { throw new RuntimeException("Repository manager could not be loaded"); } String autoInstall = System.getProperty("eclipse.p2.autoInstall"); - Collector allJobs = mgr.query(new InstallableUnitQuery(autoInstall, VersionRange.emptyRange), new Collector(), null); + IQueryResult allJobs = mgr.query(new InstallableUnitQuery(autoInstall, VersionRange.emptyRange), null); String installFolder = System.getProperty(IProfile.PROP_INSTALL_FOLDER); - ServiceReference profileRegSr = TestActivator.context.getServiceReference(IProfileRegistry.class.getName()); - IProfileRegistry profileRegistry = (IProfileRegistry) TestActivator.context.getService(profileRegSr); + IProfileRegistry profileRegistry = getProfileRegistry(); if (profileRegistry == null) { throw new RuntimeException("Profile registry service not available"); } - String newFlavor = System.getProperty("eclipse.p2.configurationFlavor"); boolean doUninstall = (Boolean.TRUE.equals(Boolean.valueOf(System.getProperty("eclipse.p2.doUninstall")))); IProfile p = null; @@ -75,12 +72,11 @@ public class DirectorTest extends AbstractProvisioningTest { } else { Map properties = new HashMap(); properties.put(IProfile.PROP_INSTALL_FOLDER, installFolder); - properties.put(IProfile.PROP_FLAVOR, newFlavor); EnvironmentInfo info = (EnvironmentInfo) ServiceHelper.getService(TestActivator.getContext(), EnvironmentInfo.class.getName()); if (info != null) properties.put(IProfile.PROP_ENVIRONMENTS, "osgi.os=" + info.getOS() + ",osgi.ws=" + info.getWS() + ",osgi.arch=" + info.getOSArch()); - p = createProfile(installFolder, null, properties); + p = createProfile(installFolder, properties); } IInstallableUnit[] allRoots = new IInstallableUnit[1]; @@ -100,24 +96,8 @@ public class DirectorTest extends AbstractProvisioningTest { if (!operationStatus.isOK()) fail("The installation has failed"); - IInstallableUnit[] result = (IInstallableUnit[]) p.query(new InstallableUnitQuery(allRoots[0].getId(), VersionRange.emptyRange), new Collector(), null).toArray(IInstallableUnit.class); + IInstallableUnit[] result = (IInstallableUnit[]) p.query(new InstallableUnitQuery(allRoots[0].getId(), VersionRange.emptyRange), null).toArray(IInstallableUnit.class); assertEquals(result.length, (!doUninstall ? 1 : 0)); - result = (IInstallableUnit[]) p.query(new InstallableUnitQuery("toolingdefault", VersionRange.emptyRange), new Collector(), null).toArray(IInstallableUnit.class); - - ensureFragmentAssociationIsNotPersisted(mgr); - } - - private void ensureFragmentAssociationIsNotPersisted(IMetadataRepositoryManager mgr) throws ProvisionException { - //Test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=177661 - AgentLocation location = (AgentLocation) ServiceHelper.getService(TestActivator.getContext(), AgentLocation.class.getName()); - mgr.removeRepository(location.getMetadataRepositoryURI()); - IMetadataRepository repo = null; - repo = mgr.loadRepository(location.getMetadataRepositoryURI(), null); - Iterator it = repo.query(new InstallableUnitQuery("org.eclipse.equinox.simpleconfigurator", VersionRange.emptyRange), new Collector(), null).iterator(); - if (!it.hasNext()) - return; - IInstallableUnit sc = (IInstallableUnit) it.next(); - if (sc.isResolved()) - fail("The repository should not store resolved installable units"); + result = (IInstallableUnit[]) p.query(new InstallableUnitQuery("toolingdefault", VersionRange.emptyRange), null).toArray(IInstallableUnit.class); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java index 4cb0f640f..6508f93cf 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java @@ -10,27 +10,29 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.full; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.io.IOException; import java.net.URI; -import java.net.URISyntaxException; import java.util.*; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -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.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; -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.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.core.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IProvidedCapability; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +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; import org.eclipse.osgi.service.environment.EnvironmentInfo; @@ -46,26 +48,21 @@ public class End2EndTest extends AbstractProvisioningTest { private ServiceTracker fwAdminTracker; + private static URI repositoryLocation = URI.create("http://download.eclipse.org/eclipse/updates/3.5"); + + private IProvisioningAgent end2endAgent = null; + protected void setUp() throws Exception { - ServiceReference sr = TestActivator.context.getServiceReference(IDirector.class.getName()); - if (sr == null) - throw new RuntimeException("Director service not available"); - director = createDirector(); - // planner = createPlanner(); - ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.class.getName()); - metadataRepoManager = (IMetadataRepositoryManager) TestActivator.context.getService(sr2); - if (metadataRepoManager == null) - throw new RuntimeException("Metadata repository manager could not be loaded"); - - ServiceReference sr3 = TestActivator.context.getServiceReference(IArtifactRepositoryManager.class.getName()); - artifactRepoManager = (IArtifactRepositoryManager) TestActivator.context.getService(sr3); - if (artifactRepoManager == null) - throw new RuntimeException("Artifact repo manager could not be loaded"); + ServiceReference sr = TestActivator.context.getServiceReference(IProvisioningAgentProvider.SERVICE_NAME); + IProvisioningAgentProvider agentFactory = (IProvisioningAgentProvider) TestActivator.context.getService(sr); + end2endAgent = agentFactory.createAgent(getTempFolder().toURI()); + metadataRepoManager = (IMetadataRepositoryManager) end2endAgent.getService(IMetadataRepositoryManager.SERVICE_NAME); + artifactRepoManager = (IArtifactRepositoryManager) end2endAgent.getService(IArtifactRepositoryManager.SERVICE_NAME); + director = (IDirector) end2endAgent.getService(IDirector.SERVICE_NAME); } protected IProfile createProfile(String profileId, String installFolder) { - ServiceReference profileRegSr = TestActivator.context.getServiceReference(IProfileRegistry.class.getName()); - IProfileRegistry profileRegistry = (IProfileRegistry) TestActivator.context.getService(profileRegSr); + IProfileRegistry profileRegistry = (IProfileRegistry) end2endAgent.getService(IProfileRegistry.SERVICE_NAME); if (profileRegistry == null) { throw new RuntimeException("Profile registry service not available"); } @@ -77,7 +74,11 @@ public class End2EndTest extends AbstractProvisioningTest { properties.put(IProfile.PROP_ENVIRONMENTS, "osgi.os=" + info.getOS() + ",osgi.ws=" + info.getWS() + ",osgi.arch=" + info.getOSArch()); properties.put("org.eclipse.update.install.features", "true"); properties.put(IProfile.PROP_CACHE, installFolder); - return createProfile(profileId, null, properties); + try { + return profileRegistry.addProfile(profileId, properties); + } catch (ProvisionException e) { + throw new IllegalArgumentException(e.getMessage()); + } } public void testInstallSDK35() { @@ -86,16 +87,13 @@ public class End2EndTest extends AbstractProvisioningTest { //Add repository of the release try { - URI location = new URI("http://download.eclipse.org/eclipse/updates/3.5"); - metadataRepoManager.addRepository(location); - metadataRepoManager.setEnabled(location, true); - metadataRepoManager.loadRepository(location, new NullProgressMonitor()); - artifactRepoManager.addRepository(location); - artifactRepoManager.setEnabled(location, true); + metadataRepoManager.addRepository(repositoryLocation); + metadataRepoManager.setEnabled(repositoryLocation, true); + metadataRepoManager.loadRepository(repositoryLocation, new NullProgressMonitor()); + artifactRepoManager.addRepository(repositoryLocation); + artifactRepoManager.setEnabled(repositoryLocation, true); } catch (ProvisionException e) { fail("Exception loading the repository.", e); - } catch (URISyntaxException e) { - fail("Invalid repository location", e); } installPlatform35(profile2, installFolder); @@ -113,19 +111,19 @@ public class End2EndTest extends AbstractProvisioningTest { } private void attemptToUninstallRCP35(IProfile profile2, File installFolder) { - Collector collect = profile2.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor()); - assertEquals(1, collect.size()); + IQueryResult collect = profile2.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor()); + assertEquals(1, queryResultSize(collect)); ProfileChangeRequest request = new ProfileChangeRequest(profile2); request.removeInstallableUnits(new IInstallableUnit[] {(IInstallableUnit) collect.iterator().next()}); IStatus s = director.provision(request, null, new NullProgressMonitor()); assertOK("Can not uninstall RCP", s); - assertEquals(1, profile2.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor()).size()); + assertEquals(1, queryResultSize(profile2.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor()))); } protected void uninstallPlatform(IProfile profile2, File installFolder) { System.out.println("Uninstall the platform"); - Collector collect = profile2.query(new InstallableUnitQuery("org.eclipse.platform.ide"), new Collector(), new NullProgressMonitor()); - assertEquals(1, collect.size()); + IQueryResult collect = profile2.query(new InstallableUnitQuery("org.eclipse.platform.ide"), new NullProgressMonitor()); + assertEquals(1, queryResultSize(collect)); // Collector collect2 = profile2.query(new InstallableUnitQuery("org.eclipse.platform.source.feature.group"), new Collector(), new NullProgressMonitor()); ProfileChangeRequest request = new ProfileChangeRequest(profile2); request.removeInstallableUnits(new IInstallableUnit[] {(IInstallableUnit) collect.iterator().next()});//, (IInstallableUnit) collect2.iterator().next()}); @@ -134,7 +132,7 @@ public class End2EndTest extends AbstractProvisioningTest { } private void rollbackPlatformSource35(IProfile profile2, File installFolder) { - IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry profileRegistry = (IProfileRegistry) end2endAgent.getService(IProfileRegistry.SERVICE_NAME); long[] timestamps = profileRegistry.listProfileTimestamps(profile2.getProfileId()); assertEquals(3, timestamps.length); @@ -149,11 +147,9 @@ public class End2EndTest extends AbstractProvisioningTest { private void installPlatformSource35(IProfile profile2, File installFolder) { final String id = "org.eclipse.platform.source.feature.group"; - final Version version = new Version("3.5.0.v20090611a-9gEeG1HFtQcmRThO4O3aR_fqSMvJR2sJ"); + final Version version = Version.create("3.5.0.v20090611a-9gEeG1HFtQcmRThO4O3aR_fqSMvJR2sJ"); IInstallableUnit toInstall = getIU(id, version); - if (toInstall == null) - assertNotNull(toInstall); ProfileChangeRequest request = new ProfileChangeRequest(profile2); request.addInstallableUnits(new IInstallableUnit[] {toInstall}); @@ -168,13 +164,13 @@ public class End2EndTest extends AbstractProvisioningTest { private void installBogusIU(IProfile profile, File installFolder) { InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription(); iud.setId("org.eclipse.equinox.p2.tests.bogusIU.end2end"); - iud.setVersion(new Version("1.0.0")); - iud.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.equinox.p2.tests.bogusIU.end2end", new Version("1.0.0"))}); + iud.setVersion(Version.create("1.0.0")); + iud.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.equinox.p2.tests.bogusIU.end2end", Version.create("1.0.0"))}); Map data = new HashMap(); data.put("install", "org.eclipse.equinox.p2.osgi.removeJvmArg(programArg:-XX:+UnlockDiagnosticVMOptions);"); iud.addTouchpointData(MetadataFactory.createTouchpointData(data)); IInstallableUnit bogusIU = MetadataFactory.createInstallableUnit(iud); - iud.setTouchpointType(MetadataFactory.createTouchpointType("org.eclipse.equinox.p2.osgi", new Version("1.0.0"))); + iud.setTouchpointType(MetadataFactory.createTouchpointType("org.eclipse.equinox.p2.osgi", Version.create("1.0.0"))); ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {bogusIU}); IStatus s = director.provision(request, null, new NullProgressMonitor()); @@ -183,13 +179,11 @@ public class End2EndTest extends AbstractProvisioningTest { private void installPlatform35(IProfile profile2, File installFolder) { final String id = "org.eclipse.platform.ide"; - final Version version = new Version("3.5.0.I20090611-1540"); + final Version version = Version.create("3.5.0.I20090611-1540"); //First we install the platform ProfileChangeRequest request = new ProfileChangeRequest(profile2); IInstallableUnit platformIU = getIU(id, version); - if (platformIU == null) - assertNotNull(platformIU); request.addInstallableUnits(new IInstallableUnit[] {platformIU}); IStatus s = director.provision(request, null, new NullProgressMonitor()); @@ -203,11 +197,31 @@ public class End2EndTest extends AbstractProvisioningTest { assertFalse(new File(installFolder, "configuration/org.eclipse.equinox.source").exists()); } + /** + * Returns the IU corresponding to the given id and version. Fails if the IU could + * not be found. Never returns null. + */ public IInstallableUnit getIU(String id, Version v) { - Iterator it = metadataRepoManager.query(new InstallableUnitQuery(id, v), new Collector(), null).iterator(); + final InstallableUnitQuery query = new InstallableUnitQuery(id, v); + Iterator it = metadataRepoManager.query(query, null).iterator(); if (it.hasNext()) return (IInstallableUnit) it.next(); - return null; + //try the repository location directly - retry because eclipse.org can be flaky + Exception failure = null; + for (int i = 0; i < 3; i++) { + try { + IMetadataRepository repo = metadataRepoManager.loadRepository(repositoryLocation, null); + it = repo.query(query, null).iterator(); + if (it.hasNext()) + return (IInstallableUnit) it.next(); + } catch (ProvisionException e) { + failure = e; + } + } + if (failure == null) + failure = new RuntimeException("IU not found"); + fail("Failed to obtain " + id + " version: " + v + " from: " + repositoryLocation, failure); + return null;//will never get here } private void validateInstallContentFor35(File installFolder) { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java index d59876f3f..3f4ffac2a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java @@ -14,15 +14,17 @@ import java.net.URI; import java.net.URISyntaxException; import java.util.*; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; -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.engine.IProfile; +import org.eclipse.equinox.p2.engine.ProvisioningContext; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +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; import org.osgi.framework.ServiceReference; @@ -30,7 +32,7 @@ import org.osgi.framework.ServiceReference; public class RepoValidator extends AbstractProvisioningTest { public void testValidate() throws ProvisionException, URISyntaxException { URI repoLoc = new URI("http://fullmoon.ottawa.ibm.com/eclipse/updates/3.5-I-builds/"); - ServiceReference sr = TestActivator.context.getServiceReference(IPlanner.class.getName()); + ServiceReference sr = TestActivator.context.getServiceReference(IPlanner.SERVICE_NAME); if (sr == null) { throw new RuntimeException("Planner service not available"); } @@ -39,7 +41,7 @@ public class RepoValidator extends AbstractProvisioningTest { throw new RuntimeException("Planner could not be loaded"); } - ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.class.getName()); + ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.SERVICE_NAME); IMetadataRepositoryManager mgr = (IMetadataRepositoryManager) TestActivator.context.getService(sr2); if (mgr == null) { throw new RuntimeException("Repository manager could not be loaded"); @@ -47,18 +49,17 @@ public class RepoValidator extends AbstractProvisioningTest { IMetadataRepository validatedRepo = mgr.loadRepository(repoLoc, null); Map properties = new HashMap(); - properties.put(IInstallableUnit.NAMESPACE_FLAVOR, "tooling"); properties.put("osgi.os", "win32"); properties.put("osgi.ws", "win32"); properties.put("osgi.arch", "x86"); - IProfile p = createProfile("repoValidator", null, properties); + IProfile p = createProfile("repoValidator", properties); - Query q; + IQuery q; q = new InstallableUnitQuery("org.eclipse.rcp.feature.group"); // q = InstallableUnitQuery.ANY; - Collector iusToTest = validatedRepo.query(q, new Collector(), null); + IQueryResult iusToTest = validatedRepo.query(q, null); ProvisioningContext pc = new ProvisioningContext(new URI[] {repoLoc}); for (Iterator iterator = iusToTest.iterator(); iterator.hasNext();) { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/EclipseSDK33Test.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/EclipseSDK33Test.java index 292f19f5e..78ccc09a8 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/EclipseSDK33Test.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/EclipseSDK33Test.java @@ -17,11 +17,11 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; -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.generator.Generator; import org.eclipse.equinox.internal.provisional.p2.metadata.generator.IGeneratorInfo; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.GroupQuery; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; import org.eclipse.equinox.p2.tests.*; import org.osgi.framework.Bundle; @@ -88,15 +88,14 @@ public class EclipseSDK33Test extends AbstractProvisioningTest { assertGroup(unit); IArtifactRepository artifactRepo = generatorInfo.getArtifactRepository(); - IArtifactKey[] keys = artifactRepo.getArtifactKeys(); - assertTrue(keys.length == 11); + assertTrue(getArtifactKeyCount(artifactRepo) == 11); } /** * Asserts that the given IU represents a group. */ private void assertGroup(IInstallableUnit unit) { - assertEquals("IU is not a group", Boolean.TRUE.toString(), unit.getProperty(IInstallableUnit.PROP_TYPE_GROUP)); + assertEquals("IU is not a group", Boolean.TRUE.toString(), GroupQuery.isGroup(unit)); } private IGeneratorInfo createGeneratorInfo() { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/FeatureToIU.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/FeatureToIU.java index 5f677588a..4593802dd 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/FeatureToIU.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/FeatureToIU.java @@ -9,9 +9,9 @@ package org.eclipse.equinox.p2.tests.generator; import org.eclipse.equinox.internal.p2.metadata.generator.features.FeatureParser; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.equinox.internal.provisional.p2.metadata.generator.Feature; import org.eclipse.equinox.internal.provisional.p2.metadata.generator.MetadataGeneratorHelper; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class FeatureToIU extends AbstractProvisioningTest { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/PatchIUGeneration.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/PatchIUGeneration.java index 5d015fcb9..5e11a2f35 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/PatchIUGeneration.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/PatchIUGeneration.java @@ -8,13 +8,16 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.generator; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.VersionRange; +import junit.framework.TestCase; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.p2.metadata.generator.features.FeatureParser; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnitPatch; import org.eclipse.equinox.internal.provisional.p2.metadata.generator.Feature; import org.eclipse.equinox.internal.provisional.p2.metadata.generator.MetadataGeneratorHelper; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IInstallableUnitPatch; +import org.eclipse.equinox.p2.metadata.query.PatchQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchIUGeneration extends AbstractProvisioningTest { @@ -31,19 +34,19 @@ public class PatchIUGeneration extends AbstractProvisioningTest { assertEquals(patchIU.getId(), "org.eclipse.jdt.3.2.1.patch.feature.group"); //Check applicability scope - assertEquals(IInstallableUnit.NAMESPACE_IU_ID, patchIU.getApplicabilityScope()[0][0].getNamespace()); - assertEquals("org.eclipse.jdt.feature.group", patchIU.getApplicabilityScope()[0][0].getName()); - assertEquals(new VersionRange("[3.2.1.r321_v20060905-R4CM1Znkvre9wC-,3.2.1.r321_v20060905-R4CM1Znkvre9wC-]"), patchIU.getApplicabilityScope()[0][0].getRange()); + assertEquals(IInstallableUnit.NAMESPACE_IU_ID, ((IRequiredCapability) patchIU.getApplicabilityScope()[0][0]).getNamespace()); + assertEquals("org.eclipse.jdt.feature.group", ((TestCase) patchIU.getApplicabilityScope()[0][0]).getName()); + assertEquals(new VersionRange("[3.2.1.r321_v20060905-R4CM1Znkvre9wC-,3.2.1.r321_v20060905-R4CM1Znkvre9wC-]"), ((IRequiredCapability) patchIU.getApplicabilityScope()[0][0]).getRange()); - assertEquals("org.eclipse.jdt.core", patchIU.getRequirementsChange()[0].applyOn().getName()); - assertEquals(VersionRange.emptyRange, patchIU.getRequirementsChange()[0].applyOn().getRange()); - assertEquals("org.eclipse.jdt.core", patchIU.getRequirementsChange()[0].newValue().getName()); - assertEquals(new VersionRange("[3.2.2,3.2.2]"), patchIU.getRequirementsChange()[0].newValue().getRange()); - assertEquals(Boolean.TRUE.toString(), patchIU.getProperty(IInstallableUnit.PROP_TYPE_PATCH)); - assertEquals(1, patchIU.getRequiredCapabilities().length); - assertEquals(featureIU.getId(), patchIU.getRequiredCapabilities()[0].getName()); - assertEquals("org.eclipse.jdt.feature.group", patchIU.getLifeCycle().getName()); + assertEquals("org.eclipse.jdt.core", patchIU.getRequirementsChange().get(0).applyOn().getName()); + assertEquals(VersionRange.emptyRange, patchIU.getRequirementsChange().get(0).applyOn().getRange()); + assertEquals("org.eclipse.jdt.core", patchIU.getRequirementsChange().get(0).newValue().getName()); + assertEquals(new VersionRange("[3.2.2,3.2.2]"), patchIU.getRequirementsChange().get(0).newValue().getRange()); + assertTrue(PatchQuery.isPatch(patchIU)); + assertEquals(1, patchIU.getRequiredCapabilities().size()); + assertEquals(featureIU.getId(), ((IRequiredCapability) patchIU.getRequiredCapabilities().iterator().next()).getName()); + assertEquals("org.eclipse.jdt.feature.group", ((IRequiredCapability) patchIU.getLifeCycle()).getName()); assertFalse(patchIU.getLifeCycle().isGreedy()); - assertFalse(patchIU.getLifeCycle().isOptional()); + assertFalse(patchIU.getLifeCycle().getMin() == 0); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/TestGeneratorInfo.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/TestGeneratorInfo.java index ea46ad3c3..ef6dc5013 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/TestGeneratorInfo.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/TestGeneratorInfo.java @@ -15,10 +15,10 @@ import java.net.URI; import java.util.*; import org.eclipse.equinox.internal.provisional.frameworkadmin.ConfigData; import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.equinox.internal.provisional.p2.metadata.generator.IGeneratorInfo; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.TestArtifactRepository; import org.eclipse.equinox.p2.tests.TestMetadataRepository; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/installer/InstallDescriptionParserTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/installer/InstallDescriptionParserTest.java index ceb2ec938..5d6e11047 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/installer/InstallDescriptionParserTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/installer/InstallDescriptionParserTest.java @@ -10,9 +10,7 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.installer; -import org.eclipse.equinox.internal.provisional.p2.metadata.IVersionedId; - -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.io.IOException; @@ -20,6 +18,7 @@ import java.net.*; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.installer.InstallDescriptionParser; import org.eclipse.equinox.internal.provisional.p2.installer.InstallDescription; +import org.eclipse.equinox.p2.metadata.IVersionedId; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestData; @@ -117,9 +116,9 @@ public class InstallDescriptionParserTest extends AbstractProvisioningTest { IVersionedId[] roots = description.getRoots(); assertEquals("1.7", 2, roots.length); assertEquals("1.8", "testRoot", roots[0].getId()); - assertEquals("1.9", new Version("2.0"), roots[0].getVersion()); + assertEquals("1.9", Version.create("2.0"), roots[0].getVersion()); assertEquals("1.8", "anotherRoot", roots[1].getId()); - assertEquals("1.9", new Version("1.0.1"), roots[1].getVersion()); + assertEquals("1.9", Version.create("1.0.1"), roots[1].getVersion()); assertTrue("1.10", !description.isAutoStart()); assertEquals("1.11", new Path("/tmp/agent/"), description.getAgentLocation()); assertEquals("1.12", new Path("/tmp/bundles/"), description.getBundleLocation()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java index c1b43a84a..0b7e19c85 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java @@ -10,11 +10,11 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import junit.framework.TestCase; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IArtifactKey; /** * Test <code>ArtifactkeyDeSerializer</code> @@ -22,12 +22,12 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; public class ArtifactKeyParsingTest extends TestCase { public void testSerialize() { - IArtifactKey key = new ArtifactKey("classifier", "identifier", new Version("1.0")); + IArtifactKey key = new ArtifactKey("classifier", "identifier", Version.create("1.0")); assertEquals("classifier,identifier,1.0.0", key.toExternalForm()); } public void testSerializeEmptyClassifier() { - IArtifactKey key = new ArtifactKey("", "identifier", new Version("1.0")); + IArtifactKey key = new ArtifactKey("", "identifier", Version.create("1.0")); assertEquals(",identifier,1.0.0", key.toExternalForm()); } @@ -36,7 +36,7 @@ public class ArtifactKeyParsingTest extends TestCase { assertNotNull(key); assertEquals("classifier", key.getClassifier()); assertEquals("identifier", key.getId()); - assertEquals(new Version("1.0"), key.getVersion()); + assertEquals(Version.create("1.0"), key.getVersion()); } public void testDeserializeEmptyClassifier() { @@ -44,7 +44,7 @@ public class ArtifactKeyParsingTest extends TestCase { assertNotNull(key); assertEquals("", key.getClassifier()); assertEquals("identifier", key.getId()); - assertEquals(new Version("1.0"), key.getVersion()); + assertEquals(Version.create("1.0"), key.getVersion()); } public void testDeserializeEmptyIdentifier() { @@ -52,7 +52,7 @@ public class ArtifactKeyParsingTest extends TestCase { assertNotNull(key); assertEquals("classifier", key.getClassifier()); assertEquals("", key.getId()); - assertEquals(new Version("1.0"), key.getVersion()); + assertEquals(Version.create("1.0"), key.getVersion()); } public void testDeserializeEmptyVersion() { @@ -60,7 +60,7 @@ public class ArtifactKeyParsingTest extends TestCase { assertNotNull(key); assertEquals("classifier", key.getClassifier()); assertEquals("identifier", key.getId()); - assertEquals(new Version("0.0"), key.getVersion()); + assertEquals(Version.create("0.0"), key.getVersion()); } public void testDeserializeEmptyEverything() { @@ -68,7 +68,7 @@ public class ArtifactKeyParsingTest extends TestCase { assertNotNull(key); assertEquals("", key.getClassifier()); assertEquals("", key.getId()); - assertEquals(new Version("0.0"), key.getVersion()); + assertEquals(Version.create("0.0"), key.getVersion()); } public void testDeserializeTooFewPartsI() { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java index e41a590f2..e6ad021f2 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java @@ -10,16 +10,18 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; -import java.util.HashSet; -import java.util.Iterator; +import java.util.*; import junit.framework.AssertionFailedError; import junit.framework.TestCase; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.metadata.*; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IProvidedCapability; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class FragmentMethodTest extends TestCase { @@ -28,10 +30,8 @@ public class FragmentMethodTest extends TestCase { private static final String TEST_REQUIRED = "testRequired"; IInstallableUnit iu1; IInstallableUnit iu3; - IRequiredCapability[] iu1Deps; - IRequiredCapability[] iu3Deps; - IProvidedCapability[] iu1Caps; - IProvidedCapability[] iu3Caps; + Collection<IProvidedCapability> iu1Caps; + Collection<IProvidedCapability> iu3Caps; protected void setUp() throws Exception { super.setUp(); @@ -39,8 +39,6 @@ public class FragmentMethodTest extends TestCase { iu3 = createIUFragment("iu.fragment"); iu1Caps = iu1.getProvidedCapabilities(); iu3Caps = iu3.getProvidedCapabilities(); - iu1Deps = iu1.getRequiredCapabilities(); - iu3Deps = iu3.getRequiredCapabilities(); HashSet hash = new HashSet(); hash.add(iu1); hash.add(iu3); @@ -57,34 +55,30 @@ public class FragmentMethodTest extends TestCase { protected void tearDown() throws Exception { iu1 = null; iu3 = null; - iu1Deps = null; - iu3Deps = null; iu1Caps = null; iu3Caps = null; super.tearDown(); } public void testCapabilities() { - IProvidedCapability[] iuCapabilities = iu1Caps; - IProvidedCapability[] initialFragmentCapabilities = iu3Caps; - - IProvidedCapability[] mergedCapabilities = iu1.getProvidedCapabilities(); - for (int i = 0; i < iuCapabilities.length; i++) { - FragmentTest.assertContainsWithEquals(mergedCapabilities, iuCapabilities[i]); + Collection<IProvidedCapability> mergedCapabilities = iu1.getProvidedCapabilities(); + for (IProvidedCapability capability : mergedCapabilities) { + FragmentTest.assertContainsWithEquals(mergedCapabilities, capability); } //The fragment property is not set - assertNull(iu1.getProperty(IInstallableUnit.PROP_TYPE_FRAGMENT)); + assertNull(iu1.getProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT)); //The fragment does not contain iu namespace - for (int i = 0; i < initialFragmentCapabilities.length; i++) { - if (initialFragmentCapabilities[i].getNamespace().equals(IInstallableUnit.NAMESPACE_IU_ID)) { - assertDoesNotContain(mergedCapabilities, initialFragmentCapabilities[i]); + Collection<IProvidedCapability> initialFragmentCapabilities = iu3Caps; + for (IProvidedCapability capability : initialFragmentCapabilities) { + if (capability.getNamespace().equals(IInstallableUnit.NAMESPACE_IU_ID)) { + assertDoesNotContain(mergedCapabilities, capability); break; } } - assertEquals("The fragment capabilities should not change", initialFragmentCapabilities, iu3.getProvidedCapabilities(), false); + assertEquals("The fragment capabilities should not change", initialFragmentCapabilities, iu3.getProvidedCapabilities()); } protected void assertEquals(String message, Object[] expected, Object[] actual) { @@ -98,38 +92,22 @@ public class FragmentMethodTest extends TestCase { assertEquals(message, expected[i], actual[i]); } - protected void assertEquals(String message, Object[] expected, Object[] actual, boolean orderImportant) { - // if the order in the array must match exactly, then call the other method - if (orderImportant) { - assertEquals(message, expected, actual); - return; - } - // otherwise use this method and check that the arrays are equal in any order + protected void assertEquals(String message, Collection<? extends Object> expected, Collection<? extends Object> actual) { if (expected == null && actual == null) return; if (expected == actual) return; if (expected == null || actual == null) assertTrue(message + ".1", false); - if (expected.length != actual.length) + if (expected.size() != actual.size()) assertTrue(message + ".2", false); - boolean[] found = new boolean[expected.length]; - for (int i = 0; i < expected.length; i++) { - for (int j = 0; j < expected.length; j++) { - if (!found[j] && expected[i].equals(actual[j])) - found[j] = true; - } - } - for (int i = 0; i < found.length; i++) - if (!found[i]) - assertTrue(message + ".3." + i, false); + if (!expected.containsAll(actual)) + fail(message + ".3"); } - public static void assertDoesNotContain(Object[] objects, Object searched) { - for (int i = 0; i < objects.length; i++) { - if (objects[i].equals(searched)) - throw new AssertionFailedError("The array should not contain the searched element"); - } + public static void assertDoesNotContain(Collection<? extends Object> objects, Object searched) { + if (objects.contains(searched)) + throw new AssertionFailedError("The array should not contain the searched element"); } public void testProperties() { @@ -141,12 +119,12 @@ public class FragmentMethodTest extends TestCase { public IInstallableUnit createIUFragment(String name) { InstallableUnitFragmentDescription iu = new InstallableUnitFragmentDescription(); iu.setId(name); - iu.setVersion(new Version(1, 0, 0)); + iu.setVersion(Version.createOSGi(1, 0, 0)); iu.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI); iu.setProperty(PROP_FRAG, "value"); IRequiredCapability[] reqs = new IRequiredCapability[] {MetadataFactory.createRequiredCapability("eclipse.touchpoint", "bundle", VersionRange.emptyRange, null, false, true), MetadataFactory.createRequiredCapability(TEST_REQUIRED, TEST_REQUIRED, VersionRange.emptyRange, null, true, false)}; iu.setHost(reqs); - IProvidedCapability[] cap = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("testCapabilityInFragment", "testCapabilityInFragment", new Version(1, 0, 0))}; + IProvidedCapability[] cap = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("testCapabilityInFragment", "testCapabilityInFragment", Version.createOSGi(1, 0, 0))}; iu.setCapabilities(cap); return MetadataFactory.createInstallableUnitFragment(iu); } @@ -154,10 +132,10 @@ public class FragmentMethodTest extends TestCase { public IInstallableUnit createIU(String name) { InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription(); iu.setId(name); - iu.setVersion(new Version(1, 0, 0)); + iu.setVersion(Version.createOSGi(1, 0, 0)); iu.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI); iu.setProperty(PROP_IU, "valueIU"); - IProvidedCapability[] cap = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("eclipse.touchpoint", "bundle", new Version(1, 0, 0)), MetadataFactory.createProvidedCapability("testCapability", "testCapability", new Version(1, 0, 0))}; + IProvidedCapability[] cap = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("eclipse.touchpoint", "bundle", Version.createOSGi(1, 0, 0)), MetadataFactory.createProvidedCapability("testCapability", "testCapability", Version.createOSGi(1, 0, 0))}; iu.setCapabilities(cap); return MetadataFactory.createInstallableUnit(iu); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java index 2e8e460ce..e51f887e5 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java @@ -10,13 +10,13 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata; -import java.util.HashMap; -import java.util.Iterator; +import java.util.*; import junit.framework.AssertionFailedError; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.MetadataFactory; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.FragmentQuery; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class FragmentTest extends AbstractProvisioningTest { @@ -27,7 +27,7 @@ public class FragmentTest extends AbstractProvisioningTest { IInstallableUnit iu2 = createBundleFragment("iuFragment.test1"); ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName())); createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2}); - Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, new Collector(), null).iterator(); + Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, null).iterator(); // ResolutionHelper rh = new ResolutionHelper(new Hashtable(), null); // HashSet set = new HashSet(); // set.add(iu1); @@ -36,8 +36,8 @@ public class FragmentTest extends AbstractProvisioningTest { for (; iterator.hasNext();) { IInstallableUnit iu = (IInstallableUnit) iterator.next(); if (iu.getId().equals(ID)) { - assertEquals(iu.getFragments().length, 1); - assertEquals(iu.getFragments()[0].getId(), "iuFragment.test1"); + assertEquals(iu.getFragments().size(), 1); + assertEquals(iu.getFragments().get(0).getId(), "iuFragment.test1"); } } } @@ -50,48 +50,48 @@ public class FragmentTest extends AbstractProvisioningTest { IInstallableUnit iu2 = createBundleFragment("iuFragment.test1"); ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName())); createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2, iu3}); - Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, new Collector(), null).iterator(); + Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, null).iterator(); for (; iterator.hasNext();) { IInstallableUnit iu = (IInstallableUnit) iterator.next(); if (iu.getId().equals(ID1)) { - assertEquals(iu.getFragments().length, 1); - assertEquals(iu.getFragments()[0].getId(), "iuFragment.test1"); + assertEquals(iu.getFragments().size(), 1); + assertEquals(iu.getFragments().get(0).getId(), "iuFragment.test1"); } if (iu.getId().equals(ID3)) { - assertEquals(iu.getFragments().length, 1); - assertEquals(iu.getFragments()[0].getId(), "iuFragment.test1"); + assertEquals(iu.getFragments().size(), 1); + assertEquals(iu.getFragments().get(0).getId(), "iuFragment.test1"); } } } public void testTouchpointData() { - assertEquals(createIUWithTouchpointData().getTouchpointData().length, 1); - assertEquals(createBundleFragment("iuFragment.test1").getTouchpointData().length, 1); + assertEquals(createIUWithTouchpointData().getTouchpointData().size(), 1); + assertEquals(createBundleFragment("iuFragment.test1").getTouchpointData().size(), 1); IInstallableUnit iu1 = createIUWithTouchpointData(); IInstallableUnit iu2 = createBundleFragment("iuFragment.test1"); ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName())); createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2}); - Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, new Collector(), null).iterator(); + Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, null).iterator(); for (; iterator.hasNext();) { IInstallableUnit iu = (IInstallableUnit) iterator.next(); if (iu.getId().equals(iu1.getId())) - assertEquals(2, iu.getTouchpointData().length); + assertEquals(2, iu.getTouchpointData().size()); } } public void testFragmentCapability() { IInstallableUnit iu = createBundleFragment("iuFragment.test1"); - assertEquals(Boolean.TRUE.toString(), iu.getProperty(IInstallableUnit.PROP_TYPE_FRAGMENT)); + assertTrue(FragmentQuery.isFragment(iu)); } public void testDefaultIUCapability() { IInstallableUnit iu = createEclipseIU("ui.test1"); - IProvidedCapability[] cap = iu.getProvidedCapabilities(); - for (int i = 0; i < cap.length; i++) { - if (cap[i].getNamespace().equals(IInstallableUnit.NAMESPACE_IU_ID)) { - assertEquals(cap[i].getNamespace(), IInstallableUnit.NAMESPACE_IU_ID); - assertEquals(cap[i].getName(), iu.getId()); + Collection<IProvidedCapability> capabilities = iu.getProvidedCapabilities(); + for (IProvidedCapability c : capabilities) { + if (c.getNamespace().equals(IInstallableUnit.NAMESPACE_IU_ID)) { + assertEquals(c.getNamespace(), IInstallableUnit.NAMESPACE_IU_ID); + assertEquals(c.getName(), iu.getId()); return; } } @@ -106,11 +106,10 @@ public class FragmentTest extends AbstractProvisioningTest { throw new AssertionFailedError("The array does not contain the searched element"); } - public static void assertContainsWithEquals(Object[] objects, Object searched) { - for (int i = 0; i < objects.length; i++) { - if (objects[i].equals(searched)) - return; - } + public static void assertContainsWithEquals(Collection<? extends Object> objects, Object searched) { + if (objects.contains(searched)) + return; + throw new AssertionFailedError("The array does not contain the searched element"); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java index cb384633f..fb301060c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java @@ -10,21 +10,20 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - import java.io.*; import java.util.*; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties; -import org.eclipse.equinox.internal.p2.metadata.InstallableUnit; -import org.eclipse.equinox.internal.p2.metadata.InstallableUnitPatch; +import org.eclipse.equinox.internal.p2.metadata.*; import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataParser; import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataWriter; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.BundleContext; +import org.osgi.framework.Filter; import org.xml.sax.*; public class IUPatchPersistenceTest extends AbstractProvisioningTest { @@ -34,8 +33,8 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest { private static String PackagesNS = "osgi.packages"; private static String id = "org.eclipse.osgi.services"; - private static Version version = new Version("3.1.200.v20070605"); - private static String filter = "(& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))"; // not really + private static Version version = Version.create("3.1.200.v20070605"); + private static Filter filter = ExpressionUtil.parseLDAP("(& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))"); // not really private static String[][] properties = new String[][] {new String[] {"equinox.p2.name", "OSGi Release 4.0.1 Services"}, // new String[] {"equinox.p2.description", "OSGi Service Platform Release 4.0.1 Service Interfaces and Classes"}, // @@ -95,7 +94,7 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest { IProvidedCapability[] provided = new IProvidedCapability[provideTuples.length]; for (int i = 0; i < provideTuples.length; i++) { String[] nextTuple = provideTuples[i]; - provided[i] = MetadataFactory.createProvidedCapability(nextTuple[0], nextTuple[1], new Version(nextTuple[2])); + provided[i] = MetadataFactory.createProvidedCapability(nextTuple[0], nextTuple[1], Version.create(nextTuple[2])); } // provided[provideTuples.length] = BUNDLE_CAPABILITY; return provided; @@ -105,7 +104,7 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest { IRequiredCapability[] required = new IRequiredCapability[requireTuples.length]; for (int i = 0; i < requireTuples.length; i++) { String[] nextTuple = requireTuples[i]; - required[i] = MetadataFactory.createRequiredCapability(nextTuple[0], nextTuple[1], new VersionRange(nextTuple[2]), null, Boolean.valueOf(nextTuple[3]).booleanValue(), false); + required[i] = (IRequiredCapability) MetadataFactory.createRequiredCapability(nextTuple[0], nextTuple[1], new VersionRange(nextTuple[2]), null, Boolean.valueOf(nextTuple[3]).booleanValue(), false); } return required; } @@ -120,7 +119,7 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest { } private static String IU_TEST_TARGET = "installableUnitTest"; - private static Version IU_TEST_VERSION = new Version("0.0.1"); + private static Version IU_TEST_VERSION = Version.create("0.0.1"); private static String IU_TEST_ELEMENT = "test"; @@ -286,8 +285,8 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest { IRequirementChange change1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequirementChange change2 = MetadataFactory.createRequirementChange(null, MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequirementChange change3 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), null); - IRequiredCapability[][] scope = new IRequiredCapability[][] { {MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true), MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true)}, {MetadataFactory.createRequiredCapability("zoo", "far", null, null, true, true)}}; - IRequiredCapability lifeCycle = MetadataFactory.createRequiredCapability("zoo", "x", null, null, false, false, false); + IRequiredCapability[][] scope = new IRequiredCapability[][] { {(IRequiredCapability) MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true), (IRequiredCapability) MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true)}, {(IRequiredCapability) MetadataFactory.createRequiredCapability("zoo", "far", null, null, true, true)}}; + IRequiredCapability lifeCycle = (IRequiredCapability) MetadataFactory.createRequiredCapability("zoo", "x", null, null, false, false, false); IInstallableUnitPatch iu = createIUPatch(id, version, filter, requirements, additionalProvides, propertyMap, TOUCHPOINT_OSGI, tpData, singleton, update, new IRequirementChange[] {change1, change2, change3}, scope, lifeCycle, metaRequirements); return iu; } @@ -296,11 +295,11 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest { validateIU(iu); assertTrue(iu.getApplicabilityScope() != null); assertTrue(iu.getRequiredCapabilities() != null); - assertEquals(3, iu.getRequirementsChange().length); - assertEquals(null, iu.getRequirementsChange()[1].applyOn()); - assertNotNull(iu.getRequirementsChange()[1].newValue()); - assertEquals(null, iu.getRequirementsChange()[2].newValue()); - assertNotNull(iu.getRequirementsChange()[2].applyOn()); + assertEquals(3, iu.getRequirementsChange().size()); + assertEquals(null, iu.getRequirementsChange().get(1).applyOn()); + assertNotNull(iu.getRequirementsChange().get(1).newValue()); + assertEquals(null, iu.getRequirementsChange().get(2).newValue()); + assertNotNull(iu.getRequirementsChange().get(2).applyOn()); assertEquals(2, iu.getApplicabilityScope().length); assertEquals(2, iu.getApplicabilityScope()[0].length); assertEquals(1, iu.getApplicabilityScope()[1].length); @@ -346,31 +345,33 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest { } private static String[][] extractProvides(IInstallableUnit iu) { - IProvidedCapability[] provydes = iu.getProvidedCapabilities(); - String[][] tuples = new String[provydes.length][3]; - for (int i = 0; i < provydes.length; i++) { - IProvidedCapability next = provydes[i]; - tuples[i] = new String[] {next.getNamespace(), next.getName(), next.getVersion().toString()}; + Collection<IProvidedCapability> provydes = iu.getProvidedCapabilities(); + String[][] tuples = new String[provydes.size()][3]; + int i = 0; + for (IProvidedCapability capability : provydes) { + tuples[i++] = new String[] {capability.getNamespace(), capability.getName(), capability.getVersion().toString()}; } return tuples; } private static String[][] extractRequires(IInstallableUnit iu) { - IRequiredCapability[] requyres = iu.getRequiredCapabilities(); - String[][] tuples = new String[requyres.length][4]; - for (int i = 0; i < requyres.length; i++) { - IRequiredCapability next = requyres[i]; - tuples[i] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.isOptional()).toString()}; + Collection<IRequirement> reqs = iu.getRequiredCapabilities(); + String[][] tuples = new String[reqs.size()][4]; + int i = 0; + for (Iterator iterator = reqs.iterator(); iterator.hasNext();) { + IRequiredCapability next = (IRequiredCapability) iterator.next(); + tuples[i++] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.getMin() == 0).toString()}; } return tuples; } private static String[][] extractMetaRequires(IInstallableUnit iu) { - IRequiredCapability[] requyres = iu.getMetaRequiredCapabilities(); - String[][] tuples = new String[requyres.length][4]; - for (int i = 0; i < requyres.length; i++) { - IRequiredCapability next = requyres[i]; - tuples[i] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.isOptional()).toString()}; + Collection<IRequirement> requyres = iu.getMetaRequiredCapabilities(); + String[][] tuples = new String[requyres.size()][4]; + int i = 0; + for (Iterator iterator = requyres.iterator(); iterator.hasNext();) { + IRequiredCapability next = (IRequiredCapability) iterator.next(); + tuples[i++] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.getMin() == 0).toString()}; } return tuples; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java index b4f5feba1..3f7989298 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java @@ -10,21 +10,22 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - import java.io.*; +import java.net.URI; import java.util.*; import javax.xml.parsers.ParserConfigurationException; import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties; -import org.eclipse.equinox.internal.p2.metadata.InstallableUnit; -import org.eclipse.equinox.internal.p2.metadata.InstallableUnitPatch; +import org.eclipse.equinox.internal.p2.metadata.*; import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataParser; import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataWriter; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.BundleContext; +import org.osgi.framework.Filter; import org.xml.sax.*; public class IUPersistenceTest extends AbstractProvisioningTest { @@ -134,7 +135,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest { } } - private static String filter = "(& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))"; // not really + private static Filter filter = ExpressionUtil.parseLDAP("(& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))"); // not really private static String id = "org.eclipse.osgi.services"; private static String[][] instructions = new String[][] {new String[] {"manifest", "Manifest-Version: 1.0\\Bundle-Vendor: Eclipse.org\\Bundle-ContactAddress: www.eclipse.org\\...a whole bunch of other manifest content..."}, new String[] {"zipped", "true"}, // @@ -144,7 +145,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest { private static String IU_TEST_TARGET = "installableUnitTest"; - private static Version IU_TEST_VERSION = new Version("0.0.1"); + private static Version IU_TEST_VERSION = Version.create("0.0.1"); // Randomly chose org.eclipse.osgi.services as the IU for testing persistence // but 'enhanced' it for better coverage. @@ -176,7 +177,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest { private static String[][] metaRequires = new String[][] {new String[] {PackagesNS, "some.actions1", "0.0.0", "true"}, // new String[] {PackagesNS, "some.actions2", "1.2.0", "false"}}; // - private static Version version = new Version("3.1.200.v20070605"); + private static Version version = Version.create("3.1.200.v20070605"); private Map propertyMap; @@ -203,7 +204,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest { IProvidedCapability[] provided = new IProvidedCapability[provideTuples.length]; for (int i = 0; i < provideTuples.length; i++) { String[] nextTuple = provideTuples[i]; - provided[i] = MetadataFactory.createProvidedCapability(nextTuple[0], nextTuple[1], new Version(nextTuple[2])); + provided[i] = MetadataFactory.createProvidedCapability(nextTuple[0], nextTuple[1], Version.create(nextTuple[2])); } // provided[provideTuples.length] = BUNDLE_CAPABILITY; return provided; @@ -213,7 +214,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest { IRequiredCapability[] required = new IRequiredCapability[requireTuples.length]; for (int i = 0; i < requireTuples.length; i++) { String[] nextTuple = requireTuples[i]; - required[i] = MetadataFactory.createRequiredCapability(nextTuple[0], nextTuple[1], new VersionRange(nextTuple[2]), null, Boolean.valueOf(nextTuple[3]).booleanValue(), false); + required[i] = (IRequiredCapability) MetadataFactory.createRequiredCapability(nextTuple[0], nextTuple[1], new VersionRange(nextTuple[2]), null, Boolean.valueOf(nextTuple[3]).booleanValue(), false); } return required; } @@ -232,38 +233,40 @@ public class IUPersistenceTest extends AbstractProvisioningTest { } private static String[][] extractProvides(IInstallableUnit iu) { - IProvidedCapability[] provydes = iu.getProvidedCapabilities(); - String[][] tuples = new String[provydes.length][3]; - for (int i = 0; i < provydes.length; i++) { - IProvidedCapability next = provydes[i]; - tuples[i] = new String[] {next.getNamespace(), next.getName(), next.getVersion().toString()}; + Collection<IProvidedCapability> provydes = iu.getProvidedCapabilities(); + String[][] tuples = new String[provydes.size()][3]; + int i = 0; + for (IProvidedCapability capability : provydes) { + tuples[i++] = new String[] {capability.getNamespace(), capability.getName(), capability.getVersion().toString()}; } return tuples; } private static String[][] extractRequires(IInstallableUnit iu) { - IRequiredCapability[] requyres = iu.getRequiredCapabilities(); - String[][] tuples = new String[requyres.length][4]; - for (int i = 0; i < requyres.length; i++) { - IRequiredCapability next = requyres[i]; - tuples[i] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.isOptional()).toString()}; + Collection<IRequirement> requyres = iu.getRequiredCapabilities(); + String[][] tuples = new String[requyres.size()][4]; + int i = 0; + for (Iterator iterator = requyres.iterator(); iterator.hasNext();) { + IRequiredCapability next = (IRequiredCapability) iterator.next(); + tuples[i++] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.getMin() == 0).toString()}; } return tuples; } private static String[][] extractMetaRequires(IInstallableUnit iu) { - IRequiredCapability[] requyres = iu.getMetaRequiredCapabilities(); - String[][] tuples = new String[requyres.length][4]; - for (int i = 0; i < requyres.length; i++) { - IRequiredCapability next = requyres[i]; - tuples[i] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.isOptional()).toString()}; + Collection<IRequirement> requyres = iu.getMetaRequiredCapabilities(); + String[][] tuples = new String[requyres.size()][4]; + int i = 0; + for (Iterator iterator = requyres.iterator(); iterator.hasNext();) { + IRequiredCapability next = (IRequiredCapability) iterator.next(); + tuples[i++] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.getMin() == 0).toString()}; } return tuples; } private IInstallableUnitPatch createPatchIU() { propertyMap = createProperties(properties); - propertyMap.put(IInstallableUnit.PROP_TYPE_PATCH, "true"); + propertyMap.put(InstallableUnitDescription.PROP_TYPE_PATCH, "true"); IProvidedCapability[] additionalProvides = createProvided(provides); IRequiredCapability[] requirements = createRequired(requires); IRequiredCapability[] metaRequirements = createRequired(metaRequires); @@ -273,14 +276,14 @@ public class IUPersistenceTest extends AbstractProvisioningTest { IRequirementChange change1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequirementChange change2 = MetadataFactory.createRequirementChange(null, MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequirementChange change3 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), null); - IRequiredCapability[][] scope = new IRequiredCapability[][] { {MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true), MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true)}, {MetadataFactory.createRequiredCapability("zoo", "far", null, null, true, true)}}; + IRequiredCapability[][] scope = new IRequiredCapability[][] { {(IRequiredCapability) MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true), (IRequiredCapability) MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true)}, {(IRequiredCapability) MetadataFactory.createRequiredCapability("zoo", "far", null, null, true, true)}}; IInstallableUnitPatch iu = createIUPatch(id, version, filter, requirements, additionalProvides, propertyMap, TOUCHPOINT_OSGI, tpData, singleton, update, new IRequirementChange[] {change1, change2, change3}, scope, null, metaRequirements); return iu; } private IInstallableUnitPatch createPatchWithEmptyScope() { propertyMap = createProperties(properties); - propertyMap.put(IInstallableUnit.PROP_TYPE_PATCH, "true"); + propertyMap.put(InstallableUnitDescription.PROP_TYPE_PATCH, "true"); IProvidedCapability[] additionalProvides = createProvided(provides); IRequiredCapability[] requirements = createRequired(requires); IRequiredCapability[] metaRequirements = createRequired(metaRequires); @@ -300,10 +303,35 @@ public class IUPersistenceTest extends AbstractProvisioningTest { IProvidedCapability[] additionalProvides = createProvided(provides); IRequiredCapability[] requirements = createRequired(requires); IRequiredCapability[] metaRequirements = createRequired(metaRequires); + ILicense[] licenses = new ILicense[] {MetadataFactory.createLicense(URI.create("http://eclipse.org"), "license text"), MetadataFactory.createLicense(URI.create("http://apache.org"), "license text2")}; ITouchpointData tpData = createTouchpointData(instructions); IUpdateDescriptor update = createUpdateDescriptor(); - boolean singleton = false; - IInstallableUnit iu = createIU(id, version, filter, requirements, additionalProvides, propertyMap, TOUCHPOINT_OSGI, tpData, singleton, update, metaRequirements); + InstallableUnitDescription iu1 = new MetadataFactory.InstallableUnitDescription(); + iu1.setId(id); + iu1.setVersion(version); + iu1.setFilter(filter); + iu1.setLicenses(licenses); + IProvidedCapability[] provides1 = new IProvidedCapability[additionalProvides.length + 1]; + provides1[0] = getSelfCapability(id, version); + for (int i = 0; i < additionalProvides.length; i++) { + provides1[i + 1] = additionalProvides[i]; + } + for (Iterator iter = propertyMap.keySet().iterator(); iter.hasNext();) { + String nextKey = (String) iter.next(); + String nextValue = (String) propertyMap.get(nextKey); + iu1.setProperty(nextKey, nextValue); + } + iu1.setCapabilities(provides1); + iu1.setRequiredCapabilities(requirements); + iu1.setTouchpointType(TOUCHPOINT_OSGI); + if (tpData != null) + iu1.addTouchpointData(tpData); + iu1.setSingleton(false); + iu1.setUpdateDescriptor(update); + if (metaRequirements == null) + metaRequirements = NO_REQUIRES; + iu1.setMetaRequiredCapabilities(metaRequirements); + IInstallableUnit iu = MetadataFactory.createInstallableUnit(iu1); return iu; } @@ -370,6 +398,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest { assertTrue("Error parsing test iu: " + parser.getStatus().getMessage(), parser.getStatus().isOK()); InstallableUnit iu1 = (InstallableUnit) parser.getRootObject(); validateIU(iu1); + assertEquals(2, iu1.getLicenses().size()); ByteArrayOutputStream output1 = new ByteArrayOutputStream(1492); IUStringWriter writer = new IUStringWriter(output1); writer.writeTest(iu1); @@ -381,7 +410,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest { private void validateIU(IInstallableUnit iu) { assertTrue("Installable unit id is not correct", id.equals(iu.getId())); assertTrue("Installable unit version is not correct", version.equals(iu.getVersion())); - assertTrue("Installable unit filter is not correct", filter.equals(iu.getFilter())); + assertTrue("Installable unit filter is not correct", filter.equals(iu.getFilter() == null ? null : iu.getFilter())); assertEquals("Installable unit properties are not correct", propertyMap, iu.getProperties()); assertTrue("Installable unit provided capabilities are not correct", equal(addSelfCapability(iu, provides), extractProvides(iu))); assertTrue("Installable unit required capabilities are not correct", equal(requires, extractRequires(iu))); @@ -396,11 +425,11 @@ public class IUPersistenceTest extends AbstractProvisioningTest { validateIU(iu); assertTrue(iu.getApplicabilityScope() != null); assertTrue(iu.getRequiredCapabilities() != null); - assertEquals(3, iu.getRequirementsChange().length); - assertEquals(null, iu.getRequirementsChange()[1].applyOn()); - assertNotNull(iu.getRequirementsChange()[1].newValue()); - assertEquals(null, iu.getRequirementsChange()[2].newValue()); - assertNotNull(iu.getRequirementsChange()[2].applyOn()); + assertEquals(3, iu.getRequirementsChange().size()); + assertEquals(null, iu.getRequirementsChange().get(1).applyOn()); + assertNotNull(iu.getRequirementsChange().get(1).newValue()); + assertEquals(null, iu.getRequirementsChange().get(2).newValue()); + assertNotNull(iu.getRequirementsChange().get(2).applyOn()); assertEquals(2, iu.getApplicabilityScope().length); assertEquals(2, iu.getApplicabilityScope()[0].length); assertEquals(1, iu.getApplicabilityScope()[1].length); @@ -411,11 +440,11 @@ public class IUPersistenceTest extends AbstractProvisioningTest { validateIU(iu); assertTrue(iu.getApplicabilityScope() != null); assertTrue(iu.getRequiredCapabilities() != null); - assertEquals(3, iu.getRequirementsChange().length); - assertEquals(null, iu.getRequirementsChange()[1].applyOn()); - assertNotNull(iu.getRequirementsChange()[1].newValue()); - assertEquals(null, iu.getRequirementsChange()[2].newValue()); - assertNotNull(iu.getRequirementsChange()[2].applyOn()); + assertEquals(3, iu.getRequirementsChange().size()); + assertEquals(null, iu.getRequirementsChange().get(1).applyOn()); + assertNotNull(iu.getRequirementsChange().get(1).newValue()); + assertEquals(null, iu.getRequirementsChange().get(2).newValue()); + assertNotNull(iu.getRequirementsChange().get(2).applyOn()); assertEquals(0, iu.getApplicabilityScope().length); assertNull(iu.getLifeCycle()); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/InstallableUnitTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/InstallableUnitTest.java index c51bf173b..68d6dd67f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/InstallableUnitTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/InstallableUnitTest.java @@ -10,10 +10,13 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IProvidedCapability; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** @@ -24,7 +27,7 @@ public class InstallableUnitTest extends AbstractProvisioningTest { * Tests for {@link org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit#satisfies(org.eclipse.equinox.internal.provisional.p2.metadata.RequiredCapability)}. */ public void testSatisfies() { - IProvidedCapability[] provides = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("testNamespace", "name", new Version(1, 0, 0))}; + IProvidedCapability[] provides = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("testNamespace", "name", Version.createOSGi(1, 0, 0))}; IInstallableUnit iu = createIU("iu", provides); IRequiredCapability wrongNamespace = MetadataFactory.createRequiredCapability("wrongNamespace", "name", VersionRange.emptyRange, null, false, false); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LatestIUTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LatestIUTest.java index 525e15c7c..8814ae826 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LatestIUTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LatestIUTest.java @@ -9,14 +9,13 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.net.URI; -import java.util.Collection; -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.LatestIUVersionQuery; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.internal.p2.metadata.query.LatestIUVersionQuery; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestData; @@ -36,10 +35,9 @@ public class LatestIUTest extends AbstractProvisioningTest { IMetadataRepositoryManager metadataRepositoryManager = getMetadataRepositoryManager(); metadataRepositoryManager.addRepository(location); - Collector query = metadataRepositoryManager.query(new LatestIUVersionQuery(), new Collector(), null); - Collection collection = query.toCollection(); - assertEquals("1.0", 1, collection.size()); - assertEquals("1.1", new Version(2, 1, 0), ((IInstallableUnit) collection.iterator().next()).getVersion()); + IQueryResult query = metadataRepositoryManager.query(new LatestIUVersionQuery(), null); + assertEquals("1.0", 1, queryResultSize(query)); + assertEquals("1.1", Version.createOSGi(2, 1, 0), ((IInstallableUnit) query.iterator().next()).getVersion()); } public void testLatestIUSingleRepo2() throws Exception { @@ -53,10 +51,9 @@ public class LatestIUTest extends AbstractProvisioningTest { IMetadataRepositoryManager metadataRepositoryManager = getMetadataRepositoryManager(); metadataRepositoryManager.addRepository(location); - Collector query = metadataRepositoryManager.query(new LatestIUVersionQuery(), new Collector(), null); - Collection collection = query.toCollection(); - assertEquals("1.0", 1, collection.size()); - assertEquals("1.1", new Version(3, 0, 0), ((IInstallableUnit) collection.iterator().next()).getVersion()); + IQueryResult query = metadataRepositoryManager.query(new LatestIUVersionQuery(), null); + assertEquals("1.0", 1, queryResultSize(query)); + assertEquals("1.1", Version.createOSGi(3, 0, 0), ((IInstallableUnit) query.iterator().next()).getVersion()); } public void testLatestIUMultiRepo() throws Exception { @@ -73,9 +70,8 @@ public class LatestIUTest extends AbstractProvisioningTest { metadataRepositoryManager.addRepository(location1); metadataRepositoryManager.addRepository(location2); - Collector collector = metadataRepositoryManager.query(new LatestIUVersionQuery(), new Collector(), null); - Collection collection = collector.toCollection(); - assertEquals("1.0", 1, collection.size()); - assertEquals("1.1", new Version(3, 0, 0), ((IInstallableUnit) collection.iterator().next()).getVersion()); + IQueryResult queryResult = metadataRepositoryManager.query(new LatestIUVersionQuery(), null); + assertEquals("1.0", 1, queryResultSize(queryResult)); + assertEquals("1.1", Version.createOSGi(3, 0, 0), ((IInstallableUnit) queryResult.iterator().next()).getVersion()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java index c51d3097c..c62b1d75d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java @@ -12,8 +12,8 @@ package org.eclipse.equinox.p2.tests.metadata; import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.ILicense; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.metadata.ILicense; /** * Tests for License class @@ -22,10 +22,10 @@ public class LicenseTest extends TestCase { public void testNormalize() { ILicense licenseOne = MetadataFactory.createLicense(null, "a b"); ILicense licenseTwo = MetadataFactory.createLicense(null, "a\t\n\r \t\n\r b"); - assertEquals("1.0", licenseOne.getDigest(), licenseTwo.getDigest()); + assertEquals("1.0", licenseOne.getUUID(), licenseTwo.getUUID()); licenseOne = MetadataFactory.createLicense(null, " a b c "); licenseTwo = MetadataFactory.createLicense(null, "a\t\nb\r \t\n\r c"); - assertEquals("1.1", licenseOne.getDigest(), licenseTwo.getDigest()); + assertEquals("1.1", licenseOne.getUUID(), licenseTwo.getUUID()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java index 44c186449..e917893f3 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java @@ -10,14 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Collection; import java.util.Iterator; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.MetadataFactory; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MultipleIUAndFragmentTest extends AbstractProvisioningTest { @@ -40,16 +41,16 @@ public class MultipleIUAndFragmentTest extends AbstractProvisioningTest { iu3 = createBundleFragment("fragment"); ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName())); createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2, iu3}); - Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, new Collector(), null).iterator(); + Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, null).iterator(); for (; iterator.hasNext();) { IInstallableUnit iu = (IInstallableUnit) iterator.next(); if (iu.getId().equals(iu1.getId())) { - assertEquals(1, iu.getFragments().length); - assertEquals(iu.getFragments()[0].getId(), iu3.getId()); + assertEquals(1, iu.getFragments().size()); + assertEquals(iu.getFragments().get(0).getId(), iu3.getId()); } if (iu.getId().equals(iu2.getId())) { - assertEquals(1, iu.getFragments().length); - assertEquals(iu.getFragments()[0].getId(), iu3.getId()); + assertEquals(1, iu.getFragments().size()); + assertEquals(iu.getFragments().get(0).getId(), iu3.getId()); } if (iu.getId().equals(iu3.getId())) { //fragments don't have fragments diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ProvidedCapabilityTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ProvidedCapabilityTest.java index d78a65e24..316d64c50 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ProvidedCapabilityTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ProvidedCapabilityTest.java @@ -10,10 +10,10 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.IProvidedCapability; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.metadata.IProvidedCapability; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** @@ -23,7 +23,7 @@ public class ProvidedCapabilityTest extends AbstractProvisioningTest { public void testEquals() { IProvidedCapability cap = MetadataFactory.createProvidedCapability("namespace", "name", DEFAULT_VERSION); IProvidedCapability equal = MetadataFactory.createProvidedCapability("namespace", "name", DEFAULT_VERSION); - IProvidedCapability notEqual = MetadataFactory.createProvidedCapability("namespace", "name", new Version(2, 0, 0)); + IProvidedCapability notEqual = MetadataFactory.createProvidedCapability("namespace", "name", Version.createOSGi(2, 0, 0)); assertEquals("1.0", cap, equal); assertFalse("1.1", cap.equals(notEqual)); assertFalse("1.1", notEqual.equals(cap)); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/AllTests.java new file mode 100644 index 000000000..39fed0b38 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/AllTests.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * Copyright (c) 2007, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.metadata.expression; + +import junit.framework.*; + +/** + * Performs all automated director tests. + */ +public class AllTests extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(AllTests.class.getName()); + suite.addTestSuite(ExpressionTest.class); + suite.addTestSuite(FilterTest.class); + return suite; + } + +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/ExpressionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/ExpressionTest.java new file mode 100644 index 000000000..9c7407c63 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/ExpressionTest.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2009 Cloudsmith Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cloudsmith Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.metadata.expression; + +import org.eclipse.equinox.p2.metadata.expression.*; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +public class ExpressionTest extends AbstractProvisioningTest { + private static final IExpressionFactory factory = ExpressionUtil.getFactory(); + + protected void testExpression(String exprStr, Object expectedOutcome) throws Exception { + IExpression expr = ExpressionUtil.parse(exprStr); + assertEquals(expr.evaluate(factory.createContext()), expectedOutcome); + } + + protected void testMatch(String expr, boolean expectedOutcome) throws Exception { + testExpression(expr, Boolean.valueOf(expectedOutcome)); + } + + public void testCompare() throws Exception { + testMatch("'foo' == 'foo'", true); + testMatch("'foo' == 'fooo'", false); + testMatch("'foo' != 'foo'", false); + testMatch("'foo' != 'fooo'", true); + testMatch("2 < 1", false); + testMatch("2 <= 1", false); + testMatch("2 < 2", false); + testMatch("2 <= 2", true); + testMatch("2 < 3", true); + testMatch("2 <= 3", true); + testMatch("1 > 2", false); + testMatch("1 >= 2", false); + testMatch("2 > 2", false); + testMatch("2 >= 2", true); + testMatch("3 > 2", true); + testMatch("3 >= 2", true); + } + + public void testAutoCoerce() throws Exception { + testMatch("'12' == 12", true); + testMatch("'012' == 12", true); + testMatch("'2' > '10'", true); + testMatch("'2' > 10", false); + testMatch("true == 'true'", true); + testMatch("true == 'True'", true); + testMatch("false == 'false'", true); + testMatch("false == 'False'", true); + } + + public void testLeftToRigthAssociativity() throws Exception { + testMatch("2 < 10 == true", true); + try { + testMatch("true == 2 < 10", false); + fail("Auto coercion from boolean to integer succeded"); + } catch (IllegalArgumentException e) { + // OK + } + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java new file mode 100644 index 000000000..cf3cba552 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java @@ -0,0 +1,267 @@ +package org.eclipse.equinox.p2.tests.metadata.expression; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.*; +import junit.framework.*; +import org.eclipse.equinox.p2.metadata.expression.*; +import org.osgi.framework.*; + +public class FilterTest extends TestCase { + private static class DictionaryServiceReference implements ServiceReference { + private final Map<String, ? extends Object> dictionary; + + private final String[] keys; + + DictionaryServiceReference(Map<String, ? extends Object> dictionary) { + if (dictionary == null) { + this.dictionary = null; + this.keys = new String[] {}; + return; + } + this.dictionary = dictionary; + List<String> keyList = new ArrayList<String>(dictionary.size()); + for (Iterator<String> e = dictionary.keySet().iterator(); e.hasNext();) { + String key = e.next(); + for (Iterator i = keyList.iterator(); i.hasNext();) { + if (key.equalsIgnoreCase((String) i.next())) { + throw new IllegalArgumentException(); + } + } + keyList.add(key); + } + this.keys = keyList.toArray(new String[keyList.size()]); + } + + public int compareTo(Object reference) { + throw new UnsupportedOperationException(); + } + + public Bundle getBundle() { + return null; + } + + public Object getProperty(String k) { + for (int i = 0, length = keys.length; i < length; i++) { + String key = keys[i]; + if (key.equalsIgnoreCase(k)) { + return dictionary.get(key); + } + } + return null; + } + + public String[] getPropertyKeys() { + return keys.clone(); + } + + public Bundle[] getUsingBundles() { + throw new UnsupportedOperationException(); + } + + public boolean isAssignableTo(Bundle bundle, String className) { + throw new UnsupportedOperationException(); + } + } + + private static class SampleComparable implements Comparable { + private int value = -1; + + public SampleComparable(String value) { + this.value = Integer.parseInt(value); + } + + public boolean equals(Object o) { + return o instanceof SampleComparable && value == ((SampleComparable) o).value; + } + + public int compareTo(Object o) { + return value - ((SampleComparable) o).value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + } + + static final int ISTRUE = 1; + + static final int ISFALSE = 2; + + static final int ISILLEGAL = 3; + + public static Test suite() { + return new TestSuite(FilterTest.class); + } + + public void testComparable() throws Exception { + IFilterExpression f1 = ExpressionUtil.parseLDAP("(comparable=42)"); //$NON-NLS-1$ + Object comp; + Map<String, Object> hash = new HashMap<String, Object>(); + + comp = new SampleComparable("42"); //$NON-NLS-1$ + hash.put("comparable", comp); //$NON-NLS-1$ + assertTrue("does not match filter", f1.match(hash)); //$NON-NLS-1$ + assertTrue("does not match filter", f1.match(new DictionaryServiceReference(hash))); //$NON-NLS-1$ + + comp = new Long(42); + hash.put("comparable", comp); //$NON-NLS-1$ + assertTrue("does not match filter", f1.match(hash)); //$NON-NLS-1$ + assertTrue("does not match filter", f1.match(new DictionaryServiceReference(hash))); //$NON-NLS-1$ + + IFilterExpression f2 = ExpressionUtil.parseLDAP("(comparable=42)"); //$NON-NLS-1$ + hash = new Hashtable<String, Object>(); + + comp = new SampleComparable("42"); //$NON-NLS-1$ + hash.put("comparable", comp); //$NON-NLS-1$ + assertTrue("does not match filter", f2.match(hash)); //$NON-NLS-1$ + assertTrue("does not match filter", f2.match(new DictionaryServiceReference(hash))); //$NON-NLS-1$ + + comp = new Long(42); + hash.put("comparable", comp); //$NON-NLS-1$ + assertTrue("does not match filter", f2.match(hash)); //$NON-NLS-1$ + assertTrue("does not match filter", f2.match(new DictionaryServiceReference(hash))); //$NON-NLS-1$ + + assertEquals("not equal", f1, f2); //$NON-NLS-1$ + } + + public void testFilter() { + Properties props = new Properties(); + props.put("room", "bedroom"); //$NON-NLS-1$ //$NON-NLS-2$ + props.put("channel", new Integer(34)); //$NON-NLS-1$ + props.put("status", "(on\\)*"); //$NON-NLS-1$//$NON-NLS-2$ + props.put("max record time", new Long(150)); //$NON-NLS-1$ + props.put("canrecord", "true(x)"); //$NON-NLS-1$ //$NON-NLS-2$ + props.put("shortvalue", new Short((short) 1000)); //$NON-NLS-1$ + props.put("bytevalue", new Byte((byte) 10)); //$NON-NLS-1$ + props.put("floatvalue", new Float(1.01)); //$NON-NLS-1$ + props.put("doublevalue", new Double(2.01)); //$NON-NLS-1$ + props.put("charvalue", new Character('A')); //$NON-NLS-1$ + props.put("booleanvalue", new Boolean(false)); //$NON-NLS-1$ + props.put("weirdvalue", new Hashtable()); //$NON-NLS-1$ + try { + props.put("bigintvalue", new BigInteger("4123456")); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (NoClassDefFoundError e) { + // ignore + } + try { + props.put("bigdecvalue", new BigDecimal("4.123456")); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (NoClassDefFoundError e) { + // ignore + } + + testFilter("(room=*)", props, ISTRUE); //$NON-NLS-1$ + testFilter("(rooom=*)", props, ISFALSE); //$NON-NLS-1$ + testFilter("(room=bedroom)", props, ISTRUE); //$NON-NLS-1$ + testFilter("(room~= B E D R O O M )", props, ISTRUE); //$NON-NLS-1$ + testFilter("(room=abc)", props, ISFALSE); //$NON-NLS-1$ + testFilter(" ( room >=aaaa)", props, ISTRUE); //$NON-NLS-1$ + testFilter("(room <=aaaa)", props, ISFALSE); //$NON-NLS-1$ + testFilter(" ( room =b*) ", props, ISTRUE); //$NON-NLS-1$ + testFilter(" ( room =*m) ", props, ISTRUE); //$NON-NLS-1$ + testFilter("(room=bed*room)", props, ISTRUE); //$NON-NLS-1$ + testFilter(" ( room =b*oo*m) ", props, ISTRUE); //$NON-NLS-1$ + testFilter(" ( room =*b*oo*m*) ", props, ISTRUE); //$NON-NLS-1$ + testFilter(" ( room =b*b* *m*) ", props, ISFALSE); //$NON-NLS-1$ + testFilter(" (& (room =bedroom) (channel = 34))", props, ISTRUE); //$NON-NLS-1$ + testFilter(" (& (room =b*) (room =*x) (channel=34))", props, ISFALSE); //$NON-NLS-1$ + testFilter("(| (room =bed*)(channel=222)) ", props, ISTRUE); //$NON-NLS-1$ + testFilter("(| (room =boom*)(channel=34)) ", props, ISTRUE); //$NON-NLS-1$ + testFilter(" (! (room =ab*b*oo*m*) ) ", props, ISTRUE); //$NON-NLS-1$ + testFilter(" (status =\\(o*\\\\\\)\\*) ", props, ISTRUE); //$NON-NLS-1$ + testFilter(" (status =\\28o*\\5c\\29\\2a) ", props, ISTRUE); //$NON-NLS-1$ + testFilter(" (status =\\28o*\\5C\\29\\2A) ", props, ISTRUE); //$NON-NLS-1$ + testFilter(" (canRecord =true\\(x\\)) ", props, ISTRUE); //$NON-NLS-1$ + testFilter("(max Record Time <=150) ", props, ISTRUE); //$NON-NLS-1$ + testFilter("(shortValue >= 100) ", props, ISTRUE); //$NON-NLS-1$ + testFilter(" ( & ( byteValue <= 100 ) ( byteValue >= 10 ) ) ", props, ISTRUE); //$NON-NLS-1$ + testFilter("(bigIntValue = 4123456) ", props, ISTRUE); //$NON-NLS-1$ + testFilter("(bigDecValue = 4.123456) ", props, ISTRUE); //$NON-NLS-1$ + testFilter("(floatValue >= 1.0) ", props, ISTRUE); //$NON-NLS-1$ + testFilter("(doubleValue <= 2.011) ", props, ISTRUE); //$NON-NLS-1$ + testFilter("(charValue ~= a) ", props, ISTRUE); //$NON-NLS-1$ + testFilter("(booleanValue = false) ", props, ISTRUE); //$NON-NLS-1$ + testFilter("(& (| (room =d*m) (room =bed*) (room=abc)) (! (channel=999)))", props, ISTRUE); //$NON-NLS-1$ + testFilter("(room=bedroom)", null, ISFALSE); //$NON-NLS-1$ + + testFilter("()", props, ISILLEGAL); //$NON-NLS-1$ + testFilter("(=foo)", props, ISILLEGAL); //$NON-NLS-1$ + testFilter("(", props, ISILLEGAL); //$NON-NLS-1$ + testFilter("(abc = ))", props, ISILLEGAL); //$NON-NLS-1$ + testFilter("(& (abc = xyz) (& (345))", props, ISILLEGAL); //$NON-NLS-1$ + testFilter(" (room = b**oo!*m*) ) ", props, ISILLEGAL); //$NON-NLS-1$ + testFilter(" (room = b**oo)*m*) ) ", props, ISILLEGAL); //$NON-NLS-1$ + testFilter(" (room = *=b**oo*m*) ) ", props, ISILLEGAL); //$NON-NLS-1$ + testFilter(" (room = =b**oo*m*) ) ", props, ISILLEGAL); //$NON-NLS-1$ + + try { + Filter f1 = ExpressionUtil.parseLDAP("( a = bedroom )"); //$NON-NLS-1$ + Filter f2 = ExpressionUtil.parseLDAP(" (a= bedroom ) "); //$NON-NLS-1$ + assertEquals("not equal", "(a= bedroom )", f1.toString()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("not equal", "(a= bedroom )", f2.toString()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("not equal", f1, f2); //$NON-NLS-1$ + assertEquals("not equal", f2, f1); //$NON-NLS-1$ + assertEquals("not equal", f1.hashCode(), f2.hashCode()); //$NON-NLS-1$ + + f1 = ExpressionUtil.parseLDAP("(status =\\28o*\\5c\\29\\2a)"); + assertEquals("not equal", "(status=\\28o*\\5c\\29\\2a)", f1.toString()); //$NON-NLS-1$ //$NON-NLS-2$ + + f1 = ExpressionUtil.parseLDAP("(|(a=1)(&(a=1)(b=1)))"); //$NON-NLS-1$ + f2 = ExpressionUtil.parseLDAP("(a=1)"); //$NON-NLS-1$ + System.out.println(f2.toString()); + System.out.println(f1.toString()); + + f1 = ExpressionUtil.parseLDAP("(|(&(os=macos)(ws=cocoa)(arch=x86))(&(ws=cocoa)(os=macos)(arch=ppc)))"); //$NON-NLS-1$ + f2 = ExpressionUtil.parseLDAP("(&(os=macos)(ws=cocoa)(|(arch=x86)(arch=ppc)))"); //$NON-NLS-1$ + System.out.println(f2.toString()); + System.out.println(f1.toString()); + assertEquals("not equal", f1, f2); //$NON-NLS-1$ + + f1 = ExpressionUtil.parseLDAP("(&(|(x=a)(y=b)(z=a))(|(x=a)(y=b)(z=b)))"); //$NON-NLS-1$ + f2 = ExpressionUtil.parseLDAP("(|(x=a)(y=b)(&(z=a)(z=b)))"); //$NON-NLS-1$ + System.out.println(f2.toString()); + System.out.println(f1.toString()); + assertEquals("not equal", f1, f2); //$NON-NLS-1$ + + f1 = ExpressionUtil.parseLDAP("(&(a=1)(|(a=1)(b=1)))"); //$NON-NLS-1$ + f2 = ExpressionUtil.parseLDAP("(a=1)"); //$NON-NLS-1$ + System.out.println(f2.toString()); + System.out.println(f1.toString()); + + f1 = ExpressionUtil.parseLDAP("(|(a=1)(&(a=1)(b=1)))"); //$NON-NLS-1$ + f2 = ExpressionUtil.parseLDAP("(a=1)"); //$NON-NLS-1$ + System.out.println(f2.toString()); + System.out.println(f1.toString()); + assertEquals("not equal", f1, f2); //$NON-NLS-1$ + } catch (IllegalArgumentException e) { + fail("unexpected invalid syntax: " + e); //$NON-NLS-1$ + } + testFilter("(weirdValue = 100) ", props, ISFALSE); //$NON-NLS-1$ + + } + + private void testFilter(String query, Dictionary<?, ?> props, int expect) { + final ServiceReference ref = new DictionaryServiceReference((Map) props); + Filter f1; + try { + f1 = ExpressionUtil.parseLDAP(query); + + if (expect == ISILLEGAL) { + fail("expected exception"); //$NON-NLS-1$ + } + } catch (ExpressionParseException e) { + System.out.println(e.toString()); + if (expect != ISILLEGAL) { + fail("exception: " + e.toString()); //$NON-NLS-1$ + } + return; + } + + boolean val = f1.match(props); + assertEquals("wrong result", expect == ISTRUE, val); //$NON-NLS-1$ + + val = f1.match(ref); + assertEquals("wrong result", expect == ISTRUE, val); //$NON-NLS-1$ + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/AuthTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/AuthTest.java index 6da986266..0338eb8ad 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/AuthTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/AuthTest.java @@ -13,8 +13,8 @@ import java.security.cert.Certificate; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.equinox.internal.p2.repository.RepositoryPreferences; import org.eclipse.equinox.internal.provisional.p2.core.IServiceUI; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.ServiceReference; @@ -30,7 +30,7 @@ public class AuthTest extends ServerBasedTestCase { super.setUp(); PRIVATE_REPO = super.getBaseURL() + "/private/mdr/composite/one"; NEVER_REPO = super.getBaseURL() + "/proxy/never"; - ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.class.getName()); + ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.SERVICE_NAME); mgr = (IMetadataRepositoryManager) TestActivator.context.getService(sr2); if (mgr == null) { throw new RuntimeException("Repository manager could not be loaded"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java index 7c7bd9a86..990e6b2c0 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java @@ -12,24 +12,26 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata.repository; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.net.URI; import java.net.URISyntaxException; import java.util.*; import org.eclipse.core.runtime.*; +import org.eclipse.equinox.internal.p2.metadata.query.LatestIUVersionQuery; import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository; import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepositoryFactory; import org.eclipse.equinox.internal.p2.persistence.CompositeRepositoryState; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; -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.internal.provisional.p2.repository.IRepository; +import org.eclipse.equinox.p2.core.ProvisionException; +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.IRepository; +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.TestData; import org.eclipse.equinox.p2.tests.core.CompoundQueryableTest.CompoundQueryTestProgressMonitor; @@ -101,7 +103,7 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { try { InstallableUnitDescription descriptor = new MetadataFactory.InstallableUnitDescription(); descriptor.setId("testIuId"); - descriptor.setVersion(new Version("3.2.1")); + descriptor.setVersion(Version.create("3.2.1")); IInstallableUnit iu = MetadataFactory.createInstallableUnit(descriptor); compRepo.addInstallableUnits(new IInstallableUnit[] {iu}); fail("Should not be able to insert InstallableUnit"); @@ -116,7 +118,8 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { //Try to remove an InstallableUnit. try { - compRepo.removeInstallableUnits(InstallableUnitQuery.ANY, null); + IQueryResult queryResult = compRepo.query(InstallableUnitQuery.ANY, null); + compRepo.removeInstallableUnits((IInstallableUnit[]) queryResult.toArray(IInstallableUnit.class), null); fail("Should not be able to remove InstallableUnit"); } catch (UnsupportedOperationException e) { //expected. fall through @@ -265,7 +268,7 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { assertContains("Assert child1's content is in composite repo", repo1, compRepo); assertContains("Assert child2's content is in composite repo", repo2, compRepo); //checks that the destination has the correct number of keys (no extras) - assertEquals("Assert correct number of IUs", getNumUnique(repo1.query(InstallableUnitQuery.ANY, new Collector(), null), repo2.query(InstallableUnitQuery.ANY, new Collector(), null)), compRepo.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals("Assert correct number of IUs", getNumUnique(repo1.query(InstallableUnitQuery.ANY, null), repo2.query(InstallableUnitQuery.ANY, null)), queryResultSize(compRepo.query(InstallableUnitQuery.ANY, null))); } public void testRemoveNonexistantChild() { @@ -430,7 +433,7 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { compRepo.addChild(repo2Location.toURI()); //force composite repository to load all children - compRepo.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()); + compRepo.query(InstallableUnitQuery.ANY, new NullProgressMonitor()); assertTrue("Ensuring previously loaded repo is enabled", getMetadataRepositoryManager().isEnabled(repo1Location.toURI())); String repo1System = getMetadataRepositoryManager().getRepositoryProperty(repo1Location.toURI(), IRepository.PROP_SYSTEM); @@ -456,10 +459,9 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { CompositeMetadataRepository compositeRepo = createRepo(false); compositeRepo.addChild(location1); compositeRepo.addChild(location2); - Collector collector = compositeRepo.query(new LatestIUVersionQuery(), new Collector(), monitor); - Collection collection = collector.toCollection(); - assertEquals("1.0", 1, collection.size()); - assertEquals("1.1", new Version(3, 0, 0), ((IInstallableUnit) collection.iterator().next()).getVersion()); + IQueryResult queryResult = compositeRepo.query(new LatestIUVersionQuery(), monitor); + assertEquals("1.0", 1, queryResultSize(queryResult)); + assertEquals("1.1", Version.createOSGi(3, 0, 0), ((IInstallableUnit) queryResult.iterator().next()).getVersion()); assertTrue("1.2", monitor.isDone()); assertTrue("1.3", monitor.isWorkDone()); } @@ -478,20 +480,19 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { CompositeMetadataRepository compositeRepo = createRepo(false); compositeRepo.addChild(location1); compositeRepo.addChild(location2); - CompositeQuery cQuery = new CompositeQuery(new Query[] {new MatchQuery() { + PipedQuery cQuery = new PipedQuery(new MatchQuery() { public boolean isMatch(Object candidate) { if (candidate instanceof IInstallableUnit) { IInstallableUnit iInstallableUnit = (IInstallableUnit) candidate; - if (iInstallableUnit.getVersion().compareTo(new Version(3, 0, 0)) < 0) + if (iInstallableUnit.getVersion().compareTo(Version.createOSGi(3, 0, 0)) < 0) return true; } return false; } - }, new LatestIUVersionQuery()}); - Collector collector = compositeRepo.query(cQuery, new Collector(), monitor); - Collection collection = collector.toCollection(); - assertEquals("1.0", 1, collection.size()); - assertEquals("1.1", new Version(2, 2, 0), ((IInstallableUnit) collection.iterator().next()).getVersion()); + }, new LatestIUVersionQuery()); + IQueryResult queryResult = compositeRepo.query(cQuery, monitor); + assertEquals("1.0", 1, queryResultSize(queryResult)); + assertEquals("1.1", Version.createOSGi(2, 2, 0), ((IInstallableUnit) queryResult.iterator().next()).getVersion()); assertTrue("1.2", monitor.isDone()); assertTrue("1.3", monitor.isWorkDone()); } @@ -535,7 +536,7 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { assertContains("Assert child1's content is in composite repo", repo1, compRepo); assertContains("Assert child2's content is in composite repo", repo2, compRepo); //checks that the destination has the correct number of keys (no extras) - assertEquals("Assert correct number of IUs", getNumUnique(repo1.query(InstallableUnitQuery.ANY, new Collector(), null), repo2.query(InstallableUnitQuery.ANY, new Collector(), null)), compRepo.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals("Assert correct number of IUs", getNumUnique(repo1.query(InstallableUnitQuery.ANY, null), repo2.query(InstallableUnitQuery.ANY, null)), queryResultSize(compRepo.query(InstallableUnitQuery.ANY, null))); } private CompositeMetadataRepository createRepo(boolean compressed) { @@ -560,9 +561,9 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { * Takes 2 collectors, compares them, and returns the number of unique keys * Needed to verify that only the appropriate number of files have been transfered by the mirror application */ - private int getNumUnique(Collector c1, Collector c2) { - Object[] repo1 = c1.toCollection().toArray(); - Object[] repo2 = c2.toCollection().toArray(); + private int getNumUnique(IQueryResult c1, IQueryResult c2) { + Object[] repo1 = c1.toArray(IInstallableUnit.class); + Object[] repo2 = c2.toArray(IInstallableUnit.class); //initialize to the size of both collectors int numKeys = repo1.length + repo2.length; @@ -584,11 +585,11 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { */ public void testNonLocalRepo() { try { - URI location = new URI("memory:/in/memory"); - URI childOne = new URI("memory:/in/memory/one"); - URI childTwo = new URI("memory:/in/memory/two"); - URI childThree = new URI("memory:/in/memory/three"); - CompositeMetadataRepository repository = new CompositeMetadataRepository(location, "in memory test", null); + URI location = new URI("http://foo.org/in/memory"); + URI childOne = new URI("http://foo.org/in/memory/one"); + URI childTwo = new URI("http://foo.org/in/memory/two"); + URI childThree = new URI("http://foo.org/in/memory/three"); + CompositeMetadataRepository repository = createRepository(location, "in memory test"); repository.addChild(childOne); repository.addChild(childTwo); repository.addChild(childThree); @@ -606,6 +607,12 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { } } + protected CompositeMetadataRepository createRepository(URI location, String name) { + CompositeMetadataRepositoryFactory factory = new CompositeMetadataRepositoryFactory(); + factory.setAgent(getAgent()); + return (CompositeMetadataRepository) factory.create(location, name, CompositeMetadataRepository.REPOSITORY_TYPE, null); + } + public void testRelativeChildren() { // setup File one = getTestData("0.0", "testData/testRepos/simple.1"); @@ -616,7 +623,7 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { // create the composite repository and add the children URI location = new File(temp, "comp").toURI(); - CompositeMetadataRepository repository = new CompositeMetadataRepository(location, "test", null); + CompositeMetadataRepository repository = createRepository(location, "test"); try { repository.addChild(new URI("../one")); repository.addChild(new URI("../two")); @@ -627,8 +634,8 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { // query the number of IUs List children = repository.getChildren(); assertEquals("2.0", 2, children.size()); - Collector collector = repository.query(InstallableUnitQuery.ANY, new Collector(), getMonitor()); - assertEquals("2.1", 2, collector.size()); + IQueryResult queryResult = repository.query(InstallableUnitQuery.ANY, getMonitor()); + assertEquals("2.1", 2, queryResultSize(queryResult)); // ensure the child URIs are stored as relative CompositeRepositoryState state = repository.toState(); @@ -644,10 +651,10 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest { public void testRelativeRemoveChild() { try { - URI location = new URI("memory:/in/memory"); + URI location = new URI("http://foo.org/in/memory"); URI one = new URI("one"); URI two = new URI("two"); - CompositeMetadataRepository repository = new CompositeMetadataRepository(location, "in memory test", null); + CompositeMetadataRepository repository = createRepository(location, "in memory test"); repository.addChild(one); repository.addChild(two); List children = repository.getChildren(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/HttpStatusTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/HttpStatusTest.java index e05f0fb08..7091fc0ec 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/HttpStatusTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/HttpStatusTest.java @@ -16,8 +16,8 @@ import java.text.ParseException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.equinox.internal.provisional.p2.core.IServiceUI; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.ServiceReference; @@ -31,7 +31,7 @@ public class HttpStatusTest extends ServerBasedTestCase { public void setUp() throws Exception { super.setUp(); - ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.class.getName()); + ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.SERVICE_NAME); mgr = (IMetadataRepositoryManager) TestActivator.context.getService(sr2); if (mgr == null) { throw new RuntimeException("Repository manager could not be loaded"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLMetadataRepositoryTest.java index 37a794bcf..d127b2417 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLMetadataRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLMetadataRepositoryTest.java @@ -11,31 +11,27 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata.repository; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; -import junit.framework.TestCase; import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; -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.provisional.p2.repository.IRepository; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager; -import org.eclipse.equinox.p2.tests.TestActivator; -import org.osgi.framework.ServiceReference; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -public class JarURLMetadataRepositoryTest extends TestCase { +public class JarURLMetadataRepositoryTest extends AbstractProvisioningTest { - private ServiceReference managerRef; private IMetadataRepositoryManager manager; private File testRepoJar; @@ -48,8 +44,7 @@ public class JarURLMetadataRepositoryTest extends TestCase { } protected void setUp() throws Exception { - managerRef = TestActivator.getContext().getServiceReference(IMetadataRepositoryManager.class.getName()); - manager = (IMetadataRepositoryManager) TestActivator.getContext().getService(managerRef); + manager = getMetadataRepositoryManager(); String tempDir = System.getProperty("java.io.tmpdir"); File testRepo = new File(tempDir, "testRepo"); @@ -61,7 +56,7 @@ public class JarURLMetadataRepositoryTest extends TestCase { InstallableUnitDescription descriptor = new MetadataFactory.InstallableUnitDescription(); descriptor.setId("testIuId"); - descriptor.setVersion(new Version("3.2.1")); + descriptor.setVersion(Version.create("3.2.1")); IInstallableUnit iu = MetadataFactory.createInstallableUnit(descriptor); repo.addInstallableUnits(new IInstallableUnit[] {iu}); @@ -73,7 +68,6 @@ public class JarURLMetadataRepositoryTest extends TestCase { protected void tearDown() throws Exception { manager = null; FileUtils.deleteAll(testRepoJar.getParentFile()); - TestActivator.getContext().ungetService(managerRef); } public void testJarURLRepository() throws ProvisionException { @@ -85,7 +79,7 @@ public class JarURLMetadataRepositoryTest extends TestCase { } IMetadataRepository repo = manager.loadRepository(jarRepoLocation, null); - assertTrue(!repo.query(InstallableUnitQuery.ANY, new Collector(), null).isEmpty()); + assertTrue(!repo.query(InstallableUnitQuery.ANY, null).isEmpty()); URI[] local = manager.getKnownRepositories(IRepositoryManager.REPOSITORIES_LOCAL); boolean found = false; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java index c00214dc5..c87edf31d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java @@ -11,20 +11,23 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.metadata.repository; +import org.eclipse.equinox.p2.metadata.Version; + import java.io.File; import java.net.URI; import java.util.*; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.SynchronousProvisioningListener; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; -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.provisional.p2.repository.IRepository; import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent; +import org.eclipse.equinox.p2.core.ProvisionException; +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.IRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** @@ -57,7 +60,7 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest { InstallableUnitDescription descriptor = new MetadataFactory.InstallableUnitDescription(); descriptor.setId("testIuId"); - descriptor.setVersion(new Version("3.2.1")); + descriptor.setVersion(Version.create("3.2.1")); IInstallableUnit iu = MetadataFactory.createInstallableUnit(descriptor); repo.addInstallableUnits(new IInstallableUnit[] {iu}); @@ -122,10 +125,10 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest { IMetadataRepository repo = manager.createRepository(repoLocation.toURI(), "TestRepo", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, null); IInstallableUnit iu = createIU("foo"); repo.addInstallableUnits(new IInstallableUnit[] {iu}); - Collector result = repo.query(new InstallableUnitQuery((String) null), new Collector(), getMonitor()); - assertTrue("1.0", result.size() == 1); + IQueryResult result = repo.query(new InstallableUnitQuery((String) null), getMonitor()); + assertEquals("1.0", 1, queryResultSize(result)); repo.removeAll(); - result = repo.query(new InstallableUnitQuery((String) null), new Collector(), getMonitor()); + result = repo.query(new InstallableUnitQuery((String) null), getMonitor()); assertTrue("1.1", result.isEmpty()); } @@ -135,13 +138,13 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest { IInstallableUnit iu = createIU("foo"); IInstallableUnit iu2 = createIU("bar"); repo.addInstallableUnits(new IInstallableUnit[] {iu, iu2}); - Collector result = repo.query(new InstallableUnitQuery((String) null), new Collector(), getMonitor()); - assertTrue("1.0", result.size() == 2); - repo.removeInstallableUnits(new InstallableUnitQuery("foo"), getMonitor()); - result = repo.query(new InstallableUnitQuery((String) null), new Collector(), getMonitor()); - assertTrue("1.1", result.size() == 1); - repo.removeInstallableUnits(new InstallableUnitQuery("bar"), getMonitor()); - result = repo.query(new InstallableUnitQuery((String) null), new Collector(), getMonitor()); + IQueryResult result = repo.query(new InstallableUnitQuery((String) null), getMonitor()); + assertEquals("1.0", 2, queryResultSize(result)); + repo.removeInstallableUnits(new IInstallableUnit[] {iu}, getMonitor()); + result = repo.query(new InstallableUnitQuery((String) null), getMonitor()); + assertEquals("1.1", 1, queryResultSize(result)); + repo.removeInstallableUnits(new IInstallableUnit[] {iu2}, getMonitor()); + result = repo.query(new InstallableUnitQuery((String) null), getMonitor()); assertTrue("1.2", result.isEmpty()); } @@ -154,7 +157,7 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest { InstallableUnitDescription descriptor = new MetadataFactory.InstallableUnitDescription(); descriptor.setId("testIuId"); - descriptor.setVersion(new Version("3.2.1")); + descriptor.setVersion(Version.create("3.2.1")); IInstallableUnit iu = MetadataFactory.createInstallableUnit(descriptor); repo.addInstallableUnits(new IInstallableUnit[] {iu}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerExceptionsTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerExceptionsTest.java index 890e5df46..8c7d4a509 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerExceptionsTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerExceptionsTest.java @@ -18,11 +18,11 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; +import org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory; import org.eclipse.equinox.internal.p2.updatesite.metadata.UpdateSiteMetadataRepositoryFactory; -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.spi.p2.metadata.repository.MetadataRepositoryFactory; -import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.SimpleMetadataRepositoryFactory; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; @@ -42,7 +42,7 @@ public class MetadataRepositoryManagerExceptionsTest extends AbstractProvisionin protected void setUp() throws Exception { super.setUp(); - manager = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.context, IMetadataRepositoryManager.class.getName()); + manager = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.context, IMetadataRepositoryManager.SERVICE_NAME); } protected void tearDown() throws Exception { @@ -64,6 +64,7 @@ public class MetadataRepositoryManagerExceptionsTest extends AbstractProvisionin MetadataRepositoryFactory factory; factory = new SimpleMetadataRepositoryFactory(); + factory.setAgent(getAgent()); try { factory.load(location, 0, new NullProgressMonitor()); } catch (ProvisionException e) { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java index 004752c03..bbe260e64 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java @@ -13,27 +13,29 @@ package org.eclipse.equinox.p2.tests.metadata.repository; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; -import java.net.*; +import java.net.URI; +import java.net.URISyntaxException; import java.util.*; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.core.runtime.*; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; -import org.eclipse.equinox.internal.p2.core.helpers.URLUtil; +import org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory; import org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager; import org.eclipse.equinox.internal.p2.updatesite.metadata.UpdateSiteMetadataRepositoryFactory; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.SynchronousProvisioningListener; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; -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.provisional.p2.repository.*; -import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.MetadataRepositoryFactory; -import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.SimpleMetadataRepositoryFactory; +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.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.IRepositoryManager; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory; import org.eclipse.equinox.p2.tests.*; /** @@ -52,7 +54,7 @@ public class MetadataRepositoryManagerTest extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - manager = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.context, IMetadataRepositoryManager.class.getName()); + manager = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.context, IMetadataRepositoryManager.SERVICE_NAME); //only enable the failing repository factory for this test to avoid noise in other tests. FailingMetadataRepositoryFactory.FAIL = true; } @@ -121,6 +123,7 @@ public class MetadataRepositoryManagerTest extends AbstractProvisioningTest { MetadataRepositoryFactory factory; factory = new SimpleMetadataRepositoryFactory(); + factory.setAgent(getAgent()); try { factory.load(location, 0, new NullProgressMonitor()); } catch (ProvisionException e) { @@ -327,9 +330,9 @@ public class MetadataRepositoryManagerTest extends AbstractProvisioningTest { */ public void testMetadataCachingLocalRepo() throws ProvisionException { File repoLocation = getTempLocation(); - AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(TestActivator.getContext(), AgentLocation.class.getName()); - URL dataArea = agentLocation.getDataArea("org.eclipse.equinox.p2.metadata.repository/cache/"); - File dataAreaFile = URLUtil.toFile(dataArea); + IAgentLocation agentLocation = (IAgentLocation) ServiceHelper.getService(TestActivator.getContext(), IAgentLocation.class.getName()); + URI dataArea = agentLocation.getDataArea("org.eclipse.equinox.p2.metadata.repository/cache/"); + File dataAreaFile = URIUtil.toFile(dataArea); File cacheFileXML = new File(dataAreaFile, "content" + repoLocation.hashCode() + ".xml"); File cacheFileJAR = new File(dataAreaFile, "content" + repoLocation.hashCode() + ".jar"); @@ -349,9 +352,9 @@ public class MetadataRepositoryManagerTest extends AbstractProvisioningTest { URI repoLocation = new URI("http://download.eclipse.org/eclipse/updates/3.4milestones/"); if (!repoAvailable(repoLocation)) return; - AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(TestActivator.getContext(), AgentLocation.class.getName()); - URL dataArea = agentLocation.getDataArea("org.eclipse.equinox.p2.metadata.repository/cache/"); - File dataAreaFile = URLUtil.toFile(dataArea); + IAgentLocation agentLocation = (IAgentLocation) ServiceHelper.getService(TestActivator.getContext(), IAgentLocation.class.getName()); + URI dataArea = agentLocation.getDataArea("org.eclipse.equinox.p2.metadata.repository/cache/"); + File dataAreaFile = URIUtil.toFile(dataArea); File cacheFileXML = new File(dataAreaFile, "content" + repoLocation.hashCode() + ".xml"); File cacheFileJAR = new File(dataAreaFile, "content" + repoLocation.hashCode() + ".jar"); File cacheFile; @@ -406,8 +409,8 @@ public class MetadataRepositoryManagerTest extends AbstractProvisioningTest { URI location = site.toURI(); try { IMetadataRepository repository = manager.loadRepository(location, getMonitor()); - Collector result = repository.query(new InstallableUnitQuery("test.bundle"), new Collector(), getMonitor()); - assertEquals("1.0", 1, result.size()); + IQueryResult result = repository.query(new InstallableUnitQuery("test.bundle"), getMonitor()); + assertEquals("1.0", 1, queryResultSize(result)); } catch (ProvisionException e) { fail("=.99", e); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/NoFailOver.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/NoFailOver.java index 84752a35d..e15e1eee5 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/NoFailOver.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/NoFailOver.java @@ -11,7 +11,7 @@ package org.eclipse.equinox.p2.tests.metadata.repository; import java.io.File; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.p2.core.ProvisionException; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/ResumeDownloadTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/ResumeDownloadTest.java index 2f70b5321..692cf93ea 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/ResumeDownloadTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/ResumeDownloadTest.java @@ -15,8 +15,8 @@ import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.ecf.filetransfer.IFileRangeSpecification; import org.eclipse.ecf.filetransfer.IIncomingFileTransfer; import org.eclipse.equinox.internal.p2.repository.FileReader; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.ServiceReference; @@ -31,7 +31,7 @@ public class ResumeDownloadTest extends TestCase { repoLoc = new URI(UPDATE_SITE); originalResumeProp = System.getProperty("org.eclipse.equinox.p2.metadata.repository.resumable", "true"); - ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.class.getName()); + ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.SERVICE_NAME); mgr = (IMetadataRepositoryManager) TestActivator.context.getService(sr2); if (mgr == null) { throw new RuntimeException("Repository manager could not be loaded"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java index 0b2dacd4f..6d64263a4 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java @@ -18,17 +18,22 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.*; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.core.helpers.CollectionUtils; import org.eclipse.equinox.internal.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitPatchDescription; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.MatchQuery; -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.provisional.p2.repository.IRepository; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil; +import org.eclipse.equinox.p2.metadata.expression.IMatchExpression; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.query.MatchQuery; +import org.eclipse.equinox.p2.repository.IRepository; +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.osgi.framework.Filter; /** * Test API of the metadata interfaces with an SPI implementation. @@ -50,25 +55,23 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { super.tearDown(); } - class SPIRequiredCapability implements IRequiredCapability { - String filter; + class SPIRequiredCapability extends MatchQuery<IInstallableUnit> implements IRequiredCapability { + Filter filter; String name; String namespace; VersionRange versionRange; - String[] selectors = new String[0]; boolean isGreedy; - boolean isMultiple; - boolean isOptional; + int min; + int max; - public SPIRequiredCapability(String namespace, String name, VersionRange versionRange, String filter, String[] selectors, boolean isGreedy, boolean isMultiple, boolean isOptional) { + public SPIRequiredCapability(String namespace, String name, VersionRange versionRange, String filter, boolean isGreedy, boolean isMultiple, boolean isOptional) { this.namespace = namespace; this.name = name; this.versionRange = versionRange; - this.filter = filter; - this.selectors = selectors; + setFilter(filter); this.isGreedy = isGreedy; - this.isMultiple = isMultiple; - this.isOptional = isOptional; + this.min = isOptional ? 0 : 1; + this.max = 1; } public SPIRequiredCapability(String namespace, String name, VersionRange versionRange) { @@ -77,7 +80,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { this.versionRange = versionRange; } - public String getFilter() { + public Filter getFilter() { return this.filter; } @@ -93,28 +96,12 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { return this.versionRange; } - public String[] getSelectors() { - return selectors; - } - public boolean isGreedy() { return isGreedy; } - public boolean isMultiple() { - return this.isMultiple; - } - - public boolean isOptional() { - return this.isOptional; - } - public void setFilter(String filter) { - this.filter = filter; - } - - public void setSelectors(String[] selectors) { - this.selectors = selectors; + this.filter = filter == null ? null : ExpressionUtil.parseLDAP(filter); } public boolean equals(Object obj) { @@ -130,13 +117,13 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { return false; } else if (!filter.equals(other.getFilter())) return false; - if (isMultiple != other.isMultiple()) - return false; if (!name.equals(other.getName())) return false; if (!namespace.equals(other.getNamespace())) return false; - if (isOptional != other.isOptional()) + if (other.getMin() != this.getMin()) + return false; + if (other.getMax() != this.getMax()) return false; if (!versionRange.equals(other.getRange())) return false; @@ -155,6 +142,28 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { return getRange().isIncluded(cap.getVersion()); } + public int getMin() { + return min; + } + + public int getMax() { + return max; + } + + public boolean isMatch(IInstallableUnit candidate) { + if (!candidate.satisfies(this)) + return false; + return true; + } + + public boolean isVersionStrict() { + // TODO Auto-generated method stub + return false; + } + + public IMatchExpression<IInstallableUnit> getMatches() { + return ExpressionUtil.getFactory().matchExpression(ExpressionUtil.parse("providedCapabilities.exists(x | x.name == $0 && x.namespace == $1 && x.version ~= $2"), name, namespace, versionRange); + } } class SPIProvidedCapability implements IProvidedCapability { @@ -194,7 +203,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { return this.version; } - public boolean satisfies(IRequiredCapability candidate) { + public boolean satisfies(IRequirement candidate) { return false; } @@ -208,9 +217,9 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { List providedCapabilities = new ArrayList(); List touchpointData = new ArrayList(); ICopyright copyright = null; - String filter = null; + Filter filter = null; String id = null; - ILicense license = null; + ILicense[] license = null; Map properties = new HashMap(); ITouchpointType touchpointType = null; IUpdateDescriptor updateDescriptor = null; @@ -228,28 +237,28 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { this.providedCapabilities.add(providedCapability); } - public IArtifactKey[] getArtifacts() { - return (IArtifactKey[]) this.artifacts.toArray(new IArtifactKey[artifacts.size()]); + public Collection<IArtifactKey> getArtifacts() { + return artifacts; } public ICopyright getCopyright() { return this.copyright; } - public String getFilter() { + public Filter getFilter() { return this.filter; } - public IInstallableUnitFragment[] getFragments() { - return (IInstallableUnitFragment[]) this.fragments.toArray(new IInstallableUnitFragment[fragments.size()]); + public List<IInstallableUnitFragment> getFragments() { + return fragments; } public String getId() { return this.id; } - public ILicense getLicense() { - return this.license; + public Collection<ILicense> getLicenses() { + return CollectionUtils.unmodifiableList(license); } public Map getProperties() { @@ -260,16 +269,16 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { return (String) this.properties.get(key); } - public IProvidedCapability[] getProvidedCapabilities() { - return (IProvidedCapability[]) this.providedCapabilities.toArray(new IProvidedCapability[profilesToRemove.size()]); + public List<IProvidedCapability> getProvidedCapabilities() { + return providedCapabilities; } - public IRequiredCapability[] getRequiredCapabilities() { - return (IRequiredCapability[]) this.requiredCapabilities.toArray(new IRequiredCapability[requiredCapabilities.size()]); + public List<IRequirement> getRequiredCapabilities() { + return requiredCapabilities; } - public ITouchpointData[] getTouchpointData() { - return (ITouchpointData[]) this.touchpointData.toArray(new ITouchpointData[touchpointData.size()]); + public List<ITouchpointData> getTouchpointData() { + return touchpointData; } public ITouchpointType getTouchpointType() { @@ -298,32 +307,36 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { return this.isSingleton; } - public boolean satisfies(IRequiredCapability candidate) { - IProvidedCapability[] provides = getProvidedCapabilities(); - for (int i = 0; i < provides.length; i++) - if (provides[i].satisfies(candidate)) - return true; - return false; + public boolean satisfies(IRequirement candidate) { + return candidate.isMatch(this); } public IInstallableUnit unresolved() { return this; } - public int compareTo(Object toCompareTo) { - if (!(toCompareTo instanceof IInstallableUnit)) { - return -1; - } - IInstallableUnit other = (IInstallableUnit) toCompareTo; + public int compareTo(IInstallableUnit other) { if (getId().compareTo(other.getId()) == 0) return (getVersion().compareTo(other.getVersion())); return getId().compareTo(other.getId()); } - public IRequiredCapability[] getMetaRequiredCapabilities() { + public List<IRequirement> getMetaRequiredCapabilities() { return null; } + public String getProperty(String key, String locale) { + return getProperty(key); + } + + public ILicense[] getLicenses(String locale) { + return license; + } + + public ICopyright getCopyright(String locale) { + return copyright; + } + } class SPITouchpointData implements ITouchpointData { @@ -538,6 +551,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { private String body; private URI location; + private String uuid; public SPILicense(String body, URI location) { this.body = body; @@ -548,8 +562,10 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { return this.body; } - public BigInteger getDigest() { - return this.calculateLicenseDigest(); + public String getUUID() { + if (uuid == null) + uuid = this.calculateLicenseDigest().toString(16); + return uuid; } public URI getLocation() { @@ -563,7 +579,7 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { return false; if (obj instanceof ILicense) { ILicense other = (ILicense) obj; - if (other.getDigest().equals(getDigest())) + if (other.getUUID().equals(getUUID())) return true; } return false; @@ -624,22 +640,20 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { properties.put(IRepository.PROP_COMPRESSED, "true"); IMetadataRepository repo = manager.createRepository(repoLocation.toURI(), "TestRepo", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); - repo.addInstallableUnits(new IInstallableUnit[] {new SPIInstallableUnit("foo", new Version(1, 1, 1))}); + repo.addInstallableUnits(new IInstallableUnit[] {new SPIInstallableUnit("foo", Version.createOSGi(1, 1, 1))}); - Collector collector = repo.query(new AllAcceptingQuery(), new Collector(), new NullProgressMonitor()); + IQueryResult queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor()); - Collection collection = collector.toCollection(); - assertEquals(1, collection.size()); + assertEquals(1, queryResultSize(queryResult)); - assertTrue("Repo contains SPI IU)", collection.iterator().next() instanceof SPIInstallableUnit); + assertTrue("Repo contains SPI IU)", queryResult.iterator().next() instanceof SPIInstallableUnit); repo = manager.refreshRepository(repoLocation.toURI(), null); - collector = repo.query(new AllAcceptingQuery(), new Collector(), new NullProgressMonitor()); + queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor()); - collection = collector.toCollection(); - assertEquals(1, collection.size()); + assertEquals(1, queryResultSize(queryResult)); - assertTrue("Refreshed repo contains default IU", collection.iterator().next() instanceof InstallableUnit); + assertTrue("Refreshed repo contains default IU", queryResult.iterator().next() instanceof InstallableUnit); } /** @@ -655,32 +669,30 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { properties.put(IRepository.PROP_COMPRESSED, "true"); IMetadataRepository repo = manager.createRepository(repoLocation.toURI(), "TestRepo", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); - IProvidedCapability providedCapability = MetadataFactory.createProvidedCapability("foo", "bar", new Version(1, 0, 0)); + IProvidedCapability providedCapability = MetadataFactory.createProvidedCapability("foo", "bar", Version.createOSGi(1, 0, 0)); - SPIInstallableUnit spiInstallableUnit = new SPIInstallableUnit("foo", new Version(1, 1, 1)); + SPIInstallableUnit spiInstallableUnit = new SPIInstallableUnit("foo", Version.createOSGi(1, 1, 1)); spiInstallableUnit.addProvidedCapability(providedCapability); repo.addInstallableUnits(new IInstallableUnit[] {spiInstallableUnit}); - Collector collector = repo.query(new AllAcceptingQuery(), new Collector(), new NullProgressMonitor()); + IQueryResult queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor()); - Collection collection = collector.toCollection(); - assertEquals(1, collection.size()); + assertEquals(1, queryResultSize(queryResult)); - IInstallableUnit spiUnit = (IInstallableUnit) collection.iterator().next(); + IInstallableUnit spiUnit = (IInstallableUnit) queryResult.iterator().next(); assertTrue("Repo contains SPI IU)", spiUnit instanceof SPIInstallableUnit); - assertEquals(spiUnit.getProvidedCapabilities().length, 1); - assertTrue(spiUnit.getProvidedCapabilities()[0] instanceof ProvidedCapability); + assertEquals(spiUnit.getProvidedCapabilities().size(), 1); + assertTrue(spiUnit.getProvidedCapabilities().iterator().next() instanceof ProvidedCapability); repo = manager.refreshRepository(repoLocation.toURI(), null); - collector = repo.query(new AllAcceptingQuery(), new Collector(), new NullProgressMonitor()); + queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor()); - collection = collector.toCollection(); - assertEquals(1, collection.size()); + assertEquals(1, queryResultSize(queryResult)); - IInstallableUnit defaultUnit = (IInstallableUnit) collection.iterator().next(); + IInstallableUnit defaultUnit = (IInstallableUnit) queryResult.iterator().next(); assertTrue("Repo contains SPI IU)", defaultUnit instanceof InstallableUnit); - assertEquals(spiUnit.getProvidedCapabilities().length, 1); - assertTrue(spiUnit.getProvidedCapabilities()[0] instanceof ProvidedCapability); + assertEquals(spiUnit.getProvidedCapabilities().size(), 1); + assertTrue(spiUnit.getProvidedCapabilities().iterator().next() instanceof ProvidedCapability); } /** @@ -698,33 +710,31 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { IMetadataRepository repo = manager.createRepository(repoLocation.toURI(), "TestRepo", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties); InstallableUnitDescription iuDescription = new InstallableUnitDescription(); iuDescription.setId("foo"); - iuDescription.setVersion(new Version(1, 1, 1)); - IRequiredCapability spiRequiredCapability = new SPIRequiredCapability("com.example", "bar", new VersionRange(new Version(1, 0, 0), true, new Version(2, 0, 0), true)); + iuDescription.setVersion(Version.createOSGi(1, 1, 1)); + IRequiredCapability spiRequiredCapability = new SPIRequiredCapability("com.example", "bar", new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), true)); Collection list = new ArrayList(); list.add(spiRequiredCapability); iuDescription.addRequiredCapabilities(list); repo.addInstallableUnits(new IInstallableUnit[] {MetadataFactory.createInstallableUnit(iuDescription)}); - Collector collector = repo.query(new AllAcceptingQuery(), new Collector(), new NullProgressMonitor()); + IQueryResult queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor()); - Collection collection = collector.toCollection(); - assertEquals(1, collection.size()); + assertEquals(1, queryResultSize(queryResult)); - IInstallableUnit unit = (IInstallableUnit) collection.iterator().next(); - assertEquals(unit.getRequiredCapabilities().length, 1); - assertTrue(unit.getRequiredCapabilities()[0] instanceof SPIRequiredCapability); + IInstallableUnit unit = (IInstallableUnit) queryResult.iterator().next(); + assertEquals(unit.getRequiredCapabilities().size(), 1); + assertTrue(unit.getRequiredCapabilities().iterator().next() instanceof SPIRequiredCapability); repo = manager.refreshRepository(repoLocation.toURI(), null); - collector = repo.query(new AllAcceptingQuery(), new Collector(), new NullProgressMonitor()); + queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor()); - collection = collector.toCollection(); - assertEquals(1, collection.size()); + assertEquals(1, queryResultSize(queryResult)); - unit = (IInstallableUnit) collection.iterator().next(); - assertEquals(unit.getRequiredCapabilities().length, 1); - assertTrue(unit.getRequiredCapabilities()[0] instanceof RequiredCapability); - assertTrue(unit.getRequiredCapabilities()[0].getName().equals("bar")); + unit = (IInstallableUnit) queryResult.iterator().next(); + assertEquals(unit.getRequiredCapabilities().size(), 1); + assertTrue(unit.getRequiredCapabilities().iterator().next() instanceof RequiredCapability); + assertTrue(((IRequiredCapability) unit.getRequiredCapabilities().iterator().next()).getName().equals("bar")); } /** @@ -741,16 +751,16 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { InstallableUnitDescription iuDescription = new InstallableUnitDescription(); InstallableUnitPatchDescription iuPatchDescription = new InstallableUnitPatchDescription(); iuDescription.setId("foo"); - iuDescription.setVersion(new Version(1, 1, 1)); + iuDescription.setVersion(Version.createOSGi(1, 1, 1)); - SPIRequiredCapability spiRequiredCapability1 = new SPIRequiredCapability("com.example", "bar", new VersionRange(new Version(1, 0, 0), true, new Version(2, 0, 0), true), "bar", new String[] {"foo", "bar"}, true, true, true); - IRequiredCapability requiredCapability1 = MetadataFactory.createRequiredCapability("com.example2", "foo", new VersionRange(new Version(1, 0, 0), true, new Version(2, 0, 0), true), "bar", false, false, false); + SPIRequiredCapability spiRequiredCapability1 = new SPIRequiredCapability("com.example", "bar", new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), true), "(bar=foo)", true, true, true); + IRequiredCapability requiredCapability1 = MetadataFactory.createRequiredCapability("com.example2", "foo", new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), true), "(bar=foo)", false, false, false); SPIRequirementChange spiRequirementChange = new SPIRequirementChange(spiRequiredCapability1, requiredCapability1); iuPatchDescription.setRequirementChanges(new IRequirementChange[] {spiRequirementChange}); - IRequiredCapability spiRequiredCapability = new SPIRequiredCapability("com.example", "bar", new VersionRange(new Version(1, 0, 0), true, new Version(2, 0, 0), true), "bar", new String[] {"foo", "bar"}, true, true, true); - IProvidedCapability spiProvidedCapability = new SPIProvidedCapability("bar", "foo", new Version(1, 1, 1)); + IRequiredCapability spiRequiredCapability = new SPIRequiredCapability("com.example", "bar", new VersionRange(Version.createOSGi(1, 0, 0), true, Version.createOSGi(2, 0, 0), true), "(bar=foo)", true, true, true); + IProvidedCapability spiProvidedCapability = new SPIProvidedCapability("bar", "foo", Version.createOSGi(1, 1, 1)); ITouchpointData spiTouchpointData = new SPITouchpointData(); ITouchpointInstruction spiTouchpointInstruction = new SPITouchpointInstruction("the body", "the import attribute"); @@ -758,9 +768,9 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { iuDescription.addTouchpointData(spiTouchpointData); SPILicense spiLicense = new SPILicense("body", new URI("http://example.com")); - iuDescription.setLicense(spiLicense); + iuDescription.setLicenses(new ILicense[] {spiLicense}); - SPITouchpointType spiTouchpointType = new SPITouchpointType("foo", new Version(3, 3, 3)); + SPITouchpointType spiTouchpointType = new SPITouchpointType("foo", Version.createOSGi(3, 3, 3)); iuDescription.setTouchpointType(spiTouchpointType); Collection requiredCapabilityList = new ArrayList(); @@ -774,11 +784,10 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { repo.addInstallableUnits(new IInstallableUnit[] {MetadataFactory.createInstallableUnit(iuDescription), MetadataFactory.createInstallableUnitPatch(iuPatchDescription)}); repo = manager.refreshRepository(repoLocation.toURI(), null); - Collector collector = repo.query(new AllAcceptingQuery(), new Collector(), new NullProgressMonitor()); + IQueryResult queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor()); - Collection collection = collector.toCollection(); - assertEquals(2, collection.size()); - Iterator iterator = collection.iterator(); + assertEquals(2, queryResultSize(queryResult)); + Iterator iterator = queryResult.iterator(); IInstallableUnit unit = null; IInstallableUnitPatch patchUnit = null; @@ -793,30 +802,32 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest { assertFalse(unit == null); assertFalse(patchUnit == null); - assertEquals(unit.getRequiredCapabilities().length, 1); - assertEquals(unit.getProvidedCapabilities().length, 1); - assertEquals(unit.getTouchpointData().length, 1); - assertEquals(unit.getRequiredCapabilities()[0], spiRequiredCapability); - assertEquals(unit.getProvidedCapabilities()[0], spiProvidedCapability); - assertEquals(unit.getTouchpointData()[0], spiTouchpointData); + assertEquals(unit.getRequiredCapabilities().size(), 1); + assertEquals(unit.getProvidedCapabilities().size(), 1); + assertEquals(unit.getTouchpointData().size(), 1); + assertEquals(((IRequiredCapability) unit.getRequiredCapabilities().iterator().next()).getNamespace(), spiRequiredCapability.getNamespace()); + assertEquals(((IRequiredCapability) unit.getRequiredCapabilities().iterator().next()).getName(), spiRequiredCapability.getName()); + assertEquals(((IRequiredCapability) unit.getRequiredCapabilities().iterator().next()).getMin(), spiRequiredCapability.getMin()); + assertEquals(((IRequiredCapability) unit.getRequiredCapabilities().iterator().next()).getMax(), spiRequiredCapability.getMax()); + assertEquals(unit.getProvidedCapabilities().iterator().next(), spiProvidedCapability); + assertEquals(unit.getTouchpointData().get(0), spiTouchpointData); assertEquals(unit.getTouchpointType(), spiTouchpointType); - assertEquals(unit.getLicense(), spiLicense); - assertEquals(spiRequiredCapability, unit.getRequiredCapabilities()[0]); - assertEquals(spiProvidedCapability, unit.getProvidedCapabilities()[0]); - assertEquals(spiTouchpointData, unit.getTouchpointData()[0]); + assertEquals(unit.getLicenses().iterator().next(), spiLicense); + assertEquals(spiProvidedCapability, unit.getProvidedCapabilities().iterator().next()); + assertEquals(spiTouchpointData, unit.getTouchpointData().get(0)); assertEquals(spiTouchpointType, unit.getTouchpointType()); - assertEquals(spiLicense, unit.getLicense()); + assertEquals(spiLicense, unit.getLicenses().iterator().next()); - assertEquals(patchUnit.getRequirementsChange().length, 1); - assertEquals(patchUnit.getRequirementsChange()[0], spiRequirementChange); - assertEquals(spiRequirementChange, patchUnit.getRequirementsChange()[0]); + assertEquals(patchUnit.getRequirementsChange().size(), 1); + assertEquals(patchUnit.getRequirementsChange().get(0), spiRequirementChange); + assertEquals(spiRequirementChange, patchUnit.getRequirementsChange().get(0)); // Check to make sure the actual objects are not equal. This is because the repo has // been refreshed, and re-parsed, thus using the default implementations. - assertFalse(spiTouchpointData == unit.getTouchpointData()[0]); - assertFalse(spiRequiredCapability == unit.getRequiredCapabilities()[0]); - assertFalse(spiProvidedCapability == unit.getProvidedCapabilities()[0]); + assertFalse(spiTouchpointData == unit.getTouchpointData().get(0)); + assertFalse(spiRequiredCapability == unit.getRequiredCapabilities().iterator().next()); + assertFalse(spiProvidedCapability == unit.getProvidedCapabilities().iterator().next()); assertFalse(spiTouchpointType == unit.getTouchpointType()); - assertFalse(spiLicense == unit.getLicense()); + assertFalse(spiLicense == unit.getLicenses().iterator().next()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/TimeoutTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/TimeoutTest.java index e5e267130..ca68bbfd0 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/TimeoutTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/TimeoutTest.java @@ -12,8 +12,8 @@ import java.net.URI; import java.security.cert.Certificate; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.provisional.p2.core.IServiceUI; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.framework.ServiceReference; @@ -27,7 +27,7 @@ public class TimeoutTest extends ServerBasedTestCase { public void setUp() throws Exception { super.setUp(); - ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.class.getName()); + ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.SERVICE_NAME); mgr = (IMetadataRepositoryManager) TestActivator.context.getService(sr2); if (mgr == null) { throw new RuntimeException("Repository manager could not be loaded"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java index 7b137916b..f3f7d67f4 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java @@ -10,29 +10,31 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.mirror; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.*; import java.net.*; import java.util.*; import org.eclipse.core.runtime.*; -import org.eclipse.equinox.app.IApplicationContext; -import org.eclipse.equinox.internal.p2.artifact.mirror.MirrorApplication; import org.eclipse.equinox.internal.p2.artifact.processors.md5.Messages; 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.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.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.MirrorApplication; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.query.IQuery; +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.TestActivator; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.framework.log.FrameworkLog; import org.eclipse.osgi.util.NLS; -import org.osgi.framework.Bundle; /** * Test API of the basic mirror application functionality's implementation. @@ -81,43 +83,11 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { */ private void runMirrorApplication(String message, final String[] args) throws Exception { MirrorApplication application = new MirrorApplication(); - application.start(new IApplicationContext() { - - public void applicationRunning() { - } - - public Map getArguments() { - Map arguments = new HashMap(); - - arguments.put(IApplicationContext.APPLICATION_ARGS, args); - - return arguments; - } - - public String getBrandingApplication() { - return null; - } - - public Bundle getBrandingBundle() { - return null; - } - - public String getBrandingDescription() { - return null; - } - - public String getBrandingId() { - return null; - } - - public String getBrandingName() { - return null; - } - - public String getBrandingProperty(String key) { - return null; - } - }); + Map map = new HashMap(); + map.put("metadataOrArtifacts", "artifacts"); + application.setInitializationData(null, null, map); + application.initializeFromArguments(args); + application.run(null); } /** @@ -319,15 +289,15 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { * Not Biconditional. */ private void assertFileSizes(String message, SimpleArtifactRepository expected, SimpleArtifactRepository actual) { - IArtifactKey[] expectedKeys = expected.getArtifactKeys(); - - for (int i = 0; i < expectedKeys.length; i++) { - IArtifactDescriptor[] expectedDescriptors = expected.getArtifactDescriptors(expectedKeys[i]); - IArtifactDescriptor[] actualDescriptors = actual.getArtifactDescriptors(expectedKeys[i]); + IQueryResult expectedKeys = expected.query(ArtifactKeyQuery.ALL_KEYS, null); + for (Iterator iterator = expectedKeys.iterator(); iterator.hasNext();) { + IArtifactKey key = (IArtifactKey) iterator.next(); + IArtifactDescriptor[] expectedDescriptors = expected.getArtifactDescriptors(key); + IArtifactDescriptor[] actualDescriptors = actual.getArtifactDescriptors(key); if (expectedDescriptors == null || actualDescriptors == null) if (!(expectedDescriptors == null && actualDescriptors == null)) - fail(message + " missing key " + expectedKeys[i]); + fail(message + " missing key " + key); top: for (int j = 0; j < expectedDescriptors.length; j++) { for (int k = 0; k < actualDescriptors.length; k++) { @@ -429,7 +399,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { assertContains("5.1", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("5.2", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("5.3", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).getArtifactKeys().length + getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).getArtifactKeys().length, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null).getArtifactKeys().length); + assertEquals("5.3", getArtifactKeyCount(sourceRepoLocation.toURI()) + getArtifactKeyCount(sourceRepo2Location.toURI()), getArtifactKeyCount(destRepoLocation.toURI())); } catch (ProvisionException e) { fail("5.4", e); } @@ -534,7 +504,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { assertContains("11.1", getArtifactRepositoryManager().loadRepository(sourceRepo3Location.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("11.2", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("11.3", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).getArtifactKeys().length + getArtifactRepositoryManager().loadRepository(sourceRepo3Location.toURI(), null).getArtifactKeys().length, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null).getArtifactKeys().length); + assertEquals("11.3", getArtifactKeyCount(sourceRepo2Location.toURI()) + getArtifactKeyCount(sourceRepo3Location.toURI()), getArtifactKeyCount(destRepoLocation.toURI())); } catch (ProvisionException e) { fail("11.4", e); } @@ -587,7 +557,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { basicRunMirrorApplication("14.1", sourceRepoLocation.toURL(), invalidDestRepository.toURL(), true); //we're expecting an UnsupportedOperationException so we should never get here fail("14.0 UnsupportedOperationException not thrown"); - } catch (UnsupportedOperationException e) { + } catch (ProvisionException e) { return; //correct type of exception has been thrown } catch (Exception e) { fail("14.2", e); @@ -722,7 +692,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { assertContains("20.2", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("20.3", getArtifactRepositoryManager().loadRepository(sourceRepo4Location.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("20.4", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).getArtifactKeys().length + getArtifactRepositoryManager().loadRepository(sourceRepo4Location.toURI(), null).getArtifactKeys().length, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null).getArtifactKeys().length); + assertEquals("20.4", getArtifactKeyCount(sourceRepoLocation.toURI()) + getArtifactKeyCount(sourceRepo4Location.toURI()), getArtifactKeyCount(destRepoLocation.toURI())); } catch (ProvisionException e) { fail("20.5", e); } @@ -735,13 +705,13 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { String[] args = null; //create arguments without a "-source" - args = new String[] {"-destination", destRepoLocation.toURI().toString()}; + args = new String[] {"-destination", "file:" + destRepoLocation.getAbsolutePath()}; try { runMirrorApplication("21.1", args); //We expect the IllegalStateException to be thrown fail("21.3 IllegalStateException not thrown"); - } catch (IllegalStateException e) { + } catch (IllegalArgumentException e) { return; //expected type of exception has been thrown } catch (Exception e) { fail("21.2", e); @@ -755,13 +725,13 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { String[] args = null; //create arguments without a "-destination" - args = new String[] {"-source", sourceRepoLocation.toURI().toString()}; + args = new String[] {"-source", "file:" + sourceRepoLocation.getAbsolutePath()}; try { runMirrorApplication("22.1", args); //We expect the IllegalStateException to be thrown fail("22.3 IllegalStateException not thrown"); - } catch (IllegalStateException e) { + } catch (IllegalArgumentException e) { return; //expected type of exception has been thrown } catch (Exception e) { fail("22.2", e); @@ -779,7 +749,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { runMirrorApplication("23.0", args); //We expect the IllegalStateException to be thrown fail("23.2 IllegalStateException not thrown"); - } catch (IllegalStateException e) { + } catch (IllegalArgumentException e) { return; //expected type of exception has been thrown } catch (Exception e) { fail("23.1", e); @@ -926,15 +896,15 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { fail(""); } - IArtifactKey[] keys = packedRepo.getArtifactKeys(); - - for (int i = 0; i < keys.length; i++) { - IArtifactDescriptor[] srcDescriptors = packedRepo.getArtifactDescriptors(keys[i]); + IQueryResult keys = packedRepo.query(ArtifactKeyQuery.ALL_KEYS, null); + for (Iterator iterator = keys.iterator(); iterator.hasNext();) { + IArtifactKey key = (IArtifactKey) iterator.next(); + IArtifactDescriptor[] srcDescriptors = packedRepo.getArtifactDescriptors(key); for (int j = 0; j < srcDescriptors.length; j++) { - if (!(srcDescriptors[j].getProperty(IArtifactDescriptor.FORMAT) == null) && srcDescriptors[j].getProperty(IArtifactDescriptor.FORMAT).equals("packed")) { + if (!(srcDescriptors[j].getProperty(IArtifactDescriptor.FORMAT) == null) && srcDescriptors[j].getProperty(IArtifactDescriptor.FORMAT).equals(IArtifactDescriptor.FORMAT_PACKED)) { //if we have a packed artifact - IArtifactDescriptor newDescriptor = new ArtifactDescriptor(keys[i]); + IArtifactDescriptor newDescriptor = new ArtifactDescriptor(key); Map properties = new OrderedProperties(); properties.putAll(srcDescriptors[j].getProperties()); properties.remove(IArtifactDescriptor.FORMAT); @@ -960,7 +930,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { fail("27.2", e); } //corresponding key should now be in the destination - IArtifactDescriptor[] destDescriptors = destinationRepo.getArtifactDescriptors(keys[i]); + IArtifactDescriptor[] destDescriptors = destinationRepo.getArtifactDescriptors(key); boolean canonicalFound = false; for (int l = 0; !canonicalFound && (l < destDescriptors.length); l++) { //No processing steps mean item is canonical @@ -968,7 +938,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { canonicalFound = true; } if (!canonicalFound) - fail("27.3 no canonical found for " + keys[i].toString()); + fail("27.3 no canonical found for " + key.toString()); //ensure the canonical matches that in the expected assertFileSizes("27.3", (SimpleArtifactRepository) destinationRepo, (SimpleArtifactRepository) packedRepo); @@ -1102,7 +1072,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { assertContains("3", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("4", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("5", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).getArtifactKeys().length + getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).getArtifactKeys().length, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null).getArtifactKeys().length); + assertEquals("5", getArtifactKeyCount(sourceRepoLocation.toURI()) + getArtifactKeyCount(sourceRepo2Location.toURI()), getArtifactKeyCount(destRepoLocation.toURI())); } catch (ProvisionException e) { fail("Could not load destination", e); } @@ -1127,18 +1097,14 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { System.setErr(oldErr); newErr.close(); - try { - assertEquals("Verifying correct number of Keys", 1, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null).getArtifactKeys().length); - //Because only 1 of the artifacts exists on disk, the number of artifacts in the destination should only be 1. - //Order in which mirror application mirrors artifacts is random. - } catch (ProvisionException e) { - fail("Error laoding destiantion repo", e); - } + assertEquals("Verifying correct number of Keys", 1, getArtifactKeyCount(destRepoLocation.toURI())); + //Because only 1 of the artifacts exists on disk, the number of artifacts in the destination should only be 1. + //Order in which mirror application mirrors artifacts is random. } public void testCompareUsingMD5Comparator() { //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); @@ -1176,7 +1142,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { System.setOut(newOut); try { //Set compare flag. - String[] args = new String[] {"-source", repo1Location.toURL().toExternalForm(), "-destination", repo2Location.toURL().toExternalForm(), "-verbose", "-compare"}; + String[] args = new String[] {"-source", repo1Location.toURL().toExternalForm(), "-destination", repo2Location.toURL().toExternalForm(), "-verbose", "-compare", "-comparator", MD5ArtifactComparator.MD5_COMPARATOR_ID}; //run the mirror application runMirrorApplication("Running with duplicate descriptors with different md5 values", args); } catch (Exception e) { @@ -1200,7 +1166,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { 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"); @@ -1246,7 +1212,7 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { System.setOut(newOut); try { //Set compareAgaist - String[] args = new String[] {"-source", repoLocation.toURL().toExternalForm(), "-destination", destRepoLocation.toURL().toExternalForm(), "-compareAgainst", baselineLocation.toURL().toExternalForm(), "-verbose", "-compare"}; + String[] args = new String[] {"-source", repoLocation.toURL().toExternalForm(), "-destination", destRepoLocation.toURL().toExternalForm(), "-compareAgainst", baselineLocation.toURL().toExternalForm(), "-verbose", "-compare", "-comparator", MD5ArtifactComparator.MD5_COMPARATOR_ID}; //run the mirror application runMirrorApplication("Running with baseline compare", args); } catch (Exception e) { @@ -1294,10 +1260,6 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { manager.removeRepository(srcLocation); } - public synchronized IArtifactKey[] getArtifactKeys() { - return source.getArtifactKeys(); - } - public synchronized IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) { return source.getArtifactDescriptors(key); } @@ -1314,6 +1276,10 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { public synchronized boolean contains(IArtifactDescriptor descriptor) { return source.contains(descriptor); } + + public synchronized IQueryResult query(IQuery query, IProgressMonitor monitor) { + return source.query(query, monitor); + } } //set up test repository @@ -1385,9 +1351,10 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { try { //Mirroring full duplicate, so any key will do. - IArtifactDescriptor[] descriptors = sourceRepository.getArtifactDescriptors(sourceRepository.getArtifactKeys()[0]); + IQueryResult<IArtifactDescriptor> descriptors = sourceRepository.descriptorQueryable().query(ArtifactDescriptorQuery.ALL_DESCRIPTORS, null); + IArtifactDescriptor descriptor = descriptors.iterator().next(); //Mirroring full duplicate, so any descriptor will do. - String message = NLS.bind(org.eclipse.equinox.internal.p2.artifact.repository.Messages.mirror_alreadyExists, descriptors[0], destRepoLocation.toURI()); + String message = NLS.bind(org.eclipse.equinox.internal.p2.artifact.repository.Messages.mirror_alreadyExists, descriptor, destRepoLocation.toURI()); assertLogDoesNotContainLine(log.getFile(), message); } catch (Exception e) { fail("Error verifying log", e); @@ -1456,9 +1423,10 @@ public class ArtifactMirrorApplicationTest extends AbstractProvisioningTest { try { //Mirroring full duplicate, so any key will do. - IArtifactDescriptor[] descriptors = sourceRepository.getArtifactDescriptors(sourceRepository.getArtifactKeys()[0]); + IQueryResult<IArtifactDescriptor> descriptors = sourceRepository.descriptorQueryable().query(ArtifactDescriptorQuery.ALL_DESCRIPTORS, null); + IArtifactDescriptor descriptor = descriptors.iterator().next(); //Mirroring full duplicate, so any descriptor will do. - String message = NLS.bind(org.eclipse.equinox.internal.p2.artifact.repository.Messages.mirror_alreadyExists, descriptors[0], destRepoLocation.toURI()); + String message = NLS.bind(org.eclipse.equinox.internal.p2.artifact.repository.Messages.mirror_alreadyExists, descriptor, destRepoLocation.toURI()); assertLogContainsLine(log.getFile(), message); } catch (Exception e) { fail("Error verifying log", e); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactRepositoryCleanupTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactRepositoryCleanupTest.java index eba8c9934..f95d562cf 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactRepositoryCleanupTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactRepositoryCleanupTest.java @@ -15,9 +15,9 @@ import java.net.MalformedURLException; import java.util.HashMap; import java.util.Map; import org.eclipse.equinox.app.IApplicationContext; -import org.eclipse.equinox.internal.p2.artifact.mirror.MirrorApplication; -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.internal.repository.tools.MirrorApplication; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.osgi.framework.Bundle; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java index 0ff0987c7..7e46b7318 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java @@ -14,18 +14,16 @@ import java.io.File; import java.net.*; import java.util.HashMap; import java.util.Map; -import org.eclipse.equinox.app.IApplicationContext; -import org.eclipse.equinox.internal.p2.metadata.mirror.MirrorApplication; import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -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.provisional.p2.repository.IRepository; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication; +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.IRepository; +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.osgi.framework.Bundle; /** * Test API of the basic mirror application functionality's implementation. @@ -74,43 +72,11 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest { */ private void runMirrorApplication(String message, final String[] args) throws Exception { MirrorApplication application = new MirrorApplication(); - application.start(new IApplicationContext() { - - public void applicationRunning() { - } - - public Map getArguments() { - Map arguments = new HashMap(); - - arguments.put(IApplicationContext.APPLICATION_ARGS, args); - - return arguments; - } - - public String getBrandingApplication() { - return null; - } - - public Bundle getBrandingBundle() { - return null; - } - - public String getBrandingDescription() { - return null; - } - - public String getBrandingId() { - return null; - } - - public String getBrandingName() { - return null; - } - - public String getBrandingProperty(String key) { - return null; - } - }); + Map map = new HashMap(); + map.put("metadataOrArtifacts", "metadata"); + application.setInitializationData(null, null, map); + application.initializeFromArguments(args); + application.run(null); } /** @@ -139,14 +105,14 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest { } /** - * Takes 2 collectors, compares them, and returns the number of unique keys + * Takes 2 QueryResults, compares them, and returns the number of unique keys * Needed to verify that only the appropriate number of files have been transfered by the mirror application */ - private int getNumUnique(Collector c1, Collector c2) { - Object[] repo1 = c1.toCollection().toArray(); - Object[] repo2 = c2.toCollection().toArray(); + private int getNumUnique(IQueryResult c1, IQueryResult c2) { + Object[] repo1 = c1.toArray(IInstallableUnit.class); + Object[] repo2 = c2.toArray(IInstallableUnit.class); - //initialize to the size of both collectors + //initialize to the size of both query results int numKeys = repo1.length + repo2.length; for (int i = 0; i < repo1.length; i++) { @@ -396,7 +362,7 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest { assertContains("5.1", getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("5.2", getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("5.3", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null), getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals("5.3", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null), getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), queryResultSize(getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null))); } catch (ProvisionException e) { fail("5.4", e); } @@ -501,7 +467,7 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest { assertContains("11.1", getMetadataRepositoryManager().loadRepository(sourceRepo3Location.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("11.2", getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("11.3", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null), getMetadataRepositoryManager().loadRepository(sourceRepo3Location.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals("11.3", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, null), getMetadataRepositoryManager().loadRepository(sourceRepo3Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), queryResultSize(getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null))); } catch (ProvisionException e) { fail("11.4", e); } @@ -686,7 +652,7 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest { assertContains("20.2", getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("20.3", getMetadataRepositoryManager().loadRepository(sourceRepo4Location.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("20.4", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null), getMetadataRepositoryManager().loadRepository(sourceRepo4Location.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals("20.4", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null), getMetadataRepositoryManager().loadRepository(sourceRepo4Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), queryResultSize(getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null))); } catch (ProvisionException e) { fail("20.5", e); } @@ -704,7 +670,7 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest { runMirrorApplication("21.1", args); //We expect the IllegalStateException to be thrown fail("21.3 IllegalStateException not thrown"); - } catch (IllegalStateException e) { + } catch (IllegalArgumentException e) { return; //expected type of exception has been thrown } catch (Exception e) { fail("21.2", e); @@ -723,7 +689,7 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest { runMirrorApplication("22.1", args); //We expect the IllegalStateException to be thrown fail("22.3 IllegalStateException not thrown"); - } catch (IllegalStateException e) { + } catch (ProvisionException e) { return; //expected type of exception has been thrown } catch (Exception e) { fail("22.2", e); @@ -741,7 +707,7 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest { runMirrorApplication("23.0", args); //We expect the IllegalStateException to be thrown fail("23.2 IllegalStateException not thrown"); - } catch (IllegalStateException e) { + } catch (IllegalArgumentException e) { return; //expected type of exception has been thrown } catch (Exception e) { fail("23.1", e); @@ -972,7 +938,7 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest { assertContains("3", getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("4", getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("5", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null), getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals("5", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null), getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), queryResultSize(getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null))); } catch (ProvisionException e) { fail("Could not load destination", e); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataRepositoryCleanupTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataRepositoryCleanupTest.java index 7faef2d4f..41a7d73cb 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataRepositoryCleanupTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataRepositoryCleanupTest.java @@ -15,9 +15,9 @@ import java.net.MalformedURLException; import java.util.HashMap; import java.util.Map; import org.eclipse.equinox.app.IApplicationContext; -import org.eclipse.equinox.internal.p2.artifact.mirror.MirrorApplication; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.osgi.framework.Bundle; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java index 867a05f44..e3a9f4bde 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.mirror; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.*; import java.net.MalformedURLException; @@ -22,12 +22,15 @@ 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.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.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.tools.MirrorApplication; import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.query.IQuery; +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.TestActivator; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; @@ -311,15 +314,15 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { * Not Biconditional. */ private void assertFileSizes(String message, SimpleArtifactRepository expected, SimpleArtifactRepository actual) { - IArtifactKey[] expectedKeys = expected.getArtifactKeys(); - - for (int i = 0; i < expectedKeys.length; i++) { - IArtifactDescriptor[] expectedDescriptors = expected.getArtifactDescriptors(expectedKeys[i]); - IArtifactDescriptor[] actualDescriptors = actual.getArtifactDescriptors(expectedKeys[i]); + IQueryResult expectedKeys = expected.query(ArtifactKeyQuery.ALL_KEYS, null); + for (Iterator iterator = expectedKeys.iterator(); iterator.hasNext();) { + IArtifactKey key = (IArtifactKey) iterator.next(); + IArtifactDescriptor[] expectedDescriptors = expected.getArtifactDescriptors(key); + IArtifactDescriptor[] actualDescriptors = actual.getArtifactDescriptors(key); if (expectedDescriptors == null || actualDescriptors == null) if (!(expectedDescriptors == null && actualDescriptors == null)) - fail(message + " missing key " + expectedKeys[i]); + fail(message + " missing key " + key); top: for (int j = 0; j < expectedDescriptors.length; j++) { for (int k = 0; k < actualDescriptors.length; k++) { @@ -421,7 +424,7 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { assertContains("5.1", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("5.2", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("5.3", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).getArtifactKeys().length + getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).getArtifactKeys().length, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null).getArtifactKeys().length); + assertEquals("5.3", getArtifactKeyCount(sourceRepoLocation.toURI()) + getArtifactKeyCount(sourceRepo2Location.toURI()), getArtifactKeyCount(destRepoLocation.toURI())); } catch (ProvisionException e) { fail("5.4", e); } @@ -526,7 +529,7 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { assertContains("11.1", getArtifactRepositoryManager().loadRepository(sourceRepo3Location.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("11.2", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("11.3", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).getArtifactKeys().length + getArtifactRepositoryManager().loadRepository(sourceRepo3Location.toURI(), null).getArtifactKeys().length, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null).getArtifactKeys().length); + assertEquals("11.3", getArtifactKeyCount(sourceRepo2Location.toURI()) + getArtifactKeyCount(sourceRepo3Location.toURI()), getArtifactKeyCount(destRepoLocation.toURI())); } catch (ProvisionException e) { fail("11.4", e); } @@ -719,7 +722,7 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { assertContains("20.2", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("20.3", getArtifactRepositoryManager().loadRepository(sourceRepo4Location.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("20.4", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).getArtifactKeys().length + getArtifactRepositoryManager().loadRepository(sourceRepo4Location.toURI(), null).getArtifactKeys().length, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null).getArtifactKeys().length); + assertEquals("20.4", getArtifactKeyCount(sourceRepoLocation.toURI()) + getArtifactKeyCount(sourceRepo4Location.toURI()), getArtifactKeyCount(destRepoLocation.toURI())); } catch (ProvisionException e) { fail("20.5", e); } @@ -907,15 +910,15 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { fail(""); } - IArtifactKey[] keys = packedRepo.getArtifactKeys(); - - for (int i = 0; i < keys.length; i++) { - IArtifactDescriptor[] srcDescriptors = packedRepo.getArtifactDescriptors(keys[i]); + IQueryResult keys = packedRepo.query(ArtifactKeyQuery.ALL_KEYS, null); + for (Iterator iterator = keys.iterator(); iterator.hasNext();) { + IArtifactKey key = (IArtifactKey) iterator.next(); + IArtifactDescriptor[] srcDescriptors = packedRepo.getArtifactDescriptors(key); for (int j = 0; j < srcDescriptors.length; j++) { - if (!(srcDescriptors[j].getProperty(IArtifactDescriptor.FORMAT) == null) && srcDescriptors[j].getProperty(IArtifactDescriptor.FORMAT).equals("packed")) { + if (!(srcDescriptors[j].getProperty(IArtifactDescriptor.FORMAT) == null) && srcDescriptors[j].getProperty(IArtifactDescriptor.FORMAT).equals(IArtifactDescriptor.FORMAT_PACKED)) { //if we have a packed artifact - IArtifactDescriptor newDescriptor = new ArtifactDescriptor(keys[i]); + IArtifactDescriptor newDescriptor = new ArtifactDescriptor(key); Map properties = new OrderedProperties(); properties.putAll(srcDescriptors[j].getProperties()); properties.remove(IArtifactDescriptor.FORMAT); @@ -941,7 +944,7 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { fail("27.2", e); } //corresponding key should now be in the destination - IArtifactDescriptor[] destDescriptors = destinationRepo.getArtifactDescriptors(keys[i]); + IArtifactDescriptor[] destDescriptors = destinationRepo.getArtifactDescriptors(key); boolean canonicalFound = false; for (int l = 0; !canonicalFound && (l < destDescriptors.length); l++) { //No processing steps mean item is canonical @@ -949,7 +952,7 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { canonicalFound = true; } if (!canonicalFound) - fail("27.3 no canonical found for " + keys[i].toString()); + fail("27.3 no canonical found for " + key.toString()); //ensure the canonical matches that in the expected assertFileSizes("27.3", (SimpleArtifactRepository) destinationRepo, (SimpleArtifactRepository) packedRepo); @@ -1083,7 +1086,7 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { assertContains("3", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("4", getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null), getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("5", getArtifactRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).getArtifactKeys().length + getArtifactRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).getArtifactKeys().length, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null).getArtifactKeys().length); + assertEquals("5", getArtifactKeyCount(sourceRepoLocation.toURI()) + getArtifactKeyCount(sourceRepo2Location.toURI()), getArtifactKeyCount(destRepoLocation.toURI())); } catch (ProvisionException e) { fail("Could not load destination", e); } @@ -1111,19 +1114,15 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { if (newErr != null) newErr.close(); } - try { - assertEquals("Verifying correct number of Keys", 2, getArtifactRepositoryManager().loadRepository(destRepoLocation.toURI(), null).getArtifactKeys().length); - //Because only 2 of the artifacts exists on disk, the number of artifacts in the destination should only be 1. - //Order in which mirror application mirrors artifacts is random. - } catch (ProvisionException e) { - fail("Error laoding destiantion repo", e); - } + assertEquals("Verifying correct number of Keys", 2, getArtifactKeyCount(destRepoLocation.toURI())); + //Because only 2 of the artifacts exists on disk, the number of artifacts in the destination should only be 1. + //Order in which mirror application mirrors artifacts is random. } public void testCompareUsingMD5Comparator() { //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); @@ -1195,7 +1194,7 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { 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"); @@ -1301,10 +1300,6 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { manager.removeRepository(srcLocation); } - public synchronized IArtifactKey[] getArtifactKeys() { - return source.getArtifactKeys(); - } - public synchronized IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) { return source.getArtifactDescriptors(key); } @@ -1321,6 +1316,10 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { public synchronized boolean contains(IArtifactDescriptor descriptor) { return source.contains(descriptor); } + + public synchronized IQueryResult query(IQuery query, IProgressMonitor monitor) { + return source.query(query, monitor); + } } //set up test repository @@ -1392,9 +1391,10 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { try { //Mirroring full duplicate, so any key will do. - IArtifactDescriptor[] descriptors = sourceRepository.getArtifactDescriptors(sourceRepository.getArtifactKeys()[0]); + IQueryResult<IArtifactDescriptor> descriptors = sourceRepository.descriptorQueryable().query(ArtifactDescriptorQuery.ALL_DESCRIPTORS, null); + IArtifactDescriptor descriptor = descriptors.iterator().next(); //Mirroring full duplicate, so any descriptor will do. - String message = NLS.bind(org.eclipse.equinox.internal.p2.artifact.repository.Messages.mirror_alreadyExists, descriptors[0], destRepoLocation.toURI()); + String message = NLS.bind(org.eclipse.equinox.internal.p2.artifact.repository.Messages.mirror_alreadyExists, descriptor, destRepoLocation.toURI()); assertLogDoesNotContainLine(log.getFile(), message); } catch (Exception e) { fail("Error verifying log", e); @@ -1469,9 +1469,10 @@ public class NewMirrorApplicationArtifactTest extends AbstractProvisioningTest { try { //Mirroring full duplicate, so any key will do. - IArtifactDescriptor[] descriptors = sourceRepository.getArtifactDescriptors(sourceRepository.getArtifactKeys()[0]); + IQueryResult<IArtifactDescriptor> descriptors = sourceRepository.descriptorQueryable().query(ArtifactDescriptorQuery.ALL_DESCRIPTORS, null); + IArtifactDescriptor descriptor = descriptors.iterator().next(); //Mirroring full duplicate, so any descriptor will do. - String message = NLS.bind(org.eclipse.equinox.internal.p2.artifact.repository.Messages.mirror_alreadyExists, descriptors[0], destRepoLocation.toURI()); + String message = NLS.bind(org.eclipse.equinox.internal.p2.artifact.repository.Messages.mirror_alreadyExists, descriptor, destRepoLocation.toURI()); assertLogContainsLine(log.getFile(), message); } catch (Exception e) { fail("Error verifying log", e); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java index 69957d0cc..8baac04e3 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java @@ -15,16 +15,16 @@ import java.net.*; import java.util.HashMap; import java.util.Map; import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -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.provisional.p2.repository.IRepository; import org.eclipse.equinox.internal.simpleconfigurator.utils.URIUtil; +import org.eclipse.equinox.p2.core.ProvisionException; import org.eclipse.equinox.p2.internal.repository.tools.MirrorApplication; import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor; +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.IRepository; +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.osgi.util.NLS; @@ -132,14 +132,14 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest { } /** - * Takes 2 collectors, compares them, and returns the number of unique keys + * Takes 2 QueryResults, compares them, and returns the number of unique keys * Needed to verify that only the appropriate number of files have been transfered by the mirror application */ - private int getNumUnique(Collector c1, Collector c2) { - Object[] repo1 = c1.toCollection().toArray(); - Object[] repo2 = c2.toCollection().toArray(); + private int getNumUnique(IQueryResult c1, IQueryResult c2) { + Object[] repo1 = c1.toArray(IInstallableUnit.class); + Object[] repo2 = c2.toArray(IInstallableUnit.class); - //initialize to the size of both collectors + //initialize to the size of both QueryResults int numKeys = repo1.length + repo2.length; for (int i = 0; i < repo1.length; i++) { @@ -394,7 +394,7 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest { assertContains("5.1", getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("5.2", getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("5.3", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null), getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals("5.3", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null), getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), queryResultSize(getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null))); } catch (ProvisionException e) { fail("5.4", e); } @@ -499,7 +499,7 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest { assertContains("11.1", getMetadataRepositoryManager().loadRepository(sourceRepo3Location.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("11.2", getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("11.3", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null), getMetadataRepositoryManager().loadRepository(sourceRepo3Location.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals("11.3", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, null), getMetadataRepositoryManager().loadRepository(sourceRepo3Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), queryResultSize(getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null))); } catch (ProvisionException e) { fail("11.4", e); } @@ -704,7 +704,7 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest { assertContains("20.2", getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("20.3", getMetadataRepositoryManager().loadRepository(sourceRepo4Location.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("20.4", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null), getMetadataRepositoryManager().loadRepository(sourceRepo4Location.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals("20.4", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null), getMetadataRepositoryManager().loadRepository(sourceRepo4Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), queryResultSize(getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null))); } catch (ProvisionException e) { fail("20.5", e); } @@ -959,7 +959,7 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest { assertContains("3", getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); assertContains("4", getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null)); //checks that the destination has the correct number of keys (no extras) - assertEquals("5", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null), getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals("5", getNumUnique(getMetadataRepositoryManager().loadRepository(sourceRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null), getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), queryResultSize(getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, null))); } catch (ProvisionException e) { fail("Could not load destination", e); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/CommonPatternsTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/CommonPatternsTest.java index c3867942e..a824495f8 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/CommonPatternsTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/CommonPatternsTest.java @@ -11,7 +11,8 @@ package org.eclipse.equinox.p2.tests.omniVersion; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.IVersionFormat; +import org.eclipse.equinox.p2.metadata.Version; /** * Test common patterns: @@ -22,8 +23,9 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.Version; * */ public class CommonPatternsTest extends VersionTesting { + public static String TRIPLET_FORMAT_STRING = "n=0;[.n=0;[.n=0;]][dS=m;]"; public static String MOZ_PREFIX = "format((<N=0;?s=m;?N=0;?s=m;?>(.<N=0;?s=m;?N=0;?s=m;?>)*)=p<0.m.0.m>;):"; - public static String TRIPLE_PREFIX = "format(n=0;[.n=0;[.n=0;]][dS=m;]):"; + public static String TRIPLE_PREFIX = "format(" + TRIPLET_FORMAT_STRING + "):"; public static String RPM_PREFIX = "format(<[n=0;:]a(d=[^a-zA-Z0-9@_-];?a)*>[-n[dS=!;]]):"; public static String JSR277_PREFIX = "format(n(.n=0;){0,3}[-S=m;]):"; @@ -142,6 +144,26 @@ public class CommonPatternsTest extends VersionTesting { assertEquals(TRIPLE_PREFIX, Version.parseVersion(test).getFormat().toString() + ':'); } + public void testTripletPatternToOSGi() throws Exception { + IVersionFormat triplet = Version.compile(TRIPLET_FORMAT_STRING); + assertEquals(Version.createOSGi(1, 0, 0), triplet.parse("1.0.0." + IVersionFormat.DEFAULT_MIN_STRING_TRANSLATION)); + assertEquals(Version.create("1.0.0." + IVersionFormat.DEFAULT_MAX_STRING_TRANSLATION), triplet.parse("1.0.0")); + assertEquals(Version.createOSGi(1, 0, 0, IVersionFormat.DEFAULT_MAX_STRING_TRANSLATION), Version.create("raw:1.0.0.m")); + assertEquals(triplet.parse("1.0"), Version.create("raw:1.0.0.m")); + assertEquals(triplet.parse("1.0." + IVersionFormat.DEFAULT_MIN_STRING_TRANSLATION), Version.create("raw:1.0.0.''")); + assertEquals(Version.createOSGi(1, 0, 0), Version.create("raw:1.0.0.''")); + } + + public void testMinTranslation() throws Exception { + IVersionFormat format = Version.compile("n=0;[.n=0;[.n=0;]][dS=m{!};]"); + assertEquals(Version.create("raw:1.0.0.''"), format.parse("1.0.0.!")); + } + + public void testMaxTranslation() throws Exception { + IVersionFormat format = Version.compile("n=0;[.n=0;[.n=0;]][dS=''{~,4};]"); + assertEquals(Version.create("raw:1.0.0.m"), format.parse("1.0.0.~~~~")); + } + // TODO: Not clear what a missing RPM EPOCH (i.e. first '.n:' should be interpreted as public void testRPMPattern() { Version v1 = Version.parseVersion(RPM_PREFIX + "33:1.2.3a-23/i386"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatATest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatATest.java index c439e9ecd..f7d4d0d74 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatATest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatATest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; /** * Tests the format(a) rule. diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatArrayTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatArrayTest.java index 62be84716..5a2afa83b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatArrayTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatArrayTest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; /** * Tests format(<>) - arrays. diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatDTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatDTest.java index 66e9de920..566bf1b95 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatDTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatDTest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; /** * Tests format(d) and explicit delimiter chars and strings. diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatNTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatNTest.java index 5065e0b19..9a67544e7 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatNTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatNTest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; /** * Tests format(n) and format(N) diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatPTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatPTest.java index f163d8482..143f623b7 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatPTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatPTest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; public class FormatPTest extends TestCase { public void testPad() { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatProcessingTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatProcessingTest.java index d7acc52a0..69baf16ca 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatProcessingTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatProcessingTest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; /** * Tests processing rules not tested elsewhere, and combinations of processing rules. diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatQTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatQTest.java index 19c8a4430..dc771aae2 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatQTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatQTest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; /** * Tests format(q) diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRTest.java index 68397a716..38983b5a4 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRTest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; /** * Tests format(r) diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRangeTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRangeTest.java index 9ebc1ef75..d141dfd56 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRangeTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRangeTest.java @@ -11,8 +11,8 @@ package org.eclipse.equinox.p2.tests.omniVersion; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; /** * Tests ranges using format(xxx) version strings. @@ -66,7 +66,7 @@ public class FormatRangeTest extends VersionTesting { } public void testGreaterThanMinimum() { - // any version equal or greater than Version.MIN_VERSION is ok + // any version equal or greater than Version.emptyVersion is ok VersionRange lowerBound = new VersionRange("raw:-M"); assertIncludedInRange("0.1", lowerBound, "raw:-M"); assertIncludedInRange("1.0", lowerBound, OSGI_PREFIX + "0.9.0"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatSTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatSTest.java index 8bfaee947..5be32493a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatSTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatSTest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; /** * Tests format(s), and format(S) diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatTest.java index 888a147c6..fa5300f06 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatTest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; /** * Test of format() performing tests not covered by tests per rule. diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/IntersectionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/IntersectionTest.java index 1c456af77..04f8a987e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/IntersectionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/IntersectionTest.java @@ -11,9 +11,10 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; /** * Tests intersection of VersionRanges. diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/MultiplicityTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/MultiplicityTest.java index cb122ec44..34c9079a0 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/MultiplicityTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/MultiplicityTest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; /** * Tests {n.m} in different combinations and the special +?* diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/OSGiRangeTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/OSGiRangeTest.java index f064b18f6..162818d7f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/OSGiRangeTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/OSGiRangeTest.java @@ -12,8 +12,8 @@ package org.eclipse.equinox.p2.tests.omniVersion; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; /** * Tests ranges of versions specified with osgi (default) version format. @@ -50,8 +50,8 @@ public class OSGiRangeTest extends VersionTesting { assertTrue("1.1", lowerBound.isIncluded(Version.parseVersion("1.0"))); assertTrue("1.2", lowerBound.isIncluded(Version.parseVersion("1.9.9.x"))); assertTrue("1.3", lowerBound.isIncluded(Version.parseVersion("999.999.999.foo"))); - assertTrue("2.0", !lowerBound.isIncluded(Version.parseVersion("raw:M"))); - assertTrue("2.1", !lowerBound.isIncluded(Version.parseVersion("raw:2147483647.2147483647.2147483647.0"))); + assertTrue("2.0", lowerBound.isIncluded(Version.parseVersion("raw:M"))); + assertTrue("2.1", lowerBound.isIncluded(Version.parseVersion("raw:2147483647.2147483647.2147483647.0"))); } @@ -94,16 +94,16 @@ public class OSGiRangeTest extends VersionTesting { /** * Tests that null values passed to the {@link VersionRange} constructor - * are interpreted as OSGi ranges. + * are not interpreted as MIN/MAX versions. */ public void testNullConstructor() { VersionRange range = new VersionRange(null); - assertEquals("1.0", range.getMinimum(), new Version(0, 0, 0)); - assertEquals("1.1", range.getMaximum(), new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)); + assertEquals("1.0", range.getMinimum(), Version.emptyVersion); + assertEquals("1.1", range.getMaximum(), Version.MAX_VERSION); range = new VersionRange(null, true, null, true); - assertEquals("2.0", range.getMinimum(), new Version(0, 0, 0)); - assertEquals("2.1", range.getMaximum(), new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)); + assertEquals("2.0", range.getMinimum(), Version.emptyVersion); + assertEquals("2.1", range.getMaximum(), Version.MAX_VERSION); } public void testSerialize() { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/OSGiVersionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/OSGiVersionTest.java index 608ae3885..d9ff27595 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/OSGiVersionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/OSGiVersionTest.java @@ -11,7 +11,7 @@ package org.eclipse.equinox.p2.tests.omniVersion; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; /** * Tests versions specified with default OSGi version strings and tests OSGi compatibility @@ -33,7 +33,7 @@ public class OSGiVersionTest extends VersionTesting { public void testOSGiStrings() { - Version v = new Version(""); + Version v = Version.parseVersion(null); assertEquals("0.0.0", v.toString()); assertNotNull(v = Version.parseVersion("")); assertEquals("0.0.0", v.toString()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/PerformanceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/PerformanceTest.java index 605bfa70d..5f7061aa8 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/PerformanceTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/PerformanceTest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; + import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; /** * Simple performance comparison between OSGi version implementation and Omni Version. @@ -30,7 +31,7 @@ public class PerformanceTest extends TestCase { public void testStringCreationPerformance() { // Ensure that classes are loaded etc. - Version.MAX_VERSION.compareTo(Version.MIN_VERSION); + Version.MAX_VERSION.compareTo(Version.emptyVersion); org.osgi.framework.Version.emptyVersion.compareTo(org.osgi.framework.Version.emptyVersion); // Create all versions in string format @@ -51,7 +52,7 @@ public class PerformanceTest extends TestCase { public void testCreationPerformance() { // Ensure that classes are loaded etc. - Version.MAX_VERSION.compareTo(Version.MIN_VERSION); + Version.MAX_VERSION.compareTo(Version.emptyVersion); org.osgi.framework.Version.emptyVersion.compareTo(org.osgi.framework.Version.emptyVersion); long start = System.currentTimeMillis(); @@ -137,7 +138,7 @@ public class PerformanceTest extends TestCase { for (int i = 0; i < MUL; i++) for (int j = 0; j < MUL; j++) for (int k = 0; k < MUL; k++) - new Version(i, j, k, qualifierTemplate); + Version.createOSGi(i, j, k, qualifierTemplate); } public static void omniVersionCompare(Version versions[]) { @@ -159,7 +160,7 @@ public class PerformanceTest extends TestCase { for (int i = 0; i < MUL; i++) for (int j = 0; j < MUL; j++) for (int k = 0; k < MUL; k++) - Version.parseVersion(strings[x++]); + Version.create(strings[x++]); } public static void osgiVersionCompare(org.osgi.framework.Version versions[]) { @@ -201,7 +202,7 @@ public class PerformanceTest extends TestCase { for (int i = 0; i < MUL; i++) for (int j = 0; j < MUL; j++) for (int k = 0; k < MUL; k++) - versions[x++] = new Version(i, j, k, qualifierTemplate.substring(0, k + 1)); + versions[x++] = Version.createOSGi(i, j, k, qualifierTemplate.substring(0, k + 1)); return versions; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawRangeTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawRangeTest.java index 3b637d812..eae2a6146 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawRangeTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawRangeTest.java @@ -11,8 +11,8 @@ package org.eclipse.equinox.p2.tests.omniVersion; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; /** * Tests version ranges specified using raw. diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawRangeWithOriginalTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawRangeWithOriginalTest.java index ab3034425..b2315f6d9 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawRangeWithOriginalTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawRangeWithOriginalTest.java @@ -11,8 +11,10 @@ package org.eclipse.equinox.p2.tests.omniVersion; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; + +import org.eclipse.equinox.internal.p2.metadata.VersionFormat; /** * Tests inclusion of original version range string in raw format. @@ -46,6 +48,11 @@ public class RawRangeWithOriginalTest extends VersionTesting { assertEquals("raw:[1.0,2.0]/format(n.n):1.0,2.0", new VersionRange("raw:[1.0,2.0]/format(n.n):[1.0,2.0]").toString()); } + public void testSimpleFormatToString() { + // range brackets are normalized in toString - not needed in original + assertEquals("raw:[1.0,2.0]/format(n.n):1.0,2.0", new VersionRange("format(n.n):[1.0,2.0]").toString()); + } + public void testRawWithSimpleFormatSerialized() { assertSerialized(new VersionRange("raw:[1.0,2.0]/format(n.n):[1.0,2.0]")); // range brackets are normalized in toString - not needed in original @@ -163,7 +170,7 @@ public class RawRangeWithOriginalTest extends VersionTesting { } public void testOSGiMinBoundary() { - String rangeString = "raw:[-M,2.1.0]/format(n[.n=0;[.n=0;[.S=[A-Za-z0-9_-];]]]):-M,2.1.0"; + String rangeString = "raw:[-M,2.1.0.'']/format(" + VersionFormat.OSGI_FORMAT_STRING + "):-M,2.1.0"; VersionRange range = new VersionRange(rangeString); VersionRange range1 = new VersionRange("[0.0.0,2.1.0]"); @@ -188,7 +195,7 @@ public class RawRangeWithOriginalTest extends VersionTesting { } public void testRecreateUsingMaxUpper() { - Version v = new Version("format(n[.n=0;[.n=0;]][d?S=M;]):2.1"); + Version v = Version.create("format(n[.n=0;[.n=0;]][d?S=M;]):2.1"); VersionRange range = new VersionRange(v, true, null, true); Version min = range.getMinimum(); Version max = range.getMaximum(); @@ -197,7 +204,7 @@ public class RawRangeWithOriginalTest extends VersionTesting { } public void testRecreateUsingMinLower() { - Version v = new Version("format(n[.n=0;[.n=0;]][d?S=M;]):2.1"); + Version v = Version.create("format(n[.n=0;[.n=0;]][d?S=M;]):2.1"); VersionRange range = new VersionRange(null, true, v, true); Version min = range.getMinimum(); Version max = range.getMaximum(); @@ -206,7 +213,7 @@ public class RawRangeWithOriginalTest extends VersionTesting { } public void testOSGiMaxBoundary() { - String rangeString = "raw:[2.1.0,MpM]/format(n[.n=0;[.n=0;[.S=[A-Za-z0-9_-];]]]):2.1.0,MpM"; + String rangeString = "raw:[2.1.0.'',MpM]/format(" + VersionFormat.OSGI_FORMAT_STRING + "):2.1.0,MpM"; VersionRange range = new VersionRange(rangeString); VersionRange range1 = new VersionRange("2.1.0"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawVersionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawVersionTest.java index ec5b5cc86..e1c80bb03 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawVersionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawVersionTest.java @@ -11,8 +11,9 @@ package org.eclipse.equinox.p2.tests.omniVersion; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionVector; +import org.eclipse.equinox.p2.metadata.Version; + +import org.eclipse.equinox.internal.p2.metadata.VersionVector; /** * Tests the OmniVersion raw version format. @@ -23,84 +24,84 @@ public class RawVersionTest extends VersionTesting { public void testBasicParsing() { // should parse without exception - assertNotNull(Version.parseVersion("raw:1")); - assertNotNull(Version.parseVersion("raw:1.0")); - assertNotNull(Version.parseVersion("raw:1.0.0")); - assertNotNull(Version.parseVersion("raw:1.0.0.9")); - assertNotNull(Version.parseVersion("raw:1.0.0.'r12345'")); - assertNotNull(Version.parseVersion("raw:1.0.0.'r12345.hello'")); + assertNotNull(Version.create("raw:1")); + assertNotNull(Version.create("raw:1.0")); + assertNotNull(Version.create("raw:1.0.0")); + assertNotNull(Version.create("raw:1.0.0.9")); + assertNotNull(Version.create("raw:1.0.0.'r12345'")); + assertNotNull(Version.create("raw:1.0.0.'r12345.hello'")); - assertNotNull(Version.parseVersion("raw:1.0.m")); - assertNotNull(Version.parseVersion("raw:1.0.M")); + assertNotNull(Version.create("raw:1.0.m")); + assertNotNull(Version.create("raw:1.0.M")); - assertNotNull(Version.parseVersion("raw:1.0.M")); - assertNotNull(Version.parseVersion("raw:1.0.-M")); + assertNotNull(Version.create("raw:1.0.M")); + assertNotNull(Version.create("raw:1.0.-M")); } public void testSerialize() { Version v = null; // should parse without exception - assertNotNull(v = Version.parseVersion("raw:1")); + assertNotNull(v = Version.create("raw:1")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0")); + assertNotNull(v = Version.create("raw:1.0")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0.0")); + assertNotNull(v = Version.create("raw:1.0.0")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0.0.9")); + assertNotNull(v = Version.create("raw:1.0.0.9")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0.0.'r12345'")); + assertNotNull(v = Version.create("raw:1.0.0.'r12345'")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0.0.'r12345.hello'")); + assertNotNull(v = Version.create("raw:1.0.0.'r12345.hello'")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0.m")); + assertNotNull(v = Version.create("raw:1.0.m")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0.M")); + assertNotNull(v = Version.create("raw:1.0.M")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0.M")); + assertNotNull(v = Version.create("raw:1.0.M")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0.-M")); + assertNotNull(v = Version.create("raw:1.0.-M")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:0")); + assertNotNull(v = Version.create("raw:0")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:0.1.2.3.4.5.6.7.8.9")); + assertNotNull(v = Version.create("raw:0.1.2.3.4.5.6.7.8.9")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:0.-1.-2.-3.-4.-5.-6.-7.-8.-9")); + assertNotNull(v = Version.create("raw:0.-1.-2.-3.-4.-5.-6.-7.-8.-9")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:123456789.-1234567890")); + assertNotNull(v = Version.create("raw:123456789.-1234567890")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:123456789.-1234567890")); + assertNotNull(v = Version.create("raw:123456789.-1234567890")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:m")); + assertNotNull(v = Version.create("raw:m")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:M")); + assertNotNull(v = Version.create("raw:M")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:-M")); + assertNotNull(v = Version.create("raw:-M")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.m")); + assertNotNull(v = Version.create("raw:1.m")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.M")); + assertNotNull(v = Version.create("raw:1.M")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.-M")); + assertNotNull(v = Version.create("raw:1.-M")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:'a'")); + assertNotNull(v = Version.create("raw:'a'")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:\"a\"")); + assertNotNull(v = Version.create("raw:\"a\"")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:'ab'")); + assertNotNull(v = Version.create("raw:'ab'")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:'abcdefghijklmnopqrstuvwxyz0123456789'")); + assertNotNull(v = Version.create("raw:'abcdefghijklmnopqrstuvwxyz0123456789'")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'")); + assertNotNull(v = Version.create("raw:'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:'-_!\"#$%&/()=?+*;,:.'")); + assertNotNull(v = Version.create("raw:'-_!\"#$%&/()=?+*;,:.'")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:\"'\"")); + assertNotNull(v = Version.create("raw:\"'\"")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:'\"'")); + assertNotNull(v = Version.create("raw:'\"'")); assertSerialized(v); } @@ -109,73 +110,73 @@ public class RawVersionTest extends VersionTesting { Version v = null; String s = null; // should parse without exception - assertNotNull(v = Version.parseVersion(s = "raw:1")); + assertNotNull(v = Version.create(s = "raw:1")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0")); + assertNotNull(v = Version.create(s = "raw:1.0")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0.0")); + assertNotNull(v = Version.create(s = "raw:1.0.0")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0.0.9")); + assertNotNull(v = Version.create(s = "raw:1.0.0.9")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0.0.'r12345'")); + assertNotNull(v = Version.create(s = "raw:1.0.0.'r12345'")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0.0.'r12345.hello'")); + assertNotNull(v = Version.create(s = "raw:1.0.0.'r12345.hello'")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0.m")); + assertNotNull(v = Version.create(s = "raw:1.0.m")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0.M")); + assertNotNull(v = Version.create(s = "raw:1.0.M")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0.M")); + assertNotNull(v = Version.create(s = "raw:1.0.M")); assertEquals(s, v.toString()); // -M is normalized - assertNotNull(v = Version.parseVersion("raw:1.0.-M")); + assertNotNull(v = Version.create("raw:1.0.-M")); s = "raw:1.0"; assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:0")); - assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:0.1.2.3.4.5.6.7.8.9")); + assertNotNull(v = Version.create(s = "raw:0")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:0.-1.-2.-3.-4.-5.-6.-7.-8.-9")); + assertNotNull(v = Version.create(s = "raw:0.1.2.3.4.5.6.7.8.9")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:123456789.-1234567890")); + assertNotNull(v = Version.create(s = "raw:0.-1.-2.-3.-4.-5.-6.-7.-8.-9")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:123456789.-1234567890")); + assertNotNull(v = Version.create(s = "raw:123456789.-1234567890")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:m")); + assertNotNull(v = Version.create(s = "raw:123456789.-1234567890")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:M")); + assertNotNull(v = Version.create(s = "raw:m")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:-M")); + assertNotNull(v = Version.create(s = "raw:M")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.m")); + assertNotNull(v = Version.create(s = "raw:-M")); + assertEquals("0.0.0", v.toString()); + assertNotNull(v = Version.create(s = "raw:1.m")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.M")); + assertNotNull(v = Version.create(s = "raw:1.M")); assertEquals(s, v.toString()); // -M is normalized - assertNotNull(v = Version.parseVersion("raw:1.-M")); + assertNotNull(v = Version.create("raw:1.-M")); s = "raw:1"; assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:'a'")); + assertNotNull(v = Version.create(s = "raw:'a'")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:\"a\"")); + assertNotNull(v = Version.create(s = "raw:\"a\"")); // " is normalized to ' s = "raw:'a'"; assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:'ab'")); + assertNotNull(v = Version.create(s = "raw:'ab'")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:'abcdefghijklmnopqrstuvwxyz0123456789'")); + assertNotNull(v = Version.create(s = "raw:'abcdefghijklmnopqrstuvwxyz0123456789'")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'")); + assertNotNull(v = Version.create(s = "raw:'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:'-_!\"#$%&/()=?+*;,:.'")); + assertNotNull(v = Version.create(s = "raw:'-_!\"#$%&/()=?+*;,:.'")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:\"'\"")); + assertNotNull(v = Version.create(s = "raw:\"'\"")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:'\"'")); + assertNotNull(v = Version.create(s = "raw:'\"'")); assertEquals(s, v.toString()); } @@ -183,24 +184,24 @@ public class RawVersionTest extends VersionTesting { public void testIntegerParsing() { // should parse without exception - Version v = Version.parseVersion("raw:0"); + Version v = Version.create("raw:0"); assertNotNull(v); assertEquals(v.getSegment(0), Integer.valueOf(0)); // single digits - v = Version.parseVersion("raw:0.1.2.3.4.5.6.7.8.9"); + v = Version.create("raw:0.1.2.3.4.5.6.7.8.9"); assertNotNull(v); for (int i = 0; i < 10; i++) assertEquals(v.getSegment(i), Integer.valueOf(i)); // negative single digits - v = Version.parseVersion("raw:0.-1.-2.-3.-4.-5.-6.-7.-8.-9"); + v = Version.create("raw:0.-1.-2.-3.-4.-5.-6.-7.-8.-9"); assertNotNull(v); for (int i = 0; i < 10; i++) assertEquals(v.getSegment(i), Integer.valueOf(-i)); // some larger numbers - v = Version.parseVersion("raw:123456789.-1234567890"); + v = Version.create("raw:123456789.-1234567890"); assertNotNull(v); assertEquals(v.getSegment(0), Integer.valueOf(123456789)); assertEquals(v.getSegment(1), Integer.valueOf(-1234567890)); @@ -209,33 +210,33 @@ public class RawVersionTest extends VersionTesting { public void testWhiteSpaceExceptions() { try { - Version.parseVersion("raw: 0 "); + Version.create("raw: 0 "); fail("space not allowed 1"); } catch (IllegalArgumentException e) { assertTrue(true); } try { - Version.parseVersion("raw:0 .1 . 'a'. 'b c d'. 4. 5. 6. 7. 8 . 9"); + Version.create("raw:0 .1 . 'a'. 'b c d'. 4. 5. 6. 7. 8 . 9"); fail("space not allowed 2"); } catch (IllegalArgumentException e) { assertTrue(true); } try { - Version.parseVersion("raw:< 1.2.3>"); + Version.create("raw:< 1.2.3>"); fail("space not allowed in array 1"); } catch (IllegalArgumentException e) { assertTrue(true); } try { - Version.parseVersion("raw:<1.2.3 >"); + Version.create("raw:<1.2.3 >"); fail("space not allowed in array 2"); } catch (IllegalArgumentException e) { assertTrue(true); } try { - Version.parseVersion("raw:1.- 1"); + Version.create("raw:1.- 1"); fail("Uncaught error: space between minus and number in negative"); } catch (IllegalArgumentException e) { assertTrue(true); @@ -244,140 +245,140 @@ public class RawVersionTest extends VersionTesting { public void testMaxParsing() { - assertNotNull(Version.parseVersion("raw:m")); - assertNotNull(Version.parseVersion("raw:M")); - assertNotNull(Version.parseVersion("raw:-M")); + assertNotNull(Version.create("raw:m")); + assertNotNull(Version.create("raw:M")); + assertNotNull(Version.create("raw:-M")); - assertNotNull(Version.parseVersion("raw:1.m")); - assertNotNull(Version.parseVersion("raw:1.M")); - assertNotNull(Version.parseVersion("raw:1.-M")); + assertNotNull(Version.create("raw:1.m")); + assertNotNull(Version.create("raw:1.M")); + assertNotNull(Version.create("raw:1.-M")); } public void testStringParsing() { - Version v = Version.parseVersion("raw:'a'"); + Version v = Version.create("raw:'a'"); assertNotNull(v); assertEquals(v.getSegment(0), "a"); - assertNotNull(v = Version.parseVersion("raw:\"a\"")); + assertNotNull(v = Version.create("raw:\"a\"")); assertEquals(v.getSegment(0), "a"); - assertNotNull(v = Version.parseVersion("raw:'ab'")); + assertNotNull(v = Version.create("raw:'ab'")); assertEquals(v.getSegment(0), "ab"); - assertNotNull(v = Version.parseVersion("raw:'abcdefghijklmnopqrstuvwxyz0123456789'")); + assertNotNull(v = Version.create("raw:'abcdefghijklmnopqrstuvwxyz0123456789'")); assertEquals(v.getSegment(0), "abcdefghijklmnopqrstuvwxyz0123456789"); - assertNotNull(v = Version.parseVersion("raw:'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'")); + assertNotNull(v = Version.create("raw:'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'")); assertEquals(v.getSegment(0), "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); - assertNotNull(v = Version.parseVersion("raw:'-_!\"#$%&/()=?+*;,:.'")); + assertNotNull(v = Version.create("raw:'-_!\"#$%&/()=?+*;,:.'")); assertEquals(v.getSegment(0), "-_!\"#$%&/()=?+*;,:."); - assertNotNull(v = Version.parseVersion("raw:\"'\"")); + assertNotNull(v = Version.create("raw:\"'\"")); assertEquals(v.getSegment(0), "'"); - assertNotNull(v = Version.parseVersion("raw:'\"'")); + assertNotNull(v = Version.create("raw:'\"'")); assertEquals(v.getSegment(0), "\""); } public void testEmptyStringParsing() { - Version v = Version.parseVersion("raw:''"); + Version v = Version.create("raw:''"); assertNotNull(v); assertEquals(v.getSegment(0), ""); - v = Version.parseVersion("raw:\"\""); + v = Version.create("raw:\"\""); assertNotNull(v); assertEquals(v.getSegment(0), ""); } public void testStringConcatenation() { - Version v = Version.parseVersion("raw:'ab''cd'"); + Version v = Version.create("raw:'ab''cd'"); assertNotNull(v); assertEquals(v.getSegment(0), "abcd"); - v = Version.parseVersion("raw:'ab'\"cd\""); + v = Version.create("raw:'ab'\"cd\""); assertNotNull(v); assertEquals(v.getSegment(0), "abcd"); - v = Version.parseVersion("raw:\"ab\"\"cd\""); + v = Version.create("raw:\"ab\"\"cd\""); assertNotNull(v); assertEquals(v.getSegment(0), "abcd"); } public void testStringToString() { // string is normalized - assertEquals("raw:'abcd'", Version.parseVersion("raw:'ab''cd'").toString()); + assertEquals("raw:'abcd'", Version.create("raw:'ab''cd'").toString()); // string is normalized - assertEquals("raw:'abcd'", Version.parseVersion("raw:'ab'\"cd\"").toString()); + assertEquals("raw:'abcd'", Version.create("raw:'ab'\"cd\"").toString()); // string is normalized - assertEquals("raw:'abcd'", Version.parseVersion("raw:\"ab\"\"cd\"").toString()); + assertEquals("raw:'abcd'", Version.create("raw:\"ab\"\"cd\"").toString()); - assertEquals("raw:\"'\"", Version.parseVersion("raw:\"'\"").toString()); + assertEquals("raw:\"'\"", Version.create("raw:\"'\"").toString()); - assertEquals("raw:'\"'", Version.parseVersion("raw:'\"'").toString()); + assertEquals("raw:'\"'", Version.create("raw:'\"'").toString()); // quotes are normalized - default ' should be used until " is needed and vice versa. - assertEquals("raw:'abc\"xxx\"and '\"'yyy'\"", Version.parseVersion("raw:'abc\"xxx\"'\"and 'yyy'\"").toString()); + assertEquals("raw:'abc\"xxx\"and '\"'yyy'\"", Version.create("raw:'abc\"xxx\"'\"and 'yyy'\"").toString()); } public void testArrayParsing() { Version v = null; - assertNotNull(v = Version.parseVersion("raw:<1>")); - assertEquals(v.getSegment(0), Version.parseVersion("raw:1")); + assertNotNull(v = Version.create("raw:<1>")); + assertEquals(v.getSegment(0), new VersionVector(new Comparable[] {new Integer(1)}, null)); - assertNotNull(v = Version.parseVersion("raw:<1.0>")); - assertEquals(v.getSegment(0), Version.parseVersion("raw:1.0")); + assertNotNull(v = Version.create("raw:<1.0>")); + assertEquals(v.getSegment(0), new VersionVector(new Comparable[] {new Integer(1), new Integer(0)}, null)); - assertNotNull(v = Version.parseVersion("raw:<'a'>")); - assertEquals(v.getSegment(0), Version.parseVersion("raw:'a'")); + assertNotNull(v = Version.create("raw:<'a'>")); + assertEquals(v.getSegment(0), new VersionVector(new Comparable[] {"a"}, null)); - assertNotNull(v = Version.parseVersion("raw:<'a'.'b'>")); - assertEquals(v.getSegment(0), Version.parseVersion("raw:'a'.'b'")); + assertNotNull(v = Version.create("raw:<'a'.'b'>")); + assertEquals(v.getSegment(0), new VersionVector(new Comparable[] {"a", "b"}, null)); - assertNotNull(v = Version.parseVersion("raw:<'a'.'b''c'>")); - assertEquals(v.getSegment(0), Version.parseVersion("raw:'a'.'bc'")); // with concatenation + assertNotNull(v = Version.create("raw:<'a'.'b''c'>")); + assertEquals(v.getSegment(0), new VersionVector(new Comparable[] {"a", "bc"}, null)); - assertNotNull(v = Version.parseVersion("raw:<1.2.-M>")); - assertEquals(v.getSegment(0), Version.parseVersion("raw:1.2.-M")); + assertNotNull(v = Version.create("raw:<1.2.-M>")); + assertEquals(v.getSegment(0), new VersionVector(new Comparable[] {new Integer(1), new Integer(2)}, null)); - assertNotNull(v = Version.parseVersion("raw:<1.2.m>")); - assertEquals(v.getSegment(0), Version.parseVersion("raw:1.2.m")); + assertNotNull(v = Version.create("raw:<1.2.m>")); + assertEquals(v.getSegment(0), new VersionVector(new Comparable[] {new Integer(1), new Integer(2), VersionVector.MAXS_VALUE}, null)); - assertNotNull(v = Version.parseVersion("raw:<1.2.M>")); - assertEquals(v.getSegment(0), Version.parseVersion("raw:1.2.M")); + assertNotNull(v = Version.create("raw:<1.2.M>")); + assertEquals(v.getSegment(0), new VersionVector(new Comparable[] {new Integer(1), new Integer(2), VersionVector.MAX_VALUE}, null)); - assertNotNull(v = Version.parseVersion("raw:<<1>>")); - assertEquals(v.getSegment(0), Version.parseVersion("raw:<1>")); + assertNotNull(v = Version.create("raw:<<1>>")); + assertEquals(v.getSegment(0), new VersionVector(new Comparable[] {new VersionVector(new Comparable[] {new Integer(1)}, null)}, null)); - assertNotNull(v = Version.parseVersion("raw:<<1.<2>>>")); - assertEquals(v.getSegment(0), Version.parseVersion("raw:<1.<2>>")); + assertNotNull(v = Version.create("raw:<<1.<2>>>")); + assertEquals(v.getSegment(0), new VersionVector(new Comparable[] {new VersionVector(new Comparable[] {new Integer(1), new VersionVector(new Comparable[] {new Integer(2)}, null)}, null)}, null)); } public void testArraySerialize() { Version v = null; - assertNotNull(v = Version.parseVersion("raw:<1>")); + assertNotNull(v = Version.create("raw:<1>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:<1.0>")); + assertNotNull(v = Version.create("raw:<1.0>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:<'a'>")); + assertNotNull(v = Version.create("raw:<'a'>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:<'a'.'b'>")); + assertNotNull(v = Version.create("raw:<'a'.'b'>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:<'a'.'b''c'>")); + assertNotNull(v = Version.create("raw:<'a'.'b''c'>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:<1.2.-M>")); + assertNotNull(v = Version.create("raw:<1.2.-M>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:<1.2.m>")); + assertNotNull(v = Version.create("raw:<1.2.m>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:<1.2.M>")); + assertNotNull(v = Version.create("raw:<1.2.M>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:<<1>>")); + assertNotNull(v = Version.create("raw:<<1>>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:<<1.<2>>>")); + assertNotNull(v = Version.create("raw:<<1.<2>>>")); assertSerialized(v); } @@ -385,37 +386,37 @@ public class RawVersionTest extends VersionTesting { public void testArraytoString() { Version v = null; String s = null; - assertNotNull(v = Version.parseVersion(s = "raw:<1>")); + assertNotNull(v = Version.create(s = "raw:<1>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:<1.0>")); + assertNotNull(v = Version.create(s = "raw:<1.0>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:<'a'>")); + assertNotNull(v = Version.create(s = "raw:<'a'>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:<'a'.'b'>")); + assertNotNull(v = Version.create(s = "raw:<'a'.'b'>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:<'a'.'bc'>")); + assertNotNull(v = Version.create(s = "raw:<'a'.'bc'>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion("raw:<1.2.-M>")); + assertNotNull(v = Version.create("raw:<1.2.-M>")); s = "raw:<1.2>"; // is normalized assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:<1.2.m>")); + assertNotNull(v = Version.create(s = "raw:<1.2.m>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:<1.2.M>")); + assertNotNull(v = Version.create(s = "raw:<1.2.M>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:<<1>>")); + assertNotNull(v = Version.create(s = "raw:<<1>>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:<<1.<2>>>")); + assertNotNull(v = Version.create(s = "raw:<<1.<2>>>")); assertEquals(s, v.toString()); } public void testArrayOrder() { - Version v1 = Version.parseVersion("raw:<1.0.0>"); - Version v2 = Version.parseVersion("raw:<1.1.0>"); + Version v1 = Version.create("raw:<1.0.0>"); + Version v2 = Version.create("raw:<1.1.0>"); - Version v3 = Version.parseVersion("raw:<1.0.0>.<1.0.0>"); - Version v4 = Version.parseVersion("raw:<1.0.0>.<1.0.0>.'a'"); - Version v5 = Version.parseVersion("raw:<1.0.0>.<1.0.1>"); - Version v6 = Version.parseVersion("raw:<2.0.0>"); + Version v3 = Version.create("raw:<1.0.0>.<1.0.0>"); + Version v4 = Version.create("raw:<1.0.0>.<1.0.0>.'a'"); + Version v5 = Version.create("raw:<1.0.0>.<1.0.1>"); + Version v6 = Version.create("raw:<2.0.0>"); assertOrder(v1, v2); assertOrder(v3, v4); @@ -425,82 +426,82 @@ public class RawVersionTest extends VersionTesting { public void testPadParsing1() { Version v = null; - assertNotNull(v = Version.parseVersion("raw:1.0p0")); + assertNotNull(v = Version.create("raw:1.0p0")); assertPad(v, "raw:0"); - assertNotNull(v = Version.parseVersion("raw:1.0p'foo'")); + assertNotNull(v = Version.create("raw:1.0p'foo'")); assertPad(v, "raw:'foo'"); - assertNotNull(v = Version.parseVersion("raw:1.0p<0>")); + assertNotNull(v = Version.create("raw:1.0p<0>")); assertPad(v, "raw:<0>"); - assertNotNull(v = Version.parseVersion("raw:1.0p<'foo'>")); + assertNotNull(v = Version.create("raw:1.0p<'foo'>")); assertPad(v, "raw:<'foo'>"); - assertNotNull(v = Version.parseVersion("raw:1.0pm")); + assertNotNull(v = Version.create("raw:1.0pm")); assertPad(v, "raw:m"); - assertNotNull(v = Version.parseVersion("raw:1.0pM")); + assertNotNull(v = Version.create("raw:1.0pM")); assertPad(v, "raw:M"); - assertNotNull(v = Version.parseVersion("raw:1.0p-M")); + assertNotNull(v = Version.create("raw:1.0p-M")); assertEquals(v.getPad(), null); - assertNotNull(v = Version.parseVersion("raw:1.0p<m>")); + assertNotNull(v = Version.create("raw:1.0p<m>")); assertPad(v, "raw:<m>"); - assertNotNull(v = Version.parseVersion("raw:1.0p<M>")); + assertNotNull(v = Version.create("raw:1.0p<M>")); assertPad(v, "raw:<M>"); - assertNotNull(v = Version.parseVersion("raw:1.0p<-M>")); + assertNotNull(v = Version.create("raw:1.0p<-M>")); assertPad(v, "raw:<-M>"); - assertNotNull(v = Version.parseVersion("raw:1.0p<1.0.0.'r12345'.m>")); + assertNotNull(v = Version.create("raw:1.0p<1.0.0.'r12345'.m>")); assertPad(v, "raw:<1.0.0.'r12345'.m>"); } public void testPadSerialize() { Version v = null; - assertNotNull(v = Version.parseVersion("raw:1.0p0")); + assertNotNull(v = Version.create("raw:1.0p0")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p'foo'")); + assertNotNull(v = Version.create("raw:1.0p'foo'")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<0>")); + assertNotNull(v = Version.create("raw:1.0p<0>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<'foo'>")); + assertNotNull(v = Version.create("raw:1.0p<'foo'>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0pm")); + assertNotNull(v = Version.create("raw:1.0pm")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0pM")); + assertNotNull(v = Version.create("raw:1.0pM")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p-M")); + assertNotNull(v = Version.create("raw:1.0p-M")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<m>")); + assertNotNull(v = Version.create("raw:1.0p<m>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<M>")); + assertNotNull(v = Version.create("raw:1.0p<M>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<-M>")); + assertNotNull(v = Version.create("raw:1.0p<-M>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<1.0.0.'r12345'.m>")); + assertNotNull(v = Version.create("raw:1.0p<1.0.0.'r12345'.m>")); assertSerialized(v); } public void testPadtoString() { Version v = null; String s = null; - assertNotNull(v = Version.parseVersion("raw:1.0p0")); + assertNotNull(v = Version.create("raw:1.0p0")); s = "raw:1p0"; // normalized assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p'foo'")); + assertNotNull(v = Version.create(s = "raw:1.0p'foo'")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<0>")); + assertNotNull(v = Version.create(s = "raw:1.0p<0>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<'foo'>")); + assertNotNull(v = Version.create(s = "raw:1.0p<'foo'>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0pm")); + assertNotNull(v = Version.create(s = "raw:1.0pm")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0pM")); + assertNotNull(v = Version.create(s = "raw:1.0pM")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion("raw:1.0p-M")); + assertNotNull(v = Version.create("raw:1.0p-M")); s = "raw:1.0"; // normalized assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<m>")); + assertNotNull(v = Version.create(s = "raw:1.0p<m>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<M>")); + assertNotNull(v = Version.create(s = "raw:1.0p<M>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<-M>")); + assertNotNull(v = Version.create(s = "raw:1.0p<-M>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<1.0.0.'r12345'.m>")); + assertNotNull(v = Version.create(s = "raw:1.0p<1.0.0.'r12345'.m>")); assertEquals(s, v.toString()); } @@ -509,91 +510,92 @@ public class RawVersionTest extends VersionTesting { */ public void testNestedPadParsing() { Version v = null; - assertNotNull(v = Version.parseVersion("raw:1.0p<0p0>")); + assertNotNull(v = Version.create("raw:1.0p<0p0>")); assertPad(v, "raw:<0p0>"); - assertPad(v.getPad(), "raw:0"); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p'foo'>")); + assertPadPad(v, "raw:0"); + assertNotNull(v = Version.create("raw:1.0p<0p'foo'>")); assertPad(v, "raw:<0p'foo'>"); - assertPad(v.getPad(), "raw:'foo'"); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p<0>>")); + assertPadPad(v, "raw:'foo'"); + assertNotNull(v = Version.create("raw:1.0p<0p<0>>")); assertPad(v, "raw:<0p<0>>"); - assertPad(v.getPad(), "raw:<0>"); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p<'foo'>>")); + assertPadPad(v, "raw:<0>"); + assertNotNull(v = Version.create("raw:1.0p<0p<'foo'>>")); assertPad(v, "raw:<0p<'foo'>>"); - assertPad(v.getPad(), "raw:<'foo'>"); + assertPadPad(v, "raw:<'foo'>"); - assertNotNull(v = Version.parseVersion("raw:1.0p<0pm>")); + assertNotNull(v = Version.create("raw:1.0p<0pm>")); assertPad(v, "raw:<0pm>"); - assertPad(v.getPad(), "raw:m"); + assertPadPad(v, "raw:m"); - assertNotNull(v = Version.parseVersion("raw:1.0p<0pM>")); + assertNotNull(v = Version.create("raw:1.0p<0pM>")); assertPad(v, "raw:<0pM>"); - assertPad(v.getPad(), "raw:M"); + assertPadPad(v, "raw:M"); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p-M>")); + assertNotNull(v = Version.create("raw:1.0p<0p-M>")); assertPad(v, "raw:<0p-M>"); + assertPadPad(v, null); assertEquals(((VersionVector) v.getPad()).getPad(), null); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p<m>>")); + assertNotNull(v = Version.create("raw:1.0p<0p<m>>")); assertPad(v, "raw:<0p<m>>"); - assertPad(v.getPad(), "raw:<m>"); + assertPadPad(v, "raw:<m>"); - assertNotNull(v = Version.parseVersion("raw:1.0p<0pM>")); + assertNotNull(v = Version.create("raw:1.0p<0pM>")); assertPad(v, "raw:<0pM>"); - assertPad(v.getPad(), "raw:M"); + assertPadPad(v, "raw:M"); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p-M>")); + assertNotNull(v = Version.create("raw:1.0p<0p-M>")); assertPad(v, "raw:<0p-M>"); - assertEquals(((VersionVector) v.getPad()).getPad(), null); + assertPadPad(v, null); } public void testNestedPadSerialize() { Version v = null; - assertNotNull(v = Version.parseVersion("raw:1.0p<0p0>")); + assertNotNull(v = Version.create("raw:1.0p<0p0>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p'foo'>")); + assertNotNull(v = Version.create("raw:1.0p<0p'foo'>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p<0>>")); + assertNotNull(v = Version.create("raw:1.0p<0p<0>>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p<'foo'>>")); + assertNotNull(v = Version.create("raw:1.0p<0p<'foo'>>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<0pm>")); + assertNotNull(v = Version.create("raw:1.0p<0pm>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<0pM>")); + assertNotNull(v = Version.create("raw:1.0p<0pM>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p-M>")); + assertNotNull(v = Version.create("raw:1.0p<0p-M>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p<m>>")); + assertNotNull(v = Version.create("raw:1.0p<0p<m>>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<0pM>")); + assertNotNull(v = Version.create("raw:1.0p<0pM>")); assertSerialized(v); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p-M>")); + assertNotNull(v = Version.create("raw:1.0p<0p-M>")); assertSerialized(v); } public void testNestedPadtoString() { Version v = null; String s = null; - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<0p0>")); + assertNotNull(v = Version.create(s = "raw:1.0p<0p0>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<0p'foo'>")); + assertNotNull(v = Version.create(s = "raw:1.0p<0p'foo'>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<0p<0>>")); + assertNotNull(v = Version.create(s = "raw:1.0p<0p<0>>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<0p<'foo'>>")); + assertNotNull(v = Version.create(s = "raw:1.0p<0p<'foo'>>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<0pm>")); + assertNotNull(v = Version.create(s = "raw:1.0p<0pm>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<0pM>")); + assertNotNull(v = Version.create(s = "raw:1.0p<0pM>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p-M>")); + assertNotNull(v = Version.create("raw:1.0p<0p-M>")); s = "raw:1.0p<0>"; // normalized assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<0p<m>>")); + assertNotNull(v = Version.create(s = "raw:1.0p<0p<m>>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion(s = "raw:1.0p<0pM>")); + assertNotNull(v = Version.create(s = "raw:1.0p<0pM>")); assertEquals(s, v.toString()); - assertNotNull(v = Version.parseVersion("raw:1.0p<0p-M>")); + assertNotNull(v = Version.create("raw:1.0p<0p-M>")); s = "raw:1.0p<0>"; // normalized assertEquals(s, v.toString()); } @@ -603,15 +605,15 @@ public class RawVersionTest extends VersionTesting { * 1p-M < 1.0.0 < 1.0.0p0 == 1p0 < 1.1 < 1.1.1 < 1p1 == 1.1p1 < 1pM */ public void testPadOrder() { - Version v1 = Version.parseVersion("raw:1p-M"); - Version v2 = Version.parseVersion("raw:1.0.0"); - Version v3 = Version.parseVersion("raw:1.0.0p0"); - Version v4 = Version.parseVersion("raw:1p0"); - Version v5 = Version.parseVersion("raw:1.1"); - Version v6 = Version.parseVersion("raw:1.1.1"); - Version v7 = Version.parseVersion("raw:1p1"); - Version v8 = Version.parseVersion("raw:1.1p1"); - Version v9 = Version.parseVersion("raw:1pM"); + Version v1 = Version.create("raw:1p-M"); + Version v2 = Version.create("raw:1.0.0"); + Version v3 = Version.create("raw:1.0.0p0"); + Version v4 = Version.create("raw:1p0"); + Version v5 = Version.create("raw:1.1"); + Version v6 = Version.create("raw:1.1.1"); + Version v7 = Version.create("raw:1p1"); + Version v8 = Version.create("raw:1.1p1"); + Version v9 = Version.create("raw:1pM"); assertOrder(v1, v2); assertOrder(v2, v3); @@ -624,13 +626,13 @@ public class RawVersionTest extends VersionTesting { } public void testPadTypeOrder() { - Version v0 = Version.parseVersion("raw:1p-M"); - Version v1 = Version.parseVersion("raw:1p'a'"); - Version v2 = Version.parseVersion("raw:1p<0>"); - Version v3 = Version.parseVersion("raw:1.0.0"); - Version v4 = Version.parseVersion("raw:1p0"); - Version v5 = Version.parseVersion("raw:1p1"); - Version v6 = Version.parseVersion("raw:1pM"); + Version v0 = Version.create("raw:1p-M"); + Version v1 = Version.create("raw:1p'a'"); + Version v2 = Version.create("raw:1p<0>"); + Version v3 = Version.create("raw:1.0.0"); + Version v4 = Version.create("raw:1p0"); + Version v5 = Version.create("raw:1p1"); + Version v6 = Version.create("raw:1pM"); assertOrder(v0, v1); assertOrder(v1, v2); assertOrder(v2, v3); @@ -643,11 +645,11 @@ public class RawVersionTest extends VersionTesting { * Test that a / is not prematurely taken as the separator between raw and original when in a string */ public void testOriginalTerminator() { - Version v = Version.parseVersion("raw:'/'"); + Version v = Version.create("raw:'/'"); assertNotNull(v); assertEquals(v.getSegment(0), "/"); - v = Version.parseVersion("raw:\"/\""); + v = Version.create("raw:\"/\""); assertNotNull(v); assertEquals(v.getSegment(0), "/"); } @@ -655,7 +657,7 @@ public class RawVersionTest extends VersionTesting { public void testEmptyInput() { // should parse with exception try { - Version.parseVersion("raw:"); + Version.create("raw:"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -665,7 +667,7 @@ public class RawVersionTest extends VersionTesting { public void testNewLine() { // should parse with exception try { - Version.parseVersion("raw:1.'\n'.2"); + Version.create("raw:1.'\n'.2"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -675,7 +677,7 @@ public class RawVersionTest extends VersionTesting { public void testSpaceInInt() { // should parse with exception try { - Version.parseVersion("raw:1 2.2"); + Version.create("raw:1 2.2"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -685,7 +687,7 @@ public class RawVersionTest extends VersionTesting { public void testFloatingPointl() { // should parse with exception try { - Version.parseVersion("raw:1,2.2"); + Version.create("raw:1,2.2"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -695,7 +697,7 @@ public class RawVersionTest extends VersionTesting { public void testScientific() { // should parse with exception try { - Version.parseVersion("raw:1E3"); + Version.create("raw:1E3"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -705,7 +707,7 @@ public class RawVersionTest extends VersionTesting { public void testHex() { // should parse with exception try { - Version.parseVersion("raw:0xABCD"); + Version.create("raw:0xABCD"); fail("Uncaught error: hexadecimal not allowed"); } catch (IllegalArgumentException e) { assertTrue(true); @@ -714,7 +716,7 @@ public class RawVersionTest extends VersionTesting { public void testUnbalancedSingleQuoteRight() { try { - Version.parseVersion("raw:'unbalanced"); + Version.create("raw:'unbalanced"); fail("Uncaught error: unbalanced sngle quote"); } catch (IllegalArgumentException e) { assertTrue(true); @@ -723,7 +725,7 @@ public class RawVersionTest extends VersionTesting { public void testMixedQuotes1() { try { - Version.parseVersion("raw:1.\"unbalanced'.10"); + Version.create("raw:1.\"unbalanced'.10"); fail("Uncaught error: mixed quotes"); } catch (IllegalArgumentException e) { assertTrue(true); @@ -732,7 +734,7 @@ public class RawVersionTest extends VersionTesting { public void testMixedQuotes2() { try { - Version.parseVersion("raw:1.'unbalanced\".10"); + Version.create("raw:1.'unbalanced\".10"); fail("Uncaught error: mixed quotes"); } catch (IllegalArgumentException e) { assertTrue(true); @@ -741,7 +743,7 @@ public class RawVersionTest extends VersionTesting { public void testUnbalancedDoubleQuoteRight() { try { - Version.parseVersion("raw:\"unbalanced"); + Version.create("raw:\"unbalanced"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -750,7 +752,7 @@ public class RawVersionTest extends VersionTesting { public void testUnbalancedArrayRight() { try { - Version.parseVersion("raw:<1.2.3"); + Version.create("raw:<1.2.3"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -759,7 +761,7 @@ public class RawVersionTest extends VersionTesting { public void testUnbalancedArrayLeft() { try { - Version.parseVersion("raw:1.2.3>"); + Version.create("raw:1.2.3>"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -768,7 +770,7 @@ public class RawVersionTest extends VersionTesting { public void testBadDecimalInteger() { try { - Version.parseVersion("raw:12af"); + Version.create("raw:12af"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -777,7 +779,7 @@ public class RawVersionTest extends VersionTesting { public void testUnquotedStringFirstValue() { try { - Version.parseVersion("raw:a"); + Version.create("raw:a"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -786,7 +788,7 @@ public class RawVersionTest extends VersionTesting { public void testUnquotedStringSecondValue() { try { - Version.parseVersion("raw:1.a"); + Version.create("raw:1.a"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -795,7 +797,7 @@ public class RawVersionTest extends VersionTesting { public void testSinglePeriod() { try { - Version.parseVersion("raw:."); + Version.create("raw:."); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -804,7 +806,7 @@ public class RawVersionTest extends VersionTesting { public void testTwoPeriods() { try { - Version.parseVersion("raw:.."); + Version.create("raw:.."); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -813,7 +815,7 @@ public class RawVersionTest extends VersionTesting { public void testThreePeriods() { try { - Version.parseVersion("raw:..."); + Version.create("raw:..."); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -823,7 +825,7 @@ public class RawVersionTest extends VersionTesting { public void testPadNotLast() { try { - Version.parseVersion("raw:p10.10"); + Version.create("raw:p10.10"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -833,7 +835,7 @@ public class RawVersionTest extends VersionTesting { public void testEmptyPad() { try { - Version.parseVersion("raw:10p"); + Version.create("raw:10p"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -842,7 +844,7 @@ public class RawVersionTest extends VersionTesting { public void testPadWithNull() { try { - Version.parseVersion("raw:10p."); + Version.create("raw:10p."); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -851,7 +853,7 @@ public class RawVersionTest extends VersionTesting { public void testWrongPadSeparator() { try { - Version.parseVersion("raw:10.p0"); + Version.create("raw:10.p0"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -860,7 +862,7 @@ public class RawVersionTest extends VersionTesting { public void testMultiplePadElements() { try { - Version.parseVersion("raw:10p1.2"); + Version.create("raw:10p1.2"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -869,7 +871,7 @@ public class RawVersionTest extends VersionTesting { public void testUnbalancedPadElementsSQ() { try { - Version.parseVersion("raw:10p'abc"); + Version.create("raw:10p'abc"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -878,7 +880,7 @@ public class RawVersionTest extends VersionTesting { public void testUnbalancedPadElementsDQ() { try { - Version.parseVersion("raw:10p\"abc"); + Version.create("raw:10p\"abc"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -887,7 +889,7 @@ public class RawVersionTest extends VersionTesting { public void testUnbalancedPadArrayElementsRight() { try { - Version.parseVersion("raw:10p<10"); + Version.create("raw:10p<10"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -896,7 +898,7 @@ public class RawVersionTest extends VersionTesting { public void testUnbalancedPadArrayElementsLeft() { try { - Version.parseVersion("raw:10p10>"); + Version.create("raw:10p10>"); fail(); } catch (IllegalArgumentException e) { assertTrue(true); @@ -904,11 +906,11 @@ public class RawVersionTest extends VersionTesting { } public void testOrder() { - Version v1 = Version.parseVersion("raw:1"); - Version v2 = Version.parseVersion("raw:1.0"); - Version v3 = Version.parseVersion("raw:1.0.0"); - Version v4 = Version.parseVersion("raw:1.0.0.'9'"); - Version v5 = Version.parseVersion("raw:1.0.0.'r12345'"); + Version v1 = Version.create("raw:1"); + Version v2 = Version.create("raw:1.0"); + Version v3 = Version.create("raw:1.0.0"); + Version v4 = Version.create("raw:1.0.0.'9'"); + Version v5 = Version.create("raw:1.0.0.'r12345'"); assertOrder(v1, v2); assertOrder(v2, v3); @@ -918,14 +920,14 @@ public class RawVersionTest extends VersionTesting { public void testTypeOrder() { // '' < 'z' < m < [0} < [M] < 0 < M - Version v0 = Version.parseVersion("raw:-M"); - Version v1 = Version.parseVersion("raw:''"); - Version v2 = Version.parseVersion("raw:'z'"); - Version v3 = Version.parseVersion("raw:m"); - Version v4 = Version.parseVersion("raw:<0>"); - Version v5 = Version.parseVersion("raw:<M>"); - Version v6 = Version.parseVersion("raw:0"); - Version v7 = Version.parseVersion("raw:M"); + Version v0 = Version.create("raw:-M"); + Version v1 = Version.create("raw:''"); + Version v2 = Version.create("raw:'z'"); + Version v3 = Version.create("raw:m"); + Version v4 = Version.create("raw:<0>"); + Version v5 = Version.create("raw:<M>"); + Version v6 = Version.create("raw:0"); + Version v7 = Version.create("raw:M"); assertOrder(v0, v1); assertOrder(v1, v2); @@ -938,14 +940,14 @@ public class RawVersionTest extends VersionTesting { public void testTypeOrder2() { // '' < 'z' < m < [0] < [M] < 0 < M - Version v0 = Version.parseVersion("raw:0.-M"); - Version v1 = Version.parseVersion("raw:0.''"); - Version v2 = Version.parseVersion("raw:0.'z'"); - Version v3 = Version.parseVersion("raw:0.m"); - Version v4 = Version.parseVersion("raw:0.<0>"); - Version v5 = Version.parseVersion("raw:0.<M>"); - Version v6 = Version.parseVersion("raw:0.0"); - Version v7 = Version.parseVersion("raw:0.M"); + Version v0 = Version.create("raw:0.-M"); + Version v1 = Version.create("raw:0.''"); + Version v2 = Version.create("raw:0.'z'"); + Version v3 = Version.create("raw:0.m"); + Version v4 = Version.create("raw:0.<0>"); + Version v5 = Version.create("raw:0.<M>"); + Version v6 = Version.create("raw:0.0"); + Version v7 = Version.create("raw:0.M"); assertOrder(v0, v1); assertOrder(v1, v2); @@ -957,17 +959,17 @@ public class RawVersionTest extends VersionTesting { } public void testShorterIsOlder() { - Version v1 = Version.parseVersion("raw:1.0"); - Version v2 = Version.parseVersion("raw:1.0.0"); - Version v3 = Version.parseVersion("raw:1.0.0.0"); + Version v1 = Version.create("raw:1.0"); + Version v2 = Version.create("raw:1.0.0"); + Version v3 = Version.create("raw:1.0.0.0"); - Version v4 = Version.parseVersion("raw:'a'"); - Version v5 = Version.parseVersion("raw:'a'.'b'.'b'"); - Version v6 = Version.parseVersion("raw:'a'.'b'.'b'.'b'"); + Version v4 = Version.create("raw:'a'"); + Version v5 = Version.create("raw:'a'.'b'.'b'"); + Version v6 = Version.create("raw:'a'.'b'.'b'.'b'"); - Version v7 = Version.parseVersion("raw:<1>"); - Version v8 = Version.parseVersion("raw:<1>.<0>.<0>"); - Version v9 = Version.parseVersion("raw:<1>.<0>.<0>.<0>"); + Version v7 = Version.create("raw:<1>"); + Version v8 = Version.create("raw:<1>.<0>.<0>"); + Version v9 = Version.create("raw:<1>.<0>.<0>.<0>"); assertOrder(v1, v2); assertOrder(v2, v3); @@ -980,14 +982,14 @@ public class RawVersionTest extends VersionTesting { } public void testNumericVersionOrder() { - Version v1 = Version.parseVersion("1"); - Version v2 = Version.parseVersion("1.0.1"); - Version v3 = Version.parseVersion("1.1"); - Version v4 = Version.parseVersion("1.1.1"); - Version v5 = Version.parseVersion("1.1.1.-"); - Version v6 = Version.parseVersion("1.2"); - Version v7 = Version.parseVersion("2"); - Version v8 = Version.parseVersion("10.0"); + Version v1 = Version.create("1"); + Version v2 = Version.create("1.0.1"); + Version v3 = Version.create("1.1"); + Version v4 = Version.create("1.1.1"); + Version v5 = Version.create("1.1.1.-"); + Version v6 = Version.create("1.2"); + Version v7 = Version.create("2"); + Version v8 = Version.create("10.0"); assertOrder(v1, v2); assertOrder(v2, v3); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawWithOriginalTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawWithOriginalTest.java index 32617bac3..55af3b42d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawWithOriginalTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawWithOriginalTest.java @@ -11,7 +11,7 @@ package org.eclipse.equinox.p2.tests.omniVersion; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; /** * Tests inclusion of original version string in the raw format. @@ -33,7 +33,7 @@ public class RawWithOriginalTest extends VersionTesting { public void testRawWithUnknownFormatSerialized() { assertSerialized(Version.parseVersion("raw:1.0/:silver.moon")); - assertEquals("raw:1.0/:silver.moon", getSerialized(new Version("raw:1.0/:silver.moon")).toString()); + assertEquals("raw:1.0/:silver.moon", getSerialized(Version.create("raw:1.0/:silver.moon")).toString()); } @@ -49,7 +49,7 @@ public class RawWithOriginalTest extends VersionTesting { public void testRawWithSimpleFormatSerialized() { assertSerialized(Version.parseVersion("raw:1.0/format(n.n):1.0")); - assertEquals("raw:1.0/format(n.n):1.0", getSerialized(new Version("raw:1.0/format(n.n):1.0")).toString()); + assertEquals("raw:1.0/format(n.n):1.0", getSerialized(Version.create("raw:1.0/format(n.n):1.0")).toString()); } public void testOriginalStatedButMissing() { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/VersionTesting.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/VersionTesting.java index 2886f0c6f..79e76d090 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/VersionTesting.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/VersionTesting.java @@ -11,9 +11,12 @@ package org.eclipse.equinox.p2.tests.omniVersion; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; + import java.io.*; import junit.framework.TestCase; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.p2.metadata.VersionVector; /** * Base class for version testing. Adds useful assert methods. @@ -62,32 +65,31 @@ public class VersionTesting extends TestCase { assertTrue(true); } - // /** - // * Assert that pad of v is the same as the single element raw version string - // * @param v - // * @param rawVersionString - // */ - // public static void assertPad(VersionVector v, String rawVersionString) { - // assertNotNull(v); - // assertNotNull(rawVersionString); - // Version v2 = Version.parseVersion(rawVersionString); - // assertNotNull(v2); - // - // assertEquals(v.getPad(), v2); - // } - - /** - * Assert that pad of v is the same as the single element raw version string - * @param v - * @param rawVersionString - */ - public static void assertPad(Comparable v, String rawVersionString) { - assertTrue(v instanceof VersionVector); - assertNotNull(rawVersionString); - Version v2 = Version.parseVersion(rawVersionString); - assertNotNull(v2); + public static void assertPad(Version v, String rawVersionString) { + assertNotNull(v); + Comparable cmp = null; + if (rawVersionString != null) { + Version v2 = Version.create(rawVersionString); + assertNotNull(v2); + assertTrue(v2.getSegmentCount() == 1); + cmp = v2.getSegment(0); + } + assertEquals(v.getPad(), cmp); + } - assertEquals(((VersionVector) v).getPad(), v2.getSegment(0)); + public void assertPadPad(Version v, String rawVersionString) { + // TODO Auto-generated method stub + assertNotNull(v); + Comparable pad = v.getPad(); + assertTrue(pad instanceof VersionVector); + Comparable cmp = null; + if (rawVersionString != null) { + Version v2 = Version.create(rawVersionString); + assertNotNull(v2); + assertTrue(v2.getSegmentCount() == 1); + cmp = v2.getSegment(0); + } + assertEquals(((VersionVector) pad).getPad(), cmp); } /** diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/MetadataRepositoryPerformanceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/MetadataRepositoryPerformanceTest.java new file mode 100644 index 000000000..fcda75acc --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/MetadataRepositoryPerformanceTest.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.perf; + +import java.io.File; +import org.eclipse.core.tests.harness.PerformanceTestRunner; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQuery; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; + +/** + * Performance tests for metadata repositories + */ +public class MetadataRepositoryPerformanceTest extends ProvisioningPerformanceTest { + private static final int REPEATS = 5; + protected File repoLocation; + IMetadataRepository repository; + + protected void setUp() throws Exception { + super.setUp(); + String tempDir = System.getProperty("java.io.tmpdir"); + repoLocation = new File(tempDir, "MetadataRepositoryPerformanceTest"); + delete(repoLocation); + repoLocation.mkdir(); + IMetadataRepositoryManager manager = getMetadataRepositoryManager(); + repository = manager.createRepository(repoLocation.toURI(), "TestRepo", IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, null); + } + + protected void tearDown() throws Exception { + getMetadataRepositoryManager().removeRepository(repoLocation.toURI()); + delete(repoLocation); + super.tearDown(); + } + + public void testQueryLocalRepository() { + final int IU_COUNT = 3000; + new PerformanceTestRunner() { + IQuery[] queries = new IQuery[IU_COUNT]; + + protected void setUp() { + IInstallableUnit[] ius = new IInstallableUnit[IU_COUNT]; + for (int i = 0; i < ius.length; i++) { + ius[i] = generateIU(i); + queries[i] = new InstallableUnitQuery(ius[i].getId(), ius[i].getVersion()); + } + repository.addInstallableUnits(ius); + } + + protected void tearDown() { + } + + protected void test() { + for (int i = 0; i < queries.length; i++) { + repository.query(queries[i], null); + } + } + }.run(this, "Test query local metadata repo for " + IU_COUNT + " ius", REPEATS, 10); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/ProvisioningPerformanceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/ProvisioningPerformanceTest.java new file mode 100644 index 000000000..cec1ec4e8 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/ProvisioningPerformanceTest.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.perf; + +import org.eclipse.equinox.p2.metadata.Version; + +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +/** + * + */ +public class ProvisioningPerformanceTest extends AbstractProvisioningTest { + + protected IInstallableUnit generateIU(int i) { + MetadataFactory.InstallableUnitDescription desc = new MetadataFactory.InstallableUnitDescription(); + desc.setId("org.eclipse.someiu" + i); + desc.setVersion(Version.createOSGi(1, 1, i)); + return MetadataFactory.createInstallableUnit(desc); + } + +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/PublisherPerformanceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/PublisherPerformanceTest.java new file mode 100644 index 000000000..a1a1c5eac --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/PublisherPerformanceTest.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.perf; + +import org.eclipse.core.tests.harness.PerformanceTestRunner; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.publisher.IPublisherResult; +import org.eclipse.equinox.p2.publisher.PublisherResult; +import org.eclipse.equinox.p2.query.IQuery; + +/** + * Performance tests for the p2 publisher + */ +public class PublisherPerformanceTest extends ProvisioningPerformanceTest { + private static final int REPEATS = 5; + + public void testQueryPublisherResult() { + final int IU_COUNT = 3000; + new PerformanceTestRunner() { + IQuery[] queries = new IQuery[IU_COUNT]; + PublisherResult result; + + protected void setUp() { + IInstallableUnit[] ius = new IInstallableUnit[IU_COUNT]; + result = new PublisherResult(); + for (int i = 0; i < ius.length; i++) { + ius[i] = generateIU(i); + result.addIU(ius[i], IPublisherResult.ROOT); + queries[i] = new InstallableUnitQuery(ius[i].getId(), ius[i].getVersion()); + } + } + + protected void tearDown() { + } + + protected void test() { + for (int i = 0; i < queries.length; i++) { + result.query(queries[i], null); + } + } + }.run(this, "Test query PublisherResult for " + IU_COUNT + " ius", REPEATS, 10); + + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java new file mode 100644 index 000000000..40b53d3e0 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java @@ -0,0 +1,80 @@ +package org.eclipse.equinox.p2.tests.planner; + +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +public class AbsolutePlanTest extends AbstractProvisioningTest { + public void testAddAndRemoveIU() { + IProfile profile = createProfile(getName()); + ProfileChangeRequest pcr = new ProfileChangeRequest(profile); + pcr.setAbsoluteMode(true); + IInstallableUnit iuA = createEclipseIU("A"); + pcr.addInstallableUnits(new IInstallableUnit[] {iuA, createEclipseIU("B"), createEclipseIU("C")}); + IPlanner planner = createPlanner(); + IProvisioningPlan plan = planner.getProvisioningPlan(pcr, new ProvisioningContext(), null); + assertEquals(3, countPlanElements(plan)); + createEngine().perform(plan, null); + + ProfileChangeRequest removeRequest = new ProfileChangeRequest(profile); + removeRequest.setAbsoluteMode(true); + removeRequest.removeInstallableUnits(new IInstallableUnit[] {iuA}); + assertEquals(1, countPlanElements(planner.getProvisioningPlan(removeRequest, new ProvisioningContext(), null))); + } + + public void testAddAndRemoveProperty() { + IInstallableUnit iuA = createEclipseIU("A"); + IProfile profile = createProfile(getName()); + + ProfileChangeRequest pcr = new ProfileChangeRequest(profile); + pcr.setAbsoluteMode(true); + pcr.addInstallableUnits(new IInstallableUnit[] {iuA}); + pcr.setInstallableUnitProfileProperty(iuA, "key", "value"); + + IPlanner planner = createPlanner(); + IProvisioningPlan plan = planner.getProvisioningPlan(pcr, new ProvisioningContext(), null); + assertEquals(1, countPlanElements(plan)); + createEngine().perform(plan, null); + + Operand[] ops = plan.getOperands(); + boolean found = false; + for (int i = 0; i < ops.length; i++) { + if (ops[i] instanceof InstallableUnitPropertyOperand) + found = true; + } + assertTrue(found); + + ProfileChangeRequest removeRequest = new ProfileChangeRequest(profile); + removeRequest.setAbsoluteMode(true); + removeRequest.removeInstallableUnits(new IInstallableUnit[] {iuA}); + removeRequest.removeInstallableUnitProfileProperty(iuA, "key"); + + assertEquals(1, countPlanElements(planner.getProvisioningPlan(removeRequest, new ProvisioningContext(), null))); + } + + public void testAddProperty() { + IProfile profile = createProfile(getName()); + + ProfileChangeRequest pcr = new ProfileChangeRequest(profile); + pcr.setAbsoluteMode(true); + pcr.setProfileProperty("foo", "bar"); + + IPlanner planner = createPlanner(); + IProvisioningPlan plan = planner.getProvisioningPlan(pcr, new ProvisioningContext(), null); + createEngine().perform(plan, null); + + assertEquals("bar", getProfileRegistry().getProfile(getName()).getProperty("foo")); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest.java index f24ed4994..868c7de50 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest.java @@ -10,16 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Map; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +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.tests.AbstractProvisioningTest; public class ActualChangeRequestTest extends AbstractProvisioningTest { @@ -32,9 +33,9 @@ public class ActualChangeRequestTest extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}, NO_PROPERTIES, true); + a = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {(IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}, NO_PROPERTIES, true); - b = createIU("B", new Version("1.0.0"), true); + b = createIU("B", Version.create("1.0.0"), true); createTestMetdataRepository(new IInstallableUnit[] {a, b}); @@ -49,33 +50,33 @@ public class ActualChangeRequestTest extends AbstractProvisioningTest { req.addInstallableUnits(new IInstallableUnit[] {b}); req.setInstallableUnitInclusionRules(b, PlannerHelper.createStrictInclusionRule(b)); req.setInstallableUnitProfileProperty(b, "foo", "bar"); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getRequestStatus(b).getSeverity()); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); - engine.perform(profile1, new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); assertProfileContainsAll("B is missing", profile1, new IInstallableUnit[] {b}); - assertEquals(1, profile1.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null))); //Install A ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {a}); req2.setInstallableUnitInclusionRules(a, PlannerHelper.createStrictInclusionRule(a)); req2.setInstallableUnitProfileProperty(a, "foo", "bar"); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); assertNull(plan2.getRequestStatus(b)); Map m = plan2.getSideEffectChanges(); m.toString(); assertEquals(IStatus.OK, plan2.getRequestStatus(a).getSeverity()); - engine.perform(profile1, new DefaultPhaseSet(), plan2.getOperands(), null, null); + engine.perform(plan2, null); assertProfileContainsAll("A is missing", profile1, new IInstallableUnit[] {a, b}); - assertEquals(2, profile1.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(2, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null))); //Uninstall B ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.removeInstallableUnits(new IInstallableUnit[] {b}); req3.removeInstallableUnitProfileProperty(b, "foo"); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.OK, plan3.getStatus().getSeverity()); assertEquals(IStatus.ERROR, plan3.getRequestStatus(b).getSeverity()); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest2.java index c5b62d116..a74fa8f02 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest2.java @@ -10,16 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Map; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +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.tests.AbstractProvisioningTest; public class ActualChangeRequestTest2 extends AbstractProvisioningTest { @@ -33,10 +34,10 @@ public class ActualChangeRequestTest2 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}, NO_PROPERTIES, true); + a = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {(IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}, NO_PROPERTIES, true); - b = createIU("B", new Version("1.0.0"), true); - b2 = createIU("B", new Version("2.0.0"), true); + b = createIU("B", Version.create("1.0.0"), true); + b2 = createIU("B", Version.create("2.0.0"), true); createTestMetdataRepository(new IInstallableUnit[] {a, b2, b}); @@ -53,19 +54,19 @@ public class ActualChangeRequestTest2 extends AbstractProvisioningTest { req.addInstallableUnits(new IInstallableUnit[] {a}); req.setInstallableUnitInclusionRules(a, PlannerHelper.createOptionalInclusionRule(a)); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getRequestStatus(b).getSeverity()); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); - engine.perform(profile1, new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); assertProfileContainsAll("B is missing", profile1, new IInstallableUnit[] {a, b}); - assertEquals(2, profile1.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(2, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null))); //Install B2 ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {b2}); req2.setInstallableUnitInclusionRules(b2, PlannerHelper.createStrictInclusionRule(b2)); req2.removeInstallableUnits(new IInstallableUnit[] {b}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); assertNotNull(plan2.getRequestStatus(b)); assertNotNull(plan2.getRequestStatus(b2)); @@ -74,26 +75,26 @@ public class ActualChangeRequestTest2 extends AbstractProvisioningTest { assertNotNull(m.get(a)); assertEquals(IStatus.INFO, ((RequestStatus) m.get(a)).getSeverity()); assertEquals(RequestStatus.REMOVED, ((RequestStatus) m.get(a)).getInitialRequestType()); - engine.perform(profile1, new DefaultPhaseSet(), plan2.getOperands(), null, null); + engine.perform(plan2, null); assertProfileContainsAll("A is missing", profile1, new IInstallableUnit[] {b2}); - assertEquals(1, profile1.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null))); //Try to Install A ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {a}); req3.setInstallableUnitInclusionRules(a, PlannerHelper.createOptionalInclusionRule(a)); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertNotNull(plan3.getRequestStatus(a)); assertEquals(IStatus.ERROR, plan3.getRequestStatus(a).getSeverity()); - assertEquals(RequestStatus.ADDED, plan3.getRequestStatus(a).getInitialRequestType()); + assertEquals(RequestStatus.ADDED, ((RequestStatus) plan3.getRequestStatus(a)).getInitialRequestType()); //Try to Install A ProfileChangeRequest req4 = new ProfileChangeRequest(profile1); req4.addInstallableUnits(new IInstallableUnit[] {a}); req4.setInstallableUnitInclusionRules(a, PlannerHelper.createStrictInclusionRule(a)); - ProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null); + IProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null); assertNotNull(plan4.getRequestStatus(a)); assertEquals(IStatus.ERROR, plan4.getRequestStatus(a).getSeverity()); - assertEquals(RequestStatus.ADDED, plan4.getRequestStatus(a).getInitialRequestType()); + assertEquals(RequestStatus.ADDED, ((RequestStatus) plan4.getRequestStatus(a)).getInitialRequestType()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AddIUProperty.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AddIUProperty.java index 1575d9049..d0cc00e13 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AddIUProperty.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AddIUProperty.java @@ -8,15 +8,16 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.director.SimplePlanner; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -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.p2.engine.*; +import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery; +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.tests.AbstractProvisioningTest; public class AddIUProperty extends AbstractProvisioningTest { @@ -28,9 +29,9 @@ public class AddIUProperty extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); - a2 = createIU("A", new Version("2.0.0"), true); + a2 = createIU("A", Version.create("2.0.0"), true); createTestMetdataRepository(new IInstallableUnit[] {a1, a2}); @@ -42,7 +43,7 @@ public class AddIUProperty extends AbstractProvisioningTest { public void testWithoutIUProperty() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); } @@ -51,7 +52,7 @@ public class AddIUProperty extends AbstractProvisioningTest { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); req.setInstallableUnitInclusionRules(a1, PlannerHelper.createOptionalInclusionRule(a1)); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); } @@ -60,43 +61,44 @@ public class AddIUProperty extends AbstractProvisioningTest { //Add a1, strictly ; ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); - engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); assertProfileContainsAll("A1 is missing", profile, new IInstallableUnit[] {a1}); - Collector allProfileIUs = profile.query(InstallableUnitQuery.ANY, new Collector(), null); - assertEquals(allProfileIUs.size(), 1); + IQueryResult allProfileIUs = profile.query(InstallableUnitQuery.ANY, null); + assertEquals(queryResultSize(allProfileIUs), 1); //Add a2 with a1. This is an error ProfileChangeRequest req4 = ProfileChangeRequest.createByProfileId(profile.getProfileId()); req4.addInstallableUnits(new IInstallableUnit[] {a2}); - ProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null); + IProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null); assertEquals(IStatus.ERROR, plan4.getStatus().getSeverity()); //Add a2, making a1 optional; ProfileChangeRequest req2 = ProfileChangeRequest.createByProfileId(profile.getProfileId()); req2.setInstallableUnitInclusionRules(a1, PlannerHelper.createOptionalInclusionRule(a1)); req2.addInstallableUnits(new IInstallableUnit[] {a2}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan2, a2); - engine.perform(profile, new DefaultPhaseSet(), plan2.getOperands(), null, null); + engine.perform(plan2, null); + profile = getProfile(profile.getProfileId()); assertProfileContainsAll("A2 is missing", profile, new IInstallableUnit[] {a2}); - allProfileIUs = profile.query(InstallableUnitQuery.ANY, new Collector(), null); - assertEquals(allProfileIUs.size(), 1); + allProfileIUs = profile.query(InstallableUnitQuery.ANY, null); + assertEquals(queryResultSize(allProfileIUs), 1); - Collector iuProfileProperties = profile.query(new IUProfilePropertyQuery(SimplePlanner.INCLUSION_RULES, null), new Collector(), null); - assertEquals(iuProfileProperties.size(), 1); + IQueryResult iuProfileProperties = profile.query(new IUProfilePropertyQuery(SimplePlanner.INCLUSION_RULES, null), null); + assertEquals(queryResultSize(iuProfileProperties), 1); //Remove a1 optionality - should be a no-op ProfileChangeRequest req3 = ProfileChangeRequest.createByProfileId(profile.getProfileId()); req3.removeInstallableUnitInclusionRules(a1); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); - engine.perform(profile, new DefaultPhaseSet(), plan3.getOperands(), null, null); - allProfileIUs = profile.query(InstallableUnitQuery.ANY, new Collector(), null); + engine.perform(plan3, null); + allProfileIUs = profile.query(InstallableUnitQuery.ANY, null); assertProfileContainsAll("A2 is missing", profile, new IInstallableUnit[] {a2}); - assertEquals(allProfileIUs.size(), 1); + assertEquals(queryResultSize(allProfileIUs), 1); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java index 92ae7647c..848b6bc8d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java @@ -10,15 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Arrays; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IRequirement; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class AdditionalConstraints extends AbstractProvisioningTest { @@ -33,15 +34,15 @@ public class AdditionalConstraints extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 4.0.0)"), null)); + a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 4.0.0)"))); - b1 = createIU("B", new Version("1.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); - b2 = createIU("B", new Version("2.0.0"), true); + b2 = createIU("B", Version.create("2.0.0"), true); - b3 = createIU("B", new Version("3.0.0"), true); + b3 = createIU("B", Version.create("3.0.0"), true); - x1 = createIU("X", new Version(2, 0, 0), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0, 2.0.0]"), null)); + x1 = createIU("X", Version.createOSGi(2, 0, 0), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0, 2.0.0]"))); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, b3, x1}); @@ -54,8 +55,8 @@ public class AdditionalConstraints extends AbstractProvisioningTest { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); ProvisioningContext ctx = new ProvisioningContext(); - ctx.setAdditionalRequirements(Arrays.asList(createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0, 2.0.0]"), null)[0])); - ProvisioningPlan plan = planner.getProvisioningPlan(req, ctx, null); + ctx.setAdditionalRequirements(Arrays.<IRequirement> asList(createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0, 2.0.0]"))[0])); + IProvisioningPlan plan = planner.getProvisioningPlan(req, ctx, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); assertInstallOperand(plan, b2); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java index 4d2337c84..bc8a9681c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java @@ -8,30 +8,25 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - import java.lang.reflect.Field; import java.net.URI; import java.util.Properties; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestActivator; public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { - Object previousSelfValue; - public void setUp() throws Exception { super.setUp(); - SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) getProfileRegistry(); try { Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$ selfField.setAccessible(true); @@ -44,11 +39,11 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { createProfile("agent"); Properties p = new Properties(); p.setProperty("org.eclipse.equinox.p2.planner.resolveMetaRequirements", "false"); - createProfile("installation", null, p); + createProfile("installation", p); } public void tearDown() throws Exception { - SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) getProfileRegistry(); try { Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$ selfField.setAccessible(true); @@ -63,7 +58,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { } public void testGetAgentPlanActionNeededButUnavailable() { - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); IProfile profile = getProfile("installation"); @@ -73,7 +68,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { request.addInstallableUnits(new IInstallableUnit[] {a}); ProvisioningContext context = new ProvisioningContext(new URI[0]); - ProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor()); assertNotOK(plan.getStatus()); } @@ -81,7 +76,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); createTestMetdataRepository(new IInstallableUnit[] {a, act1}); @@ -91,7 +86,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertTrue(plan.getStatus().isOK()); assertNotNull(plan.getInstallerPlan()); } @@ -100,10 +95,10 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { //This tests the case where the action is in conflict with the thing being installed //The action needs another version of A which is singleton IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); - IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]"), null), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]")), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); - IInstallableUnit a2 = createIU("A", new Version(2, 0, 0)); + IInstallableUnit a2 = createIU("A", Version.createOSGi(2, 0, 0)); createTestMetdataRepository(new IInstallableUnit[] {a, a2, act1}); @@ -113,7 +108,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertOK("Provisioning plan", plan.getStatus()); } @@ -121,7 +116,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); IInstallableUnit b = createEclipseIU("B"); @@ -133,19 +128,19 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { ProfileChangeRequest request = new ProfileChangeRequest(getProfile("installation")); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); //Check that the actions are installed properly - assertOK("install actions", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan.getInstallerPlan().getOperands(), null, null)); + assertOK("install actions", engine.perform(plan.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1}); //Check that the IUs are installed in the profile - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan.getOperands(), null, null)); + assertOK("install A", engine.perform(plan, null)); assertProfileContainsAll("Checking profile after initial install", getProfile("installation"), new IInstallableUnit[] {a}); ProfileChangeRequest request2 = new ProfileChangeRequest(getProfile("installation")); request2.addInstallableUnits(new IInstallableUnit[] {b}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); + IProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); assertNull(plan2.getInstallerPlan()); - assertOK("install b", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan2.getOperands(), null, null)); + assertOK("install b", engine.perform(plan2, null)); assertProfileContainsAll("Checking profile after initial install", getProfile("installation"), new IInstallableUnit[] {a, b}); assertProfileContainsAll("Checking actions are still installed", getProfile("agent"), new IInstallableUnit[] {act1}); } @@ -153,10 +148,10 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { public void testWithOveralInDependency() { IInstallableUnit common = createEclipseIU("Common"); IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); - IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common", null), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); + IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common"), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); - IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common", null), metaReq); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); + IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common"), metaReq); createTestMetdataRepository(new IInstallableUnit[] {a, act1, common}); @@ -167,10 +162,10 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); - assertOK("install actions", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + assertOK("install actions", engine.perform(plan.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1, common}); - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan.getOperands(), null, null)); + assertOK("install A", engine.perform(plan, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {a, common}); } @@ -178,13 +173,13 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); IProvidedCapability act2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", DEFAULT_VERSION); IInstallableUnit act2 = createIU("Action2", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit b = createIUWithMetaRequirement("B", DEFAULT_VERSION, true, NO_REQUIRES, metaReq2); createTestMetdataRepository(new IInstallableUnit[] {a, b, act1, act2,}); @@ -196,19 +191,19 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { //install A which will install Action1 ProfileChangeRequest request = new ProfileChangeRequest(getProfile("installation")); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); - assertOK("install actions", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + assertOK("install actions", engine.perform(plan.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1}); - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan.getOperands(), null, null)); + assertOK("install A", engine.perform(plan, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {a}); //install B which will install Action2 ProfileChangeRequest request2 = new ProfileChangeRequest(getProfile("installation")); request2.addInstallableUnits(new IInstallableUnit[] {b}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); - assertOK("install actions", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan2.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); + assertOK("install actions", engine.perform(plan2.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act2, act1}); - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan2.getOperands(), null, null)); + assertOK("install A", engine.perform(plan2, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {b, a}); } @@ -216,25 +211,25 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); IProvidedCapability act1bCap = MetadataFactory.createProvidedCapability("p2.action", "action1b", DEFAULT_VERSION); IInstallableUnit act1b = createIU("Action1b", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1bCap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReqb = createRequiredCapabilities("p2.action", "action1b", new VersionRange("[0.0.0, 1.0.0]"), null); - IInstallableUnit a111 = createIUWithMetaRequirement("A", new Version(1, 1, 1), true, NO_REQUIRES, metaReqb); + IRequiredCapability[] metaReqb = createRequiredCapabilities("p2.action", "action1b", new VersionRange("[0.0.0, 1.0.0]")); + IInstallableUnit a111 = createIUWithMetaRequirement("A", Version.createOSGi(1, 1, 1), true, NO_REQUIRES, metaReqb); IProvidedCapability act2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", DEFAULT_VERSION); IInstallableUnit act2 = createIU("Action2", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", new Version(2, 0, 0)); - IInstallableUnit act1v2 = createIU("Action1", new Version("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); + IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", Version.createOSGi(2, 0, 0)); + IInstallableUnit act1v2 = createIU("Action1", Version.create("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"), null); + IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]")); IInstallableUnit d = createIUWithMetaRequirement("D", DEFAULT_VERSION, true, NO_REQUIRES, metaReqd); - IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit b = createIUWithMetaRequirement("B", DEFAULT_VERSION, true, NO_REQUIRES, metaReq2); IInstallableUnit c = createEclipseIU("C"); @@ -247,27 +242,27 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { //install A which will install Action1 ProfileChangeRequest request = new ProfileChangeRequest(getProfile("installation")); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); - assertOK("install actions for A", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + assertOK("install actions for A", engine.perform(plan.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1}); - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan.getOperands(), null, null)); + assertOK("install A", engine.perform(plan, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {a}); //install B which will install Action2 ProfileChangeRequest request2 = new ProfileChangeRequest(getProfile("installation")); request2.addInstallableUnits(new IInstallableUnit[] {b}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); - assertOK("install actions for B", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan2.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); + assertOK("install actions for B", engine.perform(plan2.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act2}); - assertOK("install B", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan2.getOperands(), null, null)); + assertOK("install B", engine.perform(plan2, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {b, a}); //install C ProfileChangeRequest requestForC = new ProfileChangeRequest(getProfile("installation")); requestForC.addInstallableUnits(new IInstallableUnit[] {c}); - ProvisioningPlan planForC = planner.getProvisioningPlan(requestForC, ctx, new NullProgressMonitor()); + IProvisioningPlan planForC = planner.getProvisioningPlan(requestForC, ctx, new NullProgressMonitor()); assertNull(planForC.getInstallerPlan()); - assertOK("install C", engine.perform(getProfile("installation"), new DefaultPhaseSet(), planForC.getOperands(), null, null)); + assertOK("install C", engine.perform(planForC, null)); assertProfileContainsAll("Checking profile after C", getProfile("installation"), new IInstallableUnit[] {a, b, c}); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act2, act1}); @@ -275,42 +270,41 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { ProfileChangeRequest requestUpdateA = new ProfileChangeRequest(getProfile("installation")); requestUpdateA.removeInstallableUnits(new IInstallableUnit[] {a}); requestUpdateA.addInstallableUnits(new IInstallableUnit[] {a111}); - ProvisioningPlan planUpdateA = planner.getProvisioningPlan(requestUpdateA, ctx, new NullProgressMonitor()); - assertOK("install actions for A 1.1.1", engine.perform(getProfile("agent"), new DefaultPhaseSet(), planUpdateA.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan planUpdateA = planner.getProvisioningPlan(requestUpdateA, ctx, new NullProgressMonitor()); + assertOK("install actions for A 1.1.1", engine.perform(planUpdateA.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1, act1b, act2}); - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), planUpdateA.getOperands(), null, null)); + assertOK("install A", engine.perform(planUpdateA, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {a111, b, c}); - assertEquals(0, getProfile("installation").query(new InstallableUnitQuery("Action1", DEFAULT_VERSION), new Collector(), null).size()); - assertEquals(requestUpdateA, planUpdateA.getProfileChangeRequest()); - assertEquals(getProfile("agent").getProfileId(), plan.getInstallerPlan().getProfileChangeRequest().getProfile().getProfileId()); + assertTrue(getProfile("installation").query(new InstallableUnitQuery("Action1", DEFAULT_VERSION), null).isEmpty()); + assertEquals(getProfile("agent").getProfileId(), plan.getInstallerPlan().getProfile().getProfileId()); //uninstall A ProfileChangeRequest request3 = new ProfileChangeRequest(getProfile("installation")); request3.removeInstallableUnits(new IInstallableUnit[] {a111}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(request3, ctx, new NullProgressMonitor()); + IProvisioningPlan plan3 = planner.getProvisioningPlan(request3, ctx, new NullProgressMonitor()); // assertOK("install actions", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan3.getInstallerPlan().getOperands(), null, null)); // assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1b}); //At this point there is not - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan3.getOperands(), null, null)); + assertOK("install A", engine.perform(plan3, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {c, b}); //uninstall C ProfileChangeRequest request4 = new ProfileChangeRequest(getProfile("installation")); request4.removeInstallableUnits(new IInstallableUnit[] {c}); - ProvisioningPlan uninstallC = planner.getProvisioningPlan(request4, ctx, new NullProgressMonitor()); + IProvisioningPlan uninstallC = planner.getProvisioningPlan(request4, ctx, new NullProgressMonitor()); assertNull(uninstallC.getInstallerPlan()); - assertOK("install C", engine.perform(getProfile("installation"), new DefaultPhaseSet(), uninstallC.getOperands(), null, null)); + assertOK("install C", engine.perform(uninstallC, null)); assertProfileContainsAll("Checking profile after C", getProfile("installation"), new IInstallableUnit[] {b}); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act2, act1b}); //install D, This will cause the removal of act1 and cause the addition of act1v2 from the installer ProfileChangeRequest requestForD = new ProfileChangeRequest(getProfile("installation")); requestForD.addInstallableUnits(new IInstallableUnit[] {d}); - ProvisioningPlan planForD = planner.getProvisioningPlan(requestForD, ctx, new NullProgressMonitor()); + IProvisioningPlan planForD = planner.getProvisioningPlan(requestForD, ctx, new NullProgressMonitor()); assertNotNull(planForD.getInstallerPlan()); - assertEquals(1, planForD.getInstallerPlan().getRemovals().query(new InstallableUnitQuery(act1b.getId()), new Collector(), null).size()); - assertOK("install actions", engine.perform(getProfile("agent"), new DefaultPhaseSet(), planForD.getInstallerPlan().getOperands(), null, null)); + assertEquals(1, queryResultSize(planForD.getInstallerPlan().getRemovals().query(new InstallableUnitQuery(act1b.getId()), null))); + assertOK("install actions", engine.perform(planForD.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1v2}); - assertOK("install D", engine.perform(getProfile("installation"), new DefaultPhaseSet(), planForD.getOperands(), null, null)); + assertOK("install D", engine.perform(planForD, null)); assertProfileContainsAll("Checking profile after D", getProfile("installation"), new IInstallableUnit[] {b, d}); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act2, act1v2}); } @@ -319,13 +313,13 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); - IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", new Version(2, 0, 0)); - IInstallableUnit act1v2 = createIU("Action1", new Version("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); + IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", Version.createOSGi(2, 0, 0)); + IInstallableUnit act1v2 = createIU("Action1", Version.create("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"), null); + IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]")); IInstallableUnit d = createIUWithMetaRequirement("D", DEFAULT_VERSION, true, NO_REQUIRES, metaReqd); createTestMetdataRepository(new IInstallableUnit[] {a, act1, d, act1v2}); @@ -336,9 +330,8 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest { ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a, d}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertNotOK(plan.getStatus()); - assertEquals(request, plan.getProfileChangeRequest()); - assertEquals(getProfile("agent").getProfileId(), plan.getInstallerPlan().getProfileChangeRequest().getProfile().getProfileId()); + assertEquals(getProfile("agent").getProfileId(), plan.getInstallerPlan().getProfile().getProfileId()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java index cefff2e34..0b100dc04 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java @@ -8,30 +8,25 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - import java.lang.reflect.Field; import java.net.URI; import java.util.Properties; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestActivator; public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProvisioningTest { - Object previousSelfValue = null; - public void setUp() throws Exception { super.setUp(); - SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) getProfileRegistry(); try { Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$ selfField.setAccessible(true); @@ -44,11 +39,11 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv createProfile("agent"); Properties p = new Properties(); p.setProperty("org.eclipse.equinox.p2.planner.resolveMetaRequirements", "true"); - createProfile("installation", null, p); + createProfile("installation", p); } public void tearDown() throws Exception { - SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) getProfileRegistry(); try { Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$ selfField.setAccessible(true); @@ -63,7 +58,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv } public void testGetAgentPlanActionNeededButUnavailable() { - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); IProfile profile = getProfile("installation"); @@ -73,7 +68,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv request.addInstallableUnits(new IInstallableUnit[] {a}); ProvisioningContext context = new ProvisioningContext(new URI[0]); - ProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor()); assertNotOK(plan.getStatus()); } @@ -81,7 +76,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); createTestMetdataRepository(new IInstallableUnit[] {a, act1}); @@ -91,7 +86,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertTrue(plan.getStatus().isOK()); assertNotNull(plan.getInstallerPlan()); } @@ -100,10 +95,10 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv //This tests the case where the action is in conflict with the thing being installed //The action needs another version of A which is singleton IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); - IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]"), null), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]")), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); - IInstallableUnit a2 = createIU("A", new Version(2, 0, 0)); + IInstallableUnit a2 = createIU("A", Version.createOSGi(2, 0, 0)); createTestMetdataRepository(new IInstallableUnit[] {a, a2, act1}); @@ -113,7 +108,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertNotOK(plan.getStatus()); } @@ -121,7 +116,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); IInstallableUnit b = createEclipseIU("B"); @@ -133,19 +128,19 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv ProfileChangeRequest request = new ProfileChangeRequest(getProfile("installation")); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); //Check that the actions are installed properly - assertOK("install actions", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan.getInstallerPlan().getOperands(), null, null)); + assertOK("install actions", engine.perform(plan.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1}); //Check that the IUs are installed in the profile - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan.getOperands(), null, null)); + assertOK("install A", engine.perform(plan, null)); assertProfileContainsAll("Checking profile after initial install", getProfile("installation"), new IInstallableUnit[] {a, act1}); ProfileChangeRequest request2 = new ProfileChangeRequest(getProfile("installation")); request2.addInstallableUnits(new IInstallableUnit[] {b}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); + IProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); assertNull(plan2.getInstallerPlan()); - assertOK("install b", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan2.getOperands(), null, null)); + assertOK("install b", engine.perform(plan2, null)); assertProfileContainsAll("Checking profile after initial install", getProfile("installation"), new IInstallableUnit[] {a, b, act1}); assertProfileContainsAll("Checking actions are still installed", getProfile("agent"), new IInstallableUnit[] {act1}); } @@ -153,10 +148,10 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv public void testWithOveralInDependency() { IInstallableUnit common = createEclipseIU("Common"); IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); - IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common", null), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); + IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common"), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); - IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common", null), metaReq); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); + IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common"), metaReq); createTestMetdataRepository(new IInstallableUnit[] {a, act1, common}); @@ -167,10 +162,10 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); - assertOK("install actions", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + assertOK("install actions", engine.perform(plan.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1, common}); - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan.getOperands(), null, null)); + assertOK("install A", engine.perform(plan, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {a, common, act1}); } @@ -178,13 +173,13 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); IProvidedCapability act2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", DEFAULT_VERSION); IInstallableUnit act2 = createIU("Action2", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit b = createIUWithMetaRequirement("B", DEFAULT_VERSION, true, NO_REQUIRES, metaReq2); createTestMetdataRepository(new IInstallableUnit[] {a, b, act1, act2,}); @@ -196,19 +191,19 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv //install A which will install Action1 ProfileChangeRequest request = new ProfileChangeRequest(getProfile("installation")); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); - assertOK("install actions", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + assertOK("install actions", engine.perform(plan.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1}); - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan.getOperands(), null, null)); + assertOK("install A", engine.perform(plan, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {a, act1}); //install B which will install Action2 ProfileChangeRequest request2 = new ProfileChangeRequest(getProfile("installation")); request2.addInstallableUnits(new IInstallableUnit[] {b}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); - assertOK("install actions", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan2.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); + assertOK("install actions", engine.perform(plan2.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act2, act1}); - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan2.getOperands(), null, null)); + assertOK("install A", engine.perform(plan2, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {b, a, act1, act2}); } @@ -216,25 +211,25 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); IProvidedCapability act1bCap = MetadataFactory.createProvidedCapability("p2.action", "action1b", DEFAULT_VERSION); IInstallableUnit act1b = createIU("Action1b", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1bCap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReqb = createRequiredCapabilities("p2.action", "action1b", new VersionRange("[0.0.0, 1.0.0]"), null); - IInstallableUnit a111 = createIUWithMetaRequirement("A", new Version(1, 1, 1), true, NO_REQUIRES, metaReqb); + IRequiredCapability[] metaReqb = createRequiredCapabilities("p2.action", "action1b", new VersionRange("[0.0.0, 1.0.0]")); + IInstallableUnit a111 = createIUWithMetaRequirement("A", Version.createOSGi(1, 1, 1), true, NO_REQUIRES, metaReqb); IProvidedCapability act2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", DEFAULT_VERSION); IInstallableUnit act2 = createIU("Action2", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", new Version(2, 0, 0)); - IInstallableUnit act1v2 = createIU("Action1", new Version("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); + IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", Version.createOSGi(2, 0, 0)); + IInstallableUnit act1v2 = createIU("Action1", Version.create("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"), null); + IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]")); IInstallableUnit d = createIUWithMetaRequirement("D", DEFAULT_VERSION, true, NO_REQUIRES, metaReqd); - IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit b = createIUWithMetaRequirement("B", DEFAULT_VERSION, true, NO_REQUIRES, metaReq2); IInstallableUnit c = createEclipseIU("C"); @@ -247,27 +242,27 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv //install A which will install Action1 ProfileChangeRequest request = new ProfileChangeRequest(getProfile("installation")); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); - assertOK("install actions for A", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + assertOK("install actions for A", engine.perform(plan.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1}); - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan.getOperands(), null, null)); + assertOK("install A", engine.perform(plan, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {a, act1}); //install B which will install Action2 ProfileChangeRequest request2 = new ProfileChangeRequest(getProfile("installation")); request2.addInstallableUnits(new IInstallableUnit[] {b}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); - assertOK("install actions for B", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan2.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); + assertOK("install actions for B", engine.perform(plan2.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act2}); - assertOK("install B", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan2.getOperands(), null, null)); + assertOK("install B", engine.perform(plan2, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {b, a, act2}); //install C ProfileChangeRequest requestForC = new ProfileChangeRequest(getProfile("installation")); requestForC.addInstallableUnits(new IInstallableUnit[] {c}); - ProvisioningPlan planForC = planner.getProvisioningPlan(requestForC, ctx, new NullProgressMonitor()); + IProvisioningPlan planForC = planner.getProvisioningPlan(requestForC, ctx, new NullProgressMonitor()); assertNull(planForC.getInstallerPlan()); - assertOK("install C", engine.perform(getProfile("installation"), new DefaultPhaseSet(), planForC.getOperands(), null, null)); + assertOK("install C", engine.perform(planForC, null)); assertProfileContainsAll("Checking profile after C", getProfile("installation"), new IInstallableUnit[] {a, b, c, act2, act1}); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act2, act1}); @@ -275,42 +270,41 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv ProfileChangeRequest requestUpdateA = new ProfileChangeRequest(getProfile("installation")); requestUpdateA.removeInstallableUnits(new IInstallableUnit[] {a}); requestUpdateA.addInstallableUnits(new IInstallableUnit[] {a111}); - ProvisioningPlan planUpdateA = planner.getProvisioningPlan(requestUpdateA, ctx, new NullProgressMonitor()); - assertOK("install actions for A 1.1.1", engine.perform(getProfile("agent"), new DefaultPhaseSet(), planUpdateA.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan planUpdateA = planner.getProvisioningPlan(requestUpdateA, ctx, new NullProgressMonitor()); + assertOK("install actions for A 1.1.1", engine.perform(planUpdateA.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1, act1b, act2}); - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), planUpdateA.getOperands(), null, null)); + assertOK("install A", engine.perform(planUpdateA, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {act2, act1b, a111, b, c}); - assertEquals(0, getProfile("installation").query(new InstallableUnitQuery("Action1", DEFAULT_VERSION), new Collector(), null).size()); - assertEquals(requestUpdateA, planUpdateA.getProfileChangeRequest()); - assertEquals(getProfile("agent").getProfileId(), plan.getInstallerPlan().getProfileChangeRequest().getProfile().getProfileId()); + assertTrue(getProfile("installation").query(new InstallableUnitQuery("Action1", DEFAULT_VERSION), null).isEmpty()); + assertEquals(getProfile("agent").getProfileId(), plan.getInstallerPlan().getProfile().getProfileId()); //uninstall A ProfileChangeRequest request3 = new ProfileChangeRequest(getProfile("installation")); request3.removeInstallableUnits(new IInstallableUnit[] {a111}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(request3, ctx, new NullProgressMonitor()); + IProvisioningPlan plan3 = planner.getProvisioningPlan(request3, ctx, new NullProgressMonitor()); // assertOK("install actions", engine.perform(getProfile("agent"), new DefaultPhaseSet(), plan3.getInstallerPlan().getOperands(), null, null)); // assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1b}); //At this point there is not - assertOK("install A", engine.perform(getProfile("installation"), new DefaultPhaseSet(), plan3.getOperands(), null, null)); + assertOK("install A", engine.perform(plan3, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("installation"), new IInstallableUnit[] {c, b, act2}); //uninstall C ProfileChangeRequest request4 = new ProfileChangeRequest(getProfile("installation")); request4.removeInstallableUnits(new IInstallableUnit[] {c}); - ProvisioningPlan uninstallC = planner.getProvisioningPlan(request4, ctx, new NullProgressMonitor()); + IProvisioningPlan uninstallC = planner.getProvisioningPlan(request4, ctx, new NullProgressMonitor()); assertNull(uninstallC.getInstallerPlan()); - assertOK("install C", engine.perform(getProfile("installation"), new DefaultPhaseSet(), uninstallC.getOperands(), null, null)); + assertOK("install C", engine.perform(uninstallC, null)); assertProfileContainsAll("Checking profile after C", getProfile("installation"), new IInstallableUnit[] {b, act2}); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act2}); //install D, This will cause the removal of act1 and cause the addition of act1v2 from the installer ProfileChangeRequest requestForD = new ProfileChangeRequest(getProfile("installation")); requestForD.addInstallableUnits(new IInstallableUnit[] {d}); - ProvisioningPlan planForD = planner.getProvisioningPlan(requestForD, ctx, new NullProgressMonitor()); + IProvisioningPlan planForD = planner.getProvisioningPlan(requestForD, ctx, new NullProgressMonitor()); assertNotNull(planForD.getInstallerPlan()); - assertEquals(1, planForD.getInstallerPlan().getRemovals().query(new InstallableUnitQuery(act1b.getId()), new Collector(), null).size()); - assertOK("install actions", engine.perform(getProfile("agent"), new DefaultPhaseSet(), planForD.getInstallerPlan().getOperands(), null, null)); + assertEquals(1, queryResultSize(planForD.getInstallerPlan().getRemovals().query(new InstallableUnitQuery(act1b.getId()), null))); + assertOK("install actions", engine.perform(planForD.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1v2}); - assertOK("install D", engine.perform(getProfile("installation"), new DefaultPhaseSet(), planForD.getOperands(), null, null)); + assertOK("install D", engine.perform(planForD, null)); assertProfileContainsAll("Checking profile after D", getProfile("installation"), new IInstallableUnit[] {b, d}); assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act2, act1v2}); } @@ -319,13 +313,13 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); - IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", new Version(2, 0, 0)); - IInstallableUnit act1v2 = createIU("Action1", new Version("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); + IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", Version.createOSGi(2, 0, 0)); + IInstallableUnit act1v2 = createIU("Action1", Version.create("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"), null); + IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]")); IInstallableUnit d = createIUWithMetaRequirement("D", DEFAULT_VERSION, true, NO_REQUIRES, metaReqd); createTestMetdataRepository(new IInstallableUnit[] {a, act1, d, act1v2}); @@ -336,8 +330,8 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a, d}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertNotOK(plan.getStatus()); - assertEquals(request, plan.getProfileChangeRequest()); + assertEquals(request.getProfile(), plan.getProfile()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java index 4e7b9d9c5..61af3ee7a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java @@ -8,25 +8,18 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - -import java.lang.reflect.Field; import java.net.URI; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; -import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.MetadataFactory; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestActivator; public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { private IProfile initialProfile = null; - private Object previousSelfValue = null; public void setUp() throws Exception { super.setUp(); @@ -35,39 +28,16 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { if (initialProfile != null) return; - if (System.getProperty("eclipse.p2.profile") == null) { - SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); - try { - Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$ - selfField.setAccessible(true); - previousSelfValue = selfField.get(profileRegistry); - if (previousSelfValue == null) - selfField.set(profileRegistry, "agent"); - } catch (Throwable t) { - fail(); - } - } - createProfile("agent"); + setUpSelfProfile(); } public void tearDown() throws Exception { if (initialProfile == null) { - if (System.getProperty("eclipse.p2.profile") == null) { - SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); - try { - Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$ - selfField.setAccessible(true); - Object self = selfField.get(profileRegistry); - if (self.equals("agent")) - selfField.set(profileRegistry, previousSelfValue); - } catch (Throwable t) { - // ignore as we still want to continue tidying up - } - } + tearDownSelfProfile(); } else { //After the test we clean up the profile IProfile profileAfterTestRun = getProfile(IProfileRegistry.SELF); - ProvisioningPlan rollbackPlan = createPlanner().getDiffPlan(profileAfterTestRun, initialProfile, new NullProgressMonitor()); + IProvisioningPlan rollbackPlan = createPlanner().getDiffPlan(profileAfterTestRun, initialProfile, new NullProgressMonitor()); assertOK("rollback plan", rollbackPlan.getStatus()); assertOK("rollback execution", PlanExecutionHelper.executePlan(rollbackPlan, createEngine(), new ProvisioningContext(), new NullProgressMonitor())); } @@ -75,7 +45,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { } public void testGetAgentPlanActionNeededButUnavailable() { - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); IProfile profile = getProfile(IProfileRegistry.SELF); @@ -85,7 +55,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { request.addInstallableUnits(new IInstallableUnit[] {a}); ProvisioningContext context = new ProvisioningContext(new URI[0]); - ProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor()); assertNotOK(plan.getStatus()); } @@ -93,7 +63,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); createTestMetdataRepository(new IInstallableUnit[] {a, act1}); @@ -103,7 +73,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertTrue(plan.getStatus().isOK()); assertNotNull(plan.getInstallerPlan()); } @@ -112,11 +82,11 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { //This tests the case where the action is in conflict with the thing being installed //The action needs another version of A which is singleton IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); - IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]"), null), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); + IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]")), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); - IInstallableUnit a2 = createIU("A", new Version(2, 0, 0)); + IInstallableUnit a2 = createIU("A", Version.createOSGi(2, 0, 0)); createTestMetdataRepository(new IInstallableUnit[] {a, a2, act1}); IProfile profile = getProfile(IProfileRegistry.SELF); @@ -125,7 +95,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertNotOK(plan.getStatus()); } @@ -133,7 +103,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); IInstallableUnit b = createEclipseIU("B"); @@ -145,19 +115,18 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { ProfileChangeRequest request = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF)); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); - assertOK("install actions", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + assertOK("install actions", engine.perform(plan.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act1}); - assertOK("install A", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan.getOperands(), null, null)); + assertOK("install A", engine.perform(plan, null)); assertProfileContainsAll("Checking profile after initial install", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {a, act1}); - assertEquals(request, plan.getProfileChangeRequest()); - assertEquals(getProfile(IProfileRegistry.SELF).getProfileId(), plan.getInstallerPlan().getProfileChangeRequest().getProfile().getProfileId()); + assertEquals(getProfile(IProfileRegistry.SELF).getProfileId(), plan.getInstallerPlan().getProfile().getProfileId()); ProfileChangeRequest request2 = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF)); request2.addInstallableUnits(new IInstallableUnit[] {b}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); + IProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); assertNull(plan2.getInstallerPlan()); - assertOK("install b", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan2.getOperands(), null, null)); + assertOK("install b", engine.perform(plan2, null)); assertProfileContainsAll("Checking profile after initial install", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {a, act1, b}); } @@ -165,10 +134,10 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { public void testWithOveralInDependency() { IInstallableUnit common = createEclipseIU("Common"); IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); - IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common", null), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); + IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common"), new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); - IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common", null), metaReq); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); + IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "Common"), metaReq); createTestMetdataRepository(new IInstallableUnit[] {a, act1, common}); @@ -179,10 +148,10 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); - assertOK("install actions", engine.perform(profile, new DefaultPhaseSet(), plan.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + assertOK("install actions", engine.perform(plan.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act1, common}); - assertOK("install A", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan.getOperands(), null, null)); + assertOK("install A", engine.perform(plan, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {a, common, act1}); } @@ -190,13 +159,13 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); IProvidedCapability act2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", DEFAULT_VERSION); IInstallableUnit act2 = createIU("Action2", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit b = createIUWithMetaRequirement("B", DEFAULT_VERSION, true, NO_REQUIRES, metaReq2); createTestMetdataRepository(new IInstallableUnit[] {a, b, act1, act2,}); @@ -209,19 +178,19 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { //install A which will install Action1 ProfileChangeRequest request = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF)); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); - assertOK("install actions", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + assertOK("install actions", engine.perform(plan.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act1}); - assertOK("install A", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan.getOperands(), null, null)); + assertOK("install A", engine.perform(plan, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {a, act1}); //install B which will install Action2 ProfileChangeRequest request2 = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF)); request2.addInstallableUnits(new IInstallableUnit[] {b}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); - assertOK("install actions", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan2.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); + assertOK("install actions", engine.perform(plan2.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act2, act1, a}); - assertOK("install A", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan2.getOperands(), null, null)); + assertOK("install A", engine.perform(plan2, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act2, act1, b, a}); } @@ -229,19 +198,19 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); IProvidedCapability act1bCap = MetadataFactory.createProvidedCapability("p2.action", "action1b", DEFAULT_VERSION); IInstallableUnit act1b = createIU("Action1b", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1bCap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReqb = createRequiredCapabilities("p2.action", "action1b", new VersionRange("[0.0.0, 1.0.0]"), null); - IInstallableUnit a111 = createIUWithMetaRequirement("A", new Version(1, 1, 1), true, NO_REQUIRES, metaReqb); + IRequiredCapability[] metaReqb = createRequiredCapabilities("p2.action", "action1b", new VersionRange("[0.0.0, 1.0.0]")); + IInstallableUnit a111 = createIUWithMetaRequirement("A", Version.createOSGi(1, 1, 1), true, NO_REQUIRES, metaReqb); IProvidedCapability act2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", DEFAULT_VERSION); IInstallableUnit act2 = createIU("Action2", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq2 = createRequiredCapabilities("p2.action", "action2", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit b = createIUWithMetaRequirement("B", DEFAULT_VERSION, true, NO_REQUIRES, metaReq2); IInstallableUnit c = createEclipseIU("C"); @@ -254,27 +223,27 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { //install A which will install Action1 ProfileChangeRequest request = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF)); request.addInstallableUnits(new IInstallableUnit[] {a}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); - assertOK("install actions for A", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + assertOK("install actions for A", engine.perform(plan.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act1}); - assertOK("install A", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan.getOperands(), null, null)); + assertOK("install A", engine.perform(plan, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {a, act1}); //install B which will install Action2 ProfileChangeRequest request2 = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF)); request2.addInstallableUnits(new IInstallableUnit[] {b}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); - assertOK("install actions for B", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan2.getInstallerPlan().getOperands(), null, null)); + IProvisioningPlan plan2 = planner.getProvisioningPlan(request2, ctx, new NullProgressMonitor()); + assertOK("install actions for B", engine.perform(plan2.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act2, act1, a}); - assertOK("install B", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan2.getOperands(), null, null)); + assertOK("install B", engine.perform(plan2, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act2, act1, b, a}); //install C ProfileChangeRequest requestForC = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF)); requestForC.addInstallableUnits(new IInstallableUnit[] {c}); - ProvisioningPlan planForC = planner.getProvisioningPlan(requestForC, ctx, new NullProgressMonitor()); + IProvisioningPlan planForC = planner.getProvisioningPlan(requestForC, ctx, new NullProgressMonitor()); assertNull(planForC.getInstallerPlan()); - assertOK("install C", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), planForC.getOperands(), null, null)); + assertOK("install C", engine.perform(planForC, null)); assertProfileContainsAll("Checking profile after C", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act1, act2, a, b, c}); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act2, act1, b, a}); @@ -282,22 +251,22 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { ProfileChangeRequest requestUpdateA = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF)); requestUpdateA.removeInstallableUnits(new IInstallableUnit[] {a}); requestUpdateA.addInstallableUnits(new IInstallableUnit[] {a111}); - ProvisioningPlan planUpdateA = planner.getProvisioningPlan(requestUpdateA, ctx, new NullProgressMonitor()); + IProvisioningPlan planUpdateA = planner.getProvisioningPlan(requestUpdateA, ctx, new NullProgressMonitor()); assertOK("Checking planUpdateA", planUpdateA.getStatus()); - assertOK("install actions for A 1.1.1", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), planUpdateA.getInstallerPlan().getOperands(), null, null)); + assertOK("install actions for A 1.1.1", engine.perform(planUpdateA.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act1, act1b}); - assertOK("install A", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), planUpdateA.getOperands(), null, null)); + assertOK("install A", engine.perform(planUpdateA, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act1b, a111, b, c}); - assertEquals(0, getProfile(IProfileRegistry.SELF).query(new InstallableUnitQuery("Action1", DEFAULT_VERSION), new Collector(), null).size()); + assertTrue(getProfile(IProfileRegistry.SELF).query(new InstallableUnitQuery("Action1", DEFAULT_VERSION), null).isEmpty()); //uninstall A ProfileChangeRequest request3 = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF)); request3.removeInstallableUnits(new IInstallableUnit[] {a111}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(request3, ctx, new NullProgressMonitor()); + IProvisioningPlan plan3 = planner.getProvisioningPlan(request3, ctx, new NullProgressMonitor()); // assertNull(plan3.getInstallerPlan()); //TODO - assertOK("install actions", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan3.getInstallerPlan().getOperands(), null, null)); + assertOK("install actions", engine.perform(plan3.getInstallerPlan(), null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act1b}); //At this point there is not - assertOK("install A", engine.perform(getProfile(IProfileRegistry.SELF), new DefaultPhaseSet(), plan3.getOperands(), null, null)); + assertOK("install A", engine.perform(plan3, null)); assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {c, b, act2}); } @@ -305,13 +274,13 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); - IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", new Version(2, 0, 0)); - IInstallableUnit act1v2 = createIU("Action1", new Version("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); + IProvidedCapability act1v2Cap = MetadataFactory.createProvidedCapability("p2.action", "action2", Version.createOSGi(2, 0, 0)); + IInstallableUnit act1v2 = createIU("Action1", Version.create("2.0.0"), null, NO_REQUIRES, new IProvidedCapability[] {act1v2Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]"), null); + IRequiredCapability[] metaReqd = createRequiredCapabilities("p2.action", "action2", new VersionRange("[2.0.0, 2.0.0]")); IInstallableUnit d = createIUWithMetaRequirement("D", DEFAULT_VERSION, true, NO_REQUIRES, metaReqd); createTestMetdataRepository(new IInstallableUnit[] {a, act1, d, act1v2}); @@ -322,7 +291,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest { ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {a, d}); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertNotOK(plan.getStatus()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOptional.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOptional.java index 7f5bb5e44..61ab19151 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOptional.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOptional.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class AllOptional extends AbstractProvisioningTest { @@ -28,16 +32,16 @@ public class AllOptional extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - IRequiredCapability[] reqA = new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, true)}; - a1 = createIU("A", new Version("1.0.0"), reqA); - b1 = createIU("B", new Version("1.0.0"), true); + IRequiredCapability[] reqA = new IRequiredCapability[] {(IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, true)}; + a1 = createIU("A", Version.create("1.0.0"), reqA); + b1 = createIU("B", Version.create("1.0.0"), true); IRequiredCapability[] reqC = new IRequiredCapability[2]; - reqC[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", VersionRange.emptyRange, null, true, false, true); - reqC[1] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "E", VersionRange.emptyRange, null, true, false, true); - c1 = createIU("C", new Version("1.0.0"), reqC); - d1 = createIU("D", new Version("1.0.0"), true); - e1 = createIU("E", new Version("1.0.0"), true); + reqC[0] = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", VersionRange.emptyRange, null, true, false, true); + reqC[1] = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "E", VersionRange.emptyRange, null, true, false, true); + c1 = createIU("C", Version.create("1.0.0"), reqC); + d1 = createIU("D", Version.create("1.0.0"), true); + e1 = createIU("E", Version.create("1.0.0"), true); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, c1, d1, e1}); @@ -48,7 +52,7 @@ public class AllOptional extends AbstractProvisioningTest { public void testInstallation() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1, c1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); assertInstallOperand(plan, b1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOrbit.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOrbit.java index 68e86b52d..ad24ab23e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOrbit.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOrbit.java @@ -15,12 +15,12 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -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.engine.*; +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.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; @@ -32,7 +32,7 @@ public class AllOrbit extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - IMetadataRepositoryManager repoMan = (MetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + IMetadataRepositoryManager repoMan = (MetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); repo = repoMan.loadRepository(getTestData("repository for wsdl test", "testData/orbitRepo/").toURI(), new NullProgressMonitor()); profile1 = createProfile("TestProfile." + getName()); @@ -42,29 +42,22 @@ public class AllOrbit extends AbstractProvisioningTest { public void testInstallTwoVersionsOptionaly() { ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); - Collector allIUs = repo.query(InstallableUnitQuery.ANY, new Collector(), null); + IQueryResult allIUs = repo.query(InstallableUnitQuery.ANY, null); req1.addInstallableUnits((IInstallableUnit[]) allIUs.toArray(IInstallableUnit.class)); for (Iterator iterator = allIUs.iterator(); iterator.hasNext();) { IInstallableUnit iu = (IInstallableUnit) iterator.next(); if (!iu.getId().equals("javax.wsdl")) req1.setInstallableUnitInclusionRules(iu, PlannerHelper.createOptionalInclusionRule(iu)); } - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); - Operand[] ops = plan1.getOperands(); - int count = 0; - for (int i = 0; i < ops.length; i++) { - if (ops[i] instanceof InstallableUnitOperand) { - count++; - } - } + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); } public void test2() { //Install everything except com.ibm.icu ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); - Collector allIUs = repo.query(InstallableUnitQuery.ANY, new Collector(), null); - ArrayList toInstall = new ArrayList(allIUs.size()); + IQueryResult allIUs = repo.query(InstallableUnitQuery.ANY, null); + ArrayList toInstall = new ArrayList(); int removed = 0; for (Iterator iterator = allIUs.iterator(); iterator.hasNext();) { IInstallableUnit toAdd = (IInstallableUnit) iterator.next(); @@ -75,23 +68,16 @@ public class AllOrbit extends AbstractProvisioningTest { } req1.addInstallableUnits((IInstallableUnit[]) toInstall.toArray(new IInstallableUnit[toInstall.size()])); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); - Operand[] ops = plan1.getOperands(); - int count = 0; - for (int i = 0; i < ops.length; i++) { - if (ops[i] instanceof InstallableUnitOperand) { - count++; - } - } - assertEquals(178, count); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + assertEquals(178, countPlanElements(plan1)); assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); } public void test3() { //Install everything optionaly (except com.ibm.icu that we don't install at all) ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); - Collector allIUs = repo.query(InstallableUnitQuery.ANY, new Collector(), null); - ArrayList toInstall = new ArrayList(allIUs.size()); + IQueryResult allIUs = repo.query(InstallableUnitQuery.ANY, null); + ArrayList toInstall = new ArrayList(); int removed = 0; for (Iterator iterator = allIUs.iterator(); iterator.hasNext();) { IInstallableUnit toAdd = (IInstallableUnit) iterator.next(); @@ -103,15 +89,8 @@ public class AllOrbit extends AbstractProvisioningTest { } req1.addInstallableUnits((IInstallableUnit[]) toInstall.toArray(new IInstallableUnit[toInstall.size()])); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); - Operand[] ops = plan1.getOperands(); - int count = 0; - for (int i = 0; i < ops.length; i++) { - if (ops[i] instanceof InstallableUnitOperand) { - count++; - } - } - assertEquals(178, count); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + assertEquals(178, countPlanElements(plan1)); assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java index 8da13e016..c2555de8d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java @@ -19,6 +19,7 @@ public class AllTests extends TestCase { public static Test suite() { TestSuite suite = new TestSuite(AllTests.class.getName()); + suite.addTestSuite(AbsolutePlanTest.class); suite.addTestSuite(ActualChangeRequestTest.class); suite.addTestSuite(ActualChangeRequestTest2.class); suite.addTestSuite(AdditionalConstraints.class); @@ -93,6 +94,8 @@ public class AllTests extends TestCase { suite.addTestSuite(PatchTest8.class); suite.addTestSuite(PatchTest9.class); suite.addTestSuite(PatchTestMultiplePatch.class); + suite.addTestSuite(PatchTestMultiplePatch2.class); + suite.addTestSuite(PatchTestMultiplePatch3.class); suite.addTestSuite(PatchTestOptional.class); suite.addTestSuite(PatchTestOptional2.class); suite.addTestSuite(PatchTestOptional3.class); @@ -121,6 +124,7 @@ public class AllTests extends TestCase { suite.addTestSuite(SWTFragment.class); suite.addTestSuite(TwoVersionsOfWSDL.class); suite.addTestSuite(UninstallEverything.class); + suite.addTestSuite(UpdateQueryTest.class); return suite; } }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AnotherSingleton.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AnotherSingleton.java index cf294e904..cb6ecc3cb 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AnotherSingleton.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AnotherSingleton.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class AnotherSingleton extends AbstractProvisioningTest { @@ -32,15 +34,15 @@ public class AnotherSingleton extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); - a2 = createIU("A", new Version("2.0.0"), true); + a2 = createIU("A", Version.create("2.0.0"), true); - IRequiredCapability c1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null, false, false); - x = createIU("X", new Version(2, 0, 0), new IRequiredCapability[] {c1}); + IRequiredCapability c1 = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null, false, false); + x = createIU("X", Version.createOSGi(2, 0, 0), new IRequiredCapability[] {c1}); - IRequiredCapability c2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]"), null, false, false); - y = createIU("Y", new Version(2, 0, 0), new IRequiredCapability[] {c2}); + IRequiredCapability c2 = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]"), null, false, false); + y = createIU("Y", Version.createOSGi(2, 0, 0), new IRequiredCapability[] {c2}); createTestMetdataRepository(new IInstallableUnit[] {a1, a2, x, y}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug207319.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug207319.java index 29ed90869..6e24f9294 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug207319.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug207319.java @@ -8,16 +8,13 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.MetadataFactory; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class Bug207319 extends AbstractProvisioningTest { @@ -28,9 +25,9 @@ public class Bug207319 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a = createIU("A", new Version("1.0.0")); - b = createIU("B", new Version("1.0.0"), new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new Version("1.0.0"))}); - c = createIU("C", new Version("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null)); + a = createIU("A", Version.create("1.0.0")); + b = createIU("B", Version.create("1.0.0"), new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", Version.create("1.0.0"))}); + c = createIU("C", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"))); createTestMetdataRepository(new IInstallableUnit[] {a, b, c}); profile = createProfile(Bug207319.class.getName()); director = createDirector(); @@ -42,13 +39,13 @@ public class Bug207319 extends AbstractProvisioningTest { req.addInstallableUnits(new IInstallableUnit[] {b}); assertEquals(IStatus.OK, director.provision(req, null, null).getSeverity()); assertProfileContainsAll("B is missing", profile, new IInstallableUnit[] {b}); - assertNotIUs(new IInstallableUnit[] {a}, profile.query(InstallableUnitQuery.ANY, new Collector(), null).iterator()); + assertNotIUs(new IInstallableUnit[] {a}, profile.query(InstallableUnitQuery.ANY, null).iterator()); ProfileChangeRequest req2 = new ProfileChangeRequest(profile); req2.addInstallableUnits(new IInstallableUnit[] {c}); assertEquals(IStatus.OK, director.provision(req2, null, null).getSeverity()); assertProfileContainsAll("B and C are missing", profile, new IInstallableUnit[] {b, c}); - assertNotIUs(new IInstallableUnit[] {a}, profile.query(InstallableUnitQuery.ANY, new Collector(), null).iterator()); + assertNotIUs(new IInstallableUnit[] {a}, profile.query(InstallableUnitQuery.ANY, null).iterator()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug249605.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug249605.java index 976aca1a9..5738f1770 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug249605.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug249605.java @@ -10,15 +10,19 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.HashMap; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class Bug249605 extends AbstractProvisioningTest { @@ -32,19 +36,19 @@ public class Bug249605 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - b1 = createIU("B", new Version(1, 1, 0), true); - b2 = createIU("B", new Version(1, 2, 0), true); - b3 = createIU("B", new Version(1, 3, 0), true); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + b1 = createIU("B", Version.createOSGi(1, 1, 0), true); + b2 = createIU("B", Version.createOSGi(1, 2, 0), true); + b3 = createIU("B", Version.createOSGi(1, 3, 0), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.2.0)"), null, false, false, true)); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); IRequirementChange change2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.2.0, 1.3.0)"), null, false, false, true)); - p2 = createIUPatch("P", new Version("1.2.0"), null, new IRequiredCapability[0], new IProvidedCapability[0], new HashMap(), null, null, true, MetadataFactory.createUpdateDescriptor("P", new VersionRange("[1.0.0, 1.2.0)"), 0, null), new IRequirementChange[] {change2}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null, new IRequiredCapability[0]); + p2 = createIUPatch("P", Version.create("1.2.0"), null, new IRequiredCapability[0], new IProvidedCapability[0], new HashMap(), null, null, true, MetadataFactory.createUpdateDescriptor("P", new VersionRange("[1.0.0, 1.2.0)"), 0, null), new IRequirementChange[] {change2}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null, new IRequiredCapability[0]); IRequirementChange change3 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.3.0, 1.4.0)"), null, false, false, true)); - p3 = createIUPatch("P", new Version("1.3.0"), null, new IRequiredCapability[0], new IProvidedCapability[0], new HashMap(), null, null, true, MetadataFactory.createUpdateDescriptor("P", new VersionRange("[1.0.0, 1.3.0)"), 0, null), new IRequirementChange[] {change3}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null, new IRequiredCapability[0]); + p3 = createIUPatch("P", Version.create("1.3.0"), null, new IRequiredCapability[0], new IProvidedCapability[0], new HashMap(), null, null, true, MetadataFactory.createUpdateDescriptor("P", new VersionRange("[1.0.0, 1.3.0)"), 0, null), new IRequirementChange[] {change3}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null, new IRequiredCapability[0]); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, b3, p1, p2, p3}); @@ -57,28 +61,28 @@ public class Bug249605 extends AbstractProvisioningTest { // The requirement from A to B is broken because there is no B satisfying. Therefore A can only install if the P is installed as well ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - req1.setInstallableUnitProfileProperty(p1, IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.toString(true)); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + req1.setInstallableUnitProfileProperty(p1, IProfile.PROP_PROFILE_ROOT_IU, Boolean.toString(true)); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); - assertOK("1.1", engine.perform(profile1, DefaultPhaseSet.createDefaultPhaseSet(0), plan1.getOperands(), null, new NullProgressMonitor())); + assertOK("1.1", engine.perform(plan1, new NullProgressMonitor())); assertProfileContains("1.2", profile1, new IInstallableUnit[] {a1, p1, b1}); ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {p2}); req2.removeInstallableUnits(new IInstallableUnit[] {p1}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, new NullProgressMonitor()); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, new NullProgressMonitor()); assertOK("2.0", plan2.getStatus()); - assertOK("2.1", engine.perform(profile1, DefaultPhaseSet.createDefaultPhaseSet(0), plan2.getOperands(), null, new NullProgressMonitor())); + assertOK("2.1", engine.perform(plan2, new NullProgressMonitor())); assertProfileContains("2.2", profile1, new IInstallableUnit[] {a1, p2, b2}); - assertEquals("true", profile1.getInstallableUnitProperty(p2, IInstallableUnit.PROP_PROFILE_ROOT_IU)); + assertTrue(UserVisibleRootQuery.isUserVisible(p2, profile1)); ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {p3}); req3.removeInstallableUnits(new IInstallableUnit[] {p2}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, new NullProgressMonitor()); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, new NullProgressMonitor()); assertOK("3.0", plan3.getStatus()); - assertOK("3.1", engine.perform(profile1, DefaultPhaseSet.createDefaultPhaseSet(0), plan3.getOperands(), null, new NullProgressMonitor())); + assertOK("3.1", engine.perform(plan3, new NullProgressMonitor())); assertProfileContains("3.2", profile1, new IInstallableUnit[] {a1, p3, b3}); - assertEquals("true", profile1.getInstallableUnitProperty(p3, IInstallableUnit.PROP_PROFILE_ROOT_IU)); + assertTrue(UserVisibleRootQuery.isUserVisible(p3, profile1)); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252638.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252638.java index 82556a6aa..895768481 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252638.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252638.java @@ -10,13 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; //Failing to install something optionally should indicate the failure in the request status for the IU being installed. @@ -30,10 +32,10 @@ public class Bug252638 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequiredCapability lifeCycle = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 3.0.0)"), null, false, false, false); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle); createTestMetdataRepository(new IInstallableUnit[] {a1, p1}); @@ -45,15 +47,15 @@ public class Bug252638 extends AbstractProvisioningTest { public void testInstall() { ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); - engine.perform(profile1, new DefaultPhaseSet(), plan1.getOperands(), null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + engine.perform(plan1, null); assertProfileContainsAll("1.0", profile1, new IInstallableUnit[] {a1}); assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {p1}); req2.setInstallableUnitInclusionRules(p1, PlannerHelper.createOptionalInclusionRule(p1)); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getCode()); assertEquals(IStatus.ERROR, plan2.getRequestStatus(p1).getSeverity()); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252682.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252682.java index 84a7f78c1..5b76c9a89 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252682.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252682.java @@ -10,18 +10,18 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.util.ArrayList; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; -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.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +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.query.IQueryResult; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class Bug252682 extends AbstractProvisioningTest { @@ -39,22 +39,22 @@ public class Bug252682 extends AbstractProvisioningTest { newIUs.add(createEclipseIU("org.eclipse.equinox.p2.core", Version.createOSGi(1, 0, 100, "v20081024"))); ProfileChangeRequest req = new ProfileChangeRequest(profile); - ProvisioningPlan plan = createPlanner().getProvisioningPlan(req, null, null); + IProvisioningPlan plan = createPlanner().getProvisioningPlan(req, null, null); assertOK("validate profile", plan.getStatus()); } public void testInstallFeaturePatch() { - IInstallableUnit p2Feature = (IInstallableUnit) profile.query(new InstallableUnitQuery("org.eclipse.equinox.p2.user.ui.feature.group"), new Collector(), new NullProgressMonitor()).iterator().next(); + IInstallableUnit p2Feature = (IInstallableUnit) profile.query(new InstallableUnitQuery("org.eclipse.equinox.p2.user.ui.feature.group"), new NullProgressMonitor()).iterator().next(); System.out.println(p2Feature); - Collector c = profile.query(new InstallableUnitQuery("org.eclipse.equinox.p2.core.patch"), new Collector(), new NullProgressMonitor()); - assertEquals(1, c.size()); + IQueryResult c = profile.query(new InstallableUnitQuery("org.eclipse.equinox.p2.core.patch"), new NullProgressMonitor()); + assertEquals(1, queryResultSize(c)); ProvisioningContext ctx = new ProvisioningContext(); ctx.setExtraIUs(newIUs); IInstallableUnit patch = (IInstallableUnit) c.iterator().next(); ProfileChangeRequest request = new ProfileChangeRequest(profile); request.removeInstallableUnits(new IInstallableUnit[] {patch}); IPlanner planner = createPlanner(); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertOK("Installation plan", plan.getStatus()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug254481dataSet1.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug254481dataSet1.java index c555c5cd5..70880af3d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug254481dataSet1.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug254481dataSet1.java @@ -14,11 +14,12 @@ import java.io.File; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -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.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +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.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class Bug254481dataSet1 extends AbstractProvisioningTest { @@ -43,20 +44,20 @@ public class Bug254481dataSet1 extends AbstractProvisioningTest { } public void testInstallFeaturePatch() { - Collector c = repo.query(new InstallableUnitQuery("RPT_ARM_TEST.feature.group"), new Collector(), new NullProgressMonitor()); - assertEquals(1, c.size()); + IQueryResult c = repo.query(new InstallableUnitQuery("RPT_ARM_TEST.feature.group"), new NullProgressMonitor()); + assertEquals(1, queryResultSize(c)); IInstallableUnit patch = (IInstallableUnit) c.iterator().next(); ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {patch}); request.setInstallableUnitInclusionRules(patch, PlannerHelper.createOptionalInclusionRule(patch)); IPlanner planner = createPlanner(); - ProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); assertInstallOperand(plan, patch); //[[R]com.ibm.rational.test.lt.arm 7.0.250.v200810021504 --> [R]com.ibm.rational.test.lt.arm 7.0.300.200811041300, - assertEquals(1, plan.getAdditions().query(new InstallableUnitQuery("com.ibm.rational.test.lt.arm"), new Collector(), null).size()); + assertEquals(1, queryResultSize(plan.getAdditions().query(new InstallableUnitQuery("com.ibm.rational.test.lt.arm"), null))); //[R]com.ibm.rational.test.lt.armbroker 7.0.250.v200810021504 --> [R]com.ibm.rational.test.lt.armbroker 7.0.300.200811041300, - assertEquals(1, plan.getAdditions().query(new InstallableUnitQuery("com.ibm.rational.test.lt.armbroker"), new Collector(), null).size()); + assertEquals(1, queryResultSize(plan.getAdditions().query(new InstallableUnitQuery("com.ibm.rational.test.lt.armbroker"), null))); //[R]com.ibm.rational.test.lt.kernel 7.2.151.v200810021605 --> [R]com.ibm.rational.test.lt.kernel 7.2.200.200811041300, - assertEquals(1, plan.getAdditions().query(new InstallableUnitQuery("com.ibm.rational.test.lt.kernel"), new Collector(), null).size()); + assertEquals(1, queryResultSize(plan.getAdditions().query(new InstallableUnitQuery("com.ibm.rational.test.lt.kernel"), null))); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug254481dataSet2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug254481dataSet2.java index 54a71d235..3bcc05187 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug254481dataSet2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug254481dataSet2.java @@ -14,11 +14,12 @@ import java.io.File; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -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.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +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.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class Bug254481dataSet2 extends AbstractProvisioningTest { @@ -43,16 +44,16 @@ public class Bug254481dataSet2 extends AbstractProvisioningTest { } public void testInstallFeaturePatch() { - Collector c = repo.query(new InstallableUnitQuery("org.eclipse.jdt.feature.patch.feature.group"), new Collector(), new NullProgressMonitor()); - assertEquals(1, c.size()); + IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.jdt.feature.patch.feature.group"), new NullProgressMonitor()); + assertEquals(1, queryResultSize(c)); IInstallableUnit patch = (IInstallableUnit) c.iterator().next(); ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {patch}); request.setInstallableUnitInclusionRules(patch, PlannerHelper.createOptionalInclusionRule(patch)); IPlanner planner = createPlanner(); - ProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); assertInstallOperand(plan, patch); - assertEquals(1, plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.jdt.core"), new Collector(), null).size()); - assertEquals(1, plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.jdt.core.manipulation"), new Collector(), null).size()); + assertEquals(1, queryResultSize(plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.jdt.core"), null))); + assertEquals(1, queryResultSize(plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.jdt.core.manipulation"), null))); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug255984.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug255984.java index cbe2b94ca..ab3247e31 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug255984.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug255984.java @@ -10,16 +10,18 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class Bug255984 extends AbstractProvisioningTest { @@ -32,9 +34,9 @@ public class Bug255984 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}, NO_PROPERTIES, true); + a = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}, NO_PROPERTIES, true); - b = createIU("B", new Version("1.0.0"), true); + b = createIU("B", Version.create("1.0.0"), true); createTestMetdataRepository(new IInstallableUnit[] {a, b}); @@ -49,32 +51,32 @@ public class Bug255984 extends AbstractProvisioningTest { req.addInstallableUnits(new IInstallableUnit[] {b}); req.setInstallableUnitInclusionRules(b, PlannerHelper.createStrictInclusionRule(b)); req.setInstallableUnitProfileProperty(b, "foo", "bar"); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); - engine.perform(profile1, new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); assertProfileContainsAll("B is missing", profile1, new IInstallableUnit[] {b}); - assertEquals(1, profile1.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null))); //Install A ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {a}); req2.setInstallableUnitInclusionRules(a, PlannerHelper.createStrictInclusionRule(a)); req2.setInstallableUnitProfileProperty(a, "foo", "bar"); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); - engine.perform(profile1, new DefaultPhaseSet(), plan2.getOperands(), null, null); + engine.perform(plan2, null); assertProfileContainsAll("A is missing", profile1, new IInstallableUnit[] {a, b}); - assertEquals(2, profile1.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(2, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null))); //Uninstall B ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.removeInstallableUnits(new IInstallableUnit[] {b}); req3.removeInstallableUnitProfileProperty(b, "foo"); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.OK, plan3.getStatus().getSeverity()); - engine.perform(profile1, new DefaultPhaseSet(), plan3.getOperands(), null, null); + engine.perform(plan3, null); assertProfileContainsAll("A is missing", profile1, new IInstallableUnit[] {a, b}); - assertEquals(1, profile1.query(new IUProfilePropertyQuery("foo", "bar"), new Collector(), new NullProgressMonitor()).size()); - assertEquals(2, profile1.query(InstallableUnitQuery.ANY, new Collector(), null).size()); + assertEquals(1, queryResultSize(profile1.query(new IUProfilePropertyQuery("foo", "bar"), new NullProgressMonitor()))); + assertEquals(2, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null))); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug262580.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug262580.java index 01c58a676..712bdc66a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug262580.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug262580.java @@ -13,8 +13,8 @@ package org.eclipse.equinox.p2.tests.planner; import java.io.File; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; -import org.eclipse.equinox.internal.provisional.p2.director.ProvisioningPlan; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class Bug262580 extends AbstractProvisioningTest { @@ -31,7 +31,7 @@ public class Bug262580 extends AbstractProvisioningTest { assertNotNull(revertProfile); IPlanner planner = createPlanner(); - ProvisioningPlan plan = planner.getDiffPlan(currentProfile, revertProfile, getMonitor()); + IProvisioningPlan plan = planner.getDiffPlan(currentProfile, revertProfile, getMonitor()); assertTrue(plan.getStatus().isOK()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug270656.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug270656.java index a1b65edff..b6db8c800 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug270656.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug270656.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class Bug270656 extends AbstractProvisioningTest { @@ -32,11 +34,11 @@ public class Bug270656 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, true, true)}); - b12 = createIU("B", new Version(1, 2, 0), true); - b10 = createIU("B", new Version(1, 0, 0), true); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {(IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, true, true)}); + b12 = createIU("B", Version.createOSGi(1, 2, 0), true); + b10 = createIU("B", Version.createOSGi(1, 0, 0), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{(IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); createTestMetdataRepository(new IInstallableUnit[] {a1, b10, b12, p1}); @@ -49,7 +51,7 @@ public class Bug270656 extends AbstractProvisioningTest { //The requirement from A to B is broken because there is no B satisfying. Therefore A can only install if the P is installed as well ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug270683.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug270683.java index e25891895..a722081fc 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug270683.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug270683.java @@ -10,14 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class Bug270683 extends AbstractProvisioningTest { @@ -34,15 +35,15 @@ public class Bug270683 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - b1 = createIU("B", new Version(1, 0, 0), true); - b2 = createIU("B", new Version(1, 2, 0), true); - b3 = createIU("B", new Version(1, 3, 0), true); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + b1 = createIU("B", Version.createOSGi(1, 0, 0), true); + b2 = createIU("B", Version.createOSGi(1, 2, 0), true); + b3 = createIU("B", Version.createOSGi(1, 3, 0), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.2.0, 1.2.0]"), null, false, false, true)); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); IRequirementChange anotherChangeB = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.3.0, 1.3.0]"), null, false, false, true)); - pp1 = createIUPatch("PP", new Version("1.0.0"), true, new IRequirementChange[] {anotherChangeB}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + pp1 = createIUPatch("PP", Version.create("1.0.0"), true, new IRequirementChange[] {anotherChangeB}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, b3, p1, pp1}); @@ -54,8 +55,8 @@ public class Bug270683 extends AbstractProvisioningTest { public void testExplanationContainsExplicitMentionOfPatch() { ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {a1, p1, pp1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + ProvisioningPlan plan3 = (ProvisioningPlan) planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.ERROR, plan3.getStatus().getSeverity()); - assertTrue(plan3.getRequestStatus().getExplanations().toString().contains("patched")); + assertTrue(((RequestStatus) plan3.getRequestStatus()).getExplanations().toString().contains("patched")); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271067.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271067.java index 5d91e9a75..5fdbf32f1 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271067.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271067.java @@ -10,21 +10,20 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.lang.reflect.Field; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -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.director.PlannerHelper; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +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.query.IQueryResult; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestActivator; public class Bug271067 extends AbstractProvisioningTest { private IProfile profile; @@ -37,7 +36,7 @@ public class Bug271067 extends AbstractProvisioningTest { File reporegistry1 = getTestData("test data bug 271067", "testData/bug271067/profileRegistry"); File tempFolder = getTempFolder(); copy("0.2", reporegistry1, tempFolder); - SimpleProfileRegistry realProfileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + SimpleProfileRegistry realProfileRegistry = (SimpleProfileRegistry) getProfileRegistry(); //Tweak the running profile registry Field profileStore = SimpleProfileRegistry.class.getDeclaredField("store"); profileStore.setAccessible(true); @@ -56,7 +55,7 @@ public class Bug271067 extends AbstractProvisioningTest { @Override protected void tearDown() throws Exception { - SimpleProfileRegistry realProfileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + SimpleProfileRegistry realProfileRegistry = (SimpleProfileRegistry) getProfileRegistry(); Field profilesMapField = SimpleProfileRegistry.class.getDeclaredField("profiles"); //$NON-NLS-1$ profilesMapField.setAccessible(true); @@ -69,8 +68,8 @@ public class Bug271067 extends AbstractProvisioningTest { } IInstallableUnit getIU(IMetadataRepository source, String id, String version) { - Collector c = repo.query(new InstallableUnitQuery(id, new Version(version)), new Collector(), new NullProgressMonitor()); - assertEquals(1, c.size()); + IQueryResult c = repo.query(new InstallableUnitQuery(id, Version.create(version)), new NullProgressMonitor()); + assertEquals(1, queryResultSize(c)); return (IInstallableUnit) c.iterator().next(); } @@ -93,9 +92,9 @@ public class Bug271067 extends AbstractProvisioningTest { installFeature1.setInstallableUnitInclusionRules(helloPatch, PlannerHelper.createOptionalInclusionRule(helloPatch)); installFeature1.setInstallableUnitInclusionRules(patchJar, PlannerHelper.createOptionalInclusionRule(patchJar)); - ProvisioningPlan feature1Plan = createPlanner().getProvisioningPlan(installFeature1, new ProvisioningContext(), null); - assertOK("installation of feature1 and patch", createEngine().perform(getProfile(profileLoadedId), new DefaultPhaseSet(), feature1Plan.getOperands(), new ProvisioningContext(), new NullProgressMonitor())); - assertEquals(1, getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", new Version("1.0.0.1")), new Collector(), new NullProgressMonitor()).size()); + IProvisioningPlan feature1Plan = createPlanner().getProvisioningPlan(installFeature1, new ProvisioningContext(), null); + assertOK("installation of feature1 and patch", createEngine().perform(feature1Plan, new NullProgressMonitor())); + assertEquals(1, queryResultSize(getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor()))); IInstallableUnit featureGroup2 = getIU(repo, "hello.feature.2.feature.group", "1.0.0"); IInstallableUnit helloIU2 = getIU(repo, "hello", "1.0.2"); @@ -107,9 +106,9 @@ public class Bug271067 extends AbstractProvisioningTest { installFeature2.setInstallableUnitInclusionRules(helloIU2, PlannerHelper.createOptionalInclusionRule(helloIU2)); installFeature2.setInstallableUnitInclusionRules(featureJar2, PlannerHelper.createOptionalInclusionRule(featureJar2)); - ProvisioningPlan feature2Plan = createPlanner().getProvisioningPlan(installFeature2, new ProvisioningContext(), null); - assertOK("installation of feature2", createEngine().perform(getProfile(profileLoadedId), new DefaultPhaseSet(), feature2Plan.getOperands(), new ProvisioningContext(), new NullProgressMonitor())); - assertEquals(1, getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", new Version("1.0.0.1")), new Collector(), new NullProgressMonitor()).size()); + IProvisioningPlan feature2Plan = createPlanner().getProvisioningPlan(installFeature2, new ProvisioningContext(), null); + assertOK("installation of feature2", createEngine().perform(feature2Plan, new NullProgressMonitor())); + assertEquals(1, queryResultSize(getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor()))); } public void testInstallFeaturePatchReverseOrder() { @@ -123,9 +122,9 @@ public class Bug271067 extends AbstractProvisioningTest { installFeature2.setInstallableUnitInclusionRules(helloIU2, PlannerHelper.createOptionalInclusionRule(helloIU2)); installFeature2.setInstallableUnitInclusionRules(featureJar2, PlannerHelper.createOptionalInclusionRule(featureJar2)); - ProvisioningPlan feature2Plan = createPlanner().getProvisioningPlan(installFeature2, new ProvisioningContext(), null); - assertOK("installation of feature2", createEngine().perform(getProfile(profileLoadedId), new DefaultPhaseSet(), feature2Plan.getOperands(), new ProvisioningContext(), new NullProgressMonitor())); - assertEquals(1, getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", new Version("1.0.2")), new Collector(), new NullProgressMonitor()).size()); + IProvisioningPlan feature2Plan = createPlanner().getProvisioningPlan(installFeature2, new ProvisioningContext(), null); + assertOK("installation of feature2", createEngine().perform(feature2Plan, new NullProgressMonitor())); + assertEquals(1, queryResultSize(getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", Version.create("1.0.2")), new NullProgressMonitor()))); ProfileChangeRequest installFeature1 = new ProfileChangeRequest(getProfile(profileLoadedId)); IInstallableUnit featureGroup = getIU(repo, "hello.feature.1.feature.group", "1.0.0"); @@ -144,9 +143,9 @@ public class Bug271067 extends AbstractProvisioningTest { installFeature1.setInstallableUnitInclusionRules(helloPatch, PlannerHelper.createOptionalInclusionRule(helloPatch)); installFeature1.setInstallableUnitInclusionRules(patchJar, PlannerHelper.createOptionalInclusionRule(patchJar)); - ProvisioningPlan feature1Plan = createPlanner().getProvisioningPlan(installFeature1, new ProvisioningContext(), null); - assertOK("installation of feature1 and patch", createEngine().perform(getProfile(profileLoadedId), new DefaultPhaseSet(), feature1Plan.getOperands(), new ProvisioningContext(), new NullProgressMonitor())); - assertEquals(1, getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", new Version("1.0.0.1")), new Collector(), new NullProgressMonitor()).size()); + IProvisioningPlan feature1Plan = createPlanner().getProvisioningPlan(installFeature1, new ProvisioningContext(), null); + assertOK("installation of feature1 and patch", createEngine().perform(feature1Plan, new NullProgressMonitor())); + assertEquals(1, queryResultSize(getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor()))); } public void installTogether() { @@ -174,8 +173,8 @@ public class Bug271067 extends AbstractProvisioningTest { installEverything.setInstallableUnitInclusionRules(helloPatch, PlannerHelper.createOptionalInclusionRule(helloPatch)); installEverything.setInstallableUnitInclusionRules(patchJar, PlannerHelper.createOptionalInclusionRule(patchJar)); - ProvisioningPlan plan = createPlanner().getProvisioningPlan(installEverything, new ProvisioningContext(), null); - assertOK("installation of feature1 and patch", createEngine().perform(getProfile(profileLoadedId), new DefaultPhaseSet(), plan.getOperands(), new ProvisioningContext(), new NullProgressMonitor())); - assertEquals(1, getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", new Version("1.0.0.1")), new Collector(), new NullProgressMonitor()).size()); + IProvisioningPlan plan = createPlanner().getProvisioningPlan(installEverything, new ProvisioningContext(), null); + assertOK("installation of feature1 and patch", createEngine().perform(plan, new NullProgressMonitor())); + assertEquals(1, queryResultSize(getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor()))); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271954.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271954.java index 7322e4048..bc4b06f8d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271954.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271954.java @@ -10,22 +10,19 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.lang.reflect.Field; import java.net.URI; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.director.ProvisioningPlan; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -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.p2.engine.*; +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.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestActivator; public class Bug271954 extends AbstractProvisioningTest { private static final String profileLoadedId = "SDKProfile"; @@ -39,7 +36,7 @@ public class Bug271954 extends AbstractProvisioningTest { File tempFolder = getTempFolder(); copy("0.2", reporegistry1, tempFolder); - SimpleProfileRegistry realProfileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + SimpleProfileRegistry realProfileRegistry = (SimpleProfileRegistry) getProfileRegistry(); //Tweak the running profile registry Field profileStore = SimpleProfileRegistry.class.getDeclaredField("store"); profileStore.setAccessible(true); @@ -60,7 +57,7 @@ public class Bug271954 extends AbstractProvisioningTest { } protected void tearDown() throws Exception { - SimpleProfileRegistry realProfileRegistry = (SimpleProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + SimpleProfileRegistry realProfileRegistry = (SimpleProfileRegistry) getProfileRegistry(); Field profilesMapField = SimpleProfileRegistry.class.getDeclaredField("profiles"); //$NON-NLS-1$ profilesMapField.setAccessible(true); @@ -78,20 +75,20 @@ public class Bug271954 extends AbstractProvisioningTest { } public void testUninstallMyBundle() { - Collector c = profile.available(new InstallableUnitQuery("A"), new Collector(), new NullProgressMonitor()); - assertEquals(1, c.size()); + IQueryResult c = profile.available(new InstallableUnitQuery("A"), new NullProgressMonitor()); + assertEquals(1, queryResultSize(c)); ProfileChangeRequest req = new ProfileChangeRequest(profile); req.removeInstallableUnits((IInstallableUnit[]) c.toArray(IInstallableUnit.class)); ProvisioningContext ctx = new ProvisioningContext(new URI[0]); ctx.setArtifactRepositories(new URI[0]); - ProvisioningPlan plan = createPlanner().getProvisioningPlan(req, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = createPlanner().getProvisioningPlan(req, ctx, new NullProgressMonitor()); assertOK("Uninstall plan for myBundle", plan.getStatus()); - assertEquals(0, plan.getInstallerPlan().getAdditions().query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); - assertEquals(0, plan.getInstallerPlan().getRemovals().query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + assertEquals(0, queryResultSize(plan.getInstallerPlan().getAdditions().query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); + assertEquals(0, queryResultSize(plan.getInstallerPlan().getRemovals().query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); assertUninstallOperand(plan, (IInstallableUnit) c.iterator().next()); - assertEquals(2, plan.getRemovals().query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); - assertEquals(1, plan.getRemovals().query(new InstallableUnitQuery("A", new Version(1, 0, 0)), new Collector(), new NullProgressMonitor()).size()); - assertEquals(1, plan.getRemovals().query(new InstallableUnitQuery("Action1", new Version(1, 0, 0)), new Collector(), new NullProgressMonitor()).size()); + assertEquals(2, queryResultSize(plan.getRemovals().query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); + assertEquals(1, queryResultSize(plan.getRemovals().query(new InstallableUnitQuery("A", Version.createOSGi(1, 0, 0)), new NullProgressMonitor()))); + assertEquals(1, queryResultSize(plan.getRemovals().query(new InstallableUnitQuery("Action1", Version.createOSGi(1, 0, 0)), new NullProgressMonitor()))); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug272251.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug272251.java index 5e8abb9e0..188664c4e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug272251.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug272251.java @@ -10,17 +10,18 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -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.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +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.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class Bug272251 extends AbstractProvisioningTest { @@ -45,16 +46,16 @@ public class Bug272251 extends AbstractProvisioningTest { } public void testInstallFeaturePatch() { - Collector c = repo.query(new InstallableUnitQuery("org.eclipse.wst.jsdt.feature.patch.feature.group", new Version("3.0.4.v200904020304-1-8d7w311_15131415")), new Collector(), new NullProgressMonitor()); - assertEquals(1, c.size()); - Collector expectedIU = repo.query(new InstallableUnitQuery("org.eclipse.wst.jsdt.web.ui", new Version("1.0.105.v200904020304")), new Collector(), new NullProgressMonitor()); - assertEquals(1, expectedIU.size()); + IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.wst.jsdt.feature.patch.feature.group", Version.create("3.0.4.v200904020304-1-8d7w311_15131415")), new NullProgressMonitor()); + assertEquals(1, queryResultSize(c)); + IQueryResult expectedIU = repo.query(new InstallableUnitQuery("org.eclipse.wst.jsdt.web.ui", Version.create("1.0.105.v200904020304")), new NullProgressMonitor()); + assertEquals(1, queryResultSize(expectedIU)); IInstallableUnit patch = (IInstallableUnit) c.iterator().next(); ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {patch}); request.setInstallableUnitInclusionRules(patch, PlannerHelper.createStrictInclusionRule(patch)); IPlanner planner = createPlanner(); - ProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); assertOK("Plan OK", plan.getStatus()); assertNoOperand(plan, patch); assertNoOperand(plan, (IInstallableUnit) expectedIU.iterator().next()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug278668.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug278668.java index 225ab7748..aa12a06d6 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug278668.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug278668.java @@ -1,14 +1,20 @@ package org.eclipse.equinox.p2.tests.planner; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; + import java.util.ArrayList; import java.util.Properties; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IProvidedCapability; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class Bug278668 extends AbstractProvisioningTest { @@ -48,10 +54,10 @@ public class Bug278668 extends AbstractProvisioningTest { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {group}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertOK("plan should be OK", plan.getStatus()); - engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); repo = getMetadataRepositoryManager().loadRepository(getTestData("test data bug 278668", "testData/bug278668").toURI(), null); } @@ -62,27 +68,27 @@ public class Bug278668 extends AbstractProvisioningTest { } public void testInstallFeaturePatch() { - Collector c = repo.query(new InstallableUnitQuery("com.borland.tg.modeling.8.2.0.hotfixexp.patch.feature.group"), new Collector(), new NullProgressMonitor()); - assertEquals(1, c.size()); - Collector c2 = repo.query(new InstallableUnitQuery("com.borland.tg.modeling.8.2.0.nl.patch.feature.group"), new Collector(), new NullProgressMonitor()); - assertEquals(1, c2.size()); + IQueryResult c = repo.query(new InstallableUnitQuery("com.borland.tg.modeling.8.2.0.hotfixexp.patch.feature.group"), new NullProgressMonitor()); + assertEquals(1, queryResultSize(c)); + IQueryResult c2 = repo.query(new InstallableUnitQuery("com.borland.tg.modeling.8.2.0.nl.patch.feature.group"), new NullProgressMonitor()); + assertEquals(1, queryResultSize(c2)); ProfileChangeRequest request = new ProfileChangeRequest(profile); request.addInstallableUnits(new IInstallableUnit[] {(IInstallableUnit) c.iterator().next()}); IPlanner planner = createPlanner(); - ProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); assertOK("Plan OK", plan.getStatus()); ProfileChangeRequest request2 = new ProfileChangeRequest(profile); request2.addInstallableUnits(new IInstallableUnit[] {(IInstallableUnit) c2.iterator().next()}); IPlanner planner2 = createPlanner(); - ProvisioningPlan plan2 = planner2.getProvisioningPlan(request2, null, new NullProgressMonitor()); + IProvisioningPlan plan2 = planner2.getProvisioningPlan(request2, null, new NullProgressMonitor()); assertOK("Plan OK", plan2.getStatus()); ProfileChangeRequest request3 = new ProfileChangeRequest(profile); request3.addInstallableUnits(new IInstallableUnit[] {(IInstallableUnit) c.iterator().next(), (IInstallableUnit) c2.iterator().next()}); IPlanner planner3 = createPlanner(); - ProvisioningPlan plan3 = planner3.getProvisioningPlan(request3, null, new NullProgressMonitor()); + IProvisioningPlan plan3 = planner3.getProvisioningPlan(request3, null, new NullProgressMonitor()); assertNotOK("Plan Not OK", plan3.getStatus()); ProfileChangeRequest request4 = new ProfileChangeRequest(profile); @@ -90,7 +96,7 @@ public class Bug278668 extends AbstractProvisioningTest { request4.setInstallableUnitInclusionRules((IInstallableUnit) c.iterator().next(), PlannerHelper.createOptionalInclusionRule((IInstallableUnit) c.iterator().next())); request4.setInstallableUnitInclusionRules((IInstallableUnit) c2.iterator().next(), PlannerHelper.createOptionalInclusionRule((IInstallableUnit) c2.iterator().next())); IPlanner planner4 = createPlanner(); - ProvisioningPlan plan4 = planner4.getProvisioningPlan(request4, null, new NullProgressMonitor()); + IProvisioningPlan plan4 = planner4.getProvisioningPlan(request4, null, new NullProgressMonitor()); assertOK("Plan OK", plan4.getStatus()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DependencyOnSelf.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DependencyOnSelf.java index c6e326f90..7edb4168f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DependencyOnSelf.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DependencyOnSelf.java @@ -10,14 +10,14 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class DependencyOnSelf extends AbstractProvisioningTest { @@ -28,7 +28,7 @@ public class DependencyOnSelf extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null)); + a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"))); createTestMetdataRepository(new IInstallableUnit[] {a1}); profile = createProfile(DependencyOnSelf.class.getName()); planner = createPlanner(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DisabledExplanation.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DisabledExplanation.java index a41319a2e..630e7d807 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DisabledExplanation.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DisabledExplanation.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class DisabledExplanation extends AbstractProvisioningTest { @@ -28,12 +30,12 @@ public class DisabledExplanation extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); //Missing non optional dependency IRequiredCapability[] req = new IRequiredCapability[1]; req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, false, false, true); - b1 = createIU("B", new Version("1.0.0"), req); + b1 = createIU("B", Version.create("1.0.0"), req); createTestMetdataRepository(new IInstallableUnit[] {a1, b1}); @@ -46,7 +48,7 @@ public class DisabledExplanation extends AbstractProvisioningTest { req.addInstallableUnits(new IInstallableUnit[] {a1, b1}); ProvisioningContext ctx = new ProvisioningContext(); ctx.setProperty("org.eclipse.equinox.p2.director.explain", "false"); - ProvisioningPlan plan = planner.getProvisioningPlan(req, ctx, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(req, ctx, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); assertNull(plan.getRequestStatus()); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DropinsScenario.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DropinsScenario.java index 1db12523d..59cfa193d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DropinsScenario.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DropinsScenario.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class DropinsScenario extends AbstractProvisioningTest { @@ -29,18 +33,18 @@ public class DropinsScenario extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); - b1 = createIU("B", new Version("1.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); - a0 = createIU("A", new Version("0.0.0"), true); - b0 = createIU("B", new Version("0.0.0"), true); + a0 = createIU("A", Version.create("0.0.0"), true); + b0 = createIU("B", Version.create("0.0.0"), true); IRequiredCapability[] reqAs = new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[0.0.0, 1.0.0]"), null, false, false, true)}; - as = createIU("AS", new Version("0.0.0"), reqAs); + as = createIU("AS", Version.create("0.0.0"), reqAs); IRequiredCapability[] reqBs = new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[0.0.0, 1.0.0]"), null, false, false, true)}; - bs = createIU("BS", new Version("0.0.0"), reqBs); + bs = createIU("BS", Version.create("0.0.0"), reqBs); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, a0, b0, as, bs}); @@ -51,7 +55,7 @@ public class DropinsScenario extends AbstractProvisioningTest { public void testInstallation() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {as, bs}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationDeepConflict.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationDeepConflict.java index 8d566fca8..72090cd34 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationDeepConflict.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationDeepConflict.java @@ -10,12 +10,12 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class ExplanationDeepConflict extends AbstractProvisioningTest { @@ -27,9 +27,9 @@ public class ExplanationDeepConflict extends AbstractProvisioningTest { @Override protected void setUp() throws Exception { super.setUp(); - sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"), null)); - IInstallableUnit sdkPart = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "InnerSDKPart", new VersionRange("[1.0.0, 1.0.0]"), null)); - IInstallableUnit innerSdkPart = createIU("InnerSDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "InnerInnerSDKPart", new VersionRange("[1.0.0, 1.0.0]"), null)); + sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"))); + IInstallableUnit sdkPart = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "InnerSDKPart", new VersionRange("[1.0.0, 1.0.0]"))); + IInstallableUnit innerSdkPart = createIU("InnerSDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "InnerInnerSDKPart", new VersionRange("[1.0.0, 1.0.0]"))); IInstallableUnit innerInnerSDKPart = createIU("InnerInnerSDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true); createTestMetdataRepository(new IInstallableUnit[] {sdk, sdkPart, innerSdkPart, innerInnerSDKPart}); @@ -40,25 +40,26 @@ public class ExplanationDeepConflict extends AbstractProvisioningTest { ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] {sdk}); - engine.perform(profile, new DefaultPhaseSet(), planner.getProvisioningPlan(pcr, null, null).getOperands(), null, null); + engine.perform(planner.getProvisioningPlan(pcr, null, null), null); assertProfileContains("1.0", profile, new IInstallableUnit[] {sdk, sdkPart, innerSdkPart, innerInnerSDKPart}); } public void testDeepSingletonConflict() { //CDT will have a singleton conflict with SDK - IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "CDTPart", new VersionRange("[1.0.0, 1.0.0]"), null)); - IInstallableUnit cdtPart = createIU("CDTPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "InnerInnerSDKPart", new VersionRange("[2.0.0, 2.0.0]"), null)); + IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "CDTPart", new VersionRange("[1.0.0, 1.0.0]"))); + IInstallableUnit cdtPart = createIU("CDTPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "InnerInnerSDKPart", new VersionRange("[2.0.0, 2.0.0]"))); IInstallableUnit innerInnerSDKPart2 = createIU("InnerInnerSDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("2.0.0")), true); createTestMetdataRepository(new IInstallableUnit[] {cdt, cdtPart, innerInnerSDKPart2}); ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] {cdt}); - ProvisioningPlan plan = planner.getProvisioningPlan(pcr, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(pcr, null, null); // System.out.println(plan.getRequestStatus().getExplanations()); - assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(cdt)); + RequestStatus requestStatus = (RequestStatus) plan.getRequestStatus(); + assertTrue(requestStatus.getConflictsWithInstalledRoots().contains(cdt)); //Here we verify that we only return the roots we asked the installation of. The SDK is installable since it is already installed - assertFalse(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(sdk)); - assertTrue(plan.getRequestStatus().getConflictsWithAnyRoots().contains(sdk)); + assertFalse(requestStatus.getConflictsWithInstalledRoots().contains(sdk)); + assertTrue(requestStatus.getConflictsWithAnyRoots().contains(sdk)); // assertTrue(plan.getRequestStatus(cdt).getConflictsWithAnyRoots().contains(sdk)); // assertTrue(plan.getRequestStatus(cdt).getConflictsWithInstalledRoots().contains(sdk)); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForOptionalDependencies.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForOptionalDependencies.java index c87a9b46b..a7aa0e159 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForOptionalDependencies.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForOptionalDependencies.java @@ -10,12 +10,14 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class ExplanationForOptionalDependencies extends AbstractProvisioningTest { @@ -27,7 +29,7 @@ public class ExplanationForOptionalDependencies extends AbstractProvisioningTest @Override protected void setUp() throws Exception { super.setUp(); - sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"), null)); + sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"))); IInstallableUnit sdkPart = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true); IInstallableUnit sdkPart2 = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("2.0.0")), true); @@ -39,7 +41,7 @@ public class ExplanationForOptionalDependencies extends AbstractProvisioningTest ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] {sdk}); - engine.perform(profile, new DefaultPhaseSet(), planner.getProvisioningPlan(pcr, null, null).getOperands(), null, null); + engine.perform(planner.getProvisioningPlan(pcr, null, null), null); } @@ -55,10 +57,11 @@ public class ExplanationForOptionalDependencies extends AbstractProvisioningTest createTestMetdataRepository(new IInstallableUnit[] {cdt, emf}); ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] {cdt, emf}); - ProvisioningPlan plan = planner.getProvisioningPlan(pcr, null, null); - assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(emf)); - assertFalse(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(cdt)); - assertFalse(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(sdk)); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(pcr, null, null); + RequestStatus requestStatus = (RequestStatus) plan.getRequestStatus(); + assertTrue(requestStatus.getConflictsWithInstalledRoots().contains(emf)); + assertFalse(requestStatus.getConflictsWithInstalledRoots().contains(cdt)); + assertFalse(requestStatus.getConflictsWithInstalledRoots().contains(sdk)); // assertTrue(plan.getRequestStatus(cdt).getSeverity() != IStatus.ERROR); // diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForPartialInstallation.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForPartialInstallation.java index 2fc286a9d..0addc22a9 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForPartialInstallation.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForPartialInstallation.java @@ -10,12 +10,12 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class ExplanationForPartialInstallation extends AbstractProvisioningTest { @@ -27,7 +27,7 @@ public class ExplanationForPartialInstallation extends AbstractProvisioningTest @Override protected void setUp() throws Exception { super.setUp(); - sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"), null)); + sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"))); IInstallableUnit sdkPart = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true); IInstallableUnit sdkPart2 = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("2.0.0")), true); @@ -39,25 +39,26 @@ public class ExplanationForPartialInstallation extends AbstractProvisioningTest ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] {sdk}); - engine.perform(profile, new DefaultPhaseSet(), planner.getProvisioningPlan(pcr, null, null).getOperands(), null, null); + engine.perform(planner.getProvisioningPlan(pcr, null, null), null); } public void testPartialProblemSingleton() { //CDT will have a singleton conflict with SDK //EMF will be good - IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[2.0.0, 2.0.0]"), null)); + IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[2.0.0, 2.0.0]"))); IInstallableUnit emf = createIU("EMF", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true); createTestMetdataRepository(new IInstallableUnit[] {cdt, emf}); ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] {cdt, emf}); - ProvisioningPlan plan = planner.getProvisioningPlan(pcr, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(pcr, null, null); // System.out.println(plan.getRequestStatus().getExplanations()); - assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(cdt)); - assertFalse(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(emf)); - assertFalse(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(sdk)); + RequestStatus requestStatus = (RequestStatus) plan.getRequestStatus(); + assertTrue(requestStatus.getConflictsWithInstalledRoots().contains(cdt)); + assertFalse(requestStatus.getConflictsWithInstalledRoots().contains(emf)); + assertFalse(requestStatus.getConflictsWithInstalledRoots().contains(sdk)); // assertTrue(plan.getRequestStatus(cdt).getSeverity() == IStatus.ERROR); // assertTrue(plan.getRequestStatus(cdt).getConflictsWithAnyRoots().contains(sdk)); @@ -73,18 +74,19 @@ public class ExplanationForPartialInstallation extends AbstractProvisioningTest public void testPartialProblemRequirement() { //CDT will be missing a requirement //EMF will be good - IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "MissingPart", new VersionRange("[2.0.0, 2.0.0]"), null)); + IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "MissingPart", new VersionRange("[2.0.0, 2.0.0]"))); IInstallableUnit emf = createIU("EMF", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true); createTestMetdataRepository(new IInstallableUnit[] {cdt, emf}); ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] {cdt, emf}); - ProvisioningPlan plan = planner.getProvisioningPlan(pcr, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(pcr, null, null); // System.out.println(plan.getRequestStatus().getExplanations()); - assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(cdt)); - assertFalse(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(emf)); - assertFalse(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(sdk)); + RequestStatus requestStatus = (RequestStatus) plan.getRequestStatus(); + assertTrue(requestStatus.getConflictsWithInstalledRoots().contains(cdt)); + assertFalse(requestStatus.getConflictsWithInstalledRoots().contains(emf)); + assertFalse(requestStatus.getConflictsWithInstalledRoots().contains(sdk)); // assertTrue(plan.getRequestStatus(cdt).getSeverity() == IStatus.ERROR); // assertEquals(0, plan.getRequestStatus(cdt).getConflictsWithAnyRoots().size()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationLargeConflict.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationLargeConflict.java index 3ab52200b..4d4fa7477 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationLargeConflict.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationLargeConflict.java @@ -10,19 +10,18 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - import java.io.File; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability; -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.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class ExplanationLargeConflict extends AbstractProvisioningTest { @@ -50,19 +49,19 @@ public class ExplanationLargeConflict extends AbstractProvisioningTest { long sTime = System.currentTimeMillis(); //Here we verify that two version of JDT can't be installed together. The SDKProfile is not used IProfile profile = createProfile("TestProfile." + getName()); - Collector c = repo1.query(new InstallableUnitQuery("org.eclipse.jdt.feature.group"), new Collector(), null); - assertEquals(1, c.size()); + IQueryResult c = repo1.query(new InstallableUnitQuery("org.eclipse.jdt.feature.group"), null); + assertEquals(1, queryResultSize(c)); IInstallableUnit jdt1 = (IInstallableUnit) c.iterator().next(); - Collector c2 = repo2.query(new InstallableUnitQuery("org.eclipse.jdt.feature.group"), new Collector(), null); - assertEquals(1, c2.size()); + IQueryResult c2 = repo2.query(new InstallableUnitQuery("org.eclipse.jdt.feature.group"), null); + assertEquals(1, queryResultSize(c2)); IInstallableUnit jdt2 = (IInstallableUnit) c2.iterator().next(); assertNotSame(jdt1, jdt2); ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] {jdt1, jdt2}); - ProvisioningPlan plan = planner.getProvisioningPlan(pcr, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(pcr, null, null); assertNotOK(plan.getStatus()); LogHelper.log(plan.getStatus()); // System.out.println(plan.getRequestStatus().getExplanations()); @@ -73,11 +72,11 @@ public class ExplanationLargeConflict extends AbstractProvisioningTest { public void testMissingRequirement() { long sTime = System.currentTimeMillis(); //Test the case of a missing requirement in the IU being installed - IRequiredCapability[] cap = createRequiredCapabilities("missing", "missing", new VersionRange("[0.0.0, 1.0.0)"), null); - IInstallableUnit otherIU2 = createIU("foo", new Version("0.9.0"), null, cap, BUNDLE_CAPABILITY, NO_PROPERTIES, TOUCHPOINT_OSGI, NO_TP_DATA, true); + IRequiredCapability[] cap = createRequiredCapabilities("missing", "missing", new VersionRange("[0.0.0, 1.0.0)")); + IInstallableUnit otherIU2 = createIU("foo", Version.create("0.9.0"), null, cap, BUNDLE_CAPABILITY, NO_PROPERTIES, TOUCHPOINT_OSGI, NO_TP_DATA, true); ProfileChangeRequest pcr3 = new ProfileChangeRequest(SDKprofile); pcr3.addInstallableUnits(new IInstallableUnit[] {otherIU2}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(pcr3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(pcr3, null, null); assertNotOK(plan3.getStatus()); LogHelper.log(plan3.getStatus()); // System.out.println(plan3.getRequestStatus().getExplanations()); @@ -88,10 +87,10 @@ public class ExplanationLargeConflict extends AbstractProvisioningTest { public void testSingletonConflict() { long sTime = System.currentTimeMillis(); //The IU being installed conflict with something already installed because of a singleton - IInstallableUnit otherIU = createIU("org.eclipse.equinox.p2.director", new Version("0.9.0"), null, NO_REQUIRES, BUNDLE_CAPABILITY, NO_PROPERTIES, TOUCHPOINT_OSGI, NO_TP_DATA, true); + IInstallableUnit otherIU = createIU("org.eclipse.equinox.p2.director", Version.create("0.9.0"), null, NO_REQUIRES, BUNDLE_CAPABILITY, NO_PROPERTIES, TOUCHPOINT_OSGI, NO_TP_DATA, true); ProfileChangeRequest pcr2 = new ProfileChangeRequest(SDKprofile); pcr2.addInstallableUnits(new IInstallableUnit[] {otherIU}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(pcr2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(pcr2, null, null); assertNotOK(plan2.getStatus()); LogHelper.log(plan2.getStatus()); // System.out.println(plan2.getRequestStatus().getExplanations()); @@ -102,13 +101,13 @@ public class ExplanationLargeConflict extends AbstractProvisioningTest { public void testExplanationLargeConflictInSDK() { long sTime = System.currentTimeMillis(); //Test large conflict. We are trying to install an inappropriate version of CVS over the already installed SDK - Collector c = repo2.query(new InstallableUnitQuery("org.eclipse.cvs.feature.group"), new Collector(), null); - assertEquals(1, c.size()); + IQueryResult c = repo2.query(new InstallableUnitQuery("org.eclipse.cvs.feature.group"), null); + assertEquals(1, queryResultSize(c)); IInstallableUnit cvs = (IInstallableUnit) c.iterator().next(); ProfileChangeRequest pcr = new ProfileChangeRequest(SDKprofile); pcr.addInstallableUnits(new IInstallableUnit[] {cvs}); - ProvisioningPlan plan = planner.getProvisioningPlan(pcr, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(pcr, null, null); assertNotOK(plan.getStatus()); LogHelper.log(plan.getStatus()); // System.out.println(plan.getRequestStatus().getExplanations()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationSeveralConflictingRoots.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationSeveralConflictingRoots.java index 664b1c819..39f734da3 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationSeveralConflictingRoots.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationSeveralConflictingRoots.java @@ -10,13 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Set; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class ExplanationSeveralConflictingRoots extends AbstractProvisioningTest { @@ -27,7 +29,7 @@ public class ExplanationSeveralConflictingRoots extends AbstractProvisioningTest @Override protected void setUp() throws Exception { super.setUp(); - sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"), null)); + sdk = createIU("SDK", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"))); IInstallableUnit sdkPart = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true); IInstallableUnit sdkPart2 = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("2.0.0")), true); @@ -39,23 +41,23 @@ public class ExplanationSeveralConflictingRoots extends AbstractProvisioningTest ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] {sdk}); - engine.perform(profile, new DefaultPhaseSet(), planner.getProvisioningPlan(pcr, null, null).getOperands(), null, null); + engine.perform(planner.getProvisioningPlan(pcr, null, null), null); } public void testConflictingSingletonAndMissingDependency() { //CDT will have a singleton conflict with SDK //EMF will be missing a dependency - IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[2.0.0, 2.0.0]"), null)); + IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[2.0.0, 2.0.0]"))); - IInstallableUnit emf = createIU("EMF", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "EMFPart", new VersionRange("[1.0.0, 1.0.0]"), null)); + IInstallableUnit emf = createIU("EMF", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "EMFPart", new VersionRange("[1.0.0, 1.0.0]"))); createTestMetdataRepository(new IInstallableUnit[] {cdt, emf}); ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] {cdt, emf}); - ProvisioningPlan plan = planner.getProvisioningPlan(pcr, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(pcr, null, null); // System.out.println(plan.getRequestStatus().getExplanations()); - Set conflictRoots = plan.getRequestStatus().getConflictsWithInstalledRoots(); + Set conflictRoots = ((RequestStatus) plan.getRequestStatus()).getConflictsWithInstalledRoots(); assertTrue(conflictRoots.contains(cdt) || conflictRoots.contains(emf)); // assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(emf)); @@ -68,7 +70,7 @@ public class ExplanationSeveralConflictingRoots extends AbstractProvisioningTest public void testConflictingSingletonAndMissingDependency2() { //CDT will have a singleton conflict EMF //EMF will be missing a dependency and will be in conflict with CDT - IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "ASingleton", new VersionRange("[2.0.0, 2.0.0]"), null)); + IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "ASingleton", new VersionRange("[2.0.0, 2.0.0]"))); IInstallableUnit aSingleton1 = createIU("ASingleton", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), true); IInstallableUnit aSingleton2 = createIU("ASingleton", Version.fromOSGiVersion(new org.osgi.framework.Version("2.0.0")), true); @@ -79,9 +81,9 @@ public class ExplanationSeveralConflictingRoots extends AbstractProvisioningTest createTestMetdataRepository(new IInstallableUnit[] {aSingleton1, aSingleton2, cdt, emf}); ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] {cdt, emf}); - ProvisioningPlan plan = planner.getProvisioningPlan(pcr, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(pcr, null, null); // System.out.println(plan.getRequestStatus().getExplanations()); - Set conflictRoots = plan.getRequestStatus().getConflictsWithInstalledRoots(); + Set conflictRoots = ((RequestStatus) plan.getRequestStatus()).getConflictsWithInstalledRoots(); assertTrue(conflictRoots.contains(cdt) || conflictRoots.contains(emf)); // assertEquals(0, plan.getRequestStatus(cdt).getConflictsWithInstalledRoots().size()); @@ -93,7 +95,7 @@ public class ExplanationSeveralConflictingRoots extends AbstractProvisioningTest public void testConflictingSingletonAndMissingDependency3() { //CDT will have a singleton conflict EMF and with the SDK //EMF will be conflicting with CDT - IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[2.0.0, 2.0.0]"), null)); + IInstallableUnit cdt = createIU("CDT", Version.fromOSGiVersion(new org.osgi.framework.Version("1.0.0")), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[2.0.0, 2.0.0]"))); IInstallableUnit sdkPart3 = createIU("SDKPart", Version.fromOSGiVersion(new org.osgi.framework.Version("3.0.0")), true); IRequiredCapability emfOnSingleton = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "SDKPart", new VersionRange("[1.0.0, 1.0.0]"), null, false, false); @@ -103,9 +105,9 @@ public class ExplanationSeveralConflictingRoots extends AbstractProvisioningTest createTestMetdataRepository(new IInstallableUnit[] {sdkPart3, cdt, emf}); ProfileChangeRequest pcr = new ProfileChangeRequest(profile); pcr.addInstallableUnits(new IInstallableUnit[] {cdt, emf}); - ProvisioningPlan plan = planner.getProvisioningPlan(pcr, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(pcr, null, null); // System.out.println(plan.getRequestStatus().getExplanations()); - Set conflictRoots = plan.getRequestStatus().getConflictsWithInstalledRoots(); + Set conflictRoots = ((RequestStatus) plan.getRequestStatus()).getConflictsWithInstalledRoots(); assertTrue(conflictRoots.contains(cdt) || conflictRoots.contains(emf)); // assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(cdt)); // assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(emf)); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/FindingPatchesThroughUpdates.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/FindingPatchesThroughUpdates.java index 01229c6b8..c7f0db941 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/FindingPatchesThroughUpdates.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/FindingPatchesThroughUpdates.java @@ -10,19 +10,22 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; +import java.util.Properties; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class FindingPatchesThroughUpdates extends AbstractProvisioningTest { IInstallableUnit a1; IInstallableUnit a120; - IInstallableUnitPatch patchA1, patchA2; + IInstallableUnitPatch patchA1, patchA2, anotherPatch2, anotherPatch3; IProfile profile1; IPlanner planner; @@ -30,24 +33,29 @@ public class FindingPatchesThroughUpdates extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0")); + a1 = createIU("A", Version.create("1.0.0")); IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor("A", new VersionRange("[1.0.0, 1.0.0]"), 0, "update description"); - a120 = createIU("UpdateA", new Version(1, 2, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES); + a120 = createIU("UpdateA", Version.createOSGi(1, 2, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequiredCapability lifeCycle = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.2.0]"), null, false, false); - patchA1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle); + patchA1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle); IRequirementChange change2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequiredCapability lifeCycle2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 3.2.0]"), null, false, false); - patchA2 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change2}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle2); + patchA2 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change2}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle2); - createTestMetdataRepository(new IInstallableUnit[] {a1, a120, patchA1, patchA2}); + IRequirementChange change3 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); + IRequiredCapability lifeCycle3 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 3.2.0]"), null, false, false); + anotherPatch2 = createIUPatch("ANOTHERPATCH", Version.create("1.0.0"), true, new IRequirementChange[] {change3}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle3); + + IRequirementChange change4 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); + IRequiredCapability lifeCycle4 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 3.2.0]"), null, false, false); + anotherPatch3 = createIUPatch("ANOTHERPATCH", Version.create("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, new Properties(), null, null, true, MetadataFactory.createUpdateDescriptor("ANOTHERPATCH", new VersionRange("[1.0.0, 1.0.0]"), 0, ""), new IRequirementChange[] {change4}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, lifeCycle4, NO_REQUIRES); + + createTestMetdataRepository(new IInstallableUnit[] {a1, a120, patchA1, patchA2, anotherPatch2, anotherPatch3}); - profile1 = createProfile("TestProfile." + getName()); planner = createPlanner(); - engine = createEngine(); - install(profile1, new IInstallableUnit[] {a1}, true, planner, engine); } public void testInstall() { @@ -55,4 +63,10 @@ public class FindingPatchesThroughUpdates extends AbstractProvisioningTest { assertEquals(2, updates.length); assertEquals("Checking updates", new IInstallableUnit[] {a120, patchA1}, updates, false); } + + public void testFindUpdatesOfPatches() { + IInstallableUnit[] updates = planner.updatesFor(anotherPatch2, new ProvisioningContext(), new NullProgressMonitor()); + assertEquals(1, updates.length); + assertEquals("Checking updates", new IInstallableUnit[] {anotherPatch3}, updates, false); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/GreedyRequirement.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/GreedyRequirement.java index b76fcaddd..8ef1e4dd7 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/GreedyRequirement.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/GreedyRequirement.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class GreedyRequirement extends AbstractProvisioningTest { @@ -26,15 +30,15 @@ public class GreedyRequirement extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - b1 = createIU("B", new Version("1.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); IRequiredCapability[] reqB = new IRequiredCapability[1]; reqB[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, true, false, false); - a1 = createIU("A", new Version("1.0.0"), reqB); + a1 = createIU("A", Version.create("1.0.0"), reqB); IRequiredCapability[] reqC = new IRequiredCapability[1]; reqC[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, true); - c1 = createIU("C", new Version("1.0.0"), reqC); + c1 = createIU("C", Version.create("1.0.0"), reqC); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, c1}); @@ -46,7 +50,7 @@ public class GreedyRequirement extends AbstractProvisioningTest { //The plan contains B because the requirement from A on B is non greedy, but we are installing C that has a greedy requirement on the B ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1, c1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); assertInstallOperand(plan, b1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUProperties.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUProperties.java index ca7ef1cde..091cc8fc2 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUProperties.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUProperties.java @@ -8,15 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -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.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class IUProperties extends AbstractProvisioningTest { @@ -31,13 +33,13 @@ public class IUProperties extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)"), null)); + a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)"))); - b1 = createIU("B1", new Version("1.0.0"), true); + b1 = createIU("B1", Version.create("1.0.0"), true); - b11 = createIU("B1", new Version("1.1.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 3.0.0)"), null), NO_PROPERTIES, true); + b11 = createIU("B1", Version.create("1.1.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 3.0.0)")), NO_PROPERTIES, true); - c = createIU("C", new Version(2, 0, 0), true); + c = createIU("C", Version.createOSGi(2, 0, 0), true); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b11, c}); @@ -53,17 +55,17 @@ public class IUProperties extends AbstractProvisioningTest { req1.addInstallableUnits(new IInstallableUnit[] {a1}); req1.setInstallableUnitProfileProperty(a1, "FOO", "BAR"); req1.setInstallableUnitProfileProperty(b1, "FOO", "BAR"); - ProvisioningPlan pp1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan pp1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.OK, pp1.getStatus().getSeverity()); - IStatus s = engine.perform(profile, new DefaultPhaseSet(), pp1.getOperands(), null, null); + IStatus s = engine.perform(pp1, null); if (!s.isOK()) LogHelper.log(s); - Collector collector = getProfile(profileId).query(new IUProfilePropertyQuery("FOO", null), new Collector(), null); - assertEquals(1, collector.size()); + IQueryResult queryResult = getProfile(profileId).query(new IUProfilePropertyQuery("FOO", null), null); + assertEquals(1, queryResultSize(queryResult)); ProfileChangeRequest req2 = new ProfileChangeRequest(profile); req2.removeInstallableUnitProfileProperty(b1, "FOO"); - ProvisioningPlan pp2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan pp2 = planner.getProvisioningPlan(req2, null, null); assertEquals(0, pp2.getOperands().length); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUPropertyRemoval.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUPropertyRemoval.java index 1bebfbb3a..814ae8c98 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUPropertyRemoval.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUPropertyRemoval.java @@ -8,14 +8,16 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -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.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class IUPropertyRemoval extends AbstractProvisioningTest { @@ -28,9 +30,9 @@ public class IUPropertyRemoval extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)"), null)); + a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)"))); - b1 = createIU("B1", new Version("1.0.0"), true); + b1 = createIU("B1", Version.create("1.0.0"), true); createTestMetdataRepository(new IInstallableUnit[] {a1, b1}); @@ -46,18 +48,18 @@ public class IUPropertyRemoval extends AbstractProvisioningTest { req1.addInstallableUnits(new IInstallableUnit[] {a1}); req1.setInstallableUnitProfileProperty(a1, "FOO", "BAR"); req1.setInstallableUnitProfileProperty(b1, "FOO", "BAR"); - ProvisioningPlan pp1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan pp1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.OK, pp1.getStatus().getSeverity()); - engine.perform(profile, new DefaultPhaseSet(), pp1.getOperands(), null, null); - Collector res = getProfile(profileId).query(new IUProfilePropertyQuery("FOO", null), new Collector(), null); - assertEquals(2, res.size()); + engine.perform(pp1, null); + IQueryResult res = getProfile(profileId).query(new IUProfilePropertyQuery("FOO", null), null); + assertEquals(2, queryResultSize(res)); ProfileChangeRequest req2 = new ProfileChangeRequest(profile); req2.removeInstallableUnitProfileProperty(b1, "FOO"); - ProvisioningPlan pp2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan pp2 = planner.getProvisioningPlan(req2, null, null); assertEquals(1, pp2.getOperands().length); - engine.perform(getProfile(profileId), new DefaultPhaseSet(), pp2.getOperands(), null, null); - Collector res2 = getProfile(profileId).query(new IUProfilePropertyQuery("FOO", null), new Collector(), null); - assertEquals(1, res2.size()); + engine.perform(pp2, null); + IQueryResult res2 = getProfile(profileId).query(new IUProfilePropertyQuery("FOO", null), null); + assertEquals(1, queryResultSize(res2)); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter.java index 393c59923..83e7701a4 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter.java @@ -10,15 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class IUWithFilter extends AbstractProvisioningTest { @@ -31,8 +31,8 @@ public class IUWithFilter extends AbstractProvisioningTest { super.setUp(); MetadataFactory.InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription(); iud.setId("A"); - iud.setVersion(new Version("1.0.0")); - iud.setRequiredCapabilities(createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null)); + iud.setVersion(Version.create("1.0.0")); + iud.setRequiredCapabilities(createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"))); iud.setFilter("(invalid=true)"); a1 = MetadataFactory.createInstallableUnit(iud); createTestMetdataRepository(new IInstallableUnit[] {a1}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter2.java index 4ae4a8a95..566a982ba 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter2.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class IUWithFilter2 extends AbstractProvisioningTest { @@ -37,7 +39,7 @@ public class IUWithFilter2 extends AbstractProvisioningTest { reqsA2[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]"), null, true, false); a2 = createIU("A", reqsA2); - b1 = createIU("B", new Version("1.0.0"), "(invalid=true)", NO_PROVIDES); + b1 = createIU("B", Version.create("1.0.0"), "(invalid=true)", NO_PROVIDES); createTestMetdataRepository(new IInstallableUnit[] {a1, a2, b1}); profile = createProfile(IUWithFilter2.class.getName()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/InclusionRuleTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/InclusionRuleTest.java index da651c25e..f4fd84b9c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/InclusionRuleTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/InclusionRuleTest.java @@ -8,14 +8,13 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -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.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class InclusionRuleTest extends AbstractProvisioningTest { @@ -31,11 +30,11 @@ public class InclusionRuleTest extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); - a2 = createIU("A", new Version("2.0.0"), true); + a2 = createIU("A", Version.create("2.0.0"), true); - b1 = createIU("B", new Version("1.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); createTestMetdataRepository(new IInstallableUnit[] {a1, a2}); @@ -47,44 +46,44 @@ public class InclusionRuleTest extends AbstractProvisioningTest { profile1 = createProfile("TestProfile." + getName()); ProfileChangeRequest req = new ProfileChangeRequest(profile1); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); - engine.perform(profile1, new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); assertProfileContainsAll("A1 is missing", profile1, new IInstallableUnit[] {a1}); - assertEquals(profile1.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 1); + assertEquals(queryResultSize(profile1.query(InstallableUnitQuery.ANY, null)), 1); //Make a1 optional. ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.setInstallableUnitInclusionRules(a1, PlannerHelper.createOptionalInclusionRule(a1)); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); - engine.perform(profile1, new DefaultPhaseSet(), plan2.getOperands(), null, null); + engine.perform(plan2, null); assertProfileContainsAll("A1 is missing", profile1, new IInstallableUnit[] {a1}); - assertEquals(profile1.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 1); + assertEquals(queryResultSize(profile1.query(InstallableUnitQuery.ANY, null)), 1); //Install b1 (this should not change anything for a1) ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {b1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.OK, plan3.getStatus().getSeverity()); - engine.perform(profile1, new DefaultPhaseSet(), plan3.getOperands(), null, null); + engine.perform(plan3, null); assertProfileContainsAll("A1 or B1 is missing", profile1, new IInstallableUnit[] {a1, b1}); - assertEquals(profile1.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 2); + assertEquals(queryResultSize(profile1.query(InstallableUnitQuery.ANY, null)), 2); //Add a2, this removes a1. ProfileChangeRequest req4 = new ProfileChangeRequest(profile1); req4.addInstallableUnits(new IInstallableUnit[] {a2}); - ProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null); + IProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null); assertEquals(IStatus.OK, plan4.getStatus().getSeverity()); - engine.perform(profile1, new DefaultPhaseSet(), plan4.getOperands(), null, null); + engine.perform(plan4, null); assertProfileContainsAll("A2 is missing", profile1, new IInstallableUnit[] {a2}); - assertNotIUs(new IInstallableUnit[] {a1}, profile1.query(InstallableUnitQuery.ANY, new Collector(), null).iterator()); - assertEquals(profile1.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 2); + assertNotIUs(new IInstallableUnit[] {a1}, profile1.query(InstallableUnitQuery.ANY, null).iterator()); + assertEquals(queryResultSize(profile1.query(InstallableUnitQuery.ANY, null)), 2); //Try to add a1 again. This will fail because since a1 has been uninstalled in the previous step and we no longer know about its optional inclusion ProfileChangeRequest req5 = new ProfileChangeRequest(profile1); req5.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); + IProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); assertEquals(IStatus.ERROR, plan5.getStatus().getSeverity()); } @@ -93,77 +92,79 @@ public class InclusionRuleTest extends AbstractProvisioningTest { //Install a1 ProfileChangeRequest req = new ProfileChangeRequest(profile2); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); - engine.perform(profile2, new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); assertProfileContainsAll("A1 is missing", profile2, new IInstallableUnit[] {a1}); - assertEquals(profile2.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 1); + assertEquals(queryResultSize(profile2.query(InstallableUnitQuery.ANY, null)), 1); //Make a1 optional. ProfileChangeRequest req2 = new ProfileChangeRequest(profile2); req2.setInstallableUnitInclusionRules(a1, PlannerHelper.createOptionalInclusionRule(a1)); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); - engine.perform(profile2, new DefaultPhaseSet(), plan2.getOperands(), null, null); + engine.perform(plan2, null); assertProfileContainsAll("A1 is missing", profile2, new IInstallableUnit[] {a1}); - assertEquals(profile2.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 1); + assertEquals(queryResultSize(profile2.query(InstallableUnitQuery.ANY, null)), 1); //Install b1 (this should not change anything for a1) ProfileChangeRequest req3 = new ProfileChangeRequest(profile2); req3.addInstallableUnits(new IInstallableUnit[] {b1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.OK, plan3.getStatus().getSeverity()); - engine.perform(profile2, new DefaultPhaseSet(), plan3.getOperands(), null, null); + engine.perform(plan3, null); + profile2 = getProfile(profile2.getProfileId()); assertProfileContainsAll("A1 or B1 is missing", profile2, new IInstallableUnit[] {a1, b1}); - assertEquals(profile2.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 2); + assertEquals(queryResultSize(profile2.query(InstallableUnitQuery.ANY, null)), 2); //Remove the optional inclusion rule from a1. a1 and b1 are still here ProfileChangeRequest req5 = new ProfileChangeRequest(profile2); req5.removeInstallableUnitInclusionRules(a1); - ProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); + IProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); assertEquals(IStatus.OK, plan5.getStatus().getSeverity()); - engine.perform(profile2, new DefaultPhaseSet(), plan5.getOperands(), null, null); + engine.perform(plan5, null); + profile2 = getProfile(profile2.getProfileId()); assertProfileContainsAll("A1 or B1 is missing", profile2, new IInstallableUnit[] {a1, b1}); - assertEquals(profile2.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 2); + assertEquals(queryResultSize(profile2.query(InstallableUnitQuery.ANY, null)), 2); } public void testRemoveIUandInclusionRule() { profile3 = createProfile("TestProfile3." + getName()); ProfileChangeRequest req = new ProfileChangeRequest(profile3); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); - engine.perform(profile3, new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); assertProfileContainsAll("A1 is missing", profile3, new IInstallableUnit[] {a1}); - assertEquals(profile3.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 1); + assertEquals(queryResultSize(profile3.query(InstallableUnitQuery.ANY, null)), 1); //Make a1 optional. ProfileChangeRequest req2 = new ProfileChangeRequest(profile3); req2.setInstallableUnitInclusionRules(a1, PlannerHelper.createOptionalInclusionRule(a1)); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); - engine.perform(profile3, new DefaultPhaseSet(), plan2.getOperands(), null, null); + engine.perform(plan2, null); assertProfileContainsAll("A1 is missing", profile3, new IInstallableUnit[] {a1}); - assertEquals(profile3.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 1); + assertEquals(queryResultSize(profile3.query(InstallableUnitQuery.ANY, null)), 1); //Install b1 (this should not change anything for a1) ProfileChangeRequest req3 = new ProfileChangeRequest(profile3); req3.addInstallableUnits(new IInstallableUnit[] {b1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.OK, plan3.getStatus().getSeverity()); - engine.perform(profile3, new DefaultPhaseSet(), plan3.getOperands(), null, null); + engine.perform(plan3, null); assertProfileContainsAll("A1 or B1 is missing", profile3, new IInstallableUnit[] {a1, b1}); - assertEquals(profile3.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 2); + assertEquals(queryResultSize(profile3.query(InstallableUnitQuery.ANY, null)), 2); //Remove the a1 and its inclusion rule ProfileChangeRequest req5 = new ProfileChangeRequest(profile3); req5.removeInstallableUnits(new IInstallableUnit[] {a1}); req5.removeInstallableUnitInclusionRules(a1); - ProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); + IProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); assertEquals(IStatus.OK, plan5.getStatus().getSeverity()); - engine.perform(profile3, new DefaultPhaseSet(), plan5.getOperands(), null, null); + engine.perform(plan5, null); assertProfileContainsAll("bB1 is missing", profile3, new IInstallableUnit[] {b1}); - assertEquals(profile3.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 1); + assertEquals(queryResultSize(profile3.query(InstallableUnitQuery.ANY, null)), 1); } public void testAdditionWithInclusionRule() { @@ -171,32 +172,32 @@ public class InclusionRuleTest extends AbstractProvisioningTest { //Try to Install a1 and a2 ProfileChangeRequest req5 = new ProfileChangeRequest(profile4); req5.addInstallableUnits(new IInstallableUnit[] {a1, a2}); - ProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); + IProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); assertEquals(IStatus.ERROR, plan5.getStatus().getSeverity()); //Install a1 and a2 marking a1 optional ProfileChangeRequest req = new ProfileChangeRequest(profile4); req.addInstallableUnits(new IInstallableUnit[] {a1, a2}); req.setInstallableUnitInclusionRules(a1, PlannerHelper.createOptionalInclusionRule(a1)); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); - engine.perform(profile4, new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); assertProfileContainsAll("A2 is missing", profile4, new IInstallableUnit[] {a2}); - assertEquals(profile4.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 1); + assertEquals(queryResultSize(profile4.query(InstallableUnitQuery.ANY, null)), 1); //Make a1 optional, this is a no-op since a1 is not in the system ProfileChangeRequest req2 = new ProfileChangeRequest(profile4); req2.setInstallableUnitInclusionRules(a1, PlannerHelper.createOptionalInclusionRule(a1)); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); - engine.perform(profile4, new DefaultPhaseSet(), plan2.getOperands(), null, null); + engine.perform(plan2, null); assertProfileContainsAll("A2 is missing", profile4, new IInstallableUnit[] {a2}); - assertEquals(profile4.query(InstallableUnitQuery.ANY, new Collector(), null).size(), 1); + assertEquals(queryResultSize(profile4.query(InstallableUnitQuery.ANY, null)), 1); //Install a1, this is expected to fail ProfileChangeRequest req3 = new ProfileChangeRequest(profile4); req3.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.ERROR, plan3.getStatus().getSeverity()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/InclusionRuleTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/InclusionRuleTest2.java index 55833cfed..668b5caf0 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/InclusionRuleTest2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/InclusionRuleTest2.java @@ -10,17 +10,19 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.ITouchpointType; +import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestActivator; public class InclusionRuleTest2 extends AbstractProvisioningTest { IInstallableUnit a1; @@ -31,10 +33,10 @@ public class InclusionRuleTest2 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); - createIU("A", new Version("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, true, MetadataFactory.createUpdateDescriptor("A", VersionRange.emptyRange, 0, "foo bar"), null); - a2 = createIU("A", new Version("2.0.0"), true); + createIU("A", Version.create("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, true, MetadataFactory.createUpdateDescriptor("A", VersionRange.emptyRange, 0, "foo bar"), null); + a2 = createIU("A", Version.create("2.0.0"), true); createTestMetdataRepository(new IInstallableUnit[] {a1, a2}); @@ -47,26 +49,27 @@ public class InclusionRuleTest2 extends AbstractProvisioningTest { //Add into the profile the version a1; ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); - req.setInstallableUnitProfileProperty(a1, IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString()); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + req.setInstallableUnitProfileProperty(a1, IProfile.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString()); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); - engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); assertProfileContainsAll("A1 is missing", profile, new IInstallableUnit[] {a1}); - IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName()); + IProfileRegistry profileRegistry = getProfileRegistry(); profile = profileRegistry.getProfile(profile.getProfileId()); - Collector c = profile.query(new IUProfilePropertyQuery(IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString()), new Collector(), null); - assertEquals(c.size(), 1); + IQueryResult c = profile.query(new UserVisibleRootQuery(), null); + assertEquals(queryResultSize(c), 1); System.gc(); ProfileChangeRequest req2 = ProfileChangeRequest.createByProfileId(profile.getProfileId()); req2.removeInstallableUnits(new IInstallableUnit[] {a1}); req2.addInstallableUnits(new IInstallableUnit[] {a2}); - // req2.setInstallableUnitProfileProperty(a2, IInstallableUnit.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString()); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + // req2.setInstallableUnitProfileProperty(a2, IProfile.PROP_PROFILE_ROOT_IU, Boolean.TRUE.toString()); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); assertInstallOperand(plan2, a2); - engine.perform(profile, new DefaultPhaseSet(), plan2.getOperands(), null, null); + engine.perform(plan2, null); + profile = getProfile(profile.getProfileId()); assertProfileContains("A2 is missing", profile, new IInstallableUnit[] {a2}); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MinimalInstall.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MinimalInstall.java index b24125558..72c232e0b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MinimalInstall.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MinimalInstall.java @@ -10,14 +10,14 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MinimalInstall extends AbstractProvisioningTest { @@ -31,13 +31,13 @@ public class MinimalInstall extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)"), null)); + a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)"))); - b1 = createIU("B1", new Version("1.0.0"), true); + b1 = createIU("B1", Version.create("1.0.0"), true); - b11 = createIU("B1", new Version("1.1.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 3.0.0)"), null), NO_PROPERTIES, true); + b11 = createIU("B1", Version.create("1.1.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 3.0.0)")), NO_PROPERTIES, true); - c = createIU("C", new Version(2, 0, 0), true); + c = createIU("C", Version.createOSGi(2, 0, 0), true); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b11, c}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency.java index 50372b450..358b16a58 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency.java @@ -10,15 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Set; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.director.Explanation; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MissingDependency extends AbstractProvisioningTest { @@ -29,12 +31,12 @@ public class MissingDependency extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); //Missing non optional dependency IRequiredCapability[] req = new IRequiredCapability[1]; req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, false, false, true); - b1 = createIU("B", new Version("1.0.0"), req); + b1 = createIU("B", Version.create("1.0.0"), req); createTestMetdataRepository(new IInstallableUnit[] {a1, b1}); @@ -45,23 +47,24 @@ public class MissingDependency extends AbstractProvisioningTest { public void testContradiction() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1, b1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); } public void testExplanation() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1, b1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); - Set explanation = plan.getRequestStatus().getExplanations(); + RequestStatus requestStatus = (RequestStatus) plan.getRequestStatus(); + Set explanation = requestStatus.getExplanations(); // System.out.println(explanation); assertEquals(2, explanation.size()); - Set rootConflictingIUs = plan.getRequestStatus().getConflictsWithInstalledRoots(); + Set rootConflictingIUs = requestStatus.getConflictsWithInstalledRoots(); // System.out.println(rootConflictingIUs); assertEquals(1, rootConflictingIUs.size()); assertTrue(rootConflictingIUs.contains(b1)); assertFalse(rootConflictingIUs.contains(a1)); - assertEquals(Explanation.MISSING_REQUIREMENT, plan.getRequestStatus().getShortExplanation()); + assertEquals(Explanation.MISSING_REQUIREMENT, requestStatus.getShortExplanation()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency2.java index 3df9d50e6..143987e9e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency2.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MissingDependency2 extends AbstractProvisioningTest { @@ -27,12 +31,12 @@ public class MissingDependency2 extends AbstractProvisioningTest { super.setUp(); IRequiredCapability[] reqA = new IRequiredCapability[1]; reqA[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, true); - a1 = createIU("A", new Version("1.0.0"), reqA); + a1 = createIU("A", Version.create("1.0.0"), reqA); //Missing optional dependency IRequiredCapability[] req = new IRequiredCapability[1]; req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, true, false, true); - b1 = createIU("B", new Version("1.0.0"), req); + b1 = createIU("B", Version.create("1.0.0"), req); createTestMetdataRepository(new IInstallableUnit[] {a1, b1}); @@ -43,7 +47,7 @@ public class MissingDependency2 extends AbstractProvisioningTest { public void testContradiction() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency3.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency3.java index 724161f0d..6e633fb7c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency3.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency3.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MissingDependency3 extends AbstractProvisioningTest { @@ -28,12 +32,12 @@ public class MissingDependency3 extends AbstractProvisioningTest { super.setUp(); IRequiredCapability[] reqA = new IRequiredCapability[1]; reqA[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, true, false, true); - a1 = createIU("A", new Version("1.0.0"), reqA); + a1 = createIU("A", Version.create("1.0.0"), reqA); //Missing dependency IRequiredCapability[] req = new IRequiredCapability[1]; req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, false, false, true); - b1 = createIU("B", new Version("1.0.0"), req); + b1 = createIU("B", Version.create("1.0.0"), req); createTestMetdataRepository(new IInstallableUnit[] {a1, b1}); @@ -44,7 +48,7 @@ public class MissingDependency3 extends AbstractProvisioningTest { public void testContradiction() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingNonGreedyRequirement.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingNonGreedyRequirement.java index dbee49eaf..1a40c65a1 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingNonGreedyRequirement.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingNonGreedyRequirement.java @@ -10,15 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Set; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.director.Explanation; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MissingNonGreedyRequirement extends AbstractProvisioningTest { @@ -30,14 +32,14 @@ public class MissingNonGreedyRequirement extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - b1 = createIU("B", new Version("1.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); - c1 = createIU("C", new Version("1.0.0"), true); + c1 = createIU("C", Version.create("1.0.0"), true); IRequiredCapability[] reqB = new IRequiredCapability[2]; reqB[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false); reqB[1] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, true, false, true); - a1 = createIU("A", new Version("1.0.0"), reqB); + a1 = createIU("A", Version.create("1.0.0"), reqB); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, c1}); @@ -49,18 +51,19 @@ public class MissingNonGreedyRequirement extends AbstractProvisioningTest { //The planner returns an error because the requirement from A on B is non greedy and no one brings in B ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); } public void testExplanation() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); - Set explanation = plan.getRequestStatus().getExplanations(); + RequestStatus requestStatus = (RequestStatus) plan.getRequestStatus(); + Set explanation = requestStatus.getExplanations(); assertFalse(explanation.isEmpty()); - assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(a1)); - assertEquals(Explanation.MISSING_REQUIREMENT, plan.getRequestStatus().getShortExplanation()); + assertTrue(requestStatus.getConflictsWithInstalledRoots().contains(a1)); + assertEquals(Explanation.MISSING_REQUIREMENT, requestStatus.getShortExplanation()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingNonGreedyRequirement2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingNonGreedyRequirement2.java index 9e3da6d22..907cdc609 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingNonGreedyRequirement2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingNonGreedyRequirement2.java @@ -10,15 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Set; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.director.Explanation; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MissingNonGreedyRequirement2 extends AbstractProvisioningTest { @@ -29,12 +31,12 @@ public class MissingNonGreedyRequirement2 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - c1 = createIU("C", new Version("1.0.0"), true); + c1 = createIU("C", Version.create("1.0.0"), true); IRequiredCapability[] reqB = new IRequiredCapability[2]; reqB[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false); reqB[1] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, true, false, true); - a1 = createIU("A", new Version("1.0.0"), reqB); + a1 = createIU("A", Version.create("1.0.0"), reqB); createTestMetdataRepository(new IInstallableUnit[] {a1, c1}); @@ -46,19 +48,20 @@ public class MissingNonGreedyRequirement2 extends AbstractProvisioningTest { //The planner returns an error because the requirement from A on B is non greedy and no one brings in B. ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); } public void testExplanation() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); - Set explanation = plan.getRequestStatus().getExplanations(); + RequestStatus requestStatus = (RequestStatus) plan.getRequestStatus(); + Set explanation = requestStatus.getExplanations(); assertFalse(explanation.isEmpty()); - assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(a1)); - assertEquals(Explanation.MISSING_REQUIREMENT, plan.getRequestStatus().getShortExplanation()); + assertTrue(requestStatus.getConflictsWithInstalledRoots().contains(a1)); + assertEquals(Explanation.MISSING_REQUIREMENT, requestStatus.getShortExplanation()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptional.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptional.java index d4dc05c29..db97fcb56 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptional.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptional.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MissingOptional extends AbstractProvisioningTest { @@ -26,8 +30,8 @@ public class MissingOptional extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); - b1 = createIU("B", new Version("1.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); IRequiredCapability[] req = new IRequiredCapability[3]; req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true); @@ -45,7 +49,7 @@ public class MissingOptional extends AbstractProvisioningTest { //Ensure that D's installation does not fail because of C's absence ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {d}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); assertInstallOperand(plan, b1); //THIS May not be in diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalNonGreedyRequirement.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalNonGreedyRequirement.java index 3eca862c1..2e8e4b529 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalNonGreedyRequirement.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalNonGreedyRequirement.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MissingOptionalNonGreedyRequirement extends AbstractProvisioningTest { @@ -25,11 +29,11 @@ public class MissingOptionalNonGreedyRequirement extends AbstractProvisioningTes protected void setUp() throws Exception { super.setUp(); - b1 = createIU("B", new Version("1.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); IRequiredCapability[] reqB = new IRequiredCapability[1]; reqB[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, true, false, false); - a1 = createIU("A", new Version("1.0.0"), reqB); + a1 = createIU("A", Version.create("1.0.0"), reqB); createTestMetdataRepository(new IInstallableUnit[] {a1, b1}); @@ -41,7 +45,7 @@ public class MissingOptionalNonGreedyRequirement extends AbstractProvisioningTes //The plan does not contains B because the requirement from A on B is non greedy and no one brings in B ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); assertNoOperand(plan, b1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies.java index 3d99c4463..55645f68f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MissingOptionalWithDependencies extends AbstractProvisioningTest { @@ -26,13 +30,13 @@ public class MissingOptionalWithDependencies extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); //B's dependency is missing IRequiredCapability[] reqB = new IRequiredCapability[2]; reqB[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, true, false, true); reqB[1] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true); - b1 = createIU("B", new Version("1.0.0"), reqB); + b1 = createIU("B", Version.create("1.0.0"), reqB); IRequiredCapability[] req = new IRequiredCapability[2]; req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true); @@ -49,7 +53,7 @@ public class MissingOptionalWithDependencies extends AbstractProvisioningTest { //Ensure that D's installation does not fail because of C's absence ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {d}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); assertInstallOperand(plan, b1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies2.java index 28fcba00e..5f06ca9cd 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies2.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MissingOptionalWithDependencies2 extends AbstractProvisioningTest { @@ -28,15 +32,15 @@ public class MissingOptionalWithDependencies2 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); - c1 = createIU("C", new Version("1.0.0"), true); - c2 = createIU("C", new Version("2.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); + c1 = createIU("C", Version.create("1.0.0"), true); + c2 = createIU("C", Version.create("2.0.0"), true); //B's dependency on C can not be satisfied IRequiredCapability[] reqB = new IRequiredCapability[2]; reqB[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 1.0.0]"), null, true, false, true); reqB[1] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true); - b1 = createIU("B", new Version("1.0.0"), reqB); + b1 = createIU("B", Version.create("1.0.0"), reqB); IRequiredCapability[] req = new IRequiredCapability[3]; req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true); @@ -54,7 +58,7 @@ public class MissingOptionalWithDependencies2 extends AbstractProvisioningTest { //Ensure that D's installation does not fail because of C's absence ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {d}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, d); assertInstallOperand(plan, a1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies3.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies3.java index f19a3a5a6..2f6cdbb92 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies3.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies3.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MissingOptionalWithDependencies3 extends AbstractProvisioningTest { @@ -28,15 +32,15 @@ public class MissingOptionalWithDependencies3 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); - c1 = createIU("C", new Version("1.0.0"), true); - c2 = createIU("C", new Version("2.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); + c1 = createIU("C", Version.create("1.0.0"), true); + c2 = createIU("C", Version.create("2.0.0"), true); //B's dependency on C can not be satisfied IRequiredCapability[] reqB = new IRequiredCapability[2]; reqB[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 1.0.0]"), null, true, false, true); reqB[1] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true); - b1 = createIU("B", new Version("1.0.0"), reqB); + b1 = createIU("B", Version.create("1.0.0"), reqB); IRequiredCapability[] req = new IRequiredCapability[3]; req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true); @@ -54,7 +58,7 @@ public class MissingOptionalWithDependencies3 extends AbstractProvisioningTest { //Ensure that D's installation does not fail because of C's absence ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {d}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); assertInstallOperand(plan, b1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleProvider.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleProvider.java index 8e24a5d42..84665e854 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleProvider.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleProvider.java @@ -10,14 +10,14 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MultipleProvider extends AbstractProvisioningTest { @@ -33,17 +33,17 @@ public class MultipleProvider extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)"), null)); + a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B1", new VersionRange("[1.0.0, 2.0.0)"))); - b1 = createIU("B1", new Version("1.0.0"), true); + b1 = createIU("B1", Version.create("1.0.0"), true); - b11 = createIU("B1", new Version("1.1.0"), true); + b11 = createIU("B1", Version.create("1.1.0"), true); - b12 = createIU("B1", new Version("1.2.0"), true); + b12 = createIU("B1", Version.create("1.2.0"), true); - b13 = createIU("B1", new Version("1.3.0"), true); + b13 = createIU("B1", Version.create("1.3.0"), true); - b14 = createIU("B1", new Version("1.4.0"), true); + b14 = createIU("B1", Version.create("1.4.0"), true); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b11, b12, b13, b14}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleSingleton.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleSingleton.java index 66e338422..081cc6f78 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleSingleton.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleSingleton.java @@ -10,17 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - import java.util.Set; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.director.Explanation; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.MetadataFactory; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.ProvisioningPlan; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MultipleSingleton extends AbstractProvisioningTest { @@ -35,32 +34,32 @@ public class MultipleSingleton extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); - a2 = createIU("A", new Version("2.0.0"), true); + a2 = createIU("A", Version.create("2.0.0"), true); - a3 = createIU("A", new Version("3.0.0"), false); + a3 = createIU("A", Version.create("3.0.0"), false); - a4 = createIU("A", new Version("4.0.0"), false); + a4 = createIU("A", Version.create("4.0.0"), false); - x = createIU("X", new Version(2, 0, 0), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 4.1.0)"), null)); + x = createIU("X", Version.createOSGi(2, 0, 0), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 4.1.0)"))); IRequiredCapability c1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null, false, false); IRequiredCapability c2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]"), null, false, false); - y = createIU("Y", new Version(2, 0, 0), new IRequiredCapability[] {c1, c2}); + y = createIU("Y", Version.createOSGi(2, 0, 0), new IRequiredCapability[] {c1, c2}); IRequiredCapability c3 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[3.0.0, 3.0.0]"), null, false, false); IRequiredCapability c4 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[4.0.0, 4.0.0]"), null, false, false); - z = createIU("Z", new Version(2, 0, 0), new IRequiredCapability[] {c3, c4}); + z = createIU("Z", Version.createOSGi(2, 0, 0), new IRequiredCapability[] {c3, c4}); IRequiredCapability c5 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null, false, false); IRequiredCapability c6 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[3.0.0, 3.0.0]"), null, false, false); - w = createIU("W", new Version(2, 0, 0), new IRequiredCapability[] {c5, c6}); + w = createIU("W", Version.createOSGi(2, 0, 0), new IRequiredCapability[] {c5, c6}); IRequiredCapability c7 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 2.0.0]"), null, false, false); IRequiredCapability c8 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[3.0.0, 4.0.0]"), null, false, false); - v = createIU("V", new Version(2, 0, 0), new IRequiredCapability[] {c7}); - u = createIU("U", new Version(2, 0, 0), new IRequiredCapability[] {c8}); + v = createIU("V", Version.createOSGi(2, 0, 0), new IRequiredCapability[] {c7}); + u = createIU("U", Version.createOSGi(2, 0, 0), new IRequiredCapability[] {c8}); createTestMetdataRepository(new IInstallableUnit[] {a1, a2, a3, a4, w, x, y, z}); @@ -72,8 +71,8 @@ public class MultipleSingleton extends AbstractProvisioningTest { public void test1() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {x}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); - assertEquals(1, plan.getCompleteState().query(new InstallableUnitQuery("X"), new Collector(), null).size()); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(req, null, null); + assertEquals(1, queryResultSize(plan.getCompleteState().query(new InstallableUnitQuery("X"), null))); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); } @@ -87,14 +86,15 @@ public class MultipleSingleton extends AbstractProvisioningTest { public void testExplanation2() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {y}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); - Set explanation = plan.getRequestStatus().getExplanations(); + final RequestStatus requestStatus = (RequestStatus) plan.getRequestStatus(); + Set explanation = requestStatus.getExplanations(); // System.out.println(explanation); assertFalse(explanation.isEmpty()); - assertEquals(Explanation.VIOLATED_SINGLETON_CONSTRAINT, plan.getRequestStatus().getShortExplanation()); - assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(y)); - assertEquals(1, plan.getRequestStatus().getConflictsWithInstalledRoots().size()); + assertEquals(Explanation.VIOLATED_SINGLETON_CONSTRAINT, requestStatus.getShortExplanation()); + assertTrue(requestStatus.getConflictsWithInstalledRoots().contains(y)); + assertEquals(1, requestStatus.getConflictsWithInstalledRoots().size()); } @@ -115,13 +115,14 @@ public class MultipleSingleton extends AbstractProvisioningTest { public void testExplanation4() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {w}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); - Set explanation = plan.getRequestStatus().getExplanations(); + final RequestStatus requestStatus = (RequestStatus) plan.getRequestStatus(); + Set explanation = requestStatus.getExplanations(); // System.out.println(explanation); assertFalse(explanation.isEmpty()); - assertEquals(Explanation.VIOLATED_SINGLETON_CONSTRAINT, plan.getRequestStatus().getShortExplanation()); - assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(w)); + assertEquals(Explanation.VIOLATED_SINGLETON_CONSTRAINT, requestStatus.getShortExplanation()); + assertTrue(requestStatus.getConflictsWithInstalledRoots().contains(w)); } @@ -149,13 +150,14 @@ public class MultipleSingleton extends AbstractProvisioningTest { public void testExplanation5() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {u, v}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); - Set explanation = plan.getRequestStatus().getExplanations(); + final RequestStatus requestStatus = (RequestStatus) plan.getRequestStatus(); + Set explanation = requestStatus.getExplanations(); assertFalse(explanation.isEmpty()); - assertEquals(Explanation.VIOLATED_SINGLETON_CONSTRAINT, plan.getRequestStatus().getShortExplanation()); - assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(u)); - assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(v)); + assertEquals(Explanation.VIOLATED_SINGLETON_CONSTRAINT, requestStatus.getShortExplanation()); + assertTrue(requestStatus.getConflictsWithInstalledRoots().contains(u)); + assertTrue(requestStatus.getConflictsWithInstalledRoots().contains(v)); // System.out.println(explanation); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NegationTesting.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NegationTesting.java index a2e498c6f..d002ce54b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NegationTesting.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NegationTesting.java @@ -1,52 +1,55 @@ package org.eclipse.equinox.p2.tests.planner; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; + import java.util.*; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.director.Slicer; -import org.eclipse.equinox.internal.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.ProvidedCapability; +import org.eclipse.equinox.internal.p2.metadata.RequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; +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.query.IQueryable; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class NegationTesting extends AbstractProvisioningTest { private static final String NS = "theNamespace"; private static final String N = "theName"; - public void testNot1() { - RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 1.2.0)"), null, false, false); - NotRequirement req = new NotRequirement(req1); - ProvidedCapability prov = new ProvidedCapability(NS, N, new Version(1, 5, 0)); - assertTrue(prov.satisfies(req)); - } - - public void testNot2() { - RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 1.2.0)"), null, false, false); - NotRequirement req = new NotRequirement(req1); - ProvidedCapability prov = new ProvidedCapability(NS, N, new Version(1, 1, 0)); - assertFalse(prov.satisfies(req)); - } - - public void testNot3() { - RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 1.2.0)"), null, false, false); - // RequiredCapability req2 = new RequiredCapability(NS, N, new VersionRange("[1.5.0, 2.0.0)"), null, false, false); - NotRequirement req = new NotRequirement(req1); - ProvidedCapability prov = new ProvidedCapability("foo", "bar", new Version(1, 5, 0)); - assertTrue(prov.satisfies(req)); - } + // public void testNot1() { + // RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 1.2.0)"), null, 0, 0, false); + // ProvidedCapability prov = new ProvidedCapability(NS, N, Version.createOSGi(1, 5, 0)); + // assertTrue(prov.satisfies(req1)); + // } + // + // public void testNot2() { + // RequiredCapability req = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 1.2.0)"), null, 0, 0, false); + // ProvidedCapability prov = new ProvidedCapability(NS, N, Version.createOSGi(1, 1, 0)); + // assertFalse(prov.satisfies(req)); + // } + // + // public void testNot3() { + // RequiredCapability req = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 1.2.0)"), null, 0, 0, false); + // // RequiredCapability req2 = new RequiredCapability(NS, N, new VersionRange("[1.5.0, 2.0.0)"), null, false, false); + // ProvidedCapability prov = new ProvidedCapability("foo", "bar", Version.createOSGi(1, 5, 0)); + // assertTrue(prov.satisfies(req)); + // } //Test the slicer and the resolver. public void testNot4() { MetadataFactory.InstallableUnitDescription iud1 = new MetadataFactory.InstallableUnitDescription(); iud1.setId("TestNegation4"); iud1.setVersion(Version.create("1.0.0")); - RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.1.0, 1.2.0)"), null, false, false); - NotRequirement req = new NotRequirement(req1); + RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.1.0, 1.2.0)"), null, 0, 0, false); RequiredCapability req2 = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 2.0.0)"), null, false, false); Collection requirements = new ArrayList(); - requirements.add(req); + requirements.add(req1); requirements.add(req2); iud1.addRequiredCapabilities(requirements); Collection capabilities = new ArrayList(); @@ -76,21 +79,21 @@ public class NegationTesting extends AbstractProvisioningTest { // Verify that the slice includes iu3 because the requirement from iu1 is a range including the provided capability of iu3. Slicer slicer = new Slicer(repo, new Properties(), false); IQueryable slice = slicer.slice(new IInstallableUnit[] {iu1}, new NullProgressMonitor()); - assertEquals(3, slice.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + assertEquals(3, queryResultSize(slice.query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); //Verify that the resolution succeeds and does not return iu3 since it is excluded by the requirement of iu1 IProfile profile = createProfile("TestProfile." + getName()); IPlanner planner = createPlanner(); ProfileChangeRequest changeRequest = new ProfileChangeRequest(profile); changeRequest.addInstallableUnits(new IInstallableUnit[] {iu1}); - ProvisioningPlan plan = planner.getProvisioningPlan(changeRequest, null, null); - assertEquals(0, plan.getCompleteState().query(new InstallableUnitQuery("ProviderOf1_1_1"), new Collector(), null).size()); - assertEquals(2, plan.getCompleteState().query(InstallableUnitQuery.ANY, new Collector(), null).size()); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(changeRequest, null, null); + assertEquals(0, queryResultSize(plan.getCompleteState().query(new InstallableUnitQuery("ProviderOf1_1_1"), null))); + assertEquals(2, queryResultSize(plan.getCompleteState().query(InstallableUnitQuery.ANY, null))); //Verify that the installing iu1 and iu3 will result in a conflict since iu3 is excluded by the requirement of iu1 ProfileChangeRequest changeRequest2 = new ProfileChangeRequest(profile); changeRequest2.addInstallableUnits(new IInstallableUnit[] {iu1, iu3}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(changeRequest2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(changeRequest2, null, null); assertNotOK("The resolution should be failing because of the negation requirement.", plan2.getStatus()); } @@ -98,11 +101,10 @@ public class NegationTesting extends AbstractProvisioningTest { MetadataFactory.InstallableUnitDescription iud1 = new MetadataFactory.InstallableUnitDescription(); iud1.setId("TestNegation4"); iud1.setVersion(Version.create("1.0.0")); - RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.1.0, 1.2.0)"), null, false, false); - NotRequirement req = new NotRequirement(req1); + RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.1.0, 1.2.0)"), null, 0, 0, false); RequiredCapability req2 = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 1.1.0)"), null, false, false); Collection requirements = new ArrayList(); - requirements.add(req); + requirements.add(req1); requirements.add(req2); iud1.addRequiredCapabilities(requirements); Collection capabilities = new ArrayList(); @@ -132,19 +134,18 @@ public class NegationTesting extends AbstractProvisioningTest { //Test the slicer. The slice will not contain iu3 because none of the range of iu1 cause it to be brought in. Slicer slicer = new Slicer(repo, new Properties(), false); IQueryable slice = slicer.slice(new IInstallableUnit[] {iu1}, new NullProgressMonitor()); - assertEquals(0, slice.query(new InstallableUnitQuery("ProviderOf1_1_1"), new Collector(), new NullProgressMonitor()).size()); - assertEquals(2, slice.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + assertEquals(0, queryResultSize(slice.query(new InstallableUnitQuery("ProviderOf1_1_1"), new NullProgressMonitor()))); + assertEquals(2, queryResultSize(slice.query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); } public void testNot6() { MetadataFactory.InstallableUnitDescription iud1 = new MetadataFactory.InstallableUnitDescription(); iud1.setId("TestNegation4"); iud1.setVersion(Version.create("1.0.0")); - RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.1.0, 1.2.0)"), null, false, false); - NotRequirement req = new NotRequirement(req1); + RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.1.0, 1.2.0)"), null, 0, 0, false); RequiredCapability req2 = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 1.1.0)"), null, false, false); Collection requirements = new ArrayList(); - requirements.add(req); + requirements.add(req1); requirements.add(req2); iud1.addRequiredCapabilities(requirements); Collection capabilities = new ArrayList(); @@ -165,17 +166,17 @@ public class NegationTesting extends AbstractProvisioningTest { //Test the slicer. The slice will not contain iu3 because none of the range of iu1 cause it to be brought in. Slicer slicer = new Slicer(repo, new Properties(), false); IQueryable slice = slicer.slice(new IInstallableUnit[] {iu1}, new NullProgressMonitor()); - assertEquals(0, slice.query(new InstallableUnitQuery("ProviderOf1_1_1"), new Collector(), new NullProgressMonitor()).size()); - assertEquals(2, slice.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + assertEquals(0, queryResultSize(slice.query(new InstallableUnitQuery("ProviderOf1_1_1"), new NullProgressMonitor()))); + assertEquals(2, queryResultSize(slice.query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); //Verify that the negation can not fail the resolution when the IUs satisfying the negative requirement are not there IProfile profile = createProfile("TestProfile." + getName()); IPlanner planner = createPlanner(); ProfileChangeRequest changeRequest = new ProfileChangeRequest(profile); changeRequest.addInstallableUnits(new IInstallableUnit[] {iu1}); - ProvisioningPlan plan = planner.getProvisioningPlan(changeRequest, null, null); - assertEquals(0, plan.getCompleteState().query(new InstallableUnitQuery("ProviderOf1_1_1"), new Collector(), null).size()); - assertEquals(2, plan.getCompleteState().query(InstallableUnitQuery.ANY, new Collector(), null).size()); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(changeRequest, null, null); + assertEquals(0, queryResultSize(plan.getCompleteState().query(new InstallableUnitQuery("ProviderOf1_1_1"), null))); + assertEquals(2, queryResultSize(plan.getCompleteState().query(InstallableUnitQuery.ANY, null))); } //Test the slicer and the resolver. @@ -183,11 +184,10 @@ public class NegationTesting extends AbstractProvisioningTest { MetadataFactory.InstallableUnitDescription iud1 = new MetadataFactory.InstallableUnitDescription(); iud1.setId("TestNegation4"); iud1.setVersion(Version.create("1.0.0")); - RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.1.0, 1.2.0)"), null, false, false); - NotRequirement req = new NotRequirement(req1); + RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.1.0, 1.2.0)"), null, 0, 0, false); RequiredCapability req2 = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 2.0.0)"), null, false, false); Collection requirements = new ArrayList(); - requirements.add(req); + requirements.add(req1); requirements.add(req2); iud1.addRequiredCapabilities(requirements); Collection capabilities = new ArrayList(); @@ -220,21 +220,21 @@ public class NegationTesting extends AbstractProvisioningTest { // Verify that the slice includes iu3 because the requirement from iu1 is a range including the provided capability of iu3. Slicer slicer = new Slicer(repo, new Properties(), false); IQueryable slice = slicer.slice(new IInstallableUnit[] {iu1}, new NullProgressMonitor()); - assertEquals(3, slice.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + assertEquals(3, queryResultSize(slice.query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); //Verify that the resolution succeeds and does not return iu3 since it is excluded by the requirement of iu1 IProfile profile = createProfile("TestProfile." + getName()); IPlanner planner = createPlanner(); ProfileChangeRequest changeRequest = new ProfileChangeRequest(profile); changeRequest.addInstallableUnits(new IInstallableUnit[] {iu1}); - ProvisioningPlan plan = planner.getProvisioningPlan(changeRequest, null, null); - assertEquals(0, plan.getCompleteState().query(new InstallableUnitQuery("ProviderOf1_1_1"), new Collector(), null).size()); - assertEquals(2, plan.getCompleteState().query(InstallableUnitQuery.ANY, new Collector(), null).size()); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(changeRequest, null, null); + assertEquals(0, queryResultSize(plan.getCompleteState().query(new InstallableUnitQuery("ProviderOf1_1_1"), null))); + assertEquals(2, queryResultSize(plan.getCompleteState().query(InstallableUnitQuery.ANY, null))); //Verify that the installing iu1 and iu3 will result in a conflict since iu3 is excluded by the requirement of iu1 ProfileChangeRequest changeRequest2 = new ProfileChangeRequest(profile); changeRequest2.addInstallableUnits(new IInstallableUnit[] {iu1, iu3}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(changeRequest2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(changeRequest2, null, null); assertNotOK("The resolution should be failing because of the negation requirement.", plan2.getStatus()); } @@ -242,11 +242,10 @@ public class NegationTesting extends AbstractProvisioningTest { MetadataFactory.InstallableUnitDescription iud1 = new MetadataFactory.InstallableUnitDescription(); iud1.setId("TestNegation4"); iud1.setVersion(Version.create("1.0.0")); - RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.1.0, 1.2.0)"), null, false, false); - NotRequirement req = new NotRequirement(req1); + RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.1.0, 1.2.0)"), null, 0, 0, false); RequiredCapability req2 = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 2.0.0)"), null, false, false); Collection requirements = new ArrayList(); - requirements.add(req); + requirements.add(req1); requirements.add(req2); iud1.addRequiredCapabilities(requirements); Collection capabilities = new ArrayList(); @@ -287,26 +286,26 @@ public class NegationTesting extends AbstractProvisioningTest { // Verify that the slice includes iu3 Slicer slicer = new Slicer(repo, new Properties(), false); IQueryable slice = slicer.slice(new IInstallableUnit[] {iu1, iu4}, new NullProgressMonitor()); - assertEquals(4, slice.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + assertEquals(4, queryResultSize(slice.query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); // Verify that the slice includes iu3 Slicer slicer2 = new Slicer(repo, new Properties(), false); IQueryable slice2 = slicer2.slice(new IInstallableUnit[] {iu4}, new NullProgressMonitor()); - assertEquals(2, slice2.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + assertEquals(2, queryResultSize(slice2.query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); //Verify that the resolution succeeds and does not return iu3 since it is excluded by the requirement of iu1 IProfile profile = createProfile("TestProfile." + getName()); IPlanner planner = createPlanner(); ProfileChangeRequest changeRequest = new ProfileChangeRequest(profile); changeRequest.addInstallableUnits(new IInstallableUnit[] {iu1}); - ProvisioningPlan plan = planner.getProvisioningPlan(changeRequest, null, null); - assertEquals(0, plan.getCompleteState().query(new InstallableUnitQuery("ProviderOf1_1_1"), new Collector(), null).size()); - assertEquals(2, plan.getCompleteState().query(InstallableUnitQuery.ANY, new Collector(), null).size()); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(changeRequest, null, null); + assertEquals(0, queryResultSize(plan.getCompleteState().query(new InstallableUnitQuery("ProviderOf1_1_1"), null))); + assertEquals(2, queryResultSize(plan.getCompleteState().query(InstallableUnitQuery.ANY, null))); //Verify that the installing iu1 and iu4 will result in a conflict since iu3 is excluded by the requirement of iu1 ProfileChangeRequest changeRequest2 = new ProfileChangeRequest(profile); changeRequest2.addInstallableUnits(new IInstallableUnit[] {iu1, iu4}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(changeRequest2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(changeRequest2, null, null); assertNotOK("The resolution should be failing because of the negation requirement.", plan2.getStatus()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoRequirements.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoRequirements.java index d607a6cd4..7b6dc4d68 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoRequirements.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoRequirements.java @@ -10,14 +10,14 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class NoRequirements extends AbstractProvisioningTest { @@ -28,7 +28,7 @@ public class NoRequirements extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null)); + a1 = createIU("A", Version.create("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"))); createTestMetdataRepository(new IInstallableUnit[] {a1}); profile = createProfile(NoRequirements.class.getName()); planner = createPlanner(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java index b192e0201..b9d58f27a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java @@ -15,11 +15,15 @@ import java.net.URI; import java.util.*; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.ExpressionQuery; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class NonMinimalState extends AbstractProvisioningTest { @@ -42,9 +46,9 @@ public class NonMinimalState extends AbstractProvisioningTest { public void testValidateProfileWithRepository() { IPlanner planner = createPlanner(); ProfileChangeRequest request = new ProfileChangeRequest(profile); - ProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); assertOK("Plan OK", plan.getStatus()); - assertEquals(0, plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.agentcontroller"), new Collector(), null).size()); + assertTrue(plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.agentcontroller"), null).isEmpty()); why("slf4j.api"); why("slf4j.jcl"); why("org.eclipse.tptp.platform.iac.administrator"); @@ -55,15 +59,15 @@ public class NonMinimalState extends AbstractProvisioningTest { IPlanner planner = createPlanner(); ProfileChangeRequest request = new ProfileChangeRequest(profile); ProvisioningContext ctx = new ProvisioningContext(new URI[0]); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertOK("Plan OK", plan.getStatus()); - assertEquals(0, plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.agentcontroller"), new Collector(), null).size()); + assertTrue(plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.agentcontroller"), null).isEmpty()); } private void why(String id) { System.out.println("=-=-=" + id + "=-=-="); visited = new HashSet(); - Collector roots = profile.query(new IUProfilePropertyQuery("org.eclipse.equinox.p2.type.root", "true"), new Collector(), null); + IQueryResult roots = profile.query(new IUProfilePropertyQuery("org.eclipse.equinox.p2.type.root", "true"), null); searchedId = id; for (Iterator iterator = roots.iterator(); iterator.hasNext();) { IInstallableUnit type = (IInstallableUnit) iterator.next(); @@ -82,19 +86,19 @@ public class NonMinimalState extends AbstractProvisioningTest { visited.add(iu); return false; } - IRequiredCapability[] caps = iu.getRequiredCapabilities(); - for (int i = 0; i < caps.length; i++) { - boolean result = expandRequirement(iu, caps[i]); + Collection<IRequirement> reqs = iu.getRequiredCapabilities(); + for (IRequirement req : reqs) { + boolean result = expandRequirement(iu, req); if (result) { - System.out.println(iu + " because " + caps[i].toString()); + System.out.println(iu + " because " + req.toString()); return true; } } return false; } - private boolean expandRequirement(IInstallableUnit iu, IRequiredCapability req) { - Collector matches = profile.query(new CapabilityQuery(req), new Collector(), null); + private boolean expandRequirement(IInstallableUnit iu, IRequirement req) { + IQueryResult matches = profile.query(new ExpressionQuery(IInstallableUnit.class, req.getMatches()), null); for (Iterator iterator = matches.iterator(); iterator.hasNext();) { IInstallableUnit match = (IInstallableUnit) iterator.next(); if (match.getId().equals(searchedId)) diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState2.java index b6b3973b0..500229461 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState2.java @@ -10,16 +10,19 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class NonMinimalState2 extends AbstractProvisioningTest { @@ -35,12 +38,12 @@ public class NonMinimalState2 extends AbstractProvisioningTest { IPlanner planner = createPlanner(); ProfileChangeRequest request = new ProfileChangeRequest(profile); - request.addInstallableUnits((IInstallableUnit[]) getMetadataRepositoryManager().query(new InstallableUnitQuery("org.mortbay.jetty.server"), new Collector(), null).toArray(IInstallableUnit.class)); - ProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); + request.addInstallableUnits((IInstallableUnit[]) getMetadataRepositoryManager().query(new InstallableUnitQuery("org.mortbay.jetty.server"), null).toArray(IInstallableUnit.class)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); assertOK("Plan OK", plan.getStatus()); - assertEquals(0, plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.agentcontroller"), new Collector(), null).size()); - assertEquals(0, plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.iac.administrator"), new Collector(), null).size()); + assertTrue(plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.agentcontroller"), null).isEmpty()); + assertTrue(plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.iac.administrator"), null).isEmpty()); } // public void testp2Source() { @@ -60,12 +63,12 @@ public class NonMinimalState2 extends AbstractProvisioningTest { IPlanner planner = createPlanner(); ProfileChangeRequest request = new ProfileChangeRequest(profile); - request.addInstallableUnits((IInstallableUnit[]) getMetadataRepositoryManager().query(new InstallableUnitQuery("org.mortbay.jetty.server"), new Collector(), null).toArray(IInstallableUnit.class)); - ProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); + request.addInstallableUnits((IInstallableUnit[]) getMetadataRepositoryManager().query(new InstallableUnitQuery("org.mortbay.jetty.server"), null).toArray(IInstallableUnit.class)); + IProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor()); assertOK("Plan OK", plan.getStatus()); - assertEquals(0, plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.agentcontroller"), new Collector(), null).size()); - assertEquals(0, plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.iac.administrator"), new Collector(), null).size()); + assertTrue(plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.agentcontroller"), null).isEmpty()); + assertTrue(plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.iac.administrator"), null).isEmpty()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ORTesting.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ORTesting.java deleted file mode 100644 index 2b391867a..000000000 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ORTesting.java +++ /dev/null @@ -1,150 +0,0 @@ -package org.eclipse.equinox.p2.tests.planner; - -import java.util.ArrayList; -import java.util.Collection; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.equinox.internal.p2.director.Slicer; -import org.eclipse.equinox.internal.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; -import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; - -public class ORTesting extends AbstractProvisioningTest { - //A[1.0] v A[1.1] - //!A[1.0.2] - - //A v C v !D[1.0.0, 1.1.0] <-- What is the semantics of negation on a range? - - private static final String NS = "theNamespace"; - private static final String N = "theName"; - - //A v C v C[1.0.0] - public void testOR() { - RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 1.2.0)"), null, false, false); - // RequiredCapability req2 = new RequiredCapability(NS, N, new VersionRange("[1.5.0, 2.0.0)"), null, false, false); - ORRequirement req = new ORRequirement(new IRequiredCapability[] {req1}); - ProvidedCapability prov = new ProvidedCapability(NS, N, new Version(1, 5, 0)); - assertFalse(prov.satisfies(req)); - } - - public void testOR2() { - RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.0.0, 1.2.0)"), null, false, false); - RequiredCapability req2 = new RequiredCapability(NS, N, new VersionRange("[1.5.0, 2.0.0)"), null, false, false); - ORRequirement req = new ORRequirement(new IRequiredCapability[] {req1, req2}); - ProvidedCapability prov = new ProvidedCapability(NS, N, new Version(1, 5, 0)); - assertTrue(prov.satisfies(req)); - } - - public void testOR3() { - MetadataFactory.InstallableUnitDescription iud1 = new MetadataFactory.InstallableUnitDescription(); - iud1.setId("TestOr"); - iud1.setVersion(Version.create("1.0.0")); - RequiredCapability req1 = new RequiredCapability(NS, N, new VersionRange("[1.1.0, 1.2.0)"), null, false, false); - RequiredCapability req2 = new RequiredCapability(NS, N, new VersionRange("[1.3.0, 1.4.0)"), null, false, false); - Collection requirements = new ArrayList(); - requirements.add(new ORRequirement(new IRequiredCapability[] {req1, req2})); - iud1.addRequiredCapabilities(requirements); - Collection capabilities = new ArrayList(); - capabilities.add(new ProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "TestOr", Version.create("1.0.0"))); - iud1.addProvidedCapabilities(capabilities); - IInstallableUnit iu1 = MetadataFactory.createInstallableUnit(iud1); - - MetadataFactory.InstallableUnitDescription iud2 = new MetadataFactory.InstallableUnitDescription(); - iud2.setId("ProviderOf1_0_0"); - iud2.setVersion(Version.create("1.0.0")); - Collection capabilities2 = new ArrayList(); - capabilities2.add(MetadataFactory.createProvidedCapability(NS, N, Version.create("1.0.0"))); - iud2.addProvidedCapabilities(capabilities2); - IInstallableUnit iu2 = MetadataFactory.createInstallableUnit(iud2); - - MetadataFactory.InstallableUnitDescription iud3 = new MetadataFactory.InstallableUnitDescription(); - iud3.setId("ProviderOf1_1_1"); - iud3.setVersion(Version.create("1.0.0")); - Collection capabilities3 = new ArrayList(); - capabilities3.add(MetadataFactory.createProvidedCapability(NS, N, Version.create("1.1.1"))); - capabilities3.add(new ProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "ProviderOf1_1_1", Version.create("1.0.0"))); - iud3.addProvidedCapabilities(capabilities3); - IInstallableUnit iu3 = MetadataFactory.createInstallableUnit(iud3); - - MetadataFactory.InstallableUnitDescription iud4 = new MetadataFactory.InstallableUnitDescription(); - iud4.setId("ProviderOf1_3_0"); - iud4.setVersion(Version.create("1.0.0")); - Collection capabilities4 = new ArrayList(); - capabilities4.add(MetadataFactory.createProvidedCapability(NS, N, Version.create("1.3.0"))); - capabilities4.add(new ProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "ProviderOf1_3_0", Version.create("1.0.0"))); - iud4.addProvidedCapabilities(capabilities4); - IInstallableUnit iu4 = MetadataFactory.createInstallableUnit(iud4); - - IMetadataRepository repo = createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2, iu3, iu4}); - - Slicer slicer = new Slicer(repo, null, false); - IQueryable slice = slicer.slice(new IInstallableUnit[] {iu1}, new NullProgressMonitor()); - Collector c = slice.query(InstallableUnitQuery.ANY, new Collector(), null); - assertEquals(3, c.size()); - - IPlanner planner = createPlanner(); - IProfile profile = createProfile("testOR3"); - ProfileChangeRequest changeRequest = new ProfileChangeRequest(profile); - changeRequest.addInstallableUnits(new IInstallableUnit[] {iu1}); - ProvisioningPlan plan = planner.getProvisioningPlan(changeRequest, null, null); - assertOK("Plan OK", plan.getStatus()); - // assertEquals(1, plan.getCompleteState().query(new InstallableUnitQuery(id), collector, monitor)) - } - - public void testOR4() { - IInstallableUnit a1 = createIU("A", Version.create("1.0.0"), true); - IInstallableUnit a2 = createIU("A", Version.create("2.0.0"), true); - - MetadataFactory.InstallableUnitDescription iud1 = new MetadataFactory.InstallableUnitDescription(); - iud1.setId("TestOr"); - iud1.setVersion(Version.create("1.0.0")); - RequiredCapability req1 = new RequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.2.0)"), null, false, false); - RequiredCapability req2 = new RequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.2.0)"), null, false, false); - - Collection requirements = new ArrayList(); - requirements.add(new ORRequirement(new IRequiredCapability[] {req1, req2})); - iud1.addRequiredCapabilities(requirements); - Collection capabilities = new ArrayList(); - capabilities.add(new ProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "TestOr", Version.create("1.0.0"))); - iud1.addProvidedCapabilities(capabilities); - IInstallableUnit iu1 = MetadataFactory.createInstallableUnit(iud1); - - createTestMetdataRepository(new IInstallableUnit[] {iu1, a2, a1}); - - IPlanner planner = createPlanner(); - IProfile profile = createProfile("TestOr4"); - ProfileChangeRequest changeRequest = new ProfileChangeRequest(profile); - changeRequest.addInstallableUnits(new IInstallableUnit[] {iu1}); - ProvisioningPlan plan = planner.getProvisioningPlan(changeRequest, null, null); - assertOK("Plan OK", plan.getStatus()); - // assertEquals(1, plan.getCompleteState().query(new InstallableUnitQuery(id), collector, monitor)) - } - - public void testOR5() { - MetadataFactory.InstallableUnitDescription iud1 = new MetadataFactory.InstallableUnitDescription(); - iud1.setId("TestOr"); - iud1.setVersion(Version.create("1.0.0")); - RequiredCapability req1 = new RequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.2.0)"), null, false, false); - RequiredCapability req2 = new RequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.2.0)"), null, false, false); - Collection requirements = new ArrayList(); - requirements.add(new ORRequirement(new IRequiredCapability[] {req1, req2})); - iud1.addRequiredCapabilities(requirements); - Collection capabilities = new ArrayList(); - capabilities.add(new ProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "TestOr", Version.create("1.0.0"))); - iud1.addProvidedCapabilities(capabilities); - IInstallableUnit iu1 = MetadataFactory.createInstallableUnit(iud1); - - createTestMetdataRepository(new IInstallableUnit[] {iu1}); - - IPlanner planner = createPlanner(); - IProfile profile = createProfile("TestOr4"); - ProfileChangeRequest changeRequest = new ProfileChangeRequest(profile); - changeRequest.addInstallableUnits(new IInstallableUnit[] {iu1}); - ProvisioningPlan plan = planner.getProvisioningPlan(changeRequest, null, null); - assertNotOK("Plan Not OK", plan.getStatus()); - // assertEquals(1, plan.getCompleteState().query(new InstallableUnitQuery(id), collector, monitor)) - } -} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PP2ShouldFailToInstall.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PP2ShouldFailToInstall.java index 785488397..36650a296 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PP2ShouldFailToInstall.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PP2ShouldFailToInstall.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IEngine; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PP2ShouldFailToInstall extends AbstractProvisioningTest { @@ -34,21 +36,21 @@ public class PP2ShouldFailToInstall extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - p2Feature = createIU("p2.feature", new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P1", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P2", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - p1 = createIU("P1", new Version(1, 0, 0), true); - p2 = createIU("P2", new Version(1, 0, 0), true); - p1b = createIU("P1", new Version(1, 1, 1), true); - p2b = createIU("P2", new Version(1, 1, 1), true); + p2Feature = createIU("p2.feature", Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P1", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P2", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU("P1", Version.createOSGi(1, 0, 0), true); + p2 = createIU("P2", Version.createOSGi(1, 0, 0), true); + p1b = createIU("P1", Version.createOSGi(1, 1, 1), true); + p2b = createIU("P2", Version.createOSGi(1, 1, 1), true); IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P1", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P1", new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "p2.feature", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "p2.feature", new VersionRange("[1.0.0,1.0.0]"), null, false, false)}}; - pp1 = createIUPatch("PP1", new Version("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + pp1 = createIUPatch("PP1", Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); IRequirementChange changepp2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P2", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P2", new VersionRange("[3.1.1, 3.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "p2.feature", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp2 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "p2.feature", new VersionRange("[1.0.0, 1.0.0]"), null, false, false)}}; - pp2 = createIUPatch("PP2", new Version("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); + pp2 = createIUPatch("PP2", Version.create("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p1b, p2b, pp1, pp2}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchFailingToInstall.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchFailingToInstall.java index 63700f374..c2e29f222 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchFailingToInstall.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchFailingToInstall.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IEngine; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchFailingToInstall extends AbstractProvisioningTest { @@ -34,21 +36,21 @@ public class PatchFailingToInstall extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - p2Feature = createIU("p2.feature", new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P1", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P2", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - p1 = createIU("P1", new Version(1, 0, 0), true); - p2 = createIU("P2", new Version(1, 0, 0), true); - p1b = createIU("P1", new Version(1, 1, 1), true); - p2b = createIU("P2", new Version(1, 1, 1), true); + p2Feature = createIU("p2.feature", Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P1", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P2", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU("P1", Version.createOSGi(1, 0, 0), true); + p2 = createIU("P2", Version.createOSGi(1, 0, 0), true); + p1b = createIU("P1", Version.createOSGi(1, 1, 1), true); + p2b = createIU("P2", Version.createOSGi(1, 1, 1), true); IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "p2.feature", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P1", new VersionRange("[1.1.1,1.1.1]"), null, false, false)}}; - pp1 = createIUPatch("PP1", new Version("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + pp1 = createIUPatch("PP1", Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); IRequirementChange changepp2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequiredCapability lifeCyclepp2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "p2.feature", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp2 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "P2", new VersionRange("[1.1.1,1.1.1]"), null, false, false)}}; - pp2 = createIUPatch("PP2", new Version("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); + pp2 = createIUPatch("PP2", Version.create("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p1b, p2b, pp1, pp2}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1.java index 5cfcb737a..2c323f982 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest1 extends AbstractProvisioningTest { @@ -31,10 +33,10 @@ public class PatchTest1 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - b1 = createIU("B", new Version(1, 2, 0), true); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + b1 = createIU("B", Version.createOSGi(1, 2, 0), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, p1}); @@ -47,7 +49,7 @@ public class PatchTest1 extends AbstractProvisioningTest { //The requirement from A to B is broken because there is no B satisifying. Therefore A can only install if the P is installed as well ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest10.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest10.java index 0cf1378ed..2f72df7f9 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest10.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest10.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest10 extends AbstractProvisioningTest { @@ -34,15 +36,15 @@ public class PatchTest10 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - b1 = createIU("B", new Version(1, 0, 0), true); - b2 = createIU("B", new Version(1, 2, 0), true); - b3 = createIU("B", new Version(1, 3, 0), true); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + b1 = createIU("B", Version.createOSGi(1, 0, 0), true); + b2 = createIU("B", Version.createOSGi(1, 2, 0), true); + b3 = createIU("B", Version.createOSGi(1, 3, 0), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.2.0, 1.2.0]"), null, false, false, true)); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); IRequirementChange anotherChangeB = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.3.0, 1.3.0]"), null, false, false, true)); - pp1 = createIUPatch("PP", new Version("1.0.0"), true, new IRequirementChange[] {anotherChangeB}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + pp1 = createIUPatch("PP", Version.create("1.0.0"), true, new IRequirementChange[] {anotherChangeB}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, b3, p1, pp1}); @@ -55,7 +57,7 @@ public class PatchTest10 extends AbstractProvisioningTest { //a1 and p1 can be installed together ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); assertInstallOperand(plan1, a1); assertInstallOperand(plan1, p1); @@ -64,7 +66,7 @@ public class PatchTest10 extends AbstractProvisioningTest { //a1 and pp1 can be installed together ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {a1, pp1}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); assertInstallOperand(plan2, a1); assertInstallOperand(plan2, pp1); @@ -73,14 +75,14 @@ public class PatchTest10 extends AbstractProvisioningTest { //a1, p1, and pp1 can not be installed together ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {a1, p1, pp1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.ERROR, plan3.getStatus().getSeverity()); } public void testExplanation() { ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {a1, p1, pp1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.ERROR, plan3.getStatus().getSeverity()); // Set problems = plan3.getRequestStatus().getConflictsWithInstalledRoots(); // System.out.println(problems); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest11.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest11.java index bca51d3e0..694599a00 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest11.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest11.java @@ -10,14 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest11 extends AbstractProvisioningTest { @@ -32,11 +33,11 @@ public class PatchTest11 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true, true)}); - b1 = createIU("B", new Version(1, 0, 0), true); - b2 = createIU("B", new Version(1, 2, 0), true); - IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), "foo=bar", false, false, true)); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true, true)}); + b1 = createIU("B", Version.createOSGi(1, 0, 0), true); + b2 = createIU("B", Version.createOSGi(1, 2, 0), true); + IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), "(foo=bar)", false, false, true)); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, p1}); @@ -51,7 +52,7 @@ public class PatchTest11 extends AbstractProvisioningTest { ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {a1, p1}); req2.setInstallableUnitInclusionRules(p1, PlannerHelper.createOptionalInclusionRule(p1)); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertTrue(IStatus.ERROR != plan2.getStatus().getSeverity()); assertNoOperand(plan2, b1); assertNoOperand(plan2, b2); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest12.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest12.java index c21886249..3d362de02 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest12.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest12.java @@ -10,16 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Set; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.director.Explanation; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest12 extends AbstractProvisioningTest { @@ -34,11 +35,11 @@ public class PatchTest12 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true, true)}); - b1 = createIU("B", new Version(1, 0, 0), true); - b2 = createIU("B", new Version(1, 2, 0), true); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true, true)}); + b1 = createIU("B", Version.createOSGi(1, 0, 0), true); + b2 = createIU("B", Version.createOSGi(1, 2, 0), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.4.0, 1.5.0)"), null, false, true, true)); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, p1}); @@ -54,7 +55,7 @@ public class PatchTest12 extends AbstractProvisioningTest { ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {a1, p1}); req2.setInstallableUnitInclusionRules(p1, PlannerHelper.createOptionalInclusionRule(p1)); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertTrue(IStatus.ERROR != plan2.getStatus().getSeverity()); assertNoOperand(plan2, p1); assertNoOperand(plan2, b2); @@ -65,7 +66,7 @@ public class PatchTest12 extends AbstractProvisioningTest { //Try to install a1 and p1. This should fail because the patch adds an invalid filter ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertTrue(IStatus.ERROR == plan3.getStatus().getSeverity()); } @@ -73,10 +74,11 @@ public class PatchTest12 extends AbstractProvisioningTest { public void testExplanation1() { ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + ProvisioningPlan plan3 = (ProvisioningPlan) planner.getProvisioningPlan(req3, null, null); assertTrue(IStatus.ERROR == plan3.getStatus().getSeverity()); - Set conflictRootIUs = plan3.getRequestStatus().getConflictsWithInstalledRoots(); + final RequestStatus requestStatus = (RequestStatus) plan3.getRequestStatus(); + Set conflictRootIUs = requestStatus.getConflictsWithInstalledRoots(); assertTrue(conflictRootIUs.contains(p1)); - assertEquals(Explanation.MISSING_REQUIREMENT, plan3.getRequestStatus().getShortExplanation()); + assertEquals(Explanation.MISSING_REQUIREMENT, requestStatus.getShortExplanation()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest13.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest13.java index 6ee942f09..4e1f7bd92 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest13.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest13.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest13 extends AbstractProvisioningTest { @@ -33,12 +35,12 @@ public class PatchTest13 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - b1 = createIU("B", new Version(1, 0, 0), true); - d1 = createIU("D", new Version(1, 0, 0), true); - c1 = createIU("C", new Version(1, 0, 0), true); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + b1 = createIU("B", Version.createOSGi(1, 0, 0), true); + d1 = createIU("D", Version.createOSGi(1, 0, 0), true); + c1 = createIU("C", Version.createOSGi(1, 0, 0), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.0.0, 1.3.0)"), null, false, false, true)); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, c1, d1, p1}); @@ -50,7 +52,7 @@ public class PatchTest13 extends AbstractProvisioningTest { public void testInstall() { ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertTrue(IStatus.ERROR != plan1.getStatus().getSeverity()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1b.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1b.java index 3c7e4771d..464dbcf01 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1b.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1b.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest1b extends AbstractProvisioningTest { @@ -32,11 +34,11 @@ public class PatchTest1b extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - b1 = createIU("B", new Version(1, 0, 0), true); - b2 = createIU("B", new Version(1, 2, 0), true); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + b1 = createIU("B", Version.createOSGi(1, 0, 0), true); + b2 = createIU("B", Version.createOSGi(1, 2, 0), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, p1}); @@ -49,7 +51,7 @@ public class PatchTest1b extends AbstractProvisioningTest { //A requires B 1.0, the installation of the P will result in B 1.2 to be installed ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertTrue(IStatus.ERROR != plan1.getStatus().getSeverity()); assertInstallOperand(plan1, a1); assertInstallOperand(plan1, p1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1c.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1c.java index 0dd2608c8..4b16ecc15 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1c.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1c.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest1c extends AbstractProvisioningTest { @@ -33,12 +35,12 @@ public class PatchTest1c extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - b1 = createIU("B", new Version(1, 0, 0), true); - b2 = createIU("B", new Version(1, 2, 0), true); - b3 = createIU("B", new Version(1, 3, 0), true); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + b1 = createIU("B", Version.createOSGi(1, 0, 0), true); + b2 = createIU("B", Version.createOSGi(1, 2, 0), true); + b3 = createIU("B", Version.createOSGi(1, 3, 0), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.2.0, 1.2.0]"), null, false, false, true)); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, p1}); @@ -51,7 +53,7 @@ public class PatchTest1c extends AbstractProvisioningTest { //A requires B [1.0, 1.1), the installation of P will result in B 1.2 to be installed ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertTrue(IStatus.ERROR != plan1.getStatus().getSeverity()); assertInstallOperand(plan1, a1); assertInstallOperand(plan1, p1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest2.java index 7bf64d544..70571a580 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest2.java @@ -10,16 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Set; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.director.Explanation; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest2 extends AbstractProvisioningTest { @@ -38,16 +39,16 @@ public class PatchTest2 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - IProvidedCapability[] cap = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("foo", "bar", new Version(1, 0, 0))}; - a1 = createIU("A", new Version("1.0.0"), null, new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, false)}, cap, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); - b1 = createIU("B", new Version(1, 2, 0), true); + IProvidedCapability[] cap = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("foo", "bar", Version.createOSGi(1, 0, 0))}; + a1 = createIU("A", Version.create("1.0.0"), null, new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, false)}, cap, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); + b1 = createIU("B", Version.createOSGi(1, 2, 0), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0]"), null, false, false, false)}}, null); - p2 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.3.0, 1.5.0]"), null, false, false, false)}}, null); - p3 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] { {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0]"), null, false, false, false)}, {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.3.0, 1.5.0]"), null, false, false, false)}}, null); - p4 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] { {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.6.0, 1.7.0]"), null, false, false, false)}, {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.3.0, 1.5.0]"), null, false, false, false)}}, null); - p5 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability("foo", "bar", new VersionRange("[1.0.0, 2.0.0)"), null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.5.0]"), null, false, false, false)}}, null); - p6 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {}, null); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0]"), null, false, false, false)}}, null); + p2 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.3.0, 1.5.0]"), null, false, false, false)}}, null); + p3 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] { {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0]"), null, false, false, false)}, {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.3.0, 1.5.0]"), null, false, false, false)}}, null); + p4 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] { {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.6.0, 1.7.0]"), null, false, false, false)}, {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.3.0, 1.5.0]"), null, false, false, false)}}, null); + p5 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability("foo", "bar", new VersionRange("[1.0.0, 2.0.0)"), null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.5.0]"), null, false, false, false)}}, null); + p6 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {}, null); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, p1, p2, p3, p4, p5, p6}); profile1 = createProfile("TestProfile." + getName()); @@ -59,37 +60,37 @@ public class PatchTest2 extends AbstractProvisioningTest { //p6 applies to all IUs therefore A's installation succeed ProfileChangeRequest req8 = new ProfileChangeRequest(profile1); req8.addInstallableUnits(new IInstallableUnit[] {a1, p6}); - ProvisioningPlan plan8 = planner.getProvisioningPlan(req8, null, null); + IProvisioningPlan plan8 = planner.getProvisioningPlan(req8, null, null); assertEquals(IStatus.OK, plan8.getStatus().getSeverity()); //p5 does not causes a1 to resolve therefore the application fails ProfileChangeRequest req6 = new ProfileChangeRequest(profile1); req6.addInstallableUnits(new IInstallableUnit[] {a1, p5}); - ProvisioningPlan plan6 = planner.getProvisioningPlan(req6, null, null); + IProvisioningPlan plan6 = planner.getProvisioningPlan(req6, null, null); assertEquals(IStatus.OK, plan6.getStatus().getSeverity()); //Ensure that p1 causes a1 to resolve ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); //p2 does not causes a1 to resolve therefore the application fails ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {a1, p2}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.ERROR, plan3.getStatus().getSeverity()); //Ensure that p3 causes a1 to resolve since it has two scopes where one is applicable ProfileChangeRequest req4 = new ProfileChangeRequest(profile1); req4.addInstallableUnits(new IInstallableUnit[] {a1, p3}); - ProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null); + IProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null); assertEquals(IStatus.OK, plan4.getStatus().getSeverity()); //p4 does not causes a1 to resolve therefore the application fails ProfileChangeRequest req5 = new ProfileChangeRequest(profile1); req5.addInstallableUnits(new IInstallableUnit[] {a1, p4}); - ProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); + IProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); assertEquals(IStatus.ERROR, plan5.getStatus().getSeverity()); } @@ -98,11 +99,12 @@ public class PatchTest2 extends AbstractProvisioningTest { //p2 does not cause a1 to resolve therefore the application fails ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {a1, p2}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + ProvisioningPlan plan3 = (ProvisioningPlan) planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.ERROR, plan3.getStatus().getSeverity()); - assertEquals(Explanation.MISSING_REQUIREMENT, plan3.getRequestStatus().getShortExplanation()); + final RequestStatus requestStatus = (RequestStatus) plan3.getRequestStatus(); + assertEquals(Explanation.MISSING_REQUIREMENT, requestStatus.getShortExplanation()); // System.out.println(plan3.getRequestStatus().getExplanations()); - Set conflictingRoot = plan3.getRequestStatus().getConflictsWithInstalledRoots(); + Set conflictingRoot = requestStatus.getConflictsWithInstalledRoots(); assertTrue(conflictingRoot.contains(a1)); assertEquals(1, conflictingRoot.size()); } @@ -111,11 +113,12 @@ public class PatchTest2 extends AbstractProvisioningTest { //p4 does not cause a1 to resolve therefore the application fails ProfileChangeRequest req5 = new ProfileChangeRequest(profile1); req5.addInstallableUnits(new IInstallableUnit[] {a1, p4}); - ProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); + ProvisioningPlan plan5 = (ProvisioningPlan) planner.getProvisioningPlan(req5, null, null); assertEquals(IStatus.ERROR, plan5.getStatus().getSeverity()); - assertEquals(Explanation.MISSING_REQUIREMENT, plan5.getRequestStatus().getShortExplanation()); + final RequestStatus requestStatus = (RequestStatus) plan5.getRequestStatus(); + assertEquals(Explanation.MISSING_REQUIREMENT, requestStatus.getShortExplanation()); // System.out.println(plan5.getRequestStatus().getExplanations()); - Set conflictingRoot = plan5.getRequestStatus().getConflictsWithInstalledRoots(); + Set conflictingRoot = requestStatus.getConflictsWithInstalledRoots(); assertTrue(conflictingRoot.contains(a1)); assertEquals(1, conflictingRoot.size()); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest3.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest3.java index 2a873da4a..a7d0dc30e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest3.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest3.java @@ -10,13 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest3 extends AbstractProvisioningTest { @@ -33,16 +35,16 @@ public class PatchTest3 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - f1 = createIU("F", new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0]"), null, false, false, true)}); - f2 = createIU("F", new Version(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[3.0.0, 4.0.0)"), null, false, false, true)}); - IProvidedCapability[] cap = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("foo", "bar", new Version(1, 0, 0))}; - a1 = createIU("A", new Version("1.0.0"), null, new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, false)}, cap, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); - a3 = createIU("A", new Version(3, 0, 0), true); - b1 = createIU("B", new Version(1, 0, 0), true); - b2 = createIU("B", new Version(2, 0, 0), true); + f1 = createIU("F", Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0]"), null, false, false, true)}); + f2 = createIU("F", Version.createOSGi(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[3.0.0, 4.0.0)"), null, false, false, true)}); + IProvidedCapability[] cap = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("foo", "bar", Version.createOSGi(1, 0, 0))}; + a1 = createIU("A", Version.create("1.0.0"), null, new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, false)}, cap, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null); + a3 = createIU("A", Version.createOSGi(3, 0, 0), true); + b1 = createIU("B", Version.createOSGi(1, 0, 0), true); + b2 = createIU("B", Version.createOSGi(2, 0, 0), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0, 2.1.0)"), null, false, false, true)); IRequiredCapability lifeCycle = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "F", new VersionRange("[1.0.0, 1.1.0)"), null, false, false, false); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0]"), null, false, false, false)}}, lifeCycle); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0]"), null, false, false, false)}}, lifeCycle); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, p1, a3, f1, f2}); profile1 = createProfile("TestProfile." + getName()); @@ -54,12 +56,12 @@ public class PatchTest3 extends AbstractProvisioningTest { // Install a1 ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {f1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); assertInstallOperand(plan1, b1); assertInstallOperand(plan1, a1); assertInstallOperand(plan1, f1); - engine.perform(profile1, new DefaultPhaseSet(), plan1.getOperands(), null, null); + engine.perform(plan1, null); assertProfileContainsAll("A1 is missing", profile1, new IInstallableUnit[] {a1}); assertProfileContainsAll("B1 is missing", profile1, new IInstallableUnit[] {b1}); assertProfileContainsAll("B1 is missing", profile1, new IInstallableUnit[] {f1}); @@ -68,11 +70,11 @@ public class PatchTest3 extends AbstractProvisioningTest { ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {p1}); req2.setInstallableUnitInclusionRules(p1, PlannerHelper.createOptionalInclusionRule(p1)); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertTrue(IStatus.ERROR != plan2.getStatus().getSeverity()); assertInstallOperand(plan2, p1); assertInstallOperand(plan2, b2); - engine.perform(profile1, new DefaultPhaseSet(), plan2.getOperands(), null, null); + engine.perform(plan2, null); assertProfileContainsAll("A1 is missing", profile1, new IInstallableUnit[] {a1}); assertProfileContainsAll("B2 is missing", profile1, new IInstallableUnit[] {b2}); assertProfileContainsAll("P1 is missing", profile1, new IInstallableUnit[] {p1}); @@ -81,7 +83,7 @@ public class PatchTest3 extends AbstractProvisioningTest { //Try to uninstall p1, this causes b1 to come back and b2 to go away ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.removeInstallableUnits(new IInstallableUnit[] {p1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertTrue(IStatus.ERROR != plan3.getStatus().getSeverity()); assertInstallOperand(plan3, b1); assertUninstallOperand(plan3, b2); @@ -90,7 +92,7 @@ public class PatchTest3 extends AbstractProvisioningTest { //Try to uninstall f should not be blocked by p1 since it is installed optionally ProfileChangeRequest req4 = new ProfileChangeRequest(profile1); req4.removeInstallableUnits(new IInstallableUnit[] {f1}); - ProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null); + IProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null); assertTrue(IStatus.ERROR != plan4.getStatus().getSeverity()); assertUninstallOperand(plan4, b2); assertUninstallOperand(plan4, a1); @@ -101,7 +103,7 @@ public class PatchTest3 extends AbstractProvisioningTest { ProfileChangeRequest req5 = new ProfileChangeRequest(profile1); req5.removeInstallableUnits(new IInstallableUnit[] {f1}); req5.addInstallableUnits(new IInstallableUnit[] {f2}); - ProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); + IProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); assertTrue(IStatus.ERROR != plan5.getStatus().getSeverity()); assertUninstallOperand(plan5, b2); assertUninstallOperand(plan5, a1); @@ -109,7 +111,7 @@ public class PatchTest3 extends AbstractProvisioningTest { assertUninstallOperand(plan5, p1); assertInstallOperand(plan5, f2); assertInstallOperand(plan5, a3); - engine.perform(profile1, new DefaultPhaseSet(), plan5.getOperands(), null, null); + engine.perform(plan5, null); assertProfileContainsAll("", profile1, new IInstallableUnit[] {f2, a3}); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest4.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest4.java index 64931dabd..ff1253f15 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest4.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest4.java @@ -10,13 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest4 extends AbstractProvisioningTest { @@ -37,21 +39,21 @@ public class PatchTest4 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - f1 = createIU("F", new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, false, false, true)}); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, false, true)}); - b1 = createIU("B", new Version(1, 0, 0), true); - c1 = createIU("C", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.0.0, 1.1.0)"), null, false, false, true)}); - d1 = createIU("D", new Version(1, 0, 0), true); - b2 = createIU("B", new Version(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[2.0.0, 3.1.0)"), null, false, false, true)}); - d2 = createIU("D", new Version(2, 0, 0), true); + f1 = createIU("F", Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, false, false, true)}); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, false, true)}); + b1 = createIU("B", Version.createOSGi(1, 0, 0), true); + c1 = createIU("C", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.0.0, 1.1.0)"), null, false, false, true)}); + d1 = createIU("D", Version.createOSGi(1, 0, 0), true); + b2 = createIU("B", Version.createOSGi(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[2.0.0, 3.1.0)"), null, false, false, true)}); + d2 = createIU("D", Version.createOSGi(2, 0, 0), true); IRequirementChange changeA = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0, 2.1.0)"), null, false, false, true)); IRequirementChange changeC = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[2.0.0, 2.1.0)"), null, false, false, true)); IRequiredCapability lifeCycle = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "F", VersionRange.emptyRange, null, false, false, false); IRequiredCapability[][] scope = new IRequiredCapability[][] { {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0]"), null, false, false, false)}, {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 1.1.0]"), null, false, false, false)}}; - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {changeA, changeC}, scope, lifeCycle); - p2 = createIUPatch("P", new Version("2.0.0"), true, new IRequirementChange[] {changeA, changeC}, new IRequiredCapability[0][0], lifeCycle); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {changeA, changeC}, scope, lifeCycle); + p2 = createIUPatch("P", Version.create("2.0.0"), true, new IRequirementChange[] {changeA, changeC}, new IRequiredCapability[0][0], lifeCycle); createTestMetdataRepository(new IInstallableUnit[] {f1, a1, b1, b2, c1, d1, d2, p1}); profile1 = createProfile("TestProfile." + getName()); @@ -63,12 +65,12 @@ public class PatchTest4 extends AbstractProvisioningTest { // Install f1 ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {f1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); assertInstallOperand(plan1, b1); assertInstallOperand(plan1, a1); assertInstallOperand(plan1, f1); - engine.perform(profile1, new DefaultPhaseSet(), plan1.getOperands(), null, null); + engine.perform(plan1, null); assertProfileContainsAll("A1 is missing", profile1, new IInstallableUnit[] {a1}); assertProfileContainsAll("B1 is missing", profile1, new IInstallableUnit[] {b1}); assertProfileContainsAll("C1 is missing", profile1, new IInstallableUnit[] {c1}); @@ -78,11 +80,11 @@ public class PatchTest4 extends AbstractProvisioningTest { ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {p1}); req2.setInstallableUnitInclusionRules(p1, PlannerHelper.createOptionalInclusionRule(p1)); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertTrue(IStatus.ERROR != plan2.getStatus().getSeverity()); assertInstallOperand(plan2, b2); assertInstallOperand(plan2, d2); - engine.perform(profile1, new DefaultPhaseSet(), plan2.getOperands(), null, null); + engine.perform(plan2, null); assertProfileContainsAll("A1 is missing", profile1, new IInstallableUnit[] {a1}); assertProfileContainsAll("B2 is missing", profile1, new IInstallableUnit[] {b2}); assertProfileContainsAll("P1 is missing", profile1, new IInstallableUnit[] {p1}); @@ -96,12 +98,12 @@ public class PatchTest4 extends AbstractProvisioningTest { // Install f1 ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {f1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); assertInstallOperand(plan1, b1); assertInstallOperand(plan1, a1); assertInstallOperand(plan1, f1); - engine.perform(profile1, new DefaultPhaseSet(), plan1.getOperands(), null, null); + engine.perform(plan1, null); assertProfileContainsAll("A1 is missing", profile1, new IInstallableUnit[] {a1}); assertProfileContainsAll("B1 is missing", profile1, new IInstallableUnit[] {b1}); assertProfileContainsAll("C1 is missing", profile1, new IInstallableUnit[] {c1}); @@ -111,11 +113,11 @@ public class PatchTest4 extends AbstractProvisioningTest { ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {p2}); req2.setInstallableUnitInclusionRules(p1, PlannerHelper.createOptionalInclusionRule(p1)); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertTrue(IStatus.ERROR != plan2.getStatus().getSeverity()); assertInstallOperand(plan2, b2); assertInstallOperand(plan2, d2); - engine.perform(profile1, new DefaultPhaseSet(), plan2.getOperands(), null, null); + engine.perform(plan2, null); assertProfileContainsAll("A1 is missing", profile1, new IInstallableUnit[] {a1}); assertProfileContainsAll("B2 is missing", profile1, new IInstallableUnit[] {b2}); assertProfileContainsAll("P1 is missing", profile1, new IInstallableUnit[] {p1}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest5.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest5.java index 02ab2a134..008a7b57f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest5.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest5.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest5 extends AbstractProvisioningTest { @@ -33,14 +35,14 @@ public class PatchTest5 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - top = createIU("TOP", new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "F", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - f1 = createIU("F", new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - b1 = createIU("B", new Version(1, 2, 0), true); + top = createIU("TOP", Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "F", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + f1 = createIU("F", Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + b1 = createIU("B", Version.createOSGi(1, 2, 0), true); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequiredCapability lifeCycle = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "F", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scope = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0,1.0.0]"), null, false, false)}}; - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, scope, lifeCycle); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, scope, lifeCycle); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, f1, top, p1}); @@ -52,12 +54,12 @@ public class PatchTest5 extends AbstractProvisioningTest { public void testInstall() { ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {top}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.ERROR, plan1.getStatus().getSeverity()); ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {top, p1}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest6.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest6.java index e53a8f741..17b87a579 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest6.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest6.java @@ -10,16 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Set; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.director.Explanation; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest6 extends AbstractProvisioningTest { @@ -37,20 +38,20 @@ public class PatchTest6 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - b1 = createIU("B", new Version(1, 2, 0), true); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + b1 = createIU("B", Version.createOSGi(1, 2, 0), true); - c1 = createIU("C", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - d1 = createIU("D", new Version(1, 2, 0), true); + c1 = createIU("C", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + d1 = createIU("D", Version.createOSGi(1, 2, 0), true); IRequirementChange changeA = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequiredCapability[][] scopeP1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, false)}}; IRequiredCapability[] reqOnPP = new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "PP", new VersionRange("[1.0.0, 2.0.0)"), null, false, false, true)}; - p1 = createIUPatch("P", new Version("1.0.0"), null, reqOnPP, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeA}, scopeP1, null, new IRequiredCapability[0]); + p1 = createIUPatch("P", Version.create("1.0.0"), null, reqOnPP, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeA}, scopeP1, null, new IRequiredCapability[0]); IRequirementChange changeC = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequiredCapability[][] scopePP1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, false, false, false)}}; - pp1 = createIUPatch("PP", new Version("1.0.0"), true, new IRequirementChange[] {changeC}, scopePP1, null); + pp1 = createIUPatch("PP", Version.create("1.0.0"), true, new IRequirementChange[] {changeC}, scopePP1, null); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, c1, d1, p1, pp1}); profile1 = createProfile("TestProfile." + getName()); @@ -62,25 +63,25 @@ public class PatchTest6 extends AbstractProvisioningTest { //Confirm that a1 and c1 can't be installed ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {a1, c1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.ERROR, plan1.getStatus().getSeverity()); //Verify that the installation of c1 and pp1 succeed ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {c1, pp1}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); //Verify that p1 can be installed alone (kind of meaningless) ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {p1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.OK, plan3.getStatus().getSeverity()); //Install a1 and p1. ProfileChangeRequest req4 = new ProfileChangeRequest(profile1); req4.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - ProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null); + IProvisioningPlan plan4 = planner.getProvisioningPlan(req4, null, null); assertEquals(IStatus.OK, plan4.getStatus().getSeverity()); assertInstallOperand(plan4, a1); assertInstallOperand(plan4, p1); @@ -90,7 +91,7 @@ public class PatchTest6 extends AbstractProvisioningTest { //Install a1, c1 and p1. ProfileChangeRequest req5 = new ProfileChangeRequest(profile1); req5.addInstallableUnits(new IInstallableUnit[] {a1, c1, p1}); - ProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); + IProvisioningPlan plan5 = planner.getProvisioningPlan(req5, null, null); assertEquals(IStatus.OK, plan5.getStatus().getSeverity()); assertInstallOperand(plan4, a1); assertInstallOperand(plan4, p1); @@ -104,10 +105,11 @@ public class PatchTest6 extends AbstractProvisioningTest { //Confirm that a1 and c1 can't be installed ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {a1, c1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + ProvisioningPlan plan1 = (ProvisioningPlan) planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.ERROR, plan1.getStatus().getSeverity()); - assertEquals(Explanation.MISSING_REQUIREMENT, plan1.getRequestStatus().getShortExplanation()); - Set conflictingRoots = plan1.getRequestStatus().getConflictsWithInstalledRoots(); + final RequestStatus requestStatus = (RequestStatus) plan1.getRequestStatus(); + assertEquals(Explanation.MISSING_REQUIREMENT, requestStatus.getShortExplanation()); + Set conflictingRoots = requestStatus.getConflictsWithInstalledRoots(); assertEquals(1, conflictingRoots.size()); assertTrue(conflictingRoots.contains(a1) || conflictingRoots.contains(c1)); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest7.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest7.java index a2e5f246e..0043baed3 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest7.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest7.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest7 extends AbstractProvisioningTest { @@ -38,26 +40,26 @@ public class PatchTest7 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - // x1 = createIU("X", new Version(1, 2, 0), true); - y1 = createIU("Y", new Version(1, 0, 0), true); - y2 = createIU("Y", new Version(1, 2, 0), true); - // a1 = createIU("A", new Version("1.0.0"), new RequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - // b1 = createIU("B", new Version("1.0.0"), new RequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - c1 = createIU("C", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "Y", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + // x1 = createIU("X", Version.createOSGi(1, 2, 0), true); + y1 = createIU("Y", Version.createOSGi(1, 0, 0), true); + y2 = createIU("Y", Version.createOSGi(1, 2, 0), true); + // a1 = createIU("A", Version.create("1.0.0"), new RequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + // b1 = createIU("B", Version.create("1.0.0"), new RequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + c1 = createIU("C", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "Y", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); IRequiredCapability[] req = new IRequiredCapability[1]; // req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0)"), null, false, true); // req[1] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true); req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 1.1.0)"), null, false, true); - f1 = createIU("F", new Version(1, 0, 0), req); + f1 = createIU("F", Version.createOSGi(1, 0, 0), req); // RequirementChange changeX = new RequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "X", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); // RequiredCapability[][] scope = new RequiredCapability[0][0]; //new RequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, false)}}; - // p1 = createIUPatch("P", new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, TouchpointType.NONE, NO_TP_DATA, false, null, new RequirementChange[] {changeX}, scope, null); + // p1 = createIUPatch("P", Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, TouchpointType.NONE, NO_TP_DATA, false, null, new RequirementChange[] {changeX}, scope, null); IRequirementChange changeY = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "Y", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "Y", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequiredCapability[][] scopePP = new IRequiredCapability[0][0]; //new RequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, false, false, false)}}; - pp1 = createIUPatch("PP", new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeY}, scopePP, null, new IRequiredCapability[0]); + pp1 = createIUPatch("PP", Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeY}, scopePP, null, new IRequiredCapability[0]); // createTestMetdataRepository(new IInstallableUnit[] {a1, b1, c1, x1, y1, y2, f1, p1, pp1}); createTestMetdataRepository(new IInstallableUnit[] {c1, y1, y2, f1, pp1}); @@ -90,7 +92,7 @@ public class PatchTest7 extends AbstractProvisioningTest { //Verify that the installation of f1 and p1 succeed ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {f1, pp1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.OK, plan3.getStatus().getSeverity()); assertInstallOperand(plan3, f1); // assertInstallOperand(plan3, a1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest7b.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest7b.java index e6cb09235..0e143f71f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest7b.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest7b.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest7b extends AbstractProvisioningTest { @@ -38,26 +40,26 @@ public class PatchTest7b extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - x1 = createIU("X", new Version(1, 2, 0), true); - y1 = createIU("Y", new Version(1, 0, 0), true); - y2 = createIU("Y", new Version(1, 2, 0), true); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - b1 = createIU("B", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - c1 = createIU("C", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "Y", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + x1 = createIU("X", Version.createOSGi(1, 2, 0), true); + y1 = createIU("Y", Version.createOSGi(1, 0, 0), true); + y2 = createIU("Y", Version.createOSGi(1, 2, 0), true); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + b1 = createIU("B", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + c1 = createIU("C", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "Y", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); IRequiredCapability[] req = new IRequiredCapability[3]; req[2] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0)"), null, false, true); req[1] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true); req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 1.1.0)"), null, false, true); - f1 = createIU("F", new Version(1, 0, 0), req); + f1 = createIU("F", Version.createOSGi(1, 0, 0), req); IRequirementChange changeX = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "X", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "X", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequiredCapability[][] scope = new IRequiredCapability[0][0]; //new RequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, false)}}; - p1 = createIUPatch("P", new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeX}, scope, null, new IRequiredCapability[0]); + p1 = createIUPatch("P", Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeX}, scope, null, new IRequiredCapability[0]); IRequirementChange changeY = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "Y", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "Y", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequiredCapability[][] scopePP = new IRequiredCapability[0][0]; //new RequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, false, false, false)}}; - pp1 = createIUPatch("PP", new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeY}, scopePP, null, new IRequiredCapability[0]); + pp1 = createIUPatch("PP", Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeY}, scopePP, null, new IRequiredCapability[0]); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, c1, x1, y1, y2, f1, p1, pp1}); // createTestMetdataRepository(new IInstallableUnit[] {c1, y1, y2, f1, pp1}); @@ -77,7 +79,7 @@ public class PatchTest7b extends AbstractProvisioningTest { //Verify that the installation of f1 and p1 succeed ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {f1, p1}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); assertInstallOperand(plan2, f1); assertInstallOperand(plan2, a1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest8.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest8.java index ede44e0db..c24ded126 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest8.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest8.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest8 extends AbstractProvisioningTest { @@ -37,25 +39,25 @@ public class PatchTest8 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version(1, 0, 0), true); - a2 = createIU("A", new Version("2.0.0"), true); - b1 = createIU("B", new Version("1.0.0"), true); - b2 = createIU("B", new Version("2.0.0"), true); - c2 = createIU("C", new Version("2.0.0"), true); + a1 = createIU("A", Version.createOSGi(1, 0, 0), true); + a2 = createIU("A", Version.create("2.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); + b2 = createIU("B", Version.create("2.0.0"), true); + c2 = createIU("C", Version.create("2.0.0"), true); IRequiredCapability[] req = new IRequiredCapability[3]; req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.1.0)"), null, false, true); req[1] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true); req[2] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[2.0.0, 3.1.0)"), null, false, true); - f1 = createIU("F", new Version(1, 0, 0), req); + f1 = createIU("F", Version.createOSGi(1, 0, 0), req); IRequirementChange changeA = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 3.0.0)"), null, false, false, true)); IRequiredCapability[][] scope = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "F", VersionRange.emptyRange, null, false, false, false)}}; - p1 = createIUPatch("P", new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeA}, scope, null, new IRequiredCapability[0]); + p1 = createIUPatch("P", Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeA}, scope, null, new IRequiredCapability[0]); IRequirementChange changeB = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0, 3.0.0)"), null, false, false, true)); IRequiredCapability[][] scopePP = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "F", VersionRange.emptyRange, null, false, false, false)}}; - r1 = createIUPatch("R", new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeB}, scopePP, null, new IRequiredCapability[0]); + r1 = createIUPatch("R", Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, new IRequirementChange[] {changeB}, scopePP, null, new IRequiredCapability[0]); createTestMetdataRepository(new IInstallableUnit[] {a1, a2, b1, b2, c2, f1, p1, r1}); @@ -87,7 +89,7 @@ public class PatchTest8 extends AbstractProvisioningTest { //Verify that the installation of f1 and p1 succeed ProfileChangeRequest req3 = new ProfileChangeRequest(profile1); req3.addInstallableUnits(new IInstallableUnit[] {f1, p1, r1}); - ProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); + IProvisioningPlan plan3 = planner.getProvisioningPlan(req3, null, null); assertEquals(IStatus.OK, plan3.getStatus().getSeverity()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest9.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest9.java index c2bde8342..0a9f4a759 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest9.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest9.java @@ -10,16 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Set; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.director.Explanation; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTest9 extends AbstractProvisioningTest { @@ -36,16 +37,16 @@ public class PatchTest9 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); - b1 = createIU("B", new Version(1, 0, 0), true); - b2 = createIU("B", new Version(1, 2, 0), true); - c1 = createIU("C", new Version(1, 0, 0), true); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.1.0)"), null, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 1.1.0)"), null, false, true)}); + b1 = createIU("B", Version.createOSGi(1, 0, 0), true); + b2 = createIU("B", Version.createOSGi(1, 2, 0), true); + c1 = createIU("C", Version.createOSGi(1, 0, 0), true); IRequirementChange changeB = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); IRequirementChange changeC = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true)); - p1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {changeB, changeC}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + p1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {changeB, changeC}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); IRequirementChange anotherChangeC = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.1.0, 1.3.0)"), null, true, false, true)); - pp1 = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {changeB, anotherChangeC}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); + pp1 = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {changeB, anotherChangeC}, new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false)}}, null); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, c1, p1, pp1}); @@ -58,7 +59,7 @@ public class PatchTest9 extends AbstractProvisioningTest { //The application of the patch does not succeed because there is no C matching the requirement imposed by the patch ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.ERROR, plan1.getStatus().getSeverity()); } @@ -66,10 +67,11 @@ public class PatchTest9 extends AbstractProvisioningTest { //The application of the patch does not succeed because there is no C matching the requirement imposed by the patch ProfileChangeRequest req1 = new ProfileChangeRequest(profile1); req1.addInstallableUnits(new IInstallableUnit[] {a1, p1}); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + ProvisioningPlan plan1 = (ProvisioningPlan) planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.ERROR, plan1.getStatus().getSeverity()); - assertEquals(Explanation.MISSING_REQUIREMENT, plan1.getRequestStatus().getShortExplanation()); - Set conflictingRoots = plan1.getRequestStatus().getConflictsWithInstalledRoots(); + final RequestStatus requestStatus = (RequestStatus) plan1.getRequestStatus(); + assertEquals(Explanation.MISSING_REQUIREMENT, requestStatus.getShortExplanation()); + Set conflictingRoots = requestStatus.getConflictsWithInstalledRoots(); assertEquals(1, conflictingRoots.size()); assertTrue(conflictingRoots.contains(p1)); } @@ -78,7 +80,7 @@ public class PatchTest9 extends AbstractProvisioningTest { //The application of the patch succeed because the dependency that PP puts on C is optional ProfileChangeRequest req2 = new ProfileChangeRequest(profile1); req2.addInstallableUnits(new IInstallableUnit[] {a1, pp1}); - ProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req2, null, null); assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); assertInstallOperand(plan2, a1); assertInstallOperand(plan2, pp1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch.java index d61858b25..0776f5d5b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch.java @@ -10,13 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IEngine; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTestMultiplePatch extends AbstractProvisioningTest { @@ -40,22 +42,22 @@ public class PatchTestMultiplePatch extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - p2Feature = createIU(P2_FEATURE, new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P3, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - p1 = createIU(P1, new Version(1, 0, 0), true); - p2 = createIU(P2, new Version(1, 0, 0), true); - p1b = createIU(P1, new Version(1, 1, 1), true); - p2b = createIU(P2, new Version(1, 1, 1), true); - p3 = createIU(P3, new Version(1, 0, 0), true); + p2Feature = createIU(P2_FEATURE, Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P3, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU(P1, Version.createOSGi(1, 0, 0), true); + p2 = createIU(P2, Version.createOSGi(1, 0, 0), true); + p1b = createIU(P1, Version.createOSGi(1, 1, 1), true); + p2b = createIU(P2, Version.createOSGi(1, 1, 1), true); + p3 = createIU(P3, Version.createOSGi(1, 0, 0), true); IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0,1.0.0]"), null, false, false)}}; - pp1 = createIUPatch(PP1, new Version("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); IRequirementChange changepp2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp2 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false)}}; - pp2 = createIUPatch(PP2, new Version("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); + pp2 = createIUPatch(PP2, Version.create("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p3, p1b, p2b, pp1, pp2}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch2.java new file mode 100644 index 000000000..81b2b0a43 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch2.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2008, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.planner; + +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +public class PatchTestMultiplePatch2 extends AbstractProvisioningTest { + private static final String PP2 = "PatchForIUP2"; + private static final String PP1 = "PatchForIUP1"; + private static final String P3 = "P3"; + private static final String P2 = "P2"; + private static final String P1 = "P1"; + private static final String P2_FEATURE = "p2.feature"; + private IInstallableUnit p2Feature; + private IInstallableUnit p1; + private IInstallableUnit p2; + private IInstallableUnit p3; + private IInstallableUnitPatch pp1; + private IInstallableUnitPatch pp2; + private IInstallableUnit p1c; + private IInstallableUnit p1b; + private IProfile profile1; + private IPlanner planner; + private IEngine engine; + + protected void setUp() throws Exception { + super.setUp(); + p2Feature = createIU(P2_FEATURE, Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P3, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU(P1, Version.createOSGi(1, 0, 0), true); + p2 = createIU(P2, Version.createOSGi(1, 0, 0), true); + p1b = createIU(P1, Version.createOSGi(1, 1, 1), true); + p1c = createIU(P1, Version.createOSGi(1, 1, 2), true); + p3 = createIU(P3, Version.createOSGi(1, 0, 0), true); + + IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); + IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); + IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0,1.0.0]"), null, false, false)}}; + pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + + IRequirementChange changepp2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.2, 1.1.2]"), null, false, false, true)); + IRequiredCapability lifeCyclepp2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); + IRequiredCapability[][] scopepp2 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false)}}; + pp2 = createIUPatch(PP2, Version.create("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); + + createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p3, p1b, p1c, pp1, pp2}); + + profile1 = createProfile("TestProfile." + getName()); + planner = createPlanner(); + engine = createEngine(); + } + + //Try to force the installation of two contradicting patches. + public void testFailingInstall() { + install(profile1, new IInstallableUnit[] {}, true, planner, engine); + ProfileChangeRequest req = new ProfileChangeRequest(profile1); + req.addInstallableUnits(new IInstallableUnit[] {p2Feature, pp1, pp2}); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch3.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch3.java new file mode 100644 index 000000000..d8e753492 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch3.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2008, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.planner; + +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; + +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +public class PatchTestMultiplePatch3 extends AbstractProvisioningTest { + private static final String PP2 = "PatchForIUP2"; + private static final String PP1 = "PatchForIUP1"; + private static final String P3 = "P3"; + private static final String P2 = "P2"; + private static final String P1 = "P1"; + private static final String P2_FEATURE = "p2.feature"; + private IInstallableUnit p2Feature; + private IInstallableUnit p1; + private IInstallableUnit p2; + private IInstallableUnit p3; + private IInstallableUnitPatch pp1; + private IInstallableUnitPatch pp2; + private IInstallableUnit p1c; + private IInstallableUnit p1b; + private IProfile profile1; + private IPlanner planner; + + protected void setUp() throws Exception { + super.setUp(); + p2Feature = createIU(P2_FEATURE, Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P3, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU(P1, Version.createOSGi(1, 0, 0), true); + p2 = createIU(P2, Version.createOSGi(1, 0, 0), true); + p1b = createIU(P1, Version.createOSGi(1, 1, 1), true); + p1c = createIU(P1, Version.createOSGi(1, 1, 2), true); + p3 = createIU(P3, Version.createOSGi(1, 0, 0), true); + + IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); + IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); + IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0,1.0.0]"), null, false, false)}}; + pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + + IRequirementChange changepp2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.2, 1.1.2]"), null, false, false, true)); + IRequiredCapability lifeCyclepp2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); + IRequiredCapability[][] scopepp2 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false)}}; + pp2 = createIUPatch(PP2, Version.create("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); + pp2 = createIUPatch(PP2, Version.create("5.0.0"), null, new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "missingThing", new VersionRange("[1.0.0, 1.0.0]"), null, false, false)}, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, true, null, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2, NO_REQUIRES); + createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p3, p1b, p1c, pp1, pp2}); + + profile1 = createProfile("TestProfile." + getName()); + planner = createPlanner(); + } + + //Test that two patches applying to the same requirement of an IU being patched does not cause any problem when one of the two patch is not applied. + public void testFailingInstall() { + ProfileChangeRequest req = new ProfileChangeRequest(profile1); + req.addInstallableUnits(new IInstallableUnit[] {p2Feature}); + req.addInstallableUnits(new IInstallableUnit[] {pp1}); + req.addInstallableUnits(new IInstallableUnit[] {pp2}); + req.setInstallableUnitInclusionRules(pp2, PlannerHelper.createOptionalInclusionRule(pp2)); + + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + assertOK("Planning should be ok", plan.getStatus()); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional.java index cb65318d2..dadbee8f1 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional.java @@ -10,13 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IEngine; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTestOptional extends AbstractProvisioningTest { @@ -36,16 +38,16 @@ public class PatchTestOptional extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - p2Feature = createIU(P2_FEATURE, new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - p1 = createIU(P1, new Version(1, 0, 0), true); - p2 = createIU(P2, new Version(1, 0, 0), true); - p1b = createIU(P1, new Version(1, 1, 1), true); - p2b = createIU(P2, new Version(1, 1, 1), true); + p2Feature = createIU(P2_FEATURE, Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU(P1, Version.createOSGi(1, 0, 0), true); + p2 = createIU(P2, Version.createOSGi(1, 0, 0), true); + p1b = createIU(P1, Version.createOSGi(1, 1, 1), true); + p2b = createIU(P2, Version.createOSGi(1, 1, 1), true); IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, true, false, true)); IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0,1.0.0]"), null, false, false)}}; - pp1 = createIUPatch(PP1, new Version("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p1b, p2b, pp1}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional2.java index 861c00eca..cde7abc17 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional2.java @@ -10,13 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IEngine; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTestOptional2 extends AbstractProvisioningTest { @@ -35,15 +37,15 @@ public class PatchTestOptional2 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - p2Feature = createIU(P2_FEATURE, new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - p1 = createIU(P1, new Version(1, 0, 0), true); - p2 = createIU(P2, new Version(1, 0, 0), true); - p2b = createIU(P2, new Version(1, 1, 1), true); + p2Feature = createIU(P2_FEATURE, Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU(P1, Version.createOSGi(1, 0, 0), true); + p2 = createIU(P2, Version.createOSGi(1, 0, 0), true); + p2b = createIU(P2, Version.createOSGi(1, 1, 1), true); IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, true, false, true)); IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0,1.0.0]"), null, false, false)}}; - pp1 = createIUPatch(PP1, new Version("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p2b, pp1}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional3.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional3.java index 91d3b7ebc..e02c1f0f1 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional3.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional3.java @@ -10,13 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IEngine; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTestOptional3 extends AbstractProvisioningTest { @@ -36,16 +38,16 @@ public class PatchTestOptional3 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - p2Feature = createIU(P2_FEATURE, new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - p1 = createIU(P1, new Version(1, 0, 0), true); - p2 = createIU(P2, new Version(1, 0, 0), true); - p2b = createIU(P2, new Version(1, 1, 1), true); + p2Feature = createIU(P2_FEATURE, Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU(P1, Version.createOSGi(1, 0, 0), true); + p2 = createIU(P2, Version.createOSGi(1, 0, 0), true); + p2b = createIU(P2, Version.createOSGi(1, 1, 1), true); IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, true, false, true)); IRequirementChange changepp2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0,1.0.0]"), null, false, false)}}; - pp1 = createIUPatch(PP1, new Version("3.0.0"), true, new IRequirementChange[] {changepp1, changepp2}, scopepp1, lifeCyclepp1); + pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1, changepp2}, scopepp1, lifeCyclepp1); createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p1b, p2b, pp1}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUninstall.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUninstall.java index 08c7d77ef..2c56c9998 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUninstall.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUninstall.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IEngine; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTestUninstall extends AbstractProvisioningTest { @@ -39,21 +41,21 @@ public class PatchTestUninstall extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - p2Feature = createIU(P2_FEATURE, new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - p1 = createIU(P1, new Version(1, 0, 0), true); - p2 = createIU(P2, new Version(1, 0, 0), true); - p1b = createIU(P1, new Version(1, 1, 1), true); - p2b = createIU(P2, new Version(1, 1, 1), true); + p2Feature = createIU(P2_FEATURE, Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU(P1, Version.createOSGi(1, 0, 0), true); + p2 = createIU(P2, Version.createOSGi(1, 0, 0), true); + p1b = createIU(P1, Version.createOSGi(1, 1, 1), true); + p2b = createIU(P2, Version.createOSGi(1, 1, 1), true); IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0,1.0.0]"), null, false, false)}}; - pp1 = createIUPatch(PP1, new Version("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); IRequirementChange changepp2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp2 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false)}}; - pp2 = createIUPatch(PP2, new Version("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); + pp2 = createIUPatch(PP2, Version.create("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p1b, p2b, pp1, pp2}); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate.java index 7ca2a56bb..f092723d1 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate.java @@ -10,16 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.Set; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.director.Explanation; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTestUpdate extends AbstractProvisioningTest { @@ -42,23 +43,23 @@ public class PatchTestUpdate extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - p2Feature = createIU(P2_FEATURE, new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - p1 = createIU(P1, new Version(1, 0, 0), true); - p2 = createIU(P2, new Version(1, 0, 0), true); - p1b = createIU(P1, new Version(1, 1, 1), true); - p2b = createIU(P2, new Version(1, 1, 1), true); + p2Feature = createIU(P2_FEATURE, Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU(P1, Version.createOSGi(1, 0, 0), true); + p2 = createIU(P2, Version.createOSGi(1, 0, 0), true); + p1b = createIU(P1, Version.createOSGi(1, 1, 1), true); + p2b = createIU(P2, Version.createOSGi(1, 1, 1), true); IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0,1.0.0]"), null, false, false)}}; - pp1 = createIUPatch(PP1, new Version("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); IRequirementChange changepp2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp2 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false)}}; - pp2 = createIUPatch(PP2, new Version("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); + pp2 = createIUPatch(PP2, Version.create("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); - p2Feature20 = createIU(P2_FEATURE, new Version(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p2Feature20 = createIU(P2_FEATURE, Version.createOSGi(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p1b, p2b, pp1, pp2, p2Feature20}); profile1 = createProfile("TestProfile." + getName()); @@ -77,7 +78,7 @@ public class PatchTestUpdate extends AbstractProvisioningTest { req1.addInstallableUnits(new IInstallableUnit[] {p2Feature20}); req1.setInstallableUnitInclusionRules(p2Feature20, PlannerHelper.createStrictInclusionRule(p2Feature20)); req1.removeInstallableUnits(new IInstallableUnit[] {p2Feature}); - ProvisioningPlan plan = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); } @@ -87,11 +88,12 @@ public class PatchTestUpdate extends AbstractProvisioningTest { req1.addInstallableUnits(new IInstallableUnit[] {p2Feature20}); req1.setInstallableUnitInclusionRules(p2Feature20, PlannerHelper.createStrictInclusionRule(p2Feature20)); req1.removeInstallableUnits(new IInstallableUnit[] {p2Feature}); - ProvisioningPlan plan = planner.getProvisioningPlan(req1, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); - Set conflictingRoot = plan.getRequestStatus().getConflictsWithInstalledRoots(); + final RequestStatus requestStatus = (RequestStatus) plan.getRequestStatus(); + Set conflictingRoot = requestStatus.getConflictsWithInstalledRoots(); assertEquals(1, conflictingRoot.size()); assertTrue(conflictingRoot.contains(p2Feature20)); - assertEquals(Explanation.VIOLATED_SINGLETON_CONSTRAINT, plan.getRequestStatus().getShortExplanation()); + assertEquals(Explanation.VIOLATED_SINGLETON_CONSTRAINT, requestStatus.getShortExplanation()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate2.java index 56b2a3004..33435997a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate2.java @@ -10,13 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTestUpdate2 extends AbstractProvisioningTest { @@ -39,23 +41,23 @@ public class PatchTestUpdate2 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - p2Feature = createIU(P2_FEATURE, new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - p1 = createIU(P1, new Version(1, 0, 0), true); - p2 = createIU(P2, new Version(1, 0, 0), true); - p1b = createIU(P1, new Version(1, 1, 1), true); - p2b = createIU(P2, new Version(1, 1, 1), true); + p2Feature = createIU(P2_FEATURE, Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU(P1, Version.createOSGi(1, 0, 0), true); + p2 = createIU(P2, Version.createOSGi(1, 0, 0), true); + p1b = createIU(P1, Version.createOSGi(1, 1, 1), true); + p2b = createIU(P2, Version.createOSGi(1, 1, 1), true); IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0,1.0.0]"), null, false, false)}}; - pp1 = createIUPatch(PP1, new Version("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); IRequirementChange changepp2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp2 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false)}}; - pp2 = createIUPatch(PP2, new Version("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); + pp2 = createIUPatch(PP2, Version.create("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); - p2Feature20 = createIU(P2_FEATURE, new Version(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)}); + p2Feature20 = createIU(P2_FEATURE, Version.createOSGi(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)}); createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p1b, p2b, pp1, pp2, p2Feature20}); profile1 = createProfile("TestProfile." + getName()); @@ -77,10 +79,10 @@ public class PatchTestUpdate2 extends AbstractProvisioningTest { req1.addInstallableUnits(new IInstallableUnit[] {p2Feature20}); req1.setInstallableUnitInclusionRules(p2Feature20, PlannerHelper.createStrictInclusionRule(p2Feature20)); req1.removeInstallableUnits(new IInstallableUnit[] {p2Feature}); - ProvisioningPlan plan = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req1, null, null); assertEquals(true, IStatus.ERROR != plan.getStatus().getSeverity()); - engine.perform(profile1, new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); assertProfileContains("The profile contains unexpected IUs", profile1, new IInstallableUnit[] {p2Feature20, p1b, p2b}); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate3.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate3.java index 3682f440b..3a801f153 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate3.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate3.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.net.URI; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTestUpdate3 extends AbstractProvisioningTest { @@ -39,23 +41,23 @@ public class PatchTestUpdate3 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - p2Feature = createIU(P2_FEATURE, new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - p1 = createIU(P1, new Version(1, 0, 0), true); - p2 = createIU(P2, new Version(1, 0, 0), true); - p1b = createIU(P1, new Version(1, 1, 1), true); - p2b = createIU(P2, new Version(1, 1, 1), true); + p2Feature = createIU(P2_FEATURE, Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU(P1, Version.createOSGi(1, 0, 0), true); + p2 = createIU(P2, Version.createOSGi(1, 0, 0), true); + p1b = createIU(P1, Version.createOSGi(1, 1, 1), true); + p2b = createIU(P2, Version.createOSGi(1, 1, 1), true); IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 3.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 3.0.0]"), null, false, false)}}; - pp1 = createIUPatch(PP1, new Version("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); IRequirementChange changepp2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp2 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 1.0.0]"), null, false, false)}}; - pp2 = createIUPatch(PP2, new Version("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); + pp2 = createIUPatch(PP2, Version.create("5.0.0"), true, new IRequirementChange[] {changepp2}, scopepp2, lifeCyclepp2); - p2Feature20 = createIU(P2_FEATURE, new Version(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p2Feature20 = createIU(P2_FEATURE, Version.createOSGi(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p1b, p2b, pp1, pp2, p2Feature20}); createProfile("TestProfile." + getName()); @@ -84,10 +86,10 @@ public class PatchTestUpdate3 extends AbstractProvisioningTest { req1.addInstallableUnits(new IInstallableUnit[] {p2Feature20}); req1.setInstallableUnitInclusionRules(p2Feature20, PlannerHelper.createStrictInclusionRule(p2Feature20)); req1.removeInstallableUnits(new IInstallableUnit[] {p2Feature}); - ProvisioningPlan plan = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req1, null, null); assertEquals(true, IStatus.ERROR != plan.getStatus().getSeverity()); - engine.perform(getProfile("TestProfile." + getName()), new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); assertProfileContains("The profile contains unexpected IUs", getProfile("TestProfile." + getName()), new IInstallableUnit[] {p2Feature20, p1b, pp1, p2}); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate4.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate4.java index 54e2baf66..8ccff47f3 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate4.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate4.java @@ -10,13 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTestUpdate4 extends AbstractProvisioningTest { @@ -38,18 +40,18 @@ public class PatchTestUpdate4 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - p2Feature = createIU(P2_FEATURE, new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - p1 = createIU(P1, new Version(1, 0, 0), true); - p2 = createIU(P2, new Version(1, 0, 0), true); - p1b = createIU(P1, new Version(1, 1, 1), true); - p2b = createIU(P2, new Version(1, 1, 1), true); + p2Feature = createIU(P2_FEATURE, Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU(P1, Version.createOSGi(1, 0, 0), true); + p2 = createIU(P2, Version.createOSGi(1, 0, 0), true); + p1b = createIU(P1, Version.createOSGi(1, 1, 1), true); + p2b = createIU(P2, Version.createOSGi(1, 1, 1), true); IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, true); IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 3.0.0]"), null, false, false)}}; - pp1 = createIUPatch(PP1, new Version("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); - p2Feature20 = createIU(P2_FEATURE, new Version(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p2Feature20 = createIU(P2_FEATURE, Version.createOSGi(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p1b, p2b, pp1, p2Feature20}); profile1 = createProfile("TestProfile." + getName()); @@ -71,10 +73,10 @@ public class PatchTestUpdate4 extends AbstractProvisioningTest { req1.addInstallableUnits(new IInstallableUnit[] {p2Feature20}); req1.setInstallableUnitInclusionRules(p2Feature20, PlannerHelper.createStrictInclusionRule(p2Feature20)); req1.removeInstallableUnits(new IInstallableUnit[] {p2Feature}); - ProvisioningPlan plan = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req1, null, null); assertEquals(true, IStatus.ERROR != plan.getStatus().getSeverity()); - engine.perform(profile1, new DefaultPhaseSet(), plan.getOperands(), null, null); + engine.perform(plan, null); assertProfileContains("The profile contains unexpected IUs", profile1, new IInstallableUnit[] {p2Feature20, p1b, p2, pp1}); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate5.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate5.java index e46e49d22..532aff861 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate5.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate5.java @@ -10,14 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IEngine; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PatchTestUpdate5 extends AbstractProvisioningTest { @@ -39,18 +41,18 @@ public class PatchTestUpdate5 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - p2Feature = createIU(P2_FEATURE, new Version(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); - p1 = createIU(P1, new Version(1, 0, 0), true); - p2 = createIU(P2, new Version(1, 0, 0), true); - p1b = createIU(P1, new Version(1, 1, 1), true); - p2b = createIU(P2, new Version(1, 1, 1), true); + p2Feature = createIU(P2_FEATURE, Version.createOSGi(1, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p1 = createIU(P1, Version.createOSGi(1, 0, 0), true); + p2 = createIU(P2, Version.createOSGi(1, 0, 0), true); + p1b = createIU(P1, Version.createOSGi(1, 1, 1), true); + p2b = createIU(P2, Version.createOSGi(1, 1, 1), true); IRequirementChange changepp1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.1.1, 1.1.1]"), null, false, false, true)); IRequiredCapability lifeCyclepp1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); IRequiredCapability[][] scopepp1 = new IRequiredCapability[][] {{MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0, 3.0.0]"), null, false, false)}}; - pp1 = createIUPatch(PP1, new Version("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); + pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1}, scopepp1, lifeCyclepp1); - p2Feature20 = createIU(P2_FEATURE, new Version(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); + p2Feature20 = createIU(P2_FEATURE, Version.createOSGi(2, 0, 0), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P1, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, P2, new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true)}); createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p1b, p2b, pp1, p2Feature20}); profile1 = createProfile("TestProfile." + getName()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PermissiveSlicerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PermissiveSlicerTest.java index 6cdf9ab1d..77f5e0f35 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PermissiveSlicerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PermissiveSlicerTest.java @@ -10,15 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - import java.io.File; import java.util.Properties; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.director.PermissiveSlicer; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.query.IQueryable; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class PermissiveSlicerTest extends AbstractProvisioningTest { @@ -33,36 +35,36 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest { public void testSliceRCPOut() { PermissiveSlicer slicer = new PermissiveSlicer(repo, new Properties(), true, false, true, false, false); - 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(); IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor()); assertNotNull(result); - result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(); - assertEquals(66, result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); - assertEquals(1, result.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor()).size()); + queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())); + assertEquals(66, queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); + assertEquals(1, queryResultSize(result.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor()))); // assertOK("1.0", slicer.getStatus()); } //Test with and without optional pieces public void testSliceRCPWithOptionalPieces() { PermissiveSlicer slicer = new PermissiveSlicer(repo, new Properties(), false, false, true, false, false); - 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(); IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor()); assertNotNull(result); - result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(); - assertEquals(64, result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())); + assertEquals(64, queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); // assertOK("1.0", slicer.getStatus()); } public void testSliceRCPWithIgnoringGreed() { PermissiveSlicer slicer = new PermissiveSlicer(repo, new Properties(), false, true, true, false, false); - 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(); IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor()); assertNotNull(result); - result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(); - assertEquals(64, result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())); + assertEquals(64, queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); // assertOK("1.0", slicer.getStatus()); } @@ -72,13 +74,13 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest { p.setProperty("osgi.ws", "win32"); p.setProperty("osgi.arch", "x86"); PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, false, false, false); - 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(); IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor()); assertNotNull(result); - result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(); - assertEquals(0, result.query(new InstallableUnitQuery("org.eclipse.swt.motif.linux.x86"), new Collector(), new NullProgressMonitor()).size()); - assertEquals(34, result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())); + assertEquals(0, queryResultSize(result.query(new InstallableUnitQuery("org.eclipse.swt.motif.linux.x86"), new NullProgressMonitor()))); + assertEquals(34, queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); // assertOK("1.0", slicer.getStatus()); } @@ -88,25 +90,25 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest { p.setProperty("osgi.ws", "win32"); p.setProperty("osgi.arch", "x86"); PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, false, false, true, false); - 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(); IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor()); assertNotNull(result); - result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(); - assertEquals(0, result.query(new InstallableUnitQuery("org.eclipse.ecf"), new Collector(), new NullProgressMonitor()).size()); - assertEquals(29, result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())); + assertEquals(0, queryResultSize(result.query(new InstallableUnitQuery("org.eclipse.ecf"), new NullProgressMonitor()))); + assertEquals(29, queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); // assertOK("1.0", slicer.getStatus()); } public void testExtractPlatformIndependentPieces() { PermissiveSlicer slicer = new PermissiveSlicer(repo, new Properties(), true, false, false, false, false); - 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(); IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor()); assertNotNull(result); - result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(); - assertEquals(32, result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); - assertEquals(1, result.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor()).size()); + queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())); + assertEquals(32, queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); + assertEquals(1, queryResultSize(result.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor()))); // assertOK("1.0", slicer.getStatus()); } @@ -114,12 +116,12 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest { IProvidedCapability act1Cap = MetadataFactory.createProvidedCapability("p2.action", "action1", DEFAULT_VERSION); IInstallableUnit act1 = createIU("Action1", DEFAULT_VERSION, null, NO_REQUIRES, new IProvidedCapability[] {act1Cap}, NO_PROPERTIES, null, NO_TP_DATA, true); - IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] metaReq = createRequiredCapabilities("p2.action", "action1", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit a = createIUWithMetaRequirement("A", DEFAULT_VERSION, true, NO_REQUIRES, metaReq); PermissiveSlicer slicer = new PermissiveSlicer(createTestMetdataRepository(new IInstallableUnit[] {a, act1}), new Properties(), true, false, false, false, false); IQueryable result = slicer.slice(new IInstallableUnit[] {a}, new NullProgressMonitor()); - assertEquals(1, result.query(new InstallableUnitQuery("Action1"), new Collector(), null).size()); + assertEquals(1, queryResultSize(result.query(new InstallableUnitQuery("Action1"), null))); } public void testValidateIU() { @@ -128,14 +130,14 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest { p.setProperty("osgi.ws", "win32"); p.setProperty("osgi.arch", "x86"); PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, false, false, true, false); - Collector c = repo.query(new InstallableUnitQuery("org.eclipse.swt.cocoa.macosx"), new Collector(), new NullProgressMonitor()); + IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.swt.cocoa.macosx"), new NullProgressMonitor()); IInstallableUnit iu = (IInstallableUnit) c.iterator().next(); assertNull(slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor())); assertNotOK(slicer.getStatus()); } public void testMissingNecessaryPiece() { - IRequiredCapability[] req = createRequiredCapabilities("B", "B", new VersionRange("[0.0.0, 1.0.0]"), null); + IRequiredCapability[] req = createRequiredCapabilities("B", "B", new VersionRange("[0.0.0, 1.0.0]")); IInstallableUnit iuA = createIU("A", DEFAULT_VERSION, null, req, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, true); PermissiveSlicer slicer = new PermissiveSlicer(createTestMetdataRepository(new IInstallableUnit[] {iuA}), new Properties(), true, false, false, false, false); IQueryable result = slicer.slice(new IInstallableUnit[] {iuA}, new NullProgressMonitor()); @@ -149,19 +151,19 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest { p.setProperty("osgi.ws", "win32"); p.setProperty("osgi.arch", "x86"); PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, false, false, false, true); - 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(); - Collector resultCollector = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor()).query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()); - assertEquals(3, resultCollector.size()); + IQueryResult resultCollector = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor()).query(InstallableUnitQuery.ANY, new NullProgressMonitor()); + assertEquals(3, queryResultSize(resultCollector)); } public void testExtractOnlyPlatformSpecific() { Properties p = new Properties(); PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, false, true, false, true); - 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(); - Collector resultCollector = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor()).query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()); - assertEquals(35, resultCollector.size()); + IQueryResult resultCollector = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor()).query(InstallableUnitQuery.ANY, new NullProgressMonitor()); + assertEquals(35, queryResultSize(resultCollector)); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ProvisioningPlanQueryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ProvisioningPlanQueryTest.java index 4a8dc4754..e237cedb9 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ProvisioningPlanQueryTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ProvisioningPlanQueryTest.java @@ -12,37 +12,35 @@ package org.eclipse.equinox.p2.tests.planner; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; -import org.eclipse.equinox.internal.provisional.p2.director.ProvisioningPlan; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.engine.Operand; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class ProvisioningPlanQueryTest extends AbstractProvisioningTest { public void testNull() { - Collector c = new ProvisioningPlan(Status.OK_STATUS, null, null).getAdditions().query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()); + IQueryResult c = new ProvisioningPlan(Status.OK_STATUS, null, null, null).getAdditions().query(InstallableUnitQuery.ANY, new NullProgressMonitor()); assertTrue(c.isEmpty()); } public void testAddition() { Operand[] ops = new Operand[] {new InstallableUnitOperand(null, createIU("A"))}; - Collector c = new ProvisioningPlan(Status.OK_STATUS, ops, null, null, null, null, null).getAdditions().query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()); - assertEquals(1, c.size()); - assertEquals(0, new ProvisioningPlan(Status.OK_STATUS, ops, null, null, null, null, null).getRemovals().query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + IQueryResult c = new ProvisioningPlan(null, ops, null).getAdditions().query(InstallableUnitQuery.ANY, new NullProgressMonitor()); + assertEquals(1, queryResultSize(c)); + assertTrue(new ProvisioningPlan(null, ops, null).getRemovals().query(InstallableUnitQuery.ANY, new NullProgressMonitor()).isEmpty()); } public void testRemoval() { Operand[] ops = new Operand[] {new InstallableUnitOperand(createIU("A"), null)}; - Collector c = new ProvisioningPlan(Status.OK_STATUS, ops, null, null, null, null, null).getRemovals().query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()); - assertEquals(1, c.size()); - assertEquals(0, new ProvisioningPlan(Status.OK_STATUS, ops, null, null, null, null, null).getAdditions().query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + IQueryResult c = new ProvisioningPlan(null, ops, null).getRemovals().query(InstallableUnitQuery.ANY, new NullProgressMonitor()); + assertEquals(1, queryResultSize(c)); + assertTrue(new ProvisioningPlan(null, ops, null).getAdditions().query(InstallableUnitQuery.ANY, new NullProgressMonitor()).isEmpty()); } public void testUpdate() { Operand[] ops = new Operand[] {new InstallableUnitOperand(createIU("A"), createIU("B"))}; - Collector c = new ProvisioningPlan(Status.OK_STATUS, ops, null, null, null, null, null).getRemovals().query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()); - assertEquals(1, c.size()); - assertEquals(1, new ProvisioningPlan(Status.OK_STATUS, ops, null, null, null, null, null).getAdditions().query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size()); + IQueryResult c = new ProvisioningPlan(null, ops, null).getRemovals().query(InstallableUnitQuery.ANY, new NullProgressMonitor()); + assertEquals(1, queryResultSize(c)); + assertEquals(1, queryResultSize(new ProvisioningPlan(null, ops, null).getAdditions().query(InstallableUnitQuery.ANY, new NullProgressMonitor()))); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java index c0edda109..1adcc25b0 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java @@ -10,19 +10,20 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.io.File; import java.util.ArrayList; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IRequirementChange; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SDKPatchingTest1 extends AbstractProvisioningTest { @@ -39,14 +40,14 @@ public class SDKPatchingTest1 extends AbstractProvisioningTest { profile = registry.getProfile("SDKPatchingTest"); assertNotNull(profile); - MetadataFactory.InstallableUnitDescription newCommon = createIUDescriptor((IInstallableUnit) profile.query(new InstallableUnitQuery("org.eclipse.equinox.common"), new Collector(), new NullProgressMonitor()).iterator().next()); - Version newVersionCommon = new Version(3, 5, 0, "zeNewVersion"); + MetadataFactory.InstallableUnitDescription newCommon = createIUDescriptor((IInstallableUnit) profile.query(new InstallableUnitQuery("org.eclipse.equinox.common"), new NullProgressMonitor()).iterator().next()); + Version newVersionCommon = Version.createOSGi(3, 5, 0, "zeNewVersion"); changeVersion(newCommon, newVersionCommon); newIUs.add(MetadataFactory.createInstallableUnit(newCommon)); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.equinox.common", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.equinox.common", new VersionRange(newVersionCommon, true, newVersionCommon, true), null, false, false, true)); IRequiredCapability lifeCycle = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.rcp.feature.group", new VersionRange("[3.5.0.v20081110-9E9vFtpFlN1yW2Ray4WRVBYE, 3.5.0.v20081110-9E9vFtpFlN1yW2Ray4WRVBYE]"), null, false, false, true); - patchInstallingCommon = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[0][0], lifeCycle); + patchInstallingCommon = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[0][0], lifeCycle); newIUs.add(patchInstallingCommon); } @@ -58,8 +59,8 @@ public class SDKPatchingTest1 extends AbstractProvisioningTest { request.addInstallableUnits(new IInstallableUnit[] {patchInstallingCommon}); request.setInstallableUnitInclusionRules(patchInstallingCommon, PlannerHelper.createOptionalInclusionRule(patchInstallingCommon)); IPlanner planner = createPlanner(); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertOK("Installation plan", plan.getStatus()); - assertEquals(4, plan.getOperands().length); + assertEquals(3, countPlanElements(plan)); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java index d9a18113d..0f204de94 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java @@ -10,19 +10,20 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.io.File; import java.util.ArrayList; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IRequirementChange; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SDKPatchingTest2 extends AbstractProvisioningTest { @@ -41,26 +42,26 @@ public class SDKPatchingTest2 extends AbstractProvisioningTest { assertNotNull(profile); //create a patch to install a new version of jdt.launching - MetadataFactory.InstallableUnitDescription newJDTLaunching = createIUDescriptor((IInstallableUnit) profile.query(new InstallableUnitQuery("org.eclipse.jdt.launching"), new Collector(), new NullProgressMonitor()).iterator().next()); - Version newJDTLaunchingVersion = new Version(3, 5, 0, "zeNewVersion"); + MetadataFactory.InstallableUnitDescription newJDTLaunching = createIUDescriptor((IInstallableUnit) profile.query(new InstallableUnitQuery("org.eclipse.jdt.launching"), new NullProgressMonitor()).iterator().next()); + Version newJDTLaunchingVersion = Version.createOSGi(3, 5, 0, "zeNewVersion"); changeVersion(newJDTLaunching, newJDTLaunchingVersion); newIUs.add(MetadataFactory.createInstallableUnit(newJDTLaunching)); IRequirementChange change = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.jdt.launching", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.jdt.launching", new VersionRange(newJDTLaunchingVersion, true, newJDTLaunchingVersion, true), null, false, false, true)); IRequiredCapability lifeCycle = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.jdt.feature.group", new VersionRange("[3.5.0.v20081202-0800-7p83FGDFHmHuj2mNpJBSKZe, 3.5.0.v20081202-0800-7p83FGDFHmHuj2mNpJBSKZe]"), null, false, false, true); - patchInstallingJDTLaunching = createIUPatch("P", new Version("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[0][0], lifeCycle); + patchInstallingJDTLaunching = createIUPatch("P", Version.create("1.0.0"), true, new IRequirementChange[] {change}, new IRequiredCapability[0][0], lifeCycle); newIUs.add(patchInstallingJDTLaunching); //create a patch to install a new version of jdt.debug.ui - MetadataFactory.InstallableUnitDescription newDebugUI = createIUDescriptor((IInstallableUnit) profile.query(new InstallableUnitQuery("org.eclipse.jdt.debug.ui"), new Collector(), new NullProgressMonitor()).iterator().next()); - Version newDebugVersion = new Version(3, 3, 0, "zeNewVersion"); + MetadataFactory.InstallableUnitDescription newDebugUI = createIUDescriptor((IInstallableUnit) profile.query(new InstallableUnitQuery("org.eclipse.jdt.debug.ui"), new NullProgressMonitor()).iterator().next()); + Version newDebugVersion = Version.createOSGi(3, 3, 0, "zeNewVersion"); changeVersion(newDebugUI, newDebugVersion); newIUs.add(MetadataFactory.createInstallableUnit(newDebugUI)); IRequirementChange change2 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.jdt.debug.ui", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.jdt.debug.ui", new VersionRange(newDebugVersion, true, newDebugVersion, true), null, false, false, true)); IRequiredCapability lifeCycle2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.jdt.feature.group", new VersionRange("[3.5.0.v20081202-0800-7p83FGDFHmHuj2mNpJBSKZe, 3.5.0.v20081202-0800-7p83FGDFHmHuj2mNpJBSKZe]"), null, false, false, true); - patchInstallingDebugUI = createIUPatch("P2", new Version("1.0.0"), true, new IRequirementChange[] {change2}, new IRequiredCapability[0][0], lifeCycle2); + patchInstallingDebugUI = createIUPatch("P2", Version.create("1.0.0"), true, new IRequirementChange[] {change2}, new IRequiredCapability[0][0], lifeCycle2); newIUs.add(patchInstallingDebugUI); @@ -70,7 +71,7 @@ public class SDKPatchingTest2 extends AbstractProvisioningTest { ProvisioningContext ctx = new ProvisioningContext(); ctx.setExtraIUs(newIUs); ProfileChangeRequest validationRequest = new ProfileChangeRequest(profile); - ProvisioningPlan validationPlan = createPlanner().getProvisioningPlan(validationRequest, null, null); + IProvisioningPlan validationPlan = createPlanner().getProvisioningPlan(validationRequest, null, null); assertOK("validation", validationPlan.getStatus()); ProfileChangeRequest request = new ProfileChangeRequest(profile); @@ -78,8 +79,8 @@ public class SDKPatchingTest2 extends AbstractProvisioningTest { request.setInstallableUnitInclusionRules(patchInstallingJDTLaunching, PlannerHelper.createOptionalInclusionRule(patchInstallingJDTLaunching)); request.setInstallableUnitInclusionRules(patchInstallingDebugUI, PlannerHelper.createOptionalInclusionRule(patchInstallingDebugUI)); IPlanner planner = createPlanner(); - ProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor()); assertOK("Installation plan", plan.getStatus()); - assertEquals(8, plan.getOperands().length); + assertEquals(6, countPlanElements(plan)); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SWTFragment.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SWTFragment.java index b7690faec..97f93aa7d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SWTFragment.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SWTFragment.java @@ -10,32 +10,33 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.Collector; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SWTFragment extends AbstractProvisioningTest { public void testFragmentPickedByCapability() { - IRequiredCapability[] reqs = createRequiredCapabilities("swt.fragment", "swt.fragment", new VersionRange("[1.0.0, 2.0.0)"), null); + IRequiredCapability[] reqs = createRequiredCapabilities("swt.fragment", "swt.fragment", new VersionRange("[1.0.0, 2.0.0)")); IInstallableUnit swt = createIU("SWT", reqs); MetadataFactory.InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription(); iud.setId("SWT.WIN32"); - iud.setVersion(new Version("1.0.0")); - iud.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability("swt.fragment", "swt.fragment", new Version(1, 0, 0))}); + iud.setVersion(Version.create("1.0.0")); + iud.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability("swt.fragment", "swt.fragment", Version.createOSGi(1, 0, 0))}); iud.setFilter("(os=win32)"); IInstallableUnit swtW = MetadataFactory.createInstallableUnit(iud); MetadataFactory.InstallableUnitDescription iud2 = new MetadataFactory.InstallableUnitDescription(); iud.setId("SWT.LINUX"); - iud.setVersion(new Version("1.0.0")); - iud.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability("swt.fragment", "swt.fragment", new Version(1, 0, 0))}); + iud.setVersion(Version.create("1.0.0")); + iud.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability("swt.fragment", "swt.fragment", Version.createOSGi(1, 0, 0))}); iud.setFilter("(os=linux)"); IInstallableUnit swtL = MetadataFactory.createInstallableUnit(iud2); @@ -46,10 +47,11 @@ public class SWTFragment extends AbstractProvisioningTest { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.setProfileProperty("os", "win32"); req.addInstallableUnits(new IInstallableUnit[] {swt}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertOK("plan", plan.getStatus()); - Collector c = plan.getAdditions().query(new InstallableUnitQuery("SWT"), new Collector(), null); - plan.getAdditions().query(new InstallableUnitQuery("SWT.WIN32"), c, null); + Collector c = new Collector(); + c.addAll(plan.getAdditions().query(new InstallableUnitQuery("SWT"), null)); + c.addAll(plan.getAdditions().query(new InstallableUnitQuery("SWT.WIN32"), null)); assertEquals(2, c.size()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies.java index a4fcb004b..1c829d081 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SeveralOptionalDependencies extends AbstractProvisioningTest { @@ -31,10 +35,10 @@ public class SeveralOptionalDependencies extends AbstractProvisioningTest { IRequiredCapability reqB = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, true); //normal dependency IRequiredCapability reqC = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[0.0.0, 1.0.0)"), null, true, false, true); //will not match IRequiredCapability reqD = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", VersionRange.emptyRange, null, true, false, true); //will not match - x1 = createIU("X", new Version("1.0.0"), new IRequiredCapability[] {reqA, reqB, reqC, reqD}); - a1 = createIU("A", new Version("1.0.0"), true); - b1 = createIU("B", new Version("1.0.0"), true); - c1 = createIU("C", new Version("2.0.0"), true); + x1 = createIU("X", Version.create("1.0.0"), new IRequiredCapability[] {reqA, reqB, reqC, reqD}); + a1 = createIU("A", Version.create("1.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); + c1 = createIU("C", Version.create("2.0.0"), true); createTestMetdataRepository(new IInstallableUnit[] {x1, a1, b1, c1}); @@ -45,7 +49,7 @@ public class SeveralOptionalDependencies extends AbstractProvisioningTest { public void testInstallation() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {x1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, x1); assertInstallOperand(plan, a1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies2.java index f9d07c8ae..220e60267 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies2.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SeveralOptionalDependencies2 extends AbstractProvisioningTest { @@ -31,10 +35,10 @@ public class SeveralOptionalDependencies2 extends AbstractProvisioningTest { IRequiredCapability reqB = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, true, false, true); //optional dependency, will be satisfied IRequiredCapability reqC = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[0.0.0, 1.0.0)"), null, true, false, true); //will not match IRequiredCapability reqD = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", VersionRange.emptyRange, null, true, false, true); //will not match - x1 = createIU("X", new Version("1.0.0"), new IRequiredCapability[] {reqA, reqB, reqC, reqD}); - a1 = createIU("A", new Version("1.0.0"), true); - b1 = createIU("B", new Version("1.0.0"), true); - c1 = createIU("C", new Version("2.0.0"), true); + x1 = createIU("X", Version.create("1.0.0"), new IRequiredCapability[] {reqA, reqB, reqC, reqD}); + a1 = createIU("A", Version.create("1.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); + c1 = createIU("C", Version.create("2.0.0"), true); createTestMetdataRepository(new IInstallableUnit[] {x1, a1, b1, c1}); @@ -45,7 +49,7 @@ public class SeveralOptionalDependencies2 extends AbstractProvisioningTest { public void testInstallation() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {x1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, x1); assertInstallOperand(plan, a1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies3.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies3.java index fe87d0b28..279b553da 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies3.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies3.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SeveralOptionalDependencies3 extends AbstractProvisioningTest { @@ -28,7 +32,7 @@ public class SeveralOptionalDependencies3 extends AbstractProvisioningTest { IRequiredCapability reqB = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, true, false, true); //optional dependency, will not be satisfied IRequiredCapability reqC = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[0.0.0, 1.0.0)"), null, true, false, true); //will not match IRequiredCapability reqD = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", VersionRange.emptyRange, null, true, false, true); //will not match - x1 = createIU("X", new Version("1.0.0"), new IRequiredCapability[] {reqA, reqB, reqC, reqD}); + x1 = createIU("X", Version.create("1.0.0"), new IRequiredCapability[] {reqA, reqB, reqC, reqD}); createTestMetdataRepository(new IInstallableUnit[] {x1}); @@ -40,7 +44,7 @@ public class SeveralOptionalDependencies3 extends AbstractProvisioningTest { //X will install because all the requirements are optional ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {x1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, x1); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies4.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies4.java index abbecf395..fd4b24977 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies4.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies4.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SeveralOptionalDependencies4 extends AbstractProvisioningTest { @@ -29,10 +33,10 @@ public class SeveralOptionalDependencies4 extends AbstractProvisioningTest { super.setUp(); IRequiredCapability reqA = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, true, false, true); //optional dependency, will be satisfied IRequiredCapability reqB = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, true); //normal dependency - x1 = createIU("X", new Version("1.0.0"), new IRequiredCapability[] {reqA, reqB,}); - a1 = createIU("A", new Version("1.0.0"), true); - a2 = createIU("A", new Version("2.0.0"), true); - b1 = createIU("B", new Version("1.0.0"), true); + x1 = createIU("X", Version.create("1.0.0"), new IRequiredCapability[] {reqA, reqB,}); + a1 = createIU("A", Version.create("1.0.0"), true); + a2 = createIU("A", Version.create("2.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); createTestMetdataRepository(new IInstallableUnit[] {x1, a1, b1, a2}); @@ -43,7 +47,7 @@ public class SeveralOptionalDependencies4 extends AbstractProvisioningTest { public void testInstallation() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {x1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, x1); assertInstallOperand(plan, b1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies5.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies5.java index c083bfb85..b7f38dff2 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies5.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies5.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SeveralOptionalDependencies5 extends AbstractProvisioningTest { @@ -30,15 +34,15 @@ public class SeveralOptionalDependencies5 extends AbstractProvisioningTest { IRequiredCapability reqA = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, true, false, true); //optional dependency, will be satisfied IRequiredCapability reqC = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)"), null, true, false, true); //optional dependency, will be satisfied because it is the highest version IRequiredCapability reqE = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "E", new VersionRange("[1.0.0, 2.0.0)"), null, true, false, true); //optional dependency, will be satisfied because it is the highest version - x1 = createIU("X", new Version("1.0.0"), new IRequiredCapability[] {reqA, reqC, reqE}); + x1 = createIU("X", Version.create("1.0.0"), new IRequiredCapability[] {reqA, reqC, reqE}); IRequiredCapability reqB = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, true); //optional dependency, will be satisfied - a1 = createIU("A", new Version("1.0.0"), new IRequiredCapability[] {reqB}); + a1 = createIU("A", Version.create("1.0.0"), new IRequiredCapability[] {reqB}); IRequiredCapability reqD = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", VersionRange.emptyRange, null, false, false, true); //optional dependency, will be satisfied - c1 = createIU("C", new Version("1.0.0"), new IRequiredCapability[] {reqD}); + c1 = createIU("C", Version.create("1.0.0"), new IRequiredCapability[] {reqD}); - b1 = createIU("B", new Version("1.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); createTestMetdataRepository(new IInstallableUnit[] {x1, a1, b1, c1}); profile = createProfile("TestProfile." + getName()); @@ -48,7 +52,7 @@ public class SeveralOptionalDependencies5 extends AbstractProvisioningTest { public void testInstallation() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {x1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, x1); assertInstallOperand(plan, a1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest.java index 78d1f4200..40a025920 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SimpleOptionalTest extends AbstractProvisioningTest { @@ -29,12 +33,12 @@ public class SimpleOptionalTest extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - b1 = createIU("B", new Version("1.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); //B's dependency is missing IRequiredCapability[] reqA = new IRequiredCapability[1]; reqA[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, true, false, true); - a1 = createIU("A", new Version("1.0.0"), reqA); + a1 = createIU("A", Version.create("1.0.0"), reqA); createTestMetdataRepository(new IInstallableUnit[] {a1, b1}); @@ -46,7 +50,7 @@ public class SimpleOptionalTest extends AbstractProvisioningTest { //Ensure that D's installation does not fail because of C's absence ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); assertInstallOperand(plan, b1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest2.java index d59c3caaf..17af35a66 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest2.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest2.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SimpleOptionalTest2 extends AbstractProvisioningTest { @@ -35,26 +39,26 @@ public class SimpleOptionalTest2 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - b1 = createIU("B", new Version("1.0.0"), true); - b2 = createIU("B", new Version("2.0.0"), true); - b3 = createIU("B", new Version("3.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); + b2 = createIU("B", Version.create("2.0.0"), true); + b3 = createIU("B", Version.create("3.0.0"), true); - c1 = createIU("C", new Version("1.0.0"), true); - c2 = createIU("C", new Version("2.0.0"), true); + c1 = createIU("C", Version.create("1.0.0"), true); + c2 = createIU("C", Version.create("2.0.0"), true); - d1 = createIU("D", new Version("1.0.0"), true); - d2 = createIU("D", new Version("2.0.0"), true); + d1 = createIU("D", Version.create("1.0.0"), true); + d2 = createIU("D", Version.create("2.0.0"), true); - y1 = createIU("Y", new Version("1.0.0"), true); + y1 = createIU("Y", Version.create("1.0.0"), true); - z1 = createIU("Z", new Version("1.0.0"), true); + z1 = createIU("Z", Version.create("1.0.0"), true); //B's dependency is missing IRequiredCapability[] reqA = new IRequiredCapability[3]; reqA[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, true); reqA[1] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, true, false, true); reqA[2] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", VersionRange.emptyRange, null, true, false, true); - a1 = createIU("A", new Version("1.0.0"), reqA); + a1 = createIU("A", Version.create("1.0.0"), reqA); IRequiredCapability[] req = new IRequiredCapability[3]; req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.0.0, 1.0.0]"), null, false, false, true); @@ -72,7 +76,7 @@ public class SimpleOptionalTest2 extends AbstractProvisioningTest { //Ensure that D's installation does not fail because of C's absence ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1, x1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); assertInstallOperand(plan, c2); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest3.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest3.java index e02c3f170..2aff62927 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest3.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest3.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SimpleOptionalTest3 extends AbstractProvisioningTest { @@ -33,21 +37,21 @@ public class SimpleOptionalTest3 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - b1 = createIU("B", new Version("1.0.0"), true); - b2 = createIU("B", new Version("2.0.0"), true); - b3 = createIU("B", new Version("3.0.0"), true); + b1 = createIU("B", Version.create("1.0.0"), true); + b2 = createIU("B", Version.create("2.0.0"), true); + b3 = createIU("B", Version.create("3.0.0"), true); - c1 = createIU("C", new Version("1.0.0"), true); - c2 = createIU("C", new Version("2.0.0"), true); + c1 = createIU("C", Version.create("1.0.0"), true); + c2 = createIU("C", Version.create("2.0.0"), true); - d1 = createIU("D", new Version("1.0.0"), true); - d2 = createIU("D", new Version("2.0.0"), true); + d1 = createIU("D", Version.create("1.0.0"), true); + d2 = createIU("D", Version.create("2.0.0"), true); IRequiredCapability[] reqA = new IRequiredCapability[3]; reqA[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, true, false, true); reqA[1] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "C", VersionRange.emptyRange, null, false, false, true); reqA[2] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "D", VersionRange.emptyRange, null, true, false, true); - a1 = createIU("A", new Version("1.0.0"), reqA); + a1 = createIU("A", Version.create("1.0.0"), reqA); IRequiredCapability[] req = new IRequiredCapability[1]; req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 2.0.0]"), null, false, false, true); @@ -63,7 +67,7 @@ public class SimpleOptionalTest3 extends AbstractProvisioningTest { //Ensure that A and X1's installation does not fail because of C's absence ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1, x1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); assertInstallOperand(plan, c2); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest4.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest4.java index d0f349f29..6d577d7a0 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest4.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest4.java @@ -8,13 +8,17 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; -import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SimpleOptionalTest4 extends AbstractProvisioningTest { @@ -32,10 +36,10 @@ public class SimpleOptionalTest4 extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - b1 = createIU("B", new Version("1.0.0"), false); - b2 = createIU("B", new Version("2.0.0"), false); - b3 = createIU("B", new Version("3.0.0"), false); - b4 = createIU("B", new Version("4.0.0"), false); + b1 = createIU("B", Version.create("1.0.0"), false); + b2 = createIU("B", Version.create("2.0.0"), false); + b3 = createIU("B", Version.create("3.0.0"), false); + b4 = createIU("B", Version.create("4.0.0"), false); //B's dependency is missing IRequiredCapability[] reqA = new IRequiredCapability[4]; @@ -43,7 +47,7 @@ public class SimpleOptionalTest4 extends AbstractProvisioningTest { reqA[1] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[2.0.0,2.0.0]"), null, true, false, true); reqA[2] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[3.0.0,3.0.0]"), null, true, false, true); reqA[3] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[4.0.0,4.0.0]"), null, true, false, true); - a1 = createIU("A", new Version("1.0.0"), reqA); + a1 = createIU("A", Version.create("1.0.0"), reqA); createTestMetdataRepository(new IInstallableUnit[] {a1, b1, b2, b3, b4}); @@ -55,7 +59,7 @@ public class SimpleOptionalTest4 extends AbstractProvisioningTest { //Ensure that D's installation does not fail because of C's absence ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {a1, b1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.OK, plan.getStatus().getSeverity()); assertInstallOperand(plan, a1); assertInstallOperand(plan, b1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleSingleton.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleSingleton.java index 40254100d..810e1097b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleSingleton.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleSingleton.java @@ -10,14 +10,17 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.director.Explanation; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.ProvisioningPlan; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SimpleSingleton extends AbstractProvisioningTest { @@ -32,13 +35,13 @@ public class SimpleSingleton extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", new Version("1.0.0"), true); + a1 = createIU("A", Version.create("1.0.0"), true); - a2 = createIU("A", new Version("2.0.0"), true); + a2 = createIU("A", Version.create("2.0.0"), true); IRequiredCapability c1 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[1.0.0, 1.0.0]"), null, false, false); IRequiredCapability c2 = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", new VersionRange("[2.0.0, 2.0.0]"), null, false, false); - y = createIU("Y", new Version(2, 0, 0), new IRequiredCapability[] {c1, c2}); + y = createIU("Y", Version.createOSGi(2, 0, 0), new IRequiredCapability[] {c1, c2}); createTestMetdataRepository(new IInstallableUnit[] {a1, a2, y}); @@ -50,7 +53,7 @@ public class SimpleSingleton extends AbstractProvisioningTest { public void test1() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {y}); - ProvisioningPlan provisioningPlan = planner.getProvisioningPlan(req, null, null); + ProvisioningPlan provisioningPlan = (ProvisioningPlan) planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.ERROR, provisioningPlan.getStatus().getSeverity()); assertNotNull(provisioningPlan.getCompleteState()); } @@ -58,9 +61,10 @@ public class SimpleSingleton extends AbstractProvisioningTest { public void testExplanation() { ProfileChangeRequest req = new ProfileChangeRequest(profile); req.addInstallableUnits(new IInstallableUnit[] {y}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); + ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(req, null, null); assertEquals(IStatus.ERROR, plan.getStatus().getSeverity()); - assertEquals(Explanation.VIOLATED_SINGLETON_CONSTRAINT, plan.getRequestStatus().getShortExplanation()); - assertTrue(plan.getRequestStatus().getConflictsWithInstalledRoots().contains(y)); + final RequestStatus requestStatus = (RequestStatus) plan.getRequestStatus(); + assertEquals(Explanation.VIOLATED_SINGLETON_CONSTRAINT, requestStatus.getShortExplanation()); + assertTrue(requestStatus.getConflictsWithInstalledRoots().contains(y)); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java index 16d0cbdfa..170c79a24 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java @@ -10,16 +10,16 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - import java.net.URI; import java.util.*; import org.eclipse.core.runtime.*; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.engine.*; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SimulatedSharedInstallTest extends AbstractProvisioningTest { @@ -34,7 +34,7 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a1 = createIU("A", Version.parseVersion("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]"), null)); + a1 = createIU("A", Version.parseVersion("1.0.0"), createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]"))); b1 = createIU("B", Version.parseVersion("1.0.0")); // Note: C has an "optional" dependency on "B" c1 = createIU("C", Version.parseVersion("1.0.0"), new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.0.0, 1.0.0]"), null, true, false)}); @@ -44,28 +44,44 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest { } public void testRemoveUnresolvedIU() { - assertEquals(IStatus.OK, engine.perform(profile, new DefaultPhaseSet(), new Operand[] {new InstallableUnitOperand(null, a1), new InstallableUnitPropertyOperand(a1, "org.eclipse.equinox.p2.internal.inclusion.rules", null, "STRICT")}, new ProvisioningContext(new URI[0]), new NullProgressMonitor()).getSeverity()); - assertTrue(profile.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().contains(a1)); + ProfileChangeRequest request = new ProfileChangeRequest(profile); + request.setAbsoluteMode(true); + request.addInstallableUnits(new IInstallableUnit[] {a1}); + request.setInstallableUnitInclusionRules(a1, PlannerHelper.createStrictInclusionRule(a1)); + final ProvisioningContext context = new ProvisioningContext(new URI[0]); + IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor()); + assertEquals(IStatus.OK, engine.perform(plan, new NullProgressMonitor()).getSeverity()); + assertContains(profile.query(InstallableUnitQuery.ANY, null), a1); ProfileChangeRequest req = new ProfileChangeRequest(profile); req.removeInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); - assertEquals(IStatus.OK, plan.getStatus().getSeverity()); - assertEquals(IStatus.OK, PlanExecutionHelper.executePlan(plan, engine, new ProvisioningContext(new URI[0]), new NullProgressMonitor()).getSeverity()); - assertFalse(profile.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().contains(a1)); + + IProvisioningPlan plan2 = planner.getProvisioningPlan(req, null, null); + assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); + assertEquals(IStatus.OK, PlanExecutionHelper.executePlan(plan2, engine, context, new NullProgressMonitor()).getSeverity()); + assertNotContains(profile.query(InstallableUnitQuery.ANY, null), a1); } public void testAvailableVsQueryInProfile() { - assertEquals(IStatus.OK, engine.perform(profile, new DefaultPhaseSet(), new Operand[] {new InstallableUnitOperand(null, c1), new InstallableUnitPropertyOperand(c1, "org.eclipse.equinox.p2.internal.inclusion.rules", null, "STRICT")}, new ProvisioningContext(new URI[0]), new NullProgressMonitor()).getSeverity()); - assertTrue(profile.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().contains(c1)); + ProfileChangeRequest request = new ProfileChangeRequest(profile); + request.setAbsoluteMode(true); + request.addInstallableUnits(new IInstallableUnit[] {c1}); + request.setInstallableUnitInclusionRules(c1, PlannerHelper.createStrictInclusionRule(c1)); + final ProvisioningContext context = new ProvisioningContext(new URI[0]); + IProvisioningPlan plan = planner.getProvisioningPlan(request, context, new NullProgressMonitor()); + assertEquals(IStatus.OK, engine.perform(plan, new NullProgressMonitor()).getSeverity()); + assertContains(profile.query(InstallableUnitQuery.ANY, null), c1); IProfile availableWrapper = new IProfile() { - public Collector available(Query query, Collector collector, IProgressMonitor monitor) { - profile.query(query, collector, monitor); + public IQueryResult available(IQuery query, IProgressMonitor monitor) { + IQueryResult queryResult = profile.query(query, monitor); + Collector collector = new Collector(); + collector.addAll(queryResult); Collection ius = new ArrayList(); ius.add(b1); - return query.perform(ius.iterator(), collector); + collector.addAll(query.perform(ius.iterator())); + return collector; } // everything else is delegated @@ -77,18 +93,6 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest { return profile.getInstallableUnitProperty(iu, key); } - public Map getLocalProperties() { - return profile.getLocalProperties(); - } - - public String getLocalProperty(String key) { - return profile.getLocalProperty(key); - } - - public IProfile getParentProfile() { - return profile.getParentProfile(); - } - public String getProfileId() { return profile.getProfileId(); } @@ -101,33 +105,21 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest { return profile.getProperty(key); } - public String[] getSubProfileIds() { - return profile.getSubProfileIds(); - } - public long getTimestamp() { return profile.getTimestamp(); } - public boolean hasSubProfiles() { - return profile.hasSubProfiles(); - } - - public boolean isRootProfile() { - return profile.isRootProfile(); - } - - public Collector query(Query query, Collector collector, IProgressMonitor monitor) { - return profile.query(query, collector, monitor); + public IQueryResult query(IQuery query, IProgressMonitor monitor) { + return profile.query(query, monitor); } }; ProfileChangeRequest req = new ProfileChangeRequest(availableWrapper); req.addInstallableUnits(new IInstallableUnit[] {a1}); - ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null); - assertEquals(IStatus.OK, plan.getStatus().getSeverity()); + IProvisioningPlan plan2 = planner.getProvisioningPlan(req, null, null); + assertEquals(IStatus.OK, plan2.getStatus().getSeverity()); //expect to have both (a1+inclusion rule) and b1 added - assertEquals(3, plan.getOperands().length); + assertEquals(2, countPlanElements(plan2)); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TopLevelFilterTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TopLevelFilterTest.java index 7bb519503..95546c1f5 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TopLevelFilterTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TopLevelFilterTest.java @@ -10,13 +10,13 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class TopLevelFilterTest extends AbstractProvisioningTest { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TwoVersionsOfWSDL.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TwoVersionsOfWSDL.java index 8027fe8c2..2a1ffea34 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TwoVersionsOfWSDL.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TwoVersionsOfWSDL.java @@ -8,20 +8,18 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -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.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager; import org.eclipse.equinox.internal.provisional.p2.director.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IEngine; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -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.engine.*; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +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; @@ -34,10 +32,10 @@ public class TwoVersionsOfWSDL extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - IMetadataRepositoryManager repoMan = (MetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + IMetadataRepositoryManager repoMan = (MetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); IMetadataRepository repo = repoMan.loadRepository(getTestData("repository for wsdl test", "testData/metadataRepo/wsdlTestRepo/").toURI(), new NullProgressMonitor()); - wsdl15 = (IInstallableUnit) repo.query(new InstallableUnitQuery("javax.wsdl", new VersionRange("[1.5, 1.6)")), new Collector(), null).iterator().next(); - wsdl14 = (IInstallableUnit) repo.query(new InstallableUnitQuery("javax.wsdl", new VersionRange("[1.4, 1.5)")), new Collector(), null).iterator().next(); + wsdl15 = (IInstallableUnit) repo.query(new InstallableUnitQuery("javax.wsdl", new VersionRange("[1.5, 1.6)")), null).iterator().next(); + wsdl14 = (IInstallableUnit) repo.query(new InstallableUnitQuery("javax.wsdl", new VersionRange("[1.4, 1.5)")), null).iterator().next(); profile1 = createProfile("TestProfile." + getName()); planner = createPlanner(); @@ -50,7 +48,7 @@ public class TwoVersionsOfWSDL extends AbstractProvisioningTest { req1.addInstallableUnits(new IInstallableUnit[] {wsdl15, wsdl14}); req1.setInstallableUnitInclusionRules(wsdl15, PlannerHelper.createStrictInclusionRule(wsdl15)); req1.setInstallableUnitInclusionRules(wsdl14, PlannerHelper.createStrictInclusionRule(wsdl14)); - ProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); + IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null); assertEquals(IStatus.OK, plan1.getStatus().getSeverity()); assertInstallOperand(plan1, wsdl15); assertInstallOperand(plan1, wsdl14); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/UninstallEverything.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/UninstallEverything.java index 020a57b07..56919d657 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/UninstallEverything.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/UninstallEverything.java @@ -8,15 +8,14 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.planner; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -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.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class UninstallEverything extends AbstractProvisioningTest { @@ -27,7 +26,7 @@ public class UninstallEverything extends AbstractProvisioningTest { protected void setUp() throws Exception { super.setUp(); - a = createIU("A", new Version("1.0.0")); + a = createIU("A", Version.create("1.0.0")); createTestMetdataRepository(new IInstallableUnit[] {a}); profile = createProfile(Bug207319.class.getName()); director = createDirector(); @@ -43,7 +42,7 @@ public class UninstallEverything extends AbstractProvisioningTest { ProfileChangeRequest req2 = new ProfileChangeRequest(profile); req2.removeInstallableUnits(new IInstallableUnit[] {a}); assertEquals(IStatus.OK, director.provision(req2, null, null).getSeverity()); - assertNotIUs(new IInstallableUnit[] {a}, profile.query(InstallableUnitQuery.ANY, new Collector(), null).iterator()); + assertNotIUs(new IInstallableUnit[] {a}, profile.query(InstallableUnitQuery.ANY, null).iterator()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/UpdateQueryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/UpdateQueryTest.java new file mode 100644 index 000000000..6d8b155c1 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/UpdateQueryTest.java @@ -0,0 +1,49 @@ +package org.eclipse.equinox.p2.tests.planner; + +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; + +import org.eclipse.equinox.internal.p2.metadata.query.UpdateQuery; +import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +public class UpdateQueryTest extends AbstractProvisioningTest { + private IInstallableUnit a1; + private IInstallableUnit updateOfA; + private IInstallableUnit a11; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + a1 = createIU("A", Version.create("2.0.0")); + IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor("A", new VersionRange("[2.0.0, 2.0.0]"), 0, "update description"); + updateOfA = createIU("UpdateA", Version.createOSGi(1, 0, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES); + a11 = createIUUpdate(); + } + + public void testUpdateWithDifferentId() { + IMetadataRepository repo = createTestMetdataRepository(new IInstallableUnit[] {a1, updateOfA}); + IQueryResult c = repo.query(new UpdateQuery(a1), null); + assertEquals(1, queryResultSize(c)); + assertEquals(updateOfA, c.iterator().next()); + } + + public void testWithSuperiorVersion() { + IMetadataRepository repo2 = createTestMetdataRepository(new IInstallableUnit[] {a11, a1}); + IQueryResult c2 = repo2.query(new UpdateQuery(a1), null); + assertEquals(1, queryResultSize(c2)); + assertEquals(a11, c2.iterator().next()); + } + + public void testUpdateWithSameId() { + + } + + private IInstallableUnit createIUUpdate() { + return createIU("A", Version.create("2.1.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, MetadataFactory.createUpdateDescriptor("A", new VersionRange("[2.0.0, 2.1.0]"), 0, "update description"), null); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java index c10371c65..aef0693c2 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java @@ -17,22 +17,23 @@ import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.artifact.repository.ArtifactRequest; import org.eclipse.equinox.internal.p2.artifact.repository.Messages; import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler; -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.IStateful; +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.artifact.*; +import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; import org.eclipse.equinox.p2.tests.TestActivator; import org.eclipse.osgi.util.NLS; -@SuppressWarnings( {"restriction", "unchecked"}) public class TestArtifactRepository implements IArtifactRepository { private static String provider = null; - private HashMap/*<IArtifactDescriptor, byte[]>*/repo; + private HashMap<IArtifactDescriptor, byte[]> repo; private String name; private String description; private String version = "1.0.0"; //$NON-NLS-1$ - protected Map properties = new OrderedProperties(); + protected Map<String, String> properties = new OrderedProperties(); public class ArtifactOutputStream extends OutputStream implements IStateful { private boolean closed; @@ -137,8 +138,7 @@ public class TestArtifactRepository implements IArtifactRepository { } public synchronized boolean contains(IArtifactKey key) { - for (Iterator/*<IArtifactDescriptor>*/iterator = repo.keySet().iterator(); iterator.hasNext();) { - IArtifactDescriptor descriptor = (IArtifactDescriptor) iterator.next(); + for (IArtifactDescriptor descriptor : repo.keySet()) { if (descriptor.getArtifactKey().equals(key)) return true; } @@ -147,7 +147,7 @@ public class TestArtifactRepository implements IArtifactRepository { public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { try { - byte[] repoContents = (byte[]) repo.get(descriptor); + byte[] repoContents = repo.get(descriptor); if (repoContents == null) return null; destination.write(repoContents); @@ -159,22 +159,12 @@ public class TestArtifactRepository implements IArtifactRepository { } public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) { - Set/*<IArtifactDescriptor>*/result = new HashSet/*<IArtifactDescriptor>*/(); - for (Iterator/*<IArtifactDescriptor>*/iterator = repo.keySet().iterator(); iterator.hasNext();) { - IArtifactDescriptor descriptor = (IArtifactDescriptor) iterator.next(); + Set<IArtifactDescriptor> result = new HashSet<IArtifactDescriptor>(); + for (IArtifactDescriptor descriptor : repo.keySet()) { if (descriptor.getArtifactKey().equals(key)) result.add(descriptor); } - return (IArtifactDescriptor[]) result.toArray(new IArtifactDescriptor[0]); - } - - public IArtifactKey[] getArtifactKeys() { - Set/*<IArtifactKey>*/result = new HashSet/*<IArtifactKey>*/(); - for (Iterator/*<IArtifactDescriptor>*/iterator = repo.keySet().iterator(); iterator.hasNext();) { - IArtifactDescriptor descriptor = (IArtifactDescriptor) iterator.next(); - result.add(descriptor.getArtifactKey()); - } - return (IArtifactKey[]) result.toArray(new IArtifactKey[0]); + return result.toArray(new IArtifactDescriptor[0]); } public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) { @@ -254,7 +244,7 @@ public class TestArtifactRepository implements IArtifactRepository { } public String setProperty(String key, String value) { - return (String) (value == null ? properties.remove(key) : properties.put(key, value)); + return (value == null ? properties.remove(key) : properties.put(key, value)); } public void setProvider(String value) { @@ -278,7 +268,7 @@ public class TestArtifactRepository implements IArtifactRepository { } public InputStream getRawInputStream(IArtifactDescriptor descriptor) { - return new ByteArrayInputStream((byte[]) repo.get(descriptor), 0, ((byte[]) repo.get(descriptor)).length); + return new ByteArrayInputStream(repo.get(descriptor), 0, repo.get(descriptor).length); } public ZipInputStream getZipInputStream(IArtifactDescriptor descriptor) { @@ -286,10 +276,35 @@ public class TestArtifactRepository implements IArtifactRepository { } public byte[] getBytes(IArtifactDescriptor artifactDescriptor) { - return (byte[]) repo.get(artifactDescriptor); + return repo.get(artifactDescriptor); } public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { return getArtifact(descriptor, destination, monitor); } + + public IArtifactDescriptor createArtifactDescriptor(IArtifactKey key) { + return new ArtifactDescriptor(key); + } + + public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) { + if (monitor != null && monitor.isCanceled()) + return Collector.emptyCollector(); + + Collector<IArtifactKey> collector = new Collector<IArtifactKey>(); + for (IArtifactDescriptor descriptor : repo.keySet()) { + collector.accept(descriptor.getArtifactKey()); + } + return collector; + } + + public IQueryable<IArtifactDescriptor> descriptorQueryable() { + final Collection<IArtifactDescriptor> descs = repo.keySet(); + return new IQueryable<IArtifactDescriptor>() { + + public IQueryResult<IArtifactDescriptor> query(IQuery<IArtifactDescriptor> query, IProgressMonitor monitor) { + return query.perform(descs.iterator()); + } + }; + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AbstractPublisherActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AbstractPublisherActionTest.java index f4d8c899c..0262ec528 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AbstractPublisherActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AbstractPublisherActionTest.java @@ -10,13 +10,15 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.publisher.actions; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.provisional.p2.metadata.*; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.metadata.IProvidedCapability; import org.eclipse.equinox.p2.publisher.*; import org.eclipse.equinox.p2.publisher.actions.ICapabilityAdvice; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; @@ -77,9 +79,9 @@ public class AbstractPublisherActionTest extends AbstractProvisioningTest { public void testAddCapabilities() { InstallableUnitDescription iu = new InstallableUnitDescription(); iu.setId("test"); - assertEquals(0, iu.getRequiredCapabilities().length); - assertEquals(0, iu.getProvidedCapabilities().length); - assertEquals(0, iu.getMetaRequiredCapabilities().length); + assertEquals(0, iu.getRequiredCapabilities().size()); + assertEquals(0, iu.getProvidedCapabilities().size()); + assertEquals(0, iu.getMetaRequiredCapabilities().size()); IPublisherInfo info = new PublisherInfo(); IRequiredCapability testRequiredCapability = MetadataFactory.createRequiredCapability("ns1", "name1", null, null, false, false, false); @@ -90,9 +92,9 @@ public class AbstractPublisherActionTest extends AbstractProvisioningTest { TestAction action = new TestAction(); action.testProcessCapabilityAdvice(iu, info); - assertEquals("name1", iu.getRequiredCapabilities()[0].getName()); - assertEquals("name2", iu.getProvidedCapabilities()[0].getName()); - assertEquals("name3", iu.getMetaRequiredCapabilities()[0].getName()); + assertEquals("name1", ((IRequiredCapability) iu.getRequiredCapabilities().iterator().next()).getName()); + assertEquals("name2", iu.getProvidedCapabilities().iterator().next().getName()); + assertEquals("name3", ((IRequiredCapability) iu.getMetaRequiredCapabilities().iterator().next()).getName()); } public void testAddCapabilitiesIdentityCounts() { @@ -123,9 +125,9 @@ public class AbstractPublisherActionTest extends AbstractProvisioningTest { metaRequiredCapabilities[4] = MetadataFactory.createRequiredCapability("mtest3", "test3", null, null, false, false, false); iu.setMetaRequiredCapabilities(metaRequiredCapabilities); - assertEquals(5, iu.getRequiredCapabilities().length); - assertEquals(5, iu.getProvidedCapabilities().length); - assertEquals(5, iu.getMetaRequiredCapabilities().length); + assertEquals(5, iu.getRequiredCapabilities().size()); + assertEquals(5, iu.getProvidedCapabilities().size()); + assertEquals(5, iu.getMetaRequiredCapabilities().size()); IPublisherInfo info = new PublisherInfo(); IRequiredCapability testRequiredCapability = MetadataFactory.createRequiredCapability("ns1", "name1", null, null, false, false, false); @@ -136,9 +138,9 @@ public class AbstractPublisherActionTest extends AbstractProvisioningTest { TestAction action = new TestAction(); action.testProcessCapabilityAdvice(iu, info); - assertEquals(6, iu.getRequiredCapabilities().length); - assertEquals(6, iu.getProvidedCapabilities().length); - assertEquals(6, iu.getMetaRequiredCapabilities().length); + assertEquals(6, iu.getRequiredCapabilities().size()); + assertEquals(6, iu.getProvidedCapabilities().size()); + assertEquals(6, iu.getMetaRequiredCapabilities().size()); } public void testReplaceCapabilities() { @@ -148,9 +150,9 @@ public class AbstractPublisherActionTest extends AbstractProvisioningTest { iu.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability("ns2", "name2", null)}); iu.setMetaRequiredCapabilities(createRequiredCapabilities("ns3", "name3", null, "")); - assertNotSame(9, iu.getProvidedCapabilities()[0].getVersion().getMajor()); - assertTrue(iu.getRequiredCapabilities()[0].isGreedy()); - assertTrue(iu.getMetaRequiredCapabilities()[0].isGreedy()); + assertNotSame(9, Version.toOSGiVersion(iu.getProvidedCapabilities().iterator().next().getVersion()).getMajor()); + assertTrue(iu.getRequiredCapabilities().iterator().next().isGreedy()); + assertTrue(iu.getMetaRequiredCapabilities().iterator().next().isGreedy()); IPublisherInfo info = new PublisherInfo(); IRequiredCapability testRequiredCapability = MetadataFactory.createRequiredCapability("ns1", "name1", null, null, false, false, false); @@ -161,9 +163,9 @@ public class AbstractPublisherActionTest extends AbstractProvisioningTest { TestAction action = new TestAction(); action.testProcessCapabilityAdvice(iu, info); - assertEquals(9, iu.getProvidedCapabilities()[0].getVersion().getMajor()); - assertFalse(iu.getRequiredCapabilities()[0].isGreedy()); - assertFalse(iu.getMetaRequiredCapabilities()[0].isGreedy()); + assertEquals(9, Version.toOSGiVersion(iu.getProvidedCapabilities().iterator().next().getVersion()).getMajor()); + assertFalse(iu.getRequiredCapabilities().iterator().next().isGreedy()); + assertFalse(iu.getMetaRequiredCapabilities().iterator().next().isGreedy()); } public void testReplaceCapabilitiesIdentityCounts() { @@ -194,9 +196,9 @@ public class AbstractPublisherActionTest extends AbstractProvisioningTest { metaRequiredCapabilities[4] = MetadataFactory.createRequiredCapability("mtest3", "test3", null, null, false, false, false); iu.setMetaRequiredCapabilities(metaRequiredCapabilities); - assertEquals(5, iu.getRequiredCapabilities().length); - assertEquals(5, iu.getProvidedCapabilities().length); - assertEquals(5, iu.getMetaRequiredCapabilities().length); + assertEquals(5, iu.getRequiredCapabilities().size()); + assertEquals(5, iu.getProvidedCapabilities().size()); + assertEquals(5, iu.getMetaRequiredCapabilities().size()); IPublisherInfo info = new PublisherInfo(); IRequiredCapability testRequiredCapability = MetadataFactory.createRequiredCapability("rtest1", "test1", null, null, false, false, false); @@ -207,9 +209,9 @@ public class AbstractPublisherActionTest extends AbstractProvisioningTest { TestAction action = new TestAction(); action.testProcessCapabilityAdvice(iu, info); - assertEquals(4, iu.getRequiredCapabilities().length); - assertEquals(4, iu.getProvidedCapabilities().length); - assertEquals(4, iu.getMetaRequiredCapabilities().length); + assertEquals(4, iu.getRequiredCapabilities().size()); + assertEquals(4, iu.getProvidedCapabilities().size()); + assertEquals(4, iu.getMetaRequiredCapabilities().size()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AccumulateConfigDataActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AccumulateConfigDataActionTest.java index 9eb4f1c01..8f84737a9 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AccumulateConfigDataActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AccumulateConfigDataActionTest.java @@ -14,7 +14,7 @@ import java.io.File; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; -import java.util.Properties; +import java.util.Map; import org.easymock.Capture; import org.easymock.EasyMock; import org.eclipse.core.runtime.NullProgressMonitor; @@ -24,7 +24,7 @@ import org.eclipse.equinox.internal.provisional.frameworkadmin.ConfigData; import org.eclipse.equinox.p2.publisher.eclipse.*; import org.eclipse.equinox.p2.tests.TestActivator; -@SuppressWarnings( {"restriction", "unchecked"}) +@SuppressWarnings({"restriction", "unchecked"}) public class AccumulateConfigDataActionTest extends ActionTest { private static String EXECUTABLE_NAME = "run.exe"; //$NON-NLS-1$ @@ -75,11 +75,11 @@ public class AccumulateConfigDataActionTest extends ActionTest { private void verifyConfigAdvice() throws Exception { ConfigAdvice captured = configAdviceCapture.getValue(); - Properties prop = captured.getProperties(); - assertTrue(prop.getProperty("eclipse.buildId").equalsIgnoreCase("TEST-ID")); //$NON-NLS-1$ //$NON-NLS-2$ - assertTrue(prop.getProperty("eclipse.p2.profile").equalsIgnoreCase("PlatformProfile")); //$NON-NLS-1$//$NON-NLS-2$ - assertTrue(prop.getProperty("org.eclipse.update.reconcile").equalsIgnoreCase("false")); //$NON-NLS-1$//$NON-NLS-2$ - assertTrue(prop.getProperty("eclipse.product").equalsIgnoreCase("org.eclipse.platform.ide")); //$NON-NLS-1$//$NON-NLS-2$ + Map<String, String> prop = captured.getProperties(); + assertTrue(prop.get("eclipse.buildId").equalsIgnoreCase("TEST-ID")); //$NON-NLS-1$ //$NON-NLS-2$ + assertTrue(prop.get("eclipse.p2.profile").equalsIgnoreCase("PlatformProfile")); //$NON-NLS-1$//$NON-NLS-2$ + assertTrue(prop.get("org.eclipse.update.reconcile").equalsIgnoreCase("false")); //$NON-NLS-1$//$NON-NLS-2$ + assertTrue(prop.get("eclipse.product").equalsIgnoreCase("org.eclipse.platform.ide")); //$NON-NLS-1$//$NON-NLS-2$ assertContainsSymbolicName(captured.getBundles(), "org.eclipse.swt"); //$NON-NLS-1$ assertContainsSymbolicName(captured.getBundles(), "org.eclipse.swt.win32.win32.x86"); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java index 8a24aea1c..d62123d01 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java @@ -11,21 +11,20 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - - import java.io.*; import java.util.*; import junit.framework.Assert; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil; import org.eclipse.equinox.p2.publisher.*; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; +import org.osgi.framework.Filter; -@SuppressWarnings( {"cast", "restriction", "unchecked"}) +@SuppressWarnings({"cast", "restriction", "unchecked"}) public abstract class ActionTest extends AbstractProvisioningTest { protected static final String COMMA_SEPARATOR = ","; //$NON-NLS-1$ protected static final String JAR = "jar";//$NON-NLS-1$ @@ -57,18 +56,21 @@ public abstract class ActionTest extends AbstractProvisioningTest { return (String[]) result.toArray(new String[result.size()]); } - protected void verifyProvidedCapability(IProvidedCapability[] prov, String namespace, String name, Version version) { - for (int i = 0; i < prov.length; i++) - if (prov[i].getName().equalsIgnoreCase(name) && prov[i].getNamespace().equalsIgnoreCase(namespace) && prov[i].getVersion().equals(version)) + protected void verifyProvidedCapability(Collection<IProvidedCapability> prov, String namespace, String name, Version version) { + for (IProvidedCapability pc : prov) { + if (pc.getName().equalsIgnoreCase(name) && pc.getNamespace().equalsIgnoreCase(namespace) && pc.getVersion().equals(version)) return; // pass + } Assert.fail("Missing ProvidedCapability: " + name + version.toString()); //$NON-NLS-1$ } - protected void verifyRequiredCapability(IRequiredCapability[] required, String namespace, String name, VersionRange range) { - for (int i = 0; i < required.length; i++) - if (required[i].getName().equalsIgnoreCase(name) && required[i].getNamespace().equalsIgnoreCase(namespace) && required[i].getRange().equals(range)) + protected void verifyRequiredCapability(Collection<IRequirement> requirement, String namespace, String name, VersionRange range) { + for (Iterator iterator = requirement.iterator(); iterator.hasNext();) { + IRequiredCapability required = (IRequiredCapability) iterator.next(); + if (required.getName().equalsIgnoreCase(name) && required.getNamespace().equalsIgnoreCase(namespace) && required.getRange().equals(range)) return; - Assert.fail("Missing RequiredCapability: " + name + range.toString()); //$NON-NLS-1$ + } + Assert.fail("Missing RequiredCapability: " + name + " " + range.toString()); //$NON-NLS-1$ } protected IInstallableUnit mockIU(String id, Version version) { @@ -106,30 +108,28 @@ public abstract class ActionTest extends AbstractProvisioningTest { return map; } - protected void contains(IProvidedCapability[] capabilities, String namespace, String name, Version version) { - for (int i = 0; i < capabilities.length; i++) { - IProvidedCapability capability = capabilities[i]; + protected void contains(Collection<IProvidedCapability> capabilities, String namespace, String name, Version version) { + for (IProvidedCapability capability : capabilities) { if (capability.getNamespace().equals(namespace) && capability.getName().equals(name) && capability.getVersion().equals(version)) return; } fail(); } - protected void contains(IRequiredCapability[] capabilities, String namespace, String name, VersionRange range, String filter, boolean optional, boolean multiple) { - for (int i = 0; i < capabilities.length; i++) { - IRequiredCapability capability = capabilities[i]; + protected void contains(Collection<IRequirement> capabilities, String namespace, String name, VersionRange range, String filterStr, boolean optional, boolean multiple) { + Filter filter = ExpressionUtil.parseLDAP(filterStr); + for (Iterator iterator = capabilities.iterator(); iterator.hasNext();) { + IRequiredCapability capability = (IRequiredCapability) iterator.next(); if (filter == null) { if (capability.getFilter() != null) continue; } else if (!filter.equals(capability.getFilter())) continue; - if (multiple != capability.isMultiple()) - continue; if (!name.equals(capability.getName())) continue; if (!namespace.equals(capability.getNamespace())) continue; - if (optional != capability.isOptional()) + if (optional != (capability.getMin() == 0)) continue; if (!range.equals(capability.getRange())) continue; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java index 0283414ad..538fcee07 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java @@ -10,18 +10,21 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.publisher.actions; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.util.*; import junit.framework.TestCase; +import org.eclipse.equinox.internal.p2.metadata.RequiredCapability; import org.eclipse.equinox.internal.provisional.p2.metadata.*; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.FragmentQuery; import org.eclipse.equinox.p2.publisher.eclipse.AdviceFileParser; public class AdviceFileParserTest extends TestCase { public void testNoAdvice() { - AdviceFileParser parser = new AdviceFileParser("id", Version.MIN_VERSION, Collections.EMPTY_MAP); + AdviceFileParser parser = new AdviceFileParser("id", Version.emptyVersion, Collections.EMPTY_MAP); parser.parse(); assertNull(parser.getAdditionalInstallableUnitDescriptions()); assertNull(parser.getProperties()); @@ -33,11 +36,11 @@ public class AdviceFileParserTest extends TestCase { public void testAdviceVersion() { Map map = new HashMap(); map.put("advice.version", "1.0"); - AdviceFileParser parser = new AdviceFileParser("id", Version.MIN_VERSION, map); + AdviceFileParser parser = new AdviceFileParser("id", Version.emptyVersion, map); parser.parse(); map.put("advice.version", "999"); - parser = new AdviceFileParser("id", Version.MIN_VERSION, map); + parser = new AdviceFileParser("id", Version.emptyVersion, map); try { parser.parse(); } catch (IllegalStateException e) { @@ -53,10 +56,10 @@ public class AdviceFileParserTest extends TestCase { map.put("properties.1.name", "testName2"); map.put("properties.1.value", "testValue2"); - AdviceFileParser parser = new AdviceFileParser("id", Version.MIN_VERSION, map); + AdviceFileParser parser = new AdviceFileParser("id", Version.emptyVersion, map); parser.parse(); - assertEquals("testValue1", parser.getProperties().getProperty("testName1")); - assertEquals("testValue2", parser.getProperties().getProperty("testName2")); + assertEquals("testValue1", parser.getProperties().get("testName1")); + assertEquals("testValue2", parser.getProperties().get("testName2")); } public void testProvidesAdvice() { @@ -65,28 +68,28 @@ public class AdviceFileParserTest extends TestCase { map.put("provides.0.name", "testName1"); map.put("provides.0.version", "1.2.3.$qualifier$"); - AdviceFileParser parser = new AdviceFileParser("id", new Version("1.0.0.v20090909"), map); + AdviceFileParser parser = new AdviceFileParser("id", Version.create("1.0.0.v20090909"), map); parser.parse(); IProvidedCapability[] capabilities = parser.getProvidedCapabilities(); assertEquals(1, capabilities.length); assertEquals("testNamespace1", capabilities[0].getNamespace()); assertEquals("testName1", capabilities[0].getName()); - assertEquals(new Version("1.2.3.v20090909"), capabilities[0].getVersion()); + assertEquals(Version.create("1.2.3.v20090909"), capabilities[0].getVersion()); map.put("provides.1.namespace", "testNamespace2"); map.put("provides.1.name", "testName2"); map.put("provides.1.version", "$version$"); - parser = new AdviceFileParser("id", Version.MIN_VERSION, map); + parser = new AdviceFileParser("id", Version.emptyVersion, map); parser.parse(); capabilities = parser.getProvidedCapabilities(); assertEquals(2, capabilities.length); assertEquals("testNamespace1", capabilities[0].getNamespace()); assertEquals("testName1", capabilities[0].getName()); - assertEquals(new Version("1.2.3"), capabilities[0].getVersion()); + assertEquals(Version.create("1.2.3"), capabilities[0].getVersion()); assertEquals("testNamespace2", capabilities[1].getNamespace()); assertEquals("testName2", capabilities[1].getName()); - assertEquals(Version.MIN_VERSION, capabilities[1].getVersion()); + assertEquals(Version.emptyVersion, capabilities[1].getVersion()); } public void testRequiresAdvice() { @@ -98,13 +101,13 @@ public class AdviceFileParserTest extends TestCase { map.put("requires.0.optional", Boolean.TRUE.toString()); map.put("requires.0.multiple", Boolean.TRUE.toString()); - AdviceFileParser parser = new AdviceFileParser("id", new Version("1.0.0.v20090909"), map); + AdviceFileParser parser = new AdviceFileParser("id", Version.create("1.0.0.v20090909"), map); parser.parse(); - IRequiredCapability[] capabilities = parser.getRequiredCapabilities(); - assertEquals(1, capabilities.length); - assertEquals("testNamespace1", capabilities[0].getNamespace()); - assertEquals("testName1", capabilities[0].getName()); - assertEquals(new VersionRange("[1.2.3.v20090909, 2)"), capabilities[0].getRange()); + IRequirement[] reqs = parser.getRequiredCapabilities(); + assertEquals(1, reqs.length); + assertEquals("testNamespace1", RequiredCapability.extractNamespace(reqs[0].getMatches())); + assertEquals("testName1", RequiredCapability.extractName(reqs[0].getMatches())); + assertEquals(new VersionRange("[1.2.3.v20090909, 2)"), RequiredCapability.extractRange(reqs[0].getMatches())); map.put("requires.1.namespace", "testNamespace2"); map.put("requires.1.name", "testName2"); @@ -114,22 +117,20 @@ public class AdviceFileParserTest extends TestCase { //default // map.put("requires.1.multiple", Boolean.FALSE.toString()); - parser = new AdviceFileParser("id", Version.MIN_VERSION, map); + parser = new AdviceFileParser("id", Version.emptyVersion, map); parser.parse(); - capabilities = parser.getRequiredCapabilities(); - assertEquals(2, capabilities.length); - assertEquals("testNamespace1", capabilities[0].getNamespace()); - assertEquals("testName1", capabilities[0].getName()); - assertEquals(new VersionRange("[1.2.3, 2)"), capabilities[0].getRange()); - assertEquals(true, capabilities[0].isGreedy()); - assertEquals(true, capabilities[0].isOptional()); - assertEquals(true, capabilities[0].isMultiple()); - assertEquals("testNamespace2", capabilities[1].getNamespace()); - assertEquals("testName2", capabilities[1].getName()); - assertEquals(new VersionRange(Version.MIN_VERSION.toString()), capabilities[1].getRange()); - assertEquals(false, capabilities[1].isGreedy()); - assertEquals(false, capabilities[1].isOptional()); - assertEquals(false, capabilities[1].isMultiple()); + reqs = parser.getRequiredCapabilities(); + assertEquals(2, reqs.length); + assertEquals("testNamespace1", RequiredCapability.extractNamespace(reqs[0].getMatches())); + assertEquals("testName1", RequiredCapability.extractName(reqs[0].getMatches())); + assertEquals(new VersionRange("[1.2.3, 2)"), RequiredCapability.extractRange(reqs[0].getMatches())); + assertEquals(true, reqs[0].isGreedy()); + assertEquals(0, reqs[0].getMin()); + assertEquals("testNamespace2", RequiredCapability.extractNamespace(reqs[1].getMatches())); + assertEquals("testName2", RequiredCapability.extractName(reqs[1].getMatches())); + assertEquals(new VersionRange(Version.emptyVersion.toString()), RequiredCapability.extractRange(reqs[1].getMatches())); + assertEquals(false, reqs[1].isGreedy()); + assertEquals(1, reqs[1].getMin()); } public void testMetaRequiresAdvice() { @@ -141,13 +142,13 @@ public class AdviceFileParserTest extends TestCase { map.put("metaRequirements.0.optional", Boolean.TRUE.toString()); map.put("metaRequirements.0.multiple", Boolean.TRUE.toString()); - AdviceFileParser parser = new AdviceFileParser("id", new Version("1.0.0.v20090909"), map); + AdviceFileParser parser = new AdviceFileParser("id", Version.create("1.0.0.v20090909"), map); parser.parse(); - IRequiredCapability[] capabilities = parser.getMetaRequiredCapabilities(); - assertEquals(1, capabilities.length); - assertEquals("testNamespace1", capabilities[0].getNamespace()); - assertEquals("testName1", capabilities[0].getName()); - assertEquals(new VersionRange("[1.2.3.v20090909, 2)"), capabilities[0].getRange()); + IRequirement[] reqs = parser.getMetaRequiredCapabilities(); + assertEquals(1, reqs.length); + assertEquals("testNamespace1", RequiredCapability.extractNamespace(reqs[0].getMatches())); + assertEquals("testName1", RequiredCapability.extractName(reqs[0].getMatches())); + assertEquals(new VersionRange("[1.2.3.v20090909, 2)"), RequiredCapability.extractRange(reqs[0].getMatches())); map.put("metaRequirements.1.namespace", "testNamespace2"); map.put("metaRequirements.1.name", "testName2"); @@ -157,22 +158,20 @@ public class AdviceFileParserTest extends TestCase { //default // map.put("requires.1.multiple", Boolean.FALSE.toString()); - parser = new AdviceFileParser("id", Version.MIN_VERSION, map); + parser = new AdviceFileParser("id", Version.emptyVersion, map); parser.parse(); - capabilities = parser.getMetaRequiredCapabilities(); - assertEquals(2, capabilities.length); - assertEquals("testNamespace1", capabilities[0].getNamespace()); - assertEquals("testName1", capabilities[0].getName()); - assertEquals(new VersionRange("[1.2.3, 2)"), capabilities[0].getRange()); - assertEquals(true, capabilities[0].isGreedy()); - assertEquals(true, capabilities[0].isOptional()); - assertEquals(true, capabilities[0].isMultiple()); - assertEquals("testNamespace2", capabilities[1].getNamespace()); - assertEquals("testName2", capabilities[1].getName()); - assertEquals(new VersionRange(Version.MIN_VERSION.toString()), capabilities[1].getRange()); - assertEquals(false, capabilities[1].isGreedy()); - assertEquals(false, capabilities[1].isOptional()); - assertEquals(false, capabilities[1].isMultiple()); + reqs = parser.getMetaRequiredCapabilities(); + assertEquals(2, reqs.length); + assertEquals("testNamespace1", RequiredCapability.extractNamespace(reqs[0].getMatches())); + assertEquals("testName1", RequiredCapability.extractName(reqs[0].getMatches())); + assertEquals(new VersionRange("[1.2.3, 2)"), RequiredCapability.extractRange(reqs[0].getMatches())); + assertEquals(true, reqs[0].isGreedy()); + assertEquals(0, reqs[0].getMin()); + assertEquals("testNamespace2", RequiredCapability.extractNamespace(reqs[1].getMatches())); + assertEquals("testName2", RequiredCapability.extractName(reqs[1].getMatches())); + assertEquals(new VersionRange(Version.emptyVersion.toString()), RequiredCapability.extractRange(reqs[1].getMatches())); + assertEquals(false, reqs[1].isGreedy()); + assertEquals(1, reqs[1].getMin()); } public void testInstructionsAdvice() { @@ -182,7 +181,7 @@ public class AdviceFileParserTest extends TestCase { map.put("instructions.unconfigure", "removeProgramArg(programArg:-startup); removeProgramArg(programArg:@artifact);)"); map.put("instructions.unconfigure.import", "some.removeProgramArg"); - AdviceFileParser parser = new AdviceFileParser("id", Version.MIN_VERSION, map); + AdviceFileParser parser = new AdviceFileParser("id", Version.emptyVersion, map); parser.parse(); ITouchpointInstruction configure = (ITouchpointInstruction) parser.getTouchpointInstructions().get("configure"); assertEquals(null, configure.getImportAttribute()); @@ -203,7 +202,7 @@ public class AdviceFileParserTest extends TestCase { map.put("units.1.singleton", "true"); map.put("units.1.copyright", "testCopyright"); map.put("units.1.copyright.location", "http://localhost/test"); - map.put("units.1.filter", "test=testFilter"); + map.put("units.1.filter", "(test=testFilter)"); map.put("units.1.touchpoint.id", "testTouchpointId"); map.put("units.1.touchpoint.version", "1.2.5"); map.put("units.1.update.id", "testid1"); @@ -266,114 +265,120 @@ public class AdviceFileParserTest extends TestCase { map.put("units.1.hostRequirements.1.greedy", Boolean.FALSE.toString()); map.put("units.1.hostRequirements.1.optional", Boolean.FALSE.toString()); - AdviceFileParser parser = new AdviceFileParser("id", Version.MIN_VERSION, map); + AdviceFileParser parser = new AdviceFileParser("id", Version.emptyVersion, map); parser.parse(); InstallableUnitDescription[] descriptions = parser.getAdditionalInstallableUnitDescriptions(); IInstallableUnit iu0 = MetadataFactory.createInstallableUnit(descriptions[0]); assertEquals("testid0", iu0.getId()); - assertEquals(new Version("1.2.3"), iu0.getVersion()); + assertEquals(Version.create("1.2.3"), iu0.getVersion()); assertFalse(iu0.isSingleton()); - assertFalse(iu0.isFragment()); - assertEquals(0, iu0.getArtifacts().length); + assertFalse(FragmentQuery.isFragment(iu0)); + assertEquals(0, iu0.getArtifacts().size()); assertEquals(null, iu0.getCopyright()); assertEquals(null, iu0.getFilter()); - assertEquals(null, iu0.getLicense()); + assertEquals(0, iu0.getLicenses().size()); assertEquals(0, iu0.getProperties().size()); - assertEquals(0, iu0.getRequiredCapabilities().length); - assertEquals(0, iu0.getProvidedCapabilities().length); - assertEquals(0, iu0.getMetaRequiredCapabilities().length); - assertEquals(0, iu0.getTouchpointData().length); + assertEquals(0, iu0.getRequiredCapabilities().size()); + assertEquals(0, iu0.getProvidedCapabilities().size()); + assertEquals(0, iu0.getMetaRequiredCapabilities().size()); + assertEquals(0, iu0.getTouchpointData().size()); assertEquals(ITouchpointType.NONE, iu0.getTouchpointType()); assertEquals(null, iu0.getUpdateDescriptor()); IInstallableUnit iu1 = MetadataFactory.createInstallableUnit(descriptions[1]); assertEquals("testid1", iu1.getId()); - assertEquals(new Version("1.2.4"), iu1.getVersion()); + assertEquals(Version.create("1.2.4"), iu1.getVersion()); assertTrue(iu1.isSingleton()); - assertEquals(2, iu1.getArtifacts().length); - assertEquals("testArtifact1", iu1.getArtifacts()[0].getId()); - assertEquals(new Version("1.2.6"), iu1.getArtifacts()[0].getVersion()); - assertEquals("testClassifier1", iu1.getArtifacts()[0].getClassifier()); - assertEquals("testArtifact2", iu1.getArtifacts()[1].getId()); - assertEquals(new Version("1.2.7"), iu1.getArtifacts()[1].getVersion()); - assertEquals("testClassifier2", iu1.getArtifacts()[1].getClassifier()); + assertEquals(2, iu1.getArtifacts().size()); + Iterator it = iu1.getArtifacts().iterator(); + IArtifactKey key0 = (IArtifactKey) it.next(); + IArtifactKey key1 = (IArtifactKey) it.next(); + assertEquals("testArtifact1", key0.getId()); + assertEquals(Version.create("1.2.6"), key0.getVersion()); + assertEquals("testClassifier1", key0.getClassifier()); + assertEquals("testArtifact2", key1.getId()); + assertEquals(Version.create("1.2.7"), key1.getVersion()); + assertEquals("testClassifier2", key1.getClassifier()); assertEquals("testCopyright", iu1.getCopyright().getBody()); assertEquals("http://localhost/test", iu1.getCopyright().getLocation().toString()); - assertEquals("test=testFilter", iu1.getFilter()); - assertEquals("testLicense", iu1.getLicense().getBody()); - assertEquals("http://localhost/license", iu1.getLicense().getLocation().toString()); + assertEquals("(test=testFilter)", iu1.getFilter().toString()); + assertEquals("testLicense", iu1.getLicenses().iterator().next().getBody()); + assertEquals("http://localhost/license", iu1.getLicenses().iterator().next().getLocation().toString()); assertEquals("testValue1", iu1.getProperty("testName1")); assertEquals("testValue2", iu1.getProperty("testName2")); - IRequiredCapability[] required = iu1.getRequiredCapabilities(); - assertEquals(2, required.length); - assertEquals("testNamespace1", required[0].getNamespace()); - assertEquals("testName1", required[0].getName()); - assertEquals(new VersionRange("[1.2.3, 2)"), required[0].getRange()); - assertEquals(true, required[0].isGreedy()); - assertEquals(true, required[0].isOptional()); - assertEquals(true, required[0].isMultiple()); - assertEquals("testNamespace2", required[1].getNamespace()); - assertEquals("testName2", required[1].getName()); - assertEquals(new VersionRange(Version.MIN_VERSION.toString()), required[1].getRange()); - assertEquals(false, required[1].isGreedy()); - assertEquals(false, required[1].isOptional()); - assertEquals(false, required[1].isMultiple()); - - IProvidedCapability[] provided = iu1.getProvidedCapabilities(); - assertEquals(2, provided.length); - assertEquals("testNamespace1", provided[0].getNamespace()); - assertEquals("testName1", provided[0].getName()); - assertEquals(new Version("1.2.3"), provided[0].getVersion()); - assertEquals("testNamespace2", provided[1].getNamespace()); - assertEquals("testName2", provided[1].getName()); - assertEquals(Version.MIN_VERSION, provided[1].getVersion()); - - IRequiredCapability[] metarequirements = iu1.getMetaRequiredCapabilities(); - assertEquals(2, metarequirements.length); - assertEquals("testNamespace1", metarequirements[0].getNamespace()); - assertEquals("testName1", metarequirements[0].getName()); - assertEquals(new VersionRange("[1.2.3, 2)"), metarequirements[0].getRange()); - assertEquals(true, metarequirements[0].isGreedy()); - assertEquals(true, metarequirements[0].isOptional()); - assertEquals(true, metarequirements[0].isMultiple()); - assertEquals("testNamespace2", metarequirements[1].getNamespace()); - assertEquals("testName2", metarequirements[1].getName()); - assertEquals(new VersionRange(Version.MIN_VERSION.toString()), metarequirements[1].getRange()); - assertEquals(false, metarequirements[1].isGreedy()); - assertEquals(false, metarequirements[1].isOptional()); - assertEquals(false, metarequirements[1].isMultiple()); - - assertEquals(1, iu1.getTouchpointData().length); - ITouchpointInstruction configure = iu1.getTouchpointData()[0].getInstruction("configure"); + Collection<IRequirement> reqs = iu1.getRequiredCapabilities(); + Iterator it2 = reqs.iterator(); + IRequirement req0 = (IRequirement) it2.next(); + IRequirement req1 = (IRequirement) it2.next(); + assertEquals(2, reqs.size()); + assertEquals("testNamespace1", RequiredCapability.extractNamespace(req0.getMatches())); + assertEquals("testName1", RequiredCapability.extractName(req0.getMatches())); + assertEquals(new VersionRange("[1.2.3, 2)"), RequiredCapability.extractRange(req0.getMatches())); + assertEquals(true, req0.isGreedy()); + assertEquals(0, req0.getMin()); + assertEquals("testNamespace2", RequiredCapability.extractNamespace(req1.getMatches())); + assertEquals("testName2", RequiredCapability.extractName(req1.getMatches())); + assertEquals(new VersionRange(Version.emptyVersion.toString()), RequiredCapability.extractRange(req1.getMatches())); + assertEquals(false, req1.isGreedy()); + assertEquals(1, req1.getMin()); + + Collection<IProvidedCapability> provided = iu1.getProvidedCapabilities(); + Iterator<IProvidedCapability> it4 = provided.iterator(); + IProvidedCapability cap1 = it4.next(); + IProvidedCapability cap2 = it4.next(); + assertEquals(2, provided.size()); + assertEquals("testNamespace1", cap1.getNamespace()); + assertEquals("testName1", cap1.getName()); + assertEquals(Version.create("1.2.3"), cap1.getVersion()); + assertEquals("testNamespace2", cap2.getNamespace()); + assertEquals("testName2", cap2.getName()); + assertEquals(Version.emptyVersion, cap2.getVersion()); + + Collection<IRequirement> metarequirements = iu1.getMetaRequiredCapabilities(); + assertEquals(2, metarequirements.size()); + Iterator it3 = metarequirements.iterator(); + IRequirement metaReq0 = (IRequirement) it3.next(); + IRequirement metaReq1 = (IRequirement) it3.next(); + + assertEquals("testNamespace1", RequiredCapability.extractNamespace(metaReq0.getMatches())); + assertEquals("testName1", RequiredCapability.extractName(metaReq0.getMatches())); + assertEquals(new VersionRange("[1.2.3, 2)"), RequiredCapability.extractRange(metaReq0.getMatches())); + assertEquals(true, metaReq0.isGreedy()); + assertEquals(0, metaReq0.getMin()); + assertEquals("testNamespace2", RequiredCapability.extractNamespace(metaReq1.getMatches())); + assertEquals("testName2", RequiredCapability.extractName(metaReq1.getMatches())); + assertEquals(new VersionRange(Version.emptyVersion.toString()), RequiredCapability.extractRange(metaReq1.getMatches())); + assertEquals(false, metaReq1.isGreedy()); + assertEquals(1, metaReq1.getMin()); + + assertEquals(1, iu1.getTouchpointData().size()); + ITouchpointInstruction configure = iu1.getTouchpointData().get(0).getInstruction("configure"); assertEquals(null, configure.getImportAttribute()); assertEquals("addProgramArg(programArg:-startup); addProgramArg(programArg:@artifact);", configure.getBody()); - ITouchpointInstruction unconfigure = iu1.getTouchpointData()[0].getInstruction("unconfigure"); + ITouchpointInstruction unconfigure = iu1.getTouchpointData().get(0).getInstruction("unconfigure"); assertEquals("some.removeProgramArg", unconfigure.getImportAttribute()); assertEquals("removeProgramArg(programArg:-startup); removeProgramArg(programArg:@artifact);)", unconfigure.getBody()); - assertEquals(MetadataFactory.createTouchpointType("testTouchpointId", new Version("1.2.5")), iu1.getTouchpointType()); + assertEquals(MetadataFactory.createTouchpointType("testTouchpointId", Version.create("1.2.5")), iu1.getTouchpointType()); assertEquals("testid1", iu1.getUpdateDescriptor().getId()); assertEquals(new VersionRange("(1,2)"), iu1.getUpdateDescriptor().getRange()); assertEquals(2, iu1.getUpdateDescriptor().getSeverity()); assertEquals("some description", iu1.getUpdateDescriptor().getDescription()); - assertTrue(iu1.isFragment()); - IRequiredCapability[] hostRequired = ((IInstallableUnitFragment) iu1).getHost(); + assertTrue(FragmentQuery.isFragment(iu1)); + IRequirement[] hostRequired = ((IInstallableUnitFragment) iu1).getHost(); assertEquals(2, hostRequired.length); - assertEquals("testNamespace1", hostRequired[0].getNamespace()); - assertEquals("testName1", hostRequired[0].getName()); - assertEquals(new VersionRange("[1.2.3, 2)"), hostRequired[0].getRange()); + assertEquals("testNamespace1", RequiredCapability.extractNamespace(hostRequired[0].getMatches())); + assertEquals("testName1", RequiredCapability.extractName(hostRequired[0].getMatches())); + assertEquals(new VersionRange("[1.2.3, 2)"), RequiredCapability.extractRange(hostRequired[0].getMatches())); assertEquals(true, hostRequired[0].isGreedy()); - assertEquals(true, hostRequired[0].isOptional()); - assertEquals(true, hostRequired[0].isMultiple()); - assertEquals("testNamespace2", hostRequired[1].getNamespace()); - assertEquals("testName2", hostRequired[1].getName()); - assertEquals(new VersionRange(Version.MIN_VERSION.toString()), hostRequired[1].getRange()); + assertEquals(0, hostRequired[0].getMin()); + assertEquals("testNamespace2", RequiredCapability.extractNamespace(hostRequired[1].getMatches())); + assertEquals("testName2", RequiredCapability.extractName(hostRequired[1].getMatches())); + assertEquals(new VersionRange(Version.emptyVersion.toString()), RequiredCapability.extractRange(hostRequired[1].getMatches())); assertEquals(false, hostRequired[1].isGreedy()); - assertEquals(false, hostRequired[1].isOptional()); - assertEquals(false, hostRequired[1].isMultiple()); + assertEquals(1, hostRequired[1].getMin()); } - } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceMatcher.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceMatcher.java index bf95d1f99..b99d3c3d8 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceMatcher.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceMatcher.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.publisher.actions; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import org.easymock.EasyMock; import org.easymock.IArgumentMatcher; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java index 327656ad1..6017d4130 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java @@ -12,9 +12,8 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.io.*; import java.util.*; @@ -23,20 +22,22 @@ import org.easymock.EasyMock; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.director.QueryableArray; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.p2.metadata.TranslationSupport; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.publisher.*; import org.eclipse.equinox.p2.publisher.actions.*; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; import org.eclipse.equinox.p2.publisher.eclipse.IBundleShapeAdvice; -import org.eclipse.equinox.p2.tests.*; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.tests.TestActivator; +import org.eclipse.equinox.p2.tests.TestData; import org.eclipse.equinox.p2.tests.publisher.TestArtifactRepository; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; -@SuppressWarnings( {"restriction", "unchecked"}) +@SuppressWarnings({"unchecked"}) public class BundlesActionTest extends ActionTest { private static final String OSGI = PublisherHelper.OSGI_BUNDLE_CLASSIFIER; private static final String JAVA_PACKAGE = "java.package";//$NON-NLS-1$ @@ -67,16 +68,16 @@ public class BundlesActionTest extends ActionTest { private static final String TEST2_PROVX_NAMESPACE = JAVA_PACKAGE; private static final String TEST1_PROVZ_NAMESPACE = JAVA_PACKAGE; - private final Version BUNDLE1_VERSION = new Version("0.1.0");//$NON-NLS-1$ - private final Version BUNDLE2_VERSION = new Version("1.0.0.qualifier");//$NON-NLS-1$ + private final Version BUNDLE1_VERSION = Version.create("0.1.0");//$NON-NLS-1$ + private final Version BUNDLE2_VERSION = Version.create("1.0.0.qualifier");//$NON-NLS-1$ private final Version PROVBUNDLE2_VERSION = BUNDLE2_VERSION; private final Version TEST2_PROVZ_VERSION = Version.emptyVersion; private final Version TEST2_PROVY_VERSION = Version.emptyVersion; private final Version TEST2_PROVX_VERSION = Version.emptyVersion; private final VersionRange TEST2_IUA_VERSION_RANGE = VersionRange.emptyRange; private final VersionRange TEST2_IUB_VERSION_RANGE = VersionRange.emptyRange; - private final VersionRange TEST2_IUC_VERSION_RANGE = new VersionRange(new Version("1.0.0"), true, new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE), true);//$NON-NLS-1$ - private final VersionRange TEST1_IUD_VERSION_RANGE = new VersionRange(new Version("1.3.0"), true, new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE), true);//$NON-NLS-1$ + private final VersionRange TEST2_IUC_VERSION_RANGE = new VersionRange(Version.create("1.0.0"), true, Version.MAX_VERSION, true);//$NON-NLS-1$ + private final VersionRange TEST1_IUD_VERSION_RANGE = new VersionRange(Version.create("1.3.0"), true, Version.MAX_VERSION, true);//$NON-NLS-1$ protected TestArtifactRepository artifactRepository = new TestArtifactRepository(); @@ -120,22 +121,23 @@ public class BundlesActionTest extends ActionTest { ius = results.getIUs(null, null); assertEquals("2.0", 1, ius.size()); QueryableArray queryableArray = new QueryableArray((IInstallableUnit[]) ius.toArray(new IInstallableUnit[ius.size()])); - Collector result = queryableArray.query(new InstallableUnitQuery("foo"), new Collector(), null); - assertEquals("3.1", 1, result.size()); + IQueryResult result = queryableArray.query(new InstallableUnitQuery("foo"), null); + assertEquals("3.1", 1, queryResultSize(result)); IInstallableUnit iu = (IInstallableUnit) result.iterator().next(); - IUPropertyUtils iuPropertyUtils = new IUPropertyUtils(queryableArray); - assertEquals("3.2", "English Foo", iuPropertyUtils.getIUProperty(iu, IInstallableUnit.PROP_NAME)); + TranslationSupport utils = new TranslationSupport(); + utils.setTranslationSource(queryableArray); + assertEquals("3.2", "English Foo", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME)); bundlesAction = new BundlesAction(new File[] {foo_fragment}); bundlesAction.perform(info, results, new NullProgressMonitor()); ius = results.getIUs(null, null); assertEquals("2.0", 3, ius.size()); queryableArray = new QueryableArray((IInstallableUnit[]) ius.toArray(new IInstallableUnit[ius.size()])); - result = queryableArray.query(new InstallableUnitQuery("foo"), new Collector(), null); - assertEquals("2.1", 1, result.size()); + result = queryableArray.query(new InstallableUnitQuery("foo"), null); + assertEquals("2.1", 1, queryResultSize(result)); iu = (IInstallableUnit) result.iterator().next(); - iuPropertyUtils = new IUPropertyUtils(queryableArray); - assertEquals("2.2", "German Foo", iuPropertyUtils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN)); + utils.setTranslationSource(queryableArray); + assertEquals("2.2", "German Foo", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN.toString())); } private void verifyBundlesAction() throws Exception { @@ -155,7 +157,7 @@ public class BundlesActionTest extends ActionTest { int packedIdx; int canonicalIdx; - if ("packed".equals(descriptors[0].getProperty(IArtifactDescriptor.FORMAT))) { + if (IArtifactDescriptor.FORMAT_PACKED.equals(descriptors[0].getProperty(IArtifactDescriptor.FORMAT))) { packedIdx = 0; canonicalIdx = 1; } else { @@ -190,22 +192,22 @@ public class BundlesActionTest extends ActionTest { assertEquals("1.1", bundle1IU.getVersion(), BUNDLE1_VERSION); // check required capabilities - IRequiredCapability[] requiredCapability = bundle1IU.getRequiredCapabilities(); + Collection<IRequirement> requiredCapability = bundle1IU.getRequiredCapabilities(); verifyRequiredCapability(requiredCapability, TEST1_IUD_NAMESPACE, TEST1_IUD_NAME, TEST1_IUD_VERSION_RANGE); - assertEquals("2.0", 1, requiredCapability.length); + assertEquals("2.0", 1, requiredCapability.size()); // check provided capabilities - IProvidedCapability[] providedCapabilities = bundle1IU.getProvidedCapabilities(); + Collection<IProvidedCapability> providedCapabilities = bundle1IU.getProvidedCapabilities(); verifyProvidedCapability(providedCapabilities, PROVBUNDLE_NAMESPACE, TEST1_PROVBUNDLE_NAME, BUNDLE1_VERSION); verifyProvidedCapability(providedCapabilities, OSGI, TEST1_PROVBUNDLE_NAME, BUNDLE1_VERSION); verifyProvidedCapability(providedCapabilities, TEST1_PROVZ_NAMESPACE, TEST1_PROVZ_NAME, TEST2_PROVZ_VERSION); - verifyProvidedCapability(providedCapabilities, PublisherHelper.NAMESPACE_ECLIPSE_TYPE, "source", new Version("1.0.0"));//$NON-NLS-1$//$NON-NLS-2$ - assertEquals("2.1", 4, providedCapabilities.length); + verifyProvidedCapability(providedCapabilities, PublisherHelper.NAMESPACE_ECLIPSE_TYPE, "source", Version.create("1.0.0"));//$NON-NLS-1$//$NON-NLS-2$ + assertEquals("2.1", 4, providedCapabilities.size()); - ITouchpointData[] data = bundle1IU.getTouchpointData(); + List<ITouchpointData> data = bundle1IU.getTouchpointData(); boolean found = false; - for (int i = 0; i < data.length; i++) { - ITouchpointInstruction configure = data[i].getInstruction("configure"); + for (int i = 0; i < data.size(); i++) { + ITouchpointInstruction configure = data.get(i).getInstruction("configure"); if (configure == null) continue; String body = configure.getBody(); @@ -225,31 +227,31 @@ public class BundlesActionTest extends ActionTest { assertEquals(bundle2IU.getVersion(), BUNDLE2_VERSION); // check required capabilities - IRequiredCapability[] requiredCapabilities = bundle2IU.getRequiredCapabilities(); + Collection<IRequirement> requiredCapabilities = bundle2IU.getRequiredCapabilities(); verifyRequiredCapability(requiredCapabilities, TEST2_IUA_NAMESPACE, TEST2_REQA_NAME, TEST2_IUA_VERSION_RANGE); verifyRequiredCapability(requiredCapabilities, TEST2_IUB_NAMESPACE, TEST2_REQB_NAME, TEST2_IUB_VERSION_RANGE); verifyRequiredCapability(requiredCapabilities, TEST2_IUC_NAMESPACE, TEST2_REQC_NAME, TEST2_IUC_VERSION_RANGE); - assertTrue(requiredCapabilities.length == 3 /*number of tested elements*/); + assertTrue(requiredCapabilities.size() == 3 /*number of tested elements*/); // check provided capabilities - IProvidedCapability[] providedCapabilities = bundle2IU.getProvidedCapabilities(); + Collection<IProvidedCapability> providedCapabilities = bundle2IU.getProvidedCapabilities(); verifyProvidedCapability(providedCapabilities, PROVBUNDLE_NAMESPACE, TEST2_PROVBUNDLE_NAME, PROVBUNDLE2_VERSION); verifyProvidedCapability(providedCapabilities, OSGI, TEST2_PROVBUNDLE_NAME, BUNDLE2_VERSION); verifyProvidedCapability(providedCapabilities, TEST2_PROVZ_NAMESPACE, TEST2_PROVZ_NAME, TEST2_PROVZ_VERSION); verifyProvidedCapability(providedCapabilities, TEST2_PROVY_NAMESPACE, TEST2_PROVY_NAME, TEST2_PROVY_VERSION); verifyProvidedCapability(providedCapabilities, TEST2_PROVX_NAMESPACE, TEST2_PROVX_NAME, TEST2_PROVX_VERSION); - verifyProvidedCapability(providedCapabilities, PublisherHelper.NAMESPACE_ECLIPSE_TYPE, "bundle", new Version("1.0.0"));//$NON-NLS-1$//$NON-NLS-2$ - assertTrue(providedCapabilities.length == 6 /*number of tested elements*/); + verifyProvidedCapability(providedCapabilities, PublisherHelper.NAMESPACE_ECLIPSE_TYPE, "bundle", Version.create("1.0.0"));//$NON-NLS-1$//$NON-NLS-2$ + assertTrue(providedCapabilities.size() == 6 /*number of tested elements*/); // check %bundle name is correct Map prop = bundle2IU.getProperties(); assertTrue(prop.get("org.eclipse.equinox.p2.name").toString().equalsIgnoreCase("%bundleName"));//$NON-NLS-1$//$NON-NLS-2$ assertTrue(prop.get("org.eclipse.equinox.p2.provider").toString().equalsIgnoreCase("%providerName"));//$NON-NLS-1$//$NON-NLS-2$ - ITouchpointData[] data = bundle2IU.getTouchpointData(); + List<ITouchpointData> data = bundle2IU.getTouchpointData(); boolean found = false; - for (int i = 0; i < data.length; i++) { - ITouchpointInstruction configure = data[i].getInstruction("configure"); + for (int i = 0; i < data.size(); i++) { + ITouchpointInstruction configure = data.get(i).getInstruction("configure"); if (configure == null) continue; String body = configure.getBody(); @@ -272,11 +274,11 @@ public class BundlesActionTest extends ActionTest { protected void insertPublisherInfoBehavior() { //super sets publisherInfo.getMetadataRepository and publisherInfo.getContextMetadataRepository super.insertPublisherInfoBehavior(); - Properties sarProperties = new Properties(); + Map<String, String> sarProperties = new HashMap<String, String>(); sarProperties.put("key1", "value1");//$NON-NLS-1$//$NON-NLS-2$ sarProperties.put("key2", "value2");//$NON-NLS-1$//$NON-NLS-2$ - Properties sdkProperties = new Properties(); + Map<String, String> sdkProperties = new HashMap<String, String>(); sdkProperties.put("key1", "value1");//$NON-NLS-1$//$NON-NLS-2$ sdkProperties.put("key2", "value2");//$NON-NLS-1$//$NON-NLS-2$ diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java index cf28eb389..9c896acdf 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java @@ -12,30 +12,27 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.expect; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - - import java.io.File; -import java.util.ArrayList; +import java.util.*; import org.easymock.EasyMock; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.metadata.InstallableUnit; import org.eclipse.equinox.internal.p2.publisher.eclipse.DataLoader; import org.eclipse.equinox.internal.provisional.frameworkadmin.ConfigData; import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil; import org.eclipse.equinox.p2.publisher.IPublisherResult; import org.eclipse.equinox.p2.publisher.eclipse.*; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.TestActivator; import org.eclipse.equinox.p2.tests.TestMetadataRepository; -@SuppressWarnings( {"unchecked", "restriction"}) +@SuppressWarnings({"unchecked", "restriction"}) public class ConfigCUsActionTest extends ActionTest { private static File configLocation = new File(TestActivator.getTestDataFolder(), "ConfigCUsActionTest/level1/level2/config.ini"); //$NON-NLS-1$ private static File executableLocation = new File(TestActivator.getTestDataFolder(), "ConfigCUsActionTest/level1/run.exe"); //$NON-NLS-1$ - private static Version version = new Version("1.0.0"); //$NON-NLS-1$ + private static Version version = Version.create("1.0.0"); //$NON-NLS-1$ private static String id = "id"; //$NON-NLS-1$ private static String flavor = "tooling"; //$NON-NLS-1$ private IMetadataRepository metadataRepo; @@ -60,16 +57,16 @@ public class ConfigCUsActionTest extends ActionTest { assertTrue(iu.getId().equalsIgnoreCase(flavor + id + ".configuration")); //$NON-NLS-1$ //verify ProvidedCapabilities - IProvidedCapability[] providedCapabilities = iu.getProvidedCapabilities(); + Collection<IProvidedCapability> providedCapabilities = iu.getProvidedCapabilities(); verifyProvidedCapability(providedCapabilities, "org.eclipse.equinox.p2.iu", iu.getId(), version); //$NON-NLS-1$ // verifyProvidedCapability(providedCapabilities, flavor + id, id + ".config", version); //$NON-NLS-1$ - assertTrue(providedCapabilities.length == 1); + assertTrue(providedCapabilities.size() == 1); //verify RequiredCapabilities - IRequiredCapability[] requiredCapability = iu.getRequiredCapabilities(); + List<IRequirement> requiredCapability = iu.getRequiredCapabilities(); verifyRequiredCapability(requiredCapability, IInstallableUnit.NAMESPACE_IU_ID, flavor + id + ".config." + configSpec, new VersionRange(version, true, version, true)); //$NON-NLS-1$ verifyRequiredCapability(requiredCapability, IInstallableUnit.NAMESPACE_IU_ID, flavor + id + ".ini." + configSpec, new VersionRange(version, true, version, true)); //$NON-NLS-1$ - assertTrue(requiredCapability.length == 2); + assertTrue(requiredCapability.size() == 2); //verify non root IUs verifyFragment("ini"); //$NON-NLS-1$ @@ -82,16 +79,14 @@ public class ConfigCUsActionTest extends ActionTest { for (int i = 0; i < IUs.size(); i++) { InstallableUnit iu = (InstallableUnit) IUs.get(i); if (iu.getId().equals(flavor + id + "." + cuType + "." + configSpec)) { //$NON-NLS-1$ //$NON-NLS-2$ - assertTrue(iu.getFilter().equals("(& (osgi.ws=win32)(osgi.os=win32)(osgi.arch=x86))")); //$NON-NLS-1$ + assertTrue(iu.getFilter().equals(ExpressionUtil.parseLDAP("(& (osgi.ws=win32)(osgi.os=win32)(osgi.arch=x86))"))); //$NON-NLS-1$ assertTrue(iu.getVersion().equals(version)); - assertTrue(iu.getProperty("org.eclipse.equinox.p2.type.fragment").equals("true")); //$NON-NLS-1$//$NON-NLS-2$ assertFalse(iu.isSingleton()); - IProvidedCapability[] providedCapabilities = iu.getProvidedCapabilities(); + Collection<IProvidedCapability> providedCapabilities = iu.getProvidedCapabilities(); verifyProvidedCapability(providedCapabilities, IInstallableUnit.NAMESPACE_IU_ID, flavor + id + "." + cuType + "." + configSpec, version); //$NON-NLS-1$//$NON-NLS-2$ verifyProvidedCapability(providedCapabilities, flavor + id, id + "." + cuType, version); //$NON-NLS-1$ - assertTrue(providedCapabilities.length == 2); - assertTrue(iu.getRequiredCapabilities().length == 0); - assertFalse(iu.isFragment()); + assertTrue(providedCapabilities.size() == 2); + assertTrue(iu.getRequiredCapabilities().size() == 0); return; //pass } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/DefaultCUsActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/DefaultCUsActionTest.java index 4efbf1258..22806f1b6 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/DefaultCUsActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/DefaultCUsActionTest.java @@ -10,18 +10,19 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.publisher.actions; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; -import java.util.ArrayList; +import java.util.Collection; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; import org.eclipse.equinox.internal.p2.metadata.InstallableUnitFragment; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.DefaultCUsAction; -@SuppressWarnings( {"restriction", "unchecked"}) +@SuppressWarnings({"unchecked"}) public class DefaultCUsActionTest extends ActionTest { - private Version version = new Version("1.0.0"); //$NON-NLS-1$ + private Version version = Version.create("1.0.0"); //$NON-NLS-1$ public void testAll() throws Exception { testAction = new DefaultCUsAction(publisherInfo, flavorArg, 4 /*start level*/, true /*start*/); @@ -34,7 +35,7 @@ public class DefaultCUsActionTest extends ActionTest { } private void verifyDefaultCUs() { - ArrayList<InstallableUnitFragment> ius = (ArrayList<InstallableUnitFragment>) publisherResult.getIUs(null, null); + Collection<IInstallableUnit> ius = publisherResult.getIUs(null, null); assertTrue(ius.size() == 3); InstallableUnitFragment iuf1 = new InstallableUnitFragment(); iuf1.setId(flavorArg + ".source.default"); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxExecutableActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxExecutableActionTest.java index 3cfcfdee3..90d6155c7 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxExecutableActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxExecutableActionTest.java @@ -12,23 +12,22 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.io.File; -import java.util.ArrayList; -import java.util.Collections; +import java.util.*; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.publisher.eclipse.ExecutablesDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil; import org.eclipse.equinox.p2.publisher.*; import org.eclipse.equinox.p2.publisher.eclipse.EquinoxExecutableAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; import org.eclipse.equinox.p2.tests.TestActivator; import org.eclipse.equinox.p2.tests.publisher.TestArtifactRepository; -@SuppressWarnings( {"restriction", "unchecked"}) +@SuppressWarnings({"restriction", "unchecked"}) public class EquinoxExecutableActionTest extends ActionTest { private static final File MAC_EXEC = new File(TestActivator.getTestDataFolder(), "EquinoxExecutableActionTest/macosx/"); //$NON-NLS-1$ @@ -41,7 +40,7 @@ public class EquinoxExecutableActionTest extends ActionTest { private String linuxConfig = "linux.gtk.x86"; //$NON-NLS-1$ private ExecutablesDescriptor executablesDescriptor; private IArtifactRepository artifactRepository; - private Version version = new Version("1.2.3"); //$NON-NLS-1$ + private Version version = Version.create("1.2.3"); //$NON-NLS-1$ public void setUp() throws Exception { setupPublisherInfo(); @@ -95,13 +94,13 @@ public class EquinoxExecutableActionTest extends ActionTest { IInstallableUnit possibleEclipse = (IInstallableUnit) iuList.get(i); if (possibleEclipse.getId().equals(flavorArg + idBase + ".executable." + configSpec)) {//$NON-NLS-1$ IInstallableUnitFragment fragment = (IInstallableUnitFragment) iuList.get(i); - IProvidedCapability[] providedCapability = fragment.getProvidedCapabilities(); + Collection<IProvidedCapability> providedCapability = fragment.getProvidedCapabilities(); verifyProvidedCapability(providedCapability, IInstallableUnit.NAMESPACE_IU_ID, flavorArg + idBase + ".executable." + configSpec, version); //$NON-NLS-1$ - assertTrue(providedCapability.length == 1); - IRequiredCapability[] requiredCapability = fragment.getRequiredCapabilities(); + assertTrue(providedCapability.size() == 1); + Collection<IRequirement> requiredCapability = fragment.getRequiredCapabilities(); verifyRequiredCapability(requiredCapability, IInstallableUnit.NAMESPACE_IU_ID, idBase + ".executable." + configSpec, new VersionRange(version, true, version, true)); //$NON-NLS-1$ - assertTrue(requiredCapability.length == 1); - assertTrue(fragment.getFilter().equals("(& (osgi.ws=" + ws + ")(osgi.os=" + os + ")(osgi.arch=" + arch + "))")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ + assertTrue(requiredCapability.size() == 1); + assertTrue(fragment.getFilter().equals(ExpressionUtil.parseLDAP("(& (osgi.ws=" + ws + ")(osgi.os=" + os + ")(osgi.arch=" + arch + "))"))); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ assertTrue(fragment.getProperty("org.eclipse.equinox.p2.type.fragment").equals("true")); //$NON-NLS-1$ //$NON-NLS-2$ return;//pass } @@ -115,11 +114,11 @@ public class EquinoxExecutableActionTest extends ActionTest { IInstallableUnit possibleEclipse = (IInstallableUnit) iuList.get(i); if (possibleEclipse.getId().equals((idBase + ".executable." + configSpec + ".eclipse"))) { //$NON-NLS-1$//$NON-NLS-2$ assertTrue(possibleEclipse.getVersion().equals(version)); - IProvidedCapability[] providedCapability = possibleEclipse.getProvidedCapabilities(); + Collection<IProvidedCapability> providedCapability = possibleEclipse.getProvidedCapabilities(); verifyProvidedCapability(providedCapability, IInstallableUnit.NAMESPACE_IU_ID, idBase + ".executable." + configSpec + ".eclipse", version); //$NON-NLS-1$ //$NON-NLS-2$ - assertTrue(providedCapability.length == 1); - IRequiredCapability[] req = possibleEclipse.getRequiredCapabilities(); - assertTrue(req.length == 0); + assertTrue(providedCapability.size() == 1); + Collection<IRequirement> req = possibleEclipse.getRequiredCapabilities(); + assertTrue(req.size() == 0); return;//pass } } @@ -136,19 +135,19 @@ public class EquinoxExecutableActionTest extends ActionTest { IInstallableUnit possibleExec = (IInstallableUnit) iuList.get(i); if (possibleExec.getId().equals(idBase + ".executable." + configSpec)) { //$NON-NLS-1$ //keep checking - assertTrue(possibleExec.getFilter().equals("(& (osgi.ws=" + ws + ")(osgi.os=" + os + ")(osgi.arch=" + arch + "))")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ - IArtifactKey eKey = possibleExec.getArtifacts()[0]; + assertTrue(possibleExec.getFilter().equals(ExpressionUtil.parseLDAP("(& (osgi.ws=" + ws + ")(osgi.os=" + os + ")(osgi.arch=" + arch + "))"))); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ + IArtifactKey eKey = possibleExec.getArtifacts().iterator().next(); assertTrue(eKey.getClassifier().equals("binary")); //$NON-NLS-1$ assertTrue(eKey.getId().equals(idBase + ".executable." + configSpec)); //$NON-NLS-1$ assertTrue(eKey.getVersion().equals(version)); - IProvidedCapability[] providedCapabilities = possibleExec.getProvidedCapabilities(); + Collection<IProvidedCapability> providedCapabilities = possibleExec.getProvidedCapabilities(); verifyProvidedCapability(providedCapabilities, IInstallableUnit.NAMESPACE_IU_ID, idBase + ".executable." + configSpec, version); //$NON-NLS-1$ verifyProvidedCapability(providedCapabilities, flavorArg + idBase, idBase + ".executable", version); //$NON-NLS-1$ - assertTrue(providedCapabilities.length == 2); + assertTrue(providedCapabilities.size() == 2); - IRequiredCapability[] requiredCapability = possibleExec.getRequiredCapabilities(); + Collection<IRequirement> requiredCapability = possibleExec.getRequiredCapabilities(); verifyRequiredCapability(requiredCapability, IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.equinox.launcher." + (idBase.equals("mac") || idBase.equals("macCocoa") ? configSpec.substring(0, configSpec.lastIndexOf(".")) : configSpec), VersionRange.emptyRange); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - assertTrue(requiredCapability.length == 1); + assertTrue(requiredCapability.size() == 1); return;//pass } } @@ -157,8 +156,8 @@ public class EquinoxExecutableActionTest extends ActionTest { protected void insertPublisherInfoBehavior() { setupArtifactRepository(); - expect(publisherInfo.getArtifactRepository()).andReturn(artifactRepository); - expect(publisherInfo.getArtifactOptions()).andReturn(IPublisherInfo.A_PUBLISH); + expect(publisherInfo.getArtifactRepository()).andReturn(artifactRepository).anyTimes(); + expect(publisherInfo.getArtifactOptions()).andReturn(IPublisherInfo.A_PUBLISH).anyTimes(); expect(publisherInfo.getAdvice((String) anyObject(), anyBoolean(), (String) anyObject(), (Version) anyObject(), (Class) anyObject())).andReturn(Collections.emptyList()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxLauncherCUActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxLauncherCUActionTest.java index 31f170b8a..1ba56c201 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxLauncherCUActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxLauncherCUActionTest.java @@ -12,16 +12,14 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; - -import java.util.ArrayList; -import java.util.Map; +import java.util.*; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.metadata.InstallableUnitFragment; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.IProvidedCapability; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IProvidedCapability; import org.eclipse.equinox.p2.publisher.IPublisherResult; import org.eclipse.equinox.p2.publisher.PublisherResult; import org.eclipse.equinox.p2.publisher.actions.IVersionAdvice; @@ -29,7 +27,7 @@ import org.eclipse.equinox.p2.publisher.actions.VersionAdvice; import org.eclipse.equinox.p2.publisher.eclipse.EquinoxLauncherCUAction; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; -@SuppressWarnings( {"restriction", "unchecked"}) +@SuppressWarnings({"restriction", "unchecked"}) public class EquinoxLauncherCUActionTest extends ActionTest { private static String a_ID = "iua.source"; //$NON-NLS-1$ @@ -56,7 +54,6 @@ public class EquinoxLauncherCUActionTest extends ActionTest { version = Version.emptyVersion; expect(result.getVersion()).andReturn(version).anyTimes(); expect(result.getFilter()).andReturn(null).anyTimes(); - expect(result.isFragment()).andReturn(fragment).anyTimes(); replay(result); return result; } @@ -70,13 +67,13 @@ public class EquinoxLauncherCUActionTest extends ActionTest { assertTrue(iu instanceof InstallableUnitFragment); //verify required capability verifyRequiredCapability(iu.getRequiredCapabilities(), PublisherHelper.OSGI_BUNDLE_CLASSIFIER, EquinoxLauncherCUAction.ORG_ECLIPSE_EQUINOX_LAUNCHER, VersionRange.emptyRange); - verifyRequiredCapability(iu.getRequiredCapabilities(), PublisherHelper.NAMESPACE_ECLIPSE_TYPE, "bundle", new VersionRange(new Version("1.0.0"), true, new Version("2.0.0"), false)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - assertTrue(iu.getRequiredCapabilities().length == 2); + verifyRequiredCapability(iu.getRequiredCapabilities(), PublisherHelper.NAMESPACE_ECLIPSE_TYPE, "bundle", new VersionRange(Version.create("1.0.0"), true, Version.create("2.0.0"), false)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + assertTrue(iu.getRequiredCapabilities().size() == 2); - IProvidedCapability[] cap = iu.getProvidedCapabilities(); + Collection<IProvidedCapability> cap = iu.getProvidedCapabilities(); verifyProvidedCapability(cap, IInstallableUnit.NAMESPACE_IU_ID, flavorArg + "org.eclipse.equinox.launcher", Version.emptyVersion); //$NON-NLS-1$ - verifyProvidedCapability(cap, "org.eclipse.equinox.p2.flavor", flavorArg, new Version("1.0.0")); //$NON-NLS-1$//$NON-NLS-2$ - assertTrue(cap.length == 2); + verifyProvidedCapability(cap, "org.eclipse.equinox.p2.flavor", flavorArg, Version.create("1.0.0")); //$NON-NLS-1$//$NON-NLS-2$ + assertTrue(cap.size() == 2); Map prop = iu.getProperties(); assertTrue(prop.get("org.eclipse.equinox.p2.type.fragment").equals("true")); //$NON-NLS-1$ //$NON-NLS-2$ @@ -100,7 +97,7 @@ public class EquinoxLauncherCUActionTest extends ActionTest { VersionAdvice versionAdvice = new VersionAdvice(); versionAdvice.setVersion(IInstallableUnit.NAMESPACE_IU_ID, flavorArg + "org.eclipse.equinox.launcher", Version.emptyVersion); //$NON-NLS-1$ versionAdvice.setVersion(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.equinox.launcher", Version.emptyVersion); //$NON-NLS-1$ - versionAdvice.setVersion("org.eclipse.equinox.p2.flavor", flavorArg, new Version("1.0.0")); //$NON-NLS-1$//$NON-NLS-2$ + versionAdvice.setVersion("org.eclipse.equinox.p2.flavor", flavorArg, Version.create("1.0.0")); //$NON-NLS-1$//$NON-NLS-2$ ArrayList versionList = new ArrayList(); versionList.add(versionAdvice); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java index e545682ac..4f2b41dd8 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java @@ -12,10 +12,6 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - - import java.io.File; import java.io.IOException; import java.util.*; @@ -25,13 +21,14 @@ import org.easymock.EasyMock; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil; import org.eclipse.equinox.p2.publisher.IPublisherInfo; import org.eclipse.equinox.p2.publisher.IPublisherResult; import org.eclipse.equinox.p2.publisher.actions.*; import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; import org.eclipse.equinox.p2.tests.*; import org.eclipse.equinox.p2.tests.publisher.TestArtifactRepository; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; @@ -45,8 +42,8 @@ public class FeaturesActionTest extends ActionTest { private static File root = new File(TestActivator.getTestDataFolder().toString(), "FeaturesActionTest"); //$NON-NLS-1$ protected TestArtifactRepository artifactRepository = new TestArtifactRepository(); protected TestMetadataRepository metadataRepository; - private Version fooVersion = new Version("1.0.0"); //$NON-NLS-1$ - private Version barVersion = new Version("1.1.1"); //$NON-NLS-1$ + private Version fooVersion = Version.create("1.0.0"); //$NON-NLS-1$ + private Version barVersion = Version.create("1.1.1"); //$NON-NLS-1$ private String BAR = "bar"; //$NON-NLS-1$ private String FOO = "foo"; //$NON-NLS-1$ private Capture<ITouchpointAdvice> tpAdvice; @@ -85,38 +82,38 @@ public class FeaturesActionTest extends ActionTest { assertTrue(foo.getVersion().equals(fooVersion)); assertEquals("Foo Feature", foo.getProperty(IInstallableUnit.PROP_NAME)); assertEquals("Foo Description", foo.getProperty(IInstallableUnit.PROP_DESCRIPTION)); - assertEquals("Foo License", foo.getLicense().getBody()); + assertEquals("Foo License", foo.getLicenses().iterator().next().getBody()); assertEquals("Foo Copyright", foo.getCopyright().getBody()); assertTrue(foo.getProperty("key1").equals("value1")); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue(foo.getProperty("key2").equals("value2")); //$NON-NLS-1$//$NON-NLS-2$ - assertTrue(foo.getArtifacts()[0].equals(FOO_KEY)); - assertTrue(foo.getFilter().equalsIgnoreCase("(org.eclipse.update.install.features=true)")); //$NON-NLS-1$ + assertTrue(foo.getArtifacts().iterator().next().equals(FOO_KEY)); + assertTrue(foo.getFilter().equals(ExpressionUtil.parseLDAP("(org.eclipse.update.install.features=true)"))); //$NON-NLS-1$ //check touchpointType assertTrue(foo.getTouchpointType().getId().equalsIgnoreCase("org.eclipse.equinox.p2.osgi")); //$NON-NLS-1$ assertTrue(foo.getTouchpointType().getVersion().equals(fooVersion)); //zipped=true - ITouchpointData[] tpData = foo.getTouchpointData(); - String fooValue = ((ITouchpointInstruction) tpData[0].getInstructions().get("zipped")).getBody(); //$NON-NLS-1$ + List<ITouchpointData> tpData = foo.getTouchpointData(); + String fooValue = ((ITouchpointInstruction) tpData.get(0).getInstructions().get("zipped")).getBody(); //$NON-NLS-1$ assertTrue(fooValue.equalsIgnoreCase("true")); //$NON-NLS-1$ - IRequiredCapability[] fooRequiredCapabilities = foo.getRequiredCapabilities(); - assertTrue(fooRequiredCapabilities.length == 0); + Collection<IRequirement> fooRequiredCapabilities = foo.getRequiredCapabilities(); + assertTrue(fooRequiredCapabilities.size() == 0); - IProvidedCapability[] fooProvidedCapabilities = foo.getProvidedCapabilities(); + Collection<IProvidedCapability> fooProvidedCapabilities = foo.getProvidedCapabilities(); contains(fooProvidedCapabilities, IInstallableUnit.NAMESPACE_IU_ID, "foo.feature.jar", fooVersion); //$NON-NLS-1$ contains(fooProvidedCapabilities, PublisherHelper.NAMESPACE_ECLIPSE_TYPE, "feature", fooVersion); //$NON-NLS-1$ contains(fooProvidedCapabilities, "org.eclipse.update.feature", FOO, fooVersion); //$NON-NLS-1$ - assertTrue(fooProvidedCapabilities.length == 3); + assertTrue(fooProvidedCapabilities.size() == 3); //feature group IU for foo fooIUs = new ArrayList(publisherResult.getIUs("foo.feature.group", IPublisherResult.ROOT)); //$NON-NLS-1$ assertTrue(fooIUs.size() == 1); IInstallableUnit fooGroup = (IInstallableUnit) fooIUs.get(0); tpData = fooGroup.getTouchpointData(); - assertEquals(1, tpData.length); - ITouchpointInstruction instruction = tpData[0].getInstruction("install"); + assertEquals(1, tpData.size()); + ITouchpointInstruction instruction = tpData.get(0).getInstruction("install"); assertNotNull(instruction); assertEquals("ln(targetDir:@artifact,linkTarget:foo/lib.1.so,linkName:lib.so);chmod(targetDir:@artifact,targetFile:lib/lib.so,permissions:755);", instruction.getBody()); System.out.println(fooGroup.getFilter()); @@ -132,21 +129,21 @@ public class FeaturesActionTest extends ActionTest { assertTrue(bar.getProperty("key2").equals("value2")); //$NON-NLS-1$//$NON-NLS-2$ assertTrue(bar.getProperties().containsKey("org.eclipse.update.installHandler")); //$NON-NLS-1$ assertTrue(bar.getProperties().containsValue("handler=bar handler")); //$NON-NLS-1$ - assertTrue(bar.getArtifacts()[0].equals(BAR_KEY)); - assertTrue(bar.getFilter().equalsIgnoreCase("(org.eclipse.update.install.features=true)")); //$NON-NLS-1$ + assertTrue(bar.getArtifacts().iterator().next().equals(BAR_KEY)); + assertTrue(bar.getFilter().equals(ExpressionUtil.parseLDAP("(org.eclipse.update.install.features=true)"))); //$NON-NLS-1$ assertTrue(bar.isSingleton()); barIUs = new ArrayList(publisherResult.getIUs("bar.feature.group", IPublisherResult.ROOT)); //$NON-NLS-1$ assertTrue(fooIUs.size() == 1); IInstallableUnit barGroup = (IInstallableUnit) barIUs.get(0); - IRequiredCapability[] barRequiredCapabilities = barGroup.getRequiredCapabilities(); + Collection<IRequirement> barRequiredCapabilities = barGroup.getRequiredCapabilities(); //contains(barRequiredCapabilities, IInstallableUnit.NAMESPACE_IU_ID, "bar_root", new VersionRange(barVersion, true, barVersion, true), null, false /*multiple*/, false /*optional*/); //$NON-NLS-1$//$NON-NLS-2$ contains(barRequiredCapabilities, IInstallableUnit.NAMESPACE_IU_ID, "bar.feature.jar", new VersionRange(barVersion, true, barVersion, true), "(org.eclipse.update.install.features=true)", false /*multiple*/, false /*optional*/); //$NON-NLS-1$//$NON-NLS-2$ contains(barRequiredCapabilities, IInstallableUnit.NAMESPACE_IU_ID, "org.bar.feature.feature.group", VersionRange.emptyRange, "(&(|(osgi.nl=de)(osgi.nl=en)(osgi.nl=fr)))", false /*multiple*/, false /*optional*/); //$NON-NLS-1$//$NON-NLS-2$ - assertTrue(barGroup.getFilter().equalsIgnoreCase("(&(|(osgi.os=macosx)(osgi.os=win32))(|(osgi.ws=carbon)(osgi.ws=win32))(|(osgi.arch=ppc)(osgi.arch=x86))(osgi.nl=en))")); + assertTrue(barGroup.getFilter().equals(ExpressionUtil.parseLDAP("(&(|(osgi.os=macosx)(osgi.os=win32))(|(osgi.ws=carbon)(osgi.ws=win32))(|(osgi.arch=ppc)(osgi.arch=x86))(osgi.nl=en))"))); //check zipped=true in touchpointData - String barValue = ((ITouchpointInstruction) bar.getTouchpointData()[0].getInstructions().get("zipped")).getBody(); //$NON-NLS-1$ + String barValue = ((ITouchpointInstruction) bar.getTouchpointData().get(0).getInstructions().get("zipped")).getBody(); //$NON-NLS-1$ assertTrue(barValue.equalsIgnoreCase("true")); //$NON-NLS-1$ //check touchpointType @@ -155,13 +152,13 @@ public class FeaturesActionTest extends ActionTest { //String namespace, String name, VersionRange range, String filter, boolean optional, boolean multiple, boolean greedy) barRequiredCapabilities = bar.getRequiredCapabilities(); - assertTrue(barRequiredCapabilities.length == 0); + assertTrue(barRequiredCapabilities.size() == 0); - IProvidedCapability[] barProvidedCapabilities = bar.getProvidedCapabilities(); + Collection<IProvidedCapability> barProvidedCapabilities = bar.getProvidedCapabilities(); contains(barProvidedCapabilities, IInstallableUnit.NAMESPACE_IU_ID, "bar.feature.jar", barVersion); //$NON-NLS-1$ contains(barProvidedCapabilities, PublisherHelper.NAMESPACE_ECLIPSE_TYPE, "feature", fooVersion); //$NON-NLS-1$ contains(barProvidedCapabilities, "org.eclipse.update.feature", BAR, barVersion); //$NON-NLS-1$ - assertTrue(barProvidedCapabilities.length == 3); + assertTrue(barProvidedCapabilities.size() == 3); } private void verifyArtifacts() throws IOException { @@ -204,9 +201,9 @@ public class FeaturesActionTest extends ActionTest { } private ArrayList fillAdvice(ArrayList adviceCollection) { - Properties prop = new Properties(); - prop.setProperty("key1", "value1"); //$NON-NLS-1$//$NON-NLS-2$ - prop.setProperty("key2", "value2"); //$NON-NLS-1$//$NON-NLS-2$ + Map<String, String> prop = new HashMap<String, String>(); + prop.put("key1", "value1"); //$NON-NLS-1$//$NON-NLS-2$ + prop.put("key2", "value2"); //$NON-NLS-1$//$NON-NLS-2$ IPropertyAdvice propertyAdvice = EasyMock.createMock(IPropertyAdvice.class); expect(propertyAdvice.getInstallableUnitProperties((InstallableUnitDescription) EasyMock.anyObject())).andReturn(prop).anyTimes(); expect(propertyAdvice.getArtifactProperties((IInstallableUnit) EasyMock.anyObject(), (IArtifactDescriptor) EasyMock.anyObject())).andReturn(null).anyTimes(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java index aa75a955a..6f1e28c72 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java @@ -12,9 +12,8 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.expect; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; - +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.io.*; import java.util.*; @@ -22,14 +21,14 @@ import java.util.zip.ZipInputStream; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.*; import org.eclipse.equinox.p2.publisher.IPublisherInfo; import org.eclipse.equinox.p2.publisher.IPublisherResult; import org.eclipse.equinox.p2.publisher.actions.JREAction; import org.eclipse.equinox.p2.tests.*; import org.eclipse.equinox.p2.tests.publisher.TestArtifactRepository; -@SuppressWarnings( {"unchecked"}) +@SuppressWarnings({"unchecked"}) public class JREActionTest extends ActionTest { private File J14 = new File(TestActivator.getTestDataFolder(), "JREActionTest/1.4/"); //$NON-NLS-1$ @@ -47,28 +46,28 @@ public class JREActionTest extends ActionTest { public void test14() throws Exception { testAction = new JREAction(J14); testAction.perform(publisherInfo, publisherResult, new NullProgressMonitor()); - verifyResults("a.jre.j2se", 92, new Version("1.4.0"), true); //$NON-NLS-1$ + verifyResults("a.jre.j2se", 92, Version.create("1.4.0"), true); //$NON-NLS-1$ verifyArtifactRepository(ArtifactKey.parse("binary,a.jre.j2se,1.4.0"), J14, "J2SE-1.4.profile"); //$NON-NLS-1$ //$NON-NLS-2$ } public void test15() throws Exception { testAction = new JREAction(J15); testAction.perform(publisherInfo, publisherResult, new NullProgressMonitor()); - verifyResults("a.jre.j2se", 119, new Version("1.5.0"), true); //$NON-NLS-1$ + verifyResults("a.jre.j2se", 119, Version.create("1.5.0"), true); //$NON-NLS-1$ verifyArtifactRepository(ArtifactKey.parse("binary,a.jre.j2se,1.5.0"), J15, "J2SE-1.5.profile"); //$NON-NLS-1$ //$NON-NLS-2$ } public void test16() throws Exception { testAction = new JREAction(J16); testAction.perform(publisherInfo, publisherResult, new NullProgressMonitor()); - verifyResults("a.jre.javase", 117, new Version("1.6.0"), true); //$NON-NLS-1$ + verifyResults("a.jre.javase", 117, Version.create("1.6.0"), true); //$NON-NLS-1$ verifyArtifactRepository(ArtifactKey.parse("binary,a.jre.javase,1.6.0"), J16, "JavaSE-1.6.profile"); //$NON-NLS-1$//$NON-NLS-2$ } public void testOSGiMin() throws Exception { testAction = new JREAction("OSGi/Minimum-1.2"); testAction.perform(publisherInfo, publisherResult, new NullProgressMonitor()); - verifyResults("a.jre.osgi.minimum", 2, new Version("1.2.0"), false); //$NON-NLS-1$ + verifyResults("a.jre.osgi.minimum", 2, Version.create("1.2.0"), false); //$NON-NLS-1$ } private void verifyResults(String id, int numProvidedCapabilities, Version JREVersion, boolean testInstructions) { @@ -81,28 +80,28 @@ public class JREActionTest extends ActionTest { // check touchpointType assertTrue(foo.getTouchpointType().getId().equalsIgnoreCase("org.eclipse.equinox.p2.native")); //$NON-NLS-1$ - assertTrue(foo.getTouchpointType().getVersion().equals(new Version("1.0.0"))); //$NON-NLS-1$ + assertTrue(foo.getTouchpointType().getVersion().equals(Version.create("1.0.0"))); //$NON-NLS-1$ // check provided capabilities - IProvidedCapability[] fooProvidedCapabilities = foo.getProvidedCapabilities(); - assertTrue(fooProvidedCapabilities.length == numProvidedCapabilities); + Collection<IProvidedCapability> fooProvidedCapabilities = foo.getProvidedCapabilities(); + assertTrue(fooProvidedCapabilities.size() == numProvidedCapabilities); ArrayList barIUs = new ArrayList(publisherResult.getIUs("config." + id, IPublisherResult.ROOT)); //$NON-NLS-1$ assertTrue(barIUs.size() == 1); IInstallableUnit bar = (IInstallableUnit) barIUs.get(0); if (testInstructions) { - Map instructions = bar.getTouchpointData()[0].getInstructions(); + Map instructions = bar.getTouchpointData().get(0).getInstructions(); assertTrue(((ITouchpointInstruction) instructions.get("install")).getBody().equals("unzip(source:@artifact, target:${installFolder});")); //$NON-NLS-1$//$NON-NLS-2$ assertTrue(((ITouchpointInstruction) instructions.get("uninstall")).getBody().equals("cleanupzip(source:@artifact, target:${installFolder});")); //$NON-NLS-1$ //$NON-NLS-2$ } - IRequiredCapability[] requiredCapability = bar.getRequiredCapabilities(); - verifyRequiredCapability(requiredCapability, IInstallableUnit.NAMESPACE_IU_ID, id, new VersionRange(JREVersion, true, new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE), true)); //$NON-NLS-1$ - assertTrue(requiredCapability.length == 1); + Collection<IRequirement> requiredCapability = bar.getRequiredCapabilities(); + verifyRequiredCapability(requiredCapability, IInstallableUnit.NAMESPACE_IU_ID, id, new VersionRange(JREVersion, true, Version.MAX_VERSION, true)); //$NON-NLS-1$ + assertTrue(requiredCapability.size() == 1); - IProvidedCapability[] providedCapability = bar.getProvidedCapabilities(); + Collection<IProvidedCapability> providedCapability = bar.getProvidedCapabilities(); verifyProvidedCapability(providedCapability, IInstallableUnit.NAMESPACE_IU_ID, "config." + id, JREVersion); //$NON-NLS-1$ - assertTrue(providedCapability.length == 1); + assertTrue(providedCapability.size() == 1); assertTrue(bar.getProperty("org.eclipse.equinox.p2.type.fragment").equals("true")); //$NON-NLS-1$//$NON-NLS-2$ assertTrue(bar.getVersion().equals(JREVersion)); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalUpdateSiteActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalUpdateSiteActionTest.java index 88b7a3664..98c428271 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalUpdateSiteActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalUpdateSiteActionTest.java @@ -11,15 +11,14 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; - +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.util.*; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.updatesite.LocalUpdateSiteAction; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.ITouchpointData; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.ITouchpointData; import org.eclipse.equinox.p2.publisher.IPublisherInfo; import org.eclipse.equinox.p2.tests.TestData; import org.eclipse.equinox.p2.tests.publisher.TestArtifactRepository; @@ -60,9 +59,9 @@ public class LocalUpdateSiteActionTest extends ActionTest { Collection ius = publisherResult.getIUs("test.feature.feature.jar", null); assertEquals("1.0", 1, ius.size()); IInstallableUnit iu = (IInstallableUnit) ius.iterator().next(); - ITouchpointData[] touchpointData = iu.getTouchpointData(); - assertEquals("1.1", 1, touchpointData.length); - Map instructions = touchpointData[0].getInstructions(); + List<ITouchpointData> touchpointData = iu.getTouchpointData(); + assertEquals("1.1", 1, touchpointData.size()); + Map instructions = touchpointData.get(0).getInstructions(); Set keys = instructions.keySet(); assertEquals("1.2", 1, keys.size()); String unzip = (String) keys.iterator().next(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalizationTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalizationTests.java index cc86e8512..5a69e5c5a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalizationTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalizationTests.java @@ -16,15 +16,15 @@ import java.util.Locale; import junit.framework.TestCase; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.metadata.TranslationSupport; import org.eclipse.equinox.internal.p2.updatesite.SiteXMLAction; -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.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.publisher.PublisherInfo; import org.eclipse.equinox.p2.publisher.PublisherResult; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction; -import org.eclipse.equinox.p2.tests.IUPropertyUtils; +import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.tests.TestData; /** @@ -33,8 +33,14 @@ import org.eclipse.equinox.p2.tests.TestData; public class LocalizationTests extends TestCase { private PublisherInfo info; - private PublisherResult results; private IProgressMonitor monitor; + private PublisherResult results; + + private TranslationSupport getTranslationSupport() { + TranslationSupport utils = new TranslationSupport(); + utils.setTranslationSource(results.query(new InstallableUnitQuery((String) null), monitor)); + return utils; + } /* (non-Javadoc) * @see junit.framework.TestCase#setUp() @@ -46,132 +52,87 @@ public class LocalizationTests extends TestCase { monitor = new NullProgressMonitor(); } - public void testFeatureLocalizationDefault() throws IOException { - File file = TestData.getFile("localizationtests/foofeature", ""); - FeaturesAction featuresAction = new FeaturesAction(new File[] {file}); - featuresAction.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("fooFeature.feature.group"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Foo English Feature", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME)); - assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER)); - assertEquals("1.3", "Foo English Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION)); - assertEquals("1.4", "Foo English Copyright", utils.getCopyright(iu).getBody()); - assertEquals("1.5", "Foo English License", utils.getLicense(iu).getBody()); + public void testBundleLocalizationDE() throws IOException { + File file = TestData.getFile("localizationtests/foobundle", ""); + BundlesAction action = new BundlesAction(new File[] {file}); + action.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("foobundle"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo German Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN.toString())); + assertEquals("1.1", "Foo German Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN.toString())); } - public void testFeatureLocalizationEN() throws IOException { - File file = TestData.getFile("localizationtests/foofeature", ""); - FeaturesAction featuresAction = new FeaturesAction(new File[] {file}); - featuresAction.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("fooFeature.feature.group"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Foo English Feature", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH)); - assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH)); - assertEquals("1.3", "Foo English Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION, Locale.ENGLISH)); - assertEquals("1.4", "Foo English Copyright", utils.getCopyright(iu, Locale.ENGLISH).getBody()); - assertEquals("1.5", "Foo English License", utils.getLicense(iu, Locale.ENGLISH).getBody()); + public void testBundleLocalizationDE_alternatePropFile() throws IOException { + File file = TestData.getFile("localizationtests/barbundle", ""); + BundlesAction action = new BundlesAction(new File[] {file}); + action.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("barbundle"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Bar German Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN.toString())); + assertEquals("1.1", "Bar German Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN.toString())); } - public void testFeatureLocalizatioDE() throws IOException { - File file = TestData.getFile("localizationtests/foofeature", ""); - FeaturesAction featuresAction = new FeaturesAction(new File[] {file}); - featuresAction.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("fooFeature.feature.group"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Foo German Feature", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN)); - assertEquals("1.1", "Foo German Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN)); - assertEquals("1.3", "Foo German Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION, Locale.GERMAN)); - assertEquals("1.4", "Foo German Copyright", utils.getCopyright(iu, Locale.GERMAN).getBody()); - assertEquals("1.5", "Foo German License", utils.getLicense(iu, Locale.GERMAN).getBody()); - } + public void testBundleLocalizationDE_alternatePropFile_fragment() throws IOException { + File bundle = TestData.getFile("localizationtests/barbundle2", ""); + File fragment = TestData.getFile("localizationtests/barfragment2", ""); + BundlesAction action = new BundlesAction(new File[] {bundle, fragment}); + action.perform(info, results, monitor); - public void testFeatureJarLocalizationDefault() throws IOException { - File file = TestData.getFile("localizationtests/foofeature", ""); - FeaturesAction featuresAction = new FeaturesAction(new File[] {file}); - featuresAction.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("fooFeature.feature.jar"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Foo English Feature", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME)); - assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER)); - assertEquals("1.3", "Foo English Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION)); - assertEquals("1.4", "Foo English Copyright", utils.getCopyright(iu).getBody()); - assertEquals("1.5", "Foo English License", utils.getLicense(iu).getBody()); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("barbundle2"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Bar German Bundle - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN.toString())); + assertEquals("1.1", "Bar German Provider - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN.toString())); } - public void testFeatureJarLocalizationEN() throws IOException { - File file = TestData.getFile("localizationtests/foofeature", ""); - FeaturesAction featuresAction = new FeaturesAction(new File[] {file}); - featuresAction.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("fooFeature.feature.jar"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Foo English Feature", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH)); - assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH)); - assertEquals("1.3", "Foo English Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION, Locale.ENGLISH)); - assertEquals("1.4", "Foo English Copyright", utils.getCopyright(iu, Locale.ENGLISH).getBody()); - assertEquals("1.5", "Foo English License", utils.getLicense(iu, Locale.ENGLISH).getBody()); - } + public void testBundleLocalizationDE_fragment() throws IOException { + File bundle = TestData.getFile("localizationtests/foobundle2", ""); + File fragment = TestData.getFile("localizationtests/foofragment2", ""); + BundlesAction action = new BundlesAction(new File[] {bundle, fragment}); + action.perform(info, results, monitor); - public void testFeatureJarLocalizatioDE() throws IOException { - File file = TestData.getFile("localizationtests/foofeature", ""); - FeaturesAction featuresAction = new FeaturesAction(new File[] {file}); - featuresAction.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("fooFeature.feature.jar"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Foo German Feature", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN)); - assertEquals("1.1", "Foo German Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN)); - assertEquals("1.3", "Foo German Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION, Locale.GERMAN)); - assertEquals("1.4", "Foo German Copyright", utils.getCopyright(iu, Locale.GERMAN).getBody()); - assertEquals("1.5", "Foo German License", utils.getLicense(iu, Locale.GERMAN).getBody()); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("foobundle2"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo German Bundle - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN.toString())); + assertEquals("1.1", "Foo German Provider - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN.toString())); } public void testBundleLocalizationEN() throws IOException { File file = TestData.getFile("localizationtests/foobundle", ""); BundlesAction action = new BundlesAction(new File[] {file}); action.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("foobundle"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Foo English Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH)); - assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH)); - } - - public void testBundleLocalizationDE() throws IOException { - File file = TestData.getFile("localizationtests/foobundle", ""); - BundlesAction action = new BundlesAction(new File[] {file}); - action.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("foobundle"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Foo German Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN)); - assertEquals("1.1", "Foo German Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN)); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("foobundle"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo English Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH.toString())); + assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH.toString())); } public void testBundleLocalizationEN_alternatePropFile() throws IOException { File file = TestData.getFile("localizationtests/barbundle", ""); BundlesAction action = new BundlesAction(new File[] {file}); action.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("barbundle"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Bar English Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH)); - assertEquals("1.1", "Bar English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH)); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("barbundle"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Bar English Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH.toString())); + assertEquals("1.1", "Bar English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH.toString())); } - public void testBundleLocalizationDE_alternatePropFile() throws IOException { - File file = TestData.getFile("localizationtests/barbundle", ""); - BundlesAction action = new BundlesAction(new File[] {file}); + public void testBundleLocalizationEN_alternatePropFile_fragment() throws IOException { + File bundle = TestData.getFile("localizationtests/barbundle2", ""); + File fragment = TestData.getFile("localizationtests/barfragment2", ""); + BundlesAction action = new BundlesAction(new File[] {bundle, fragment}); action.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("barbundle"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Bar German Bundle", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN)); - assertEquals("1.1", "Bar German Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN)); + + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("barbundle2"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Bar English Bundle - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH.toString())); + assertEquals("1.1", "Bar English Provider - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH.toString())); } public void testBundleLocalizationEN_fragment() throws IOException { @@ -180,79 +141,124 @@ public class LocalizationTests extends TestCase { BundlesAction action = new BundlesAction(new File[] {bundle, fragment}); action.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("foobundle2"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Foo English Bundle - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH)); - assertEquals("1.1", "Foo English Provider - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH)); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("foobundle2"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo English Bundle - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH.toString())); + assertEquals("1.1", "Foo English Provider - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH.toString())); } - public void testBundleLocalizationDE_fragment() throws IOException { - File bundle = TestData.getFile("localizationtests/foobundle2", ""); - File fragment = TestData.getFile("localizationtests/foofragment2", ""); - BundlesAction action = new BundlesAction(new File[] {bundle, fragment}); - action.perform(info, results, monitor); + public void testFeatureJarLocalizatioDE() throws IOException { + File file = TestData.getFile("localizationtests/foofeature", ""); + FeaturesAction featuresAction = new FeaturesAction(new File[] {file}); + featuresAction.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("fooFeature.feature.jar"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo German Feature", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN.toString())); + assertEquals("1.1", "Foo German Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN.toString())); + assertEquals("1.3", "Foo German Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION, Locale.GERMAN.toString())); + assertEquals("1.4", "Foo German Copyright", utils.getCopyright(iu, Locale.GERMAN.toString()).getBody()); + assertEquals("1.5", "Foo German License", utils.getLicenses(iu, Locale.GERMAN.toString())[0].getBody()); + } - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("foobundle2"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Foo German Bundle - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN)); - assertEquals("1.1", "Foo German Provider - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN)); + public void testFeatureJarLocalizationDefault() throws IOException { + File file = TestData.getFile("localizationtests/foofeature", ""); + FeaturesAction featuresAction = new FeaturesAction(new File[] {file}); + featuresAction.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("fooFeature.feature.jar"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo English Feature", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME)); + assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER)); + assertEquals("1.3", "Foo English Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION)); + assertEquals("1.4", "Foo English Copyright", utils.getCopyright(iu, null).getBody()); + assertEquals("1.5", "Foo English License", utils.getLicenses(iu, null)[0].getBody()); } - public void testBundleLocalizationEN_alternatePropFile_fragment() throws IOException { - File bundle = TestData.getFile("localizationtests/barbundle2", ""); - File fragment = TestData.getFile("localizationtests/barfragment2", ""); - BundlesAction action = new BundlesAction(new File[] {bundle, fragment}); - action.perform(info, results, monitor); + public void testFeatureJarLocalizationEN() throws IOException { + File file = TestData.getFile("localizationtests/foofeature", ""); + FeaturesAction featuresAction = new FeaturesAction(new File[] {file}); + featuresAction.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("fooFeature.feature.jar"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo English Feature", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH.toString())); + assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH.toString())); + assertEquals("1.3", "Foo English Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION, Locale.ENGLISH.toString())); + assertEquals("1.4", "Foo English Copyright", utils.getCopyright(iu, Locale.ENGLISH.toString()).getBody()); + assertEquals("1.5", "Foo English License", utils.getLicenses(iu, Locale.ENGLISH.toString())[0].getBody()); + } - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("barbundle2"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Bar English Bundle - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH)); - assertEquals("1.1", "Bar English Provider - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH)); + public void testFeatureLocalizatioDE() throws IOException { + File file = TestData.getFile("localizationtests/foofeature", ""); + FeaturesAction featuresAction = new FeaturesAction(new File[] {file}); + featuresAction.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("fooFeature.feature.group"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo German Feature", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN.toString())); + assertEquals("1.1", "Foo German Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN.toString())); + assertEquals("1.3", "Foo German Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION, Locale.GERMAN.toString())); + assertEquals("1.4", "Foo German Copyright", utils.getCopyright(iu, Locale.GERMAN.toString()).getBody()); + assertEquals("1.5", "Foo German License", utils.getLicenses(iu, Locale.GERMAN.toString())[0].getBody()); } - public void testBundleLocalizationDE_alternatePropFile_fragment() throws IOException { - File bundle = TestData.getFile("localizationtests/barbundle2", ""); - File fragment = TestData.getFile("localizationtests/barfragment2", ""); - BundlesAction action = new BundlesAction(new File[] {bundle, fragment}); - action.perform(info, results, monitor); + public void testFeatureLocalizationDefault() throws IOException { + File file = TestData.getFile("localizationtests/foofeature", ""); + FeaturesAction featuresAction = new FeaturesAction(new File[] {file}); + featuresAction.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("fooFeature.feature.group"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo English Feature", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME)); + assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER)); + assertEquals("1.3", "Foo English Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION)); + assertEquals("1.4", "Foo English Copyright", utils.getCopyright(iu, null).getBody()); + assertEquals("1.5", "Foo English License", utils.getLicenses(iu, null)[0].getBody()); + } - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("barbundle2"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "Bar German Bundle - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN)); - assertEquals("1.1", "Bar German Provider - Translated in the Fragment", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN)); + public void testFeatureLocalizationEN() throws IOException { + File file = TestData.getFile("localizationtests/foofeature", ""); + FeaturesAction featuresAction = new FeaturesAction(new File[] {file}); + featuresAction.perform(info, results, monitor); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("fooFeature.feature.group"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "Foo English Feature", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH.toString())); + assertEquals("1.1", "Foo English Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH.toString())); + assertEquals("1.3", "Foo English Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION, Locale.ENGLISH.toString())); + assertEquals("1.4", "Foo English Copyright", utils.getCopyright(iu, Locale.ENGLISH.toString()).getBody()); + assertEquals("1.5", "Foo English License", utils.getLicenses(iu, Locale.ENGLISH.toString())[0].getBody()); } - public void testFragmentTranslation_EN() throws IOException { + public void testFragmentTranslation_DE() throws IOException { File bundle = TestData.getFile("localizationtests/barbundle2", ""); File fragment = TestData.getFile("localizationtests/barfragment2", ""); BundlesAction action = new BundlesAction(new File[] {bundle, fragment}); action.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("barfragment2"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "English Fragment Name", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH)); - assertEquals("1.1", "English Fragment Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH)); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("barfragment2"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "German Fragment Name", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN.toString())); + assertEquals("1.1", "German Fragment Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN.toString())); } - public void testFragmentTranslation_DE() throws IOException { + public void testFragmentTranslation_EN() throws IOException { File bundle = TestData.getFile("localizationtests/barbundle2", ""); File fragment = TestData.getFile("localizationtests/barfragment2", ""); BundlesAction action = new BundlesAction(new File[] {bundle, fragment}); action.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("barfragment2"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "German Fragment Name", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN)); - assertEquals("1.1", "German Fragment Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.GERMAN)); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("barfragment2"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "English Fragment Name", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH.toString())); + assertEquals("1.1", "English Fragment Provider", utils.getIUProperty(iu, IInstallableUnit.PROP_PROVIDER, Locale.ENGLISH.toString())); } - public void testSite_EN() throws IOException { + public void testSite_DE() throws IOException { File feature = TestData.getFile("localizationtests/foofeature", ""); URI site = TestData.getFile("localizationtests/site", "").toURI(); @@ -261,15 +267,15 @@ public class LocalizationTests extends TestCase { action.perform(info, results, monitor); siteAction.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("foo.new_category_1"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "English Category Name", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH)); - assertEquals("1.1", "English Category Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION, Locale.ENGLISH)); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("foo.new_category_1"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "German Category Name", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN.toString())); + assertEquals("1.1", "German Category Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION, Locale.GERMAN.toString())); } - public void testSite_DE() throws IOException { + public void testSite_EN() throws IOException { File feature = TestData.getFile("localizationtests/foofeature", ""); URI site = TestData.getFile("localizationtests/site", "").toURI(); @@ -278,11 +284,11 @@ public class LocalizationTests extends TestCase { action.perform(info, results, monitor); siteAction.perform(info, results, monitor); - IUPropertyUtils utils = new IUPropertyUtils(results.query(new InstallableUnitQuery((String) null), new Collector(), monitor)); - Collector collector = results.query(new InstallableUnitQuery("foo.new_category_1"), new Collector(), monitor); - IInstallableUnit iu = (IInstallableUnit) collector.iterator().next(); - assertEquals("1.0", "German Category Name", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.GERMAN)); - assertEquals("1.1", "German Category Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION, Locale.GERMAN)); + TranslationSupport utils = getTranslationSupport(); + IQueryResult queryResult = results.query(new InstallableUnitQuery("foo.new_category_1"), monitor); + IInstallableUnit iu = (IInstallableUnit) queryResult.iterator().next(); + assertEquals("1.0", "English Category Name", utils.getIUProperty(iu, IInstallableUnit.PROP_NAME, Locale.ENGLISH.toString())); + assertEquals("1.1", "English Category Description", utils.getIUProperty(iu, IInstallableUnit.PROP_DESCRIPTION, Locale.ENGLISH.toString())); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/MD5GenerationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/MD5GenerationTest.java index f16856573..e4b41a024 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/MD5GenerationTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/MD5GenerationTest.java @@ -10,41 +10,41 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.publisher.actions; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; public class MD5GenerationTest extends AbstractProvisioningTest { public void testGenerationFile() { - IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(new ArtifactKey("classifierTest", "idTest", new Version(1, 0, 0)), getTestData("Artifact to generate from", "testData/artifactRepo/simpleWithMD5/plugins/aaPlugin_1.0.0.jar")); + IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(new ArtifactKey("classifierTest", "idTest", Version.createOSGi(1, 0, 0)), getTestData("Artifact to generate from", "testData/artifactRepo/simpleWithMD5/plugins/aaPlugin_1.0.0.jar")); assertEquals("50d4ea58b02706ab373a908338877e02", ad.getProperty(IArtifactDescriptor.DOWNLOAD_MD5)); } public void testGenerationFile2() { - IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(new ArtifactKey("classifierTest", "idTest", new Version(1, 0, 0)), getTestData("Artifact to generate from", "testData/artifactRepo/simpleWithMD5/plugins/aaPlugin_1.0.0.jar")); + IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(new ArtifactKey("classifierTest", "idTest", Version.createOSGi(1, 0, 0)), getTestData("Artifact to generate from", "testData/artifactRepo/simpleWithMD5/plugins/aaPlugin_1.0.0.jar")); assertEquals("50d4ea58b02706ab373a908338877e02", ad.getProperty(IArtifactDescriptor.DOWNLOAD_MD5)); } public void testGenerationFolder() { - IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(new ArtifactKey("classifierTest", "idTest", new Version(1, 0, 0)), getTestData("Artifact to generate from", "testData/artifactRepo/simpleWithMD5/plugins/")); + IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(new ArtifactKey("classifierTest", "idTest", Version.createOSGi(1, 0, 0)), getTestData("Artifact to generate from", "testData/artifactRepo/simpleWithMD5/plugins/")); assertNull(ad.getProperty(IArtifactDescriptor.DOWNLOAD_MD5)); } public void testGenerationFolder2() { - IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(new ArtifactKey("classifierTest", "idTest", new Version(1, 0, 0)), getTestData("Artifact to generate from", "testData/artifactRepo/simpleWithMD5/plugins/")); + IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(new ArtifactKey("classifierTest", "idTest", Version.createOSGi(1, 0, 0)), getTestData("Artifact to generate from", "testData/artifactRepo/simpleWithMD5/plugins/")); assertNull(ad.getProperty(IArtifactDescriptor.DOWNLOAD_MD5)); } public void testGenerationNoFolder() { - IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(new ArtifactKey("classifierTest", "idTest", new Version(1, 0, 0)), null); + IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(new ArtifactKey("classifierTest", "idTest", Version.createOSGi(1, 0, 0)), null); assertNull(ad.getProperty(IArtifactDescriptor.DOWNLOAD_MD5)); } public void testGenerationNoFolder2() { - IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(new ArtifactKey("classifierTest", "idTest", new Version(1, 0, 0)), null); + IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(new ArtifactKey("classifierTest", "idTest", Version.createOSGi(1, 0, 0)), null); assertNull(ad.getProperty(IArtifactDescriptor.DOWNLOAD_MD5)); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java index 964725793..3900d2b3e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java @@ -12,9 +12,6 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; - - import java.io.File; import java.io.IOException; import java.util.Collection; @@ -22,19 +19,21 @@ import java.util.Collections; import org.easymock.Capture; import org.easymock.EasyMock; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.metadata.RequiredCapability; import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile; import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.publisher.*; import org.eclipse.equinox.p2.publisher.actions.RootIUAdvice; import org.eclipse.equinox.p2.publisher.eclipse.*; +import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.tests.TestData; import org.eclipse.equinox.p2.tests.publisher.TestArtifactRepository; -@SuppressWarnings( {"unchecked"}) +@SuppressWarnings({"unchecked"}) public class ProductActionTest extends ActionTest { private String winFitler = "(& (osgi.ws=win32)(osgi.os=win32)(osgi.arch=x86))"; @@ -93,8 +92,8 @@ public class ProductActionTest extends ActionTest { Collection ius = publisherResult.getIUs("licenseIU.product", IPublisherResult.NON_ROOT); assertEquals("1.0", 1, ius.size()); IInstallableUnit iu = (IInstallableUnit) ius.iterator().next(); - assertEquals("1.1", "http://www.example.com", iu.getLicense().getLocation().toString()); - assertEquals("1.2", "This is the liCenSE.", iu.getLicense().getBody().trim()); + assertEquals("1.1", "http://www.example.com", iu.getLicenses().iterator().next().getLocation().toString()); + assertEquals("1.2", "This is the liCenSE.", iu.getLicenses().iterator().next().getBody().trim()); } public void testLicenseNoURL() throws Exception { @@ -106,8 +105,8 @@ public class ProductActionTest extends ActionTest { Collection ius = publisherResult.getIUs("licenseIU.product", IPublisherResult.NON_ROOT); assertEquals("1.0", 1, ius.size()); IInstallableUnit iu = (IInstallableUnit) ius.iterator().next(); - assertEquals("1.1", "", iu.getLicense().getLocation().toString()); - assertEquals("1.2", "This is the liCenSE.", iu.getLicense().getBody().trim()); + assertEquals("1.1", "", iu.getLicenses().iterator().next().getLocation().toString()); + assertEquals("1.2", "This is the liCenSE.", iu.getLicenses().iterator().next().getBody().trim()); } public void testLicenseNoText() throws Exception { @@ -119,8 +118,8 @@ public class ProductActionTest extends ActionTest { Collection ius = publisherResult.getIUs("licenseIU.product", IPublisherResult.NON_ROOT); assertEquals("1.0", 1, ius.size()); IInstallableUnit iu = (IInstallableUnit) ius.iterator().next(); - assertEquals("1.1", "http://www.example.com", iu.getLicense().getLocation().toString()); - assertEquals("1.2", "", iu.getLicense().getBody().trim()); + assertEquals("1.1", "http://www.example.com", iu.getLicenses().iterator().next().getLocation().toString()); + assertEquals("1.2", "", iu.getLicenses().iterator().next().getBody().trim()); } public void testMissingLicense() throws Exception { @@ -132,7 +131,7 @@ public class ProductActionTest extends ActionTest { Collection ius = publisherResult.getIUs("licenseIU.product", IPublisherResult.NON_ROOT); assertEquals("1.0", 1, ius.size()); IInstallableUnit iu = (IInstallableUnit) ius.iterator().next(); - assertNull("1.1", iu.getLicense()); + assertEquals(0, iu.getLicenses().size()); } /** @@ -179,8 +178,8 @@ public class ProductActionTest extends ActionTest { results.addIU(iu, IPublisherResult.NON_ROOT); action2.perform(info, results, new NullProgressMonitor()); - Collector collector = results.query(new InstallableUnitQuery(flavorArg + configSpec + "org.eclipse.core.runtime"), new Collector(), new NullProgressMonitor()); - assertEquals("1.0", 1, collector.size()); + IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + configSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + assertEquals("1.0", 1, queryResultSize(queryResult)); } public void testMultiPlatformCUs_DifferentPlatforms() throws Exception { @@ -202,11 +201,11 @@ public class ProductActionTest extends ActionTest { action.perform(info, results, new NullProgressMonitor()); - Collector collector = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new Collector(), new NullProgressMonitor()); - assertEquals("1.0", 0, collector.size()); + IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + assertEquals("1.0", 0, queryResultSize(queryResult)); - collector = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new Collector(), new NullProgressMonitor()); - assertEquals("2.0", 0, collector.size()); + queryResult = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + assertEquals("2.0", 0, queryResultSize(queryResult)); } public void testMultiPlatformCUs_SamePlatforms() throws Exception { @@ -228,11 +227,11 @@ public class ProductActionTest extends ActionTest { action.perform(info, results, new NullProgressMonitor()); - Collector collector = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new Collector(), new NullProgressMonitor()); - assertEquals("1.0", 1, collector.size()); + IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + assertEquals("1.0", 1, queryResultSize(queryResult)); - collector = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new Collector(), new NullProgressMonitor()); - assertEquals("2.0", 0, collector.size()); + queryResult = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + assertEquals("2.0", 0, queryResultSize(queryResult)); } public void testMultiPlatformCUs_SamePlatforms_NoVersion() throws Exception { @@ -253,11 +252,11 @@ public class ProductActionTest extends ActionTest { action.perform(info, results, new NullProgressMonitor()); - Collector collector = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new Collector(), new NullProgressMonitor()); - assertEquals("1.0", 1, collector.size()); + IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + assertEquals("1.0", 1, queryResultSize(queryResult)); - collector = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new Collector(), new NullProgressMonitor()); - assertEquals("2.0", 0, collector.size()); + queryResult = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + assertEquals("2.0", 0, queryResultSize(queryResult)); } public void testMultiPlatformCUs_SamePlatforms_BoundedVersions() throws Exception { @@ -279,11 +278,11 @@ public class ProductActionTest extends ActionTest { action.perform(info, results, new NullProgressMonitor()); - Collector collector = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new Collector(), new NullProgressMonitor()); - assertEquals("1.0", 1, collector.size()); + IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + assertEquals("1.0", 1, queryResultSize(queryResult)); - collector = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new Collector(), new NullProgressMonitor()); - assertEquals("2.0", 0, collector.size()); + queryResult = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + assertEquals("2.0", 0, queryResultSize(queryResult)); } public void testCUsHost() throws Exception { @@ -304,11 +303,11 @@ public class ProductActionTest extends ActionTest { action.perform(info, results, new NullProgressMonitor()); - Collector collector = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new Collector(), new NullProgressMonitor()); - assertEquals("1.0", 1, collector.size()); - IInstallableUnitFragment fragment = (IInstallableUnitFragment) collector.iterator().next(); - assertEquals("1.1", "org.eclipse.core.runtime", fragment.getHost()[0].getName()); - assertEquals("1.2", Version.create("4.0.0"), fragment.getHost()[0].getRange().getMinimum()); + IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + assertEquals("1.0", 1, queryResultSize(queryResult)); + IInstallableUnitFragment fragment = (IInstallableUnitFragment) queryResult.iterator().next(); + assertEquals("1.1", "org.eclipse.core.runtime", RequiredCapability.extractName(fragment.getHost()[0].getMatches())); + assertEquals("1.2", Version.create("4.0.0"), RequiredCapability.extractRange(fragment.getHost()[0].getMatches()).getMinimum()); assertEquals("1.3", Version.create("1.0.0"), fragment.getVersion()); } @@ -325,11 +324,11 @@ public class ProductActionTest extends ActionTest { action.perform(info, results, new NullProgressMonitor()); - Collector collector = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new Collector(), new NullProgressMonitor()); - assertEquals("1.0", 0, collector.size()); + IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + assertEquals("1.0", 0, queryResultSize(queryResult)); - collector = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new Collector(), new NullProgressMonitor()); - assertEquals("2.0", 0, collector.size()); + queryResult = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor()); + assertEquals("2.0", 0, queryResultSize(queryResult)); } public void testMultiConfigspecProductPublishing() throws IOException, Exception { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTestMac.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTestMac.java index b435c9e34..fbe719c61 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTestMac.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTestMac.java @@ -12,8 +12,7 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; - +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.util.Collections; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java index f29b6d99e..a30a3d39f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java @@ -10,26 +10,28 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.publisher.actions; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.io.File; import java.net.URI; -import java.util.Collection; +import java.util.*; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.MatchQuery; -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.metadata.*; import org.eclipse.equinox.p2.publisher.IPublisherResult; import org.eclipse.equinox.p2.publisher.PublisherInfo; import org.eclipse.equinox.p2.publisher.actions.QueryableFilterAdvice; import org.eclipse.equinox.p2.publisher.eclipse.ProductAction; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.query.MatchQuery; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.TestData; -@SuppressWarnings( {"unchecked"}) +@SuppressWarnings({"unchecked"}) /** * Tests the product action when run on a product file that has a corresponding * advice file (p2.inf). @@ -78,19 +80,21 @@ public class ProductActionWithAdviceFileTest extends ActionTest { info.addAdvice(new QueryableFilterAdvice(info.getContextMetadataRepository())); testAction.perform(info, publisherResult, null); - Collector results = publisherResult.query(new IUQuery("org.eclipse.platform.ide", new Version("3.5.0.I20081118")), new Collector(), null); - assertEquals("1.0", 1, results.size()); + IQueryResult results = publisherResult.query(new IUQuery("org.eclipse.platform.ide", Version.create("3.5.0.I20081118")), null); + assertEquals("1.0", 1, queryResultSize(results)); IInstallableUnit unit = (IInstallableUnit) results.iterator().next(); - IRequiredCapability[] requiredCapabilities = unit.getRequiredCapabilities(); + Collection<IRequirement> requiredCapabilities = unit.getRequiredCapabilities(); IRequiredCapability capability = null; - for (int i = 0; i < requiredCapabilities.length; i++) - if (requiredCapabilities[i].getName().equals("org.eclipse.equinox.p2.user.ui.feature.group")) { - capability = requiredCapabilities[i]; + for (Iterator iterator = requiredCapabilities.iterator(); iterator.hasNext();) { + IRequiredCapability req = (IRequiredCapability) iterator.next(); + if (req.getName().equals("org.eclipse.equinox.p2.user.ui.feature.group")) { + capability = req; break; } + } assertTrue("1.1", capability != null); - assertEquals("1.2", "(org.eclipse.update.install.features=true)", capability.getFilter()); + assertEquals("1.2", "(org.eclipse.update.install.features=true)", capability.getFilter().toString()); } /** @@ -104,9 +108,9 @@ public class ProductActionWithAdviceFileTest extends ActionTest { Collection productIUs = publisherResult.getIUs("productWithAdvice.product", IPublisherResult.NON_ROOT); assertEquals("1.0", 1, productIUs.size()); IInstallableUnit product = (IInstallableUnit) productIUs.iterator().next(); - ITouchpointData[] data = product.getTouchpointData(); - assertEquals("1.1", 1, data.length); - String configure = data[0].getInstruction("configure").getBody(); + List<ITouchpointData> data = product.getTouchpointData(); + assertEquals("1.1", 1, data.size()); + String configure = data.get(0).getInstruction("configure").getBody(); assertEquals("1.2", "addRepository(type:0,location:http${#58}//download.eclipse.org/releases/fred);addRepository(type:1,location:http${#58}//download.eclipse.org/releases/fred);", configure); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileAdviceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileAdviceTest.java index 1558ca18a..f1434b554 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileAdviceTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileAdviceTest.java @@ -11,6 +11,7 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import java.io.File; +import java.util.Map; import java.util.Properties; import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile; import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; @@ -149,7 +150,7 @@ public class ProductFileAdviceTest extends AbstractProvisioningTest { * Test method for {@link org.eclipse.equinox.p2.publisher.eclipse.ProductFileAdvice#getProperties()}. */ public void testGetProperties() { - Properties properties = productFileAdviceWin32.getProperties(); + Map<String, String> properties = productFileAdviceWin32.getProperties(); assertEquals("1.0", 7, properties.size()); assertEquals("1.2", "bar", properties.get("foo")); assertEquals("1.3", "", properties.get("foo1")); @@ -253,7 +254,7 @@ public class ProductFileAdviceTest extends AbstractProvisioningTest { BundleInfo[] bundles = advice.getBundles(); assertEquals("bundlers length", 2, bundles.length); - Properties adviceProperties = advice.getProperties(); + Map<String, String> adviceProperties = advice.getProperties(); assertEquals("instance.area.default", "@user.home/workspace", adviceProperties.get("osgi.instance.area.default")); assertEquals("eclipse.application", "test.application", adviceProperties.get("eclipse.application")); assertEquals("eclipse.product", "test.product", adviceProperties.get("eclipse.product")); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java index 190362468..683589f92 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java @@ -9,15 +9,14 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.publisher.actions; -import org.eclipse.equinox.internal.provisional.p2.metadata.IVersionedId; - -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.util.List; -import java.util.Properties; +import java.util.Map; import junit.framework.TestCase; import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile; import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; +import org.eclipse.equinox.p2.metadata.IVersionedId; import org.eclipse.equinox.p2.tests.TestData; /** @@ -57,7 +56,7 @@ public class ProductFileTest extends TestCase { * Test method for {@link org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile#getProperties()}. */ public void testGetConfigurationProperties() { - Properties properties = productFile.getConfigurationProperties(); + Map<String, String> properties = productFile.getConfigurationProperties(); assertEquals("1.0", 4, properties.size()); assertEquals("1.1", "bar", properties.get("foo")); assertEquals("1.2", "", properties.get("foo1")); @@ -72,7 +71,7 @@ public class ProductFileTest extends TestCase { List bundles = productFile.getBundles(false); assertEquals("1.0", 1, bundles.size()); assertEquals("1.1", "org.eclipse.core.runtime", ((IVersionedId) bundles.get(0)).getId()); - assertEquals("1.2", new Version(1, 0, 4), ((IVersionedId) bundles.get(0)).getVersion()); + assertEquals("1.2", Version.createOSGi(1, 0, 4), ((IVersionedId) bundles.get(0)).getVersion()); bundles = productFile.getBundles(true); assertEquals("1.3", 2, bundles.size()); } @@ -105,7 +104,7 @@ public class ProductFileTest extends TestCase { List features = productFile.getFeatures(); assertEquals("1.0", 1, features.size()); assertEquals("1.1", "org.eclipse.rcp", ((IVersionedId) features.get(0)).getId()); - assertEquals("1.2", new Version("3.5.0.v20081110-9C9tEvNEla71LZ2jFz-RFB-t"), ((IVersionedId) features.get(0)).getVersion()); + assertEquals("1.2", Version.create("3.5.0.v20081110-9C9tEvNEla71LZ2jFz-RFB-t"), ((IVersionedId) features.get(0)).getVersion()); } /** @@ -175,7 +174,7 @@ public class ProductFileTest extends TestCase { */ public void testGetVersion() { String version = productFile.getVersion(); - assertEquals("1.0", new Version("1"), new Version(version)); + assertEquals("1.0", Version.create("1"), Version.create(version)); } /** diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootFilesActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootFilesActionTest.java index 57ffaf89e..7e5e88fab 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootFilesActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootFilesActionTest.java @@ -12,8 +12,7 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.expect; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; - +import org.eclipse.equinox.p2.metadata.Version; import java.io.*; import java.util.*; @@ -21,16 +20,16 @@ import java.util.zip.ZipInputStream; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.core.helpers.FileUtils; 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.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IArtifactKey; import org.eclipse.equinox.p2.publisher.AbstractPublisherAction; import org.eclipse.equinox.p2.publisher.IPublisherInfo; import org.eclipse.equinox.p2.publisher.actions.*; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; import org.eclipse.equinox.p2.tests.TestActivator; import org.eclipse.equinox.p2.tests.TestData; import org.eclipse.equinox.p2.tests.publisher.TestArtifactRepository; -@SuppressWarnings( {"restriction", "unchecked"}) +@SuppressWarnings({"unchecked"}) public class RootFilesActionTest extends ActionTest { private static final int INCLUDES_ROOT = 1; private static final int ARTIFACT_REPO = 2; @@ -43,11 +42,11 @@ public class RootFilesActionTest extends ActionTest { protected String rootExclusions = null; protected IArtifactRepository artifactRepository; protected String idArg = "sdk"; //$NON-NLS-1$ - protected Version versionArg = new Version("3.4.0.i0305"); //$NON-NLS-1$ + protected Version versionArg = Version.create("3.4.0.i0305"); //$NON-NLS-1$ private File root = new File(TestActivator.getTestDataFolder(), "RootFilesActionTest/eclipse"); //$NON-NLS-1$ private File[] includedFiles; private File[] excludedFiles; - private Collection<RootFilesAdvice> adviceCollection; + private Collection<IRootFilesAdvice> adviceCollection; private String FILE1 = "level1/level2/file1.jar"; //$NON-NLS-1$ private String FILE2 = "level1/level2/level3/file1.jar"; //$NON-NLS-1$ private int testArg; @@ -68,6 +67,7 @@ public class RootFilesActionTest extends ActionTest { expect(publisherInfo.getArtifactRepository()).andReturn(artifactRepository).anyTimes(); expect(publisherInfo.getArtifactOptions()).andReturn(IPublisherInfo.A_INDEX | IPublisherInfo.A_OVERWRITE | IPublisherInfo.A_PUBLISH).anyTimes(); expect(publisherInfo.getAdvice(configSpec, true, null, null, IRootFilesAdvice.class)).andReturn(adviceCollection).anyTimes(); + expect(publisherInfo.getAdvice(configSpec, false, flavorArg + topArg, versionArg, ITouchpointAdvice.class)).andReturn(null).anyTimes(); } private void setupTestCase(int testArg) throws Exception { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootIUActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootIUActionTest.java index 9636dff0f..e1e4deaca 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootIUActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootIUActionTest.java @@ -12,23 +12,22 @@ package org.eclipse.equinox.p2.tests.publisher.actions; import static org.easymock.EasyMock.expect; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; - -import java.util.ArrayList; -import java.util.Collection; +import java.util.*; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.MatchQuery; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Query; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IRequirement; import org.eclipse.equinox.p2.publisher.IPublisherResult; import org.eclipse.equinox.p2.publisher.actions.*; +import org.eclipse.equinox.p2.query.IQuery; +import org.eclipse.equinox.p2.query.MatchQuery; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.TestMetadataRepository; -@SuppressWarnings( {"restriction", "unchecked"}) +@SuppressWarnings({"restriction", "unchecked"}) public class RootIUActionTest extends ActionTest { private static final int CONTAINS_A = 1; private static final int CONTAINS_B = 2; @@ -42,7 +41,7 @@ public class RootIUActionTest extends ActionTest { private IMetadataRepository metadataRepository; private String rootIU = "sdk"; //$NON-NLS-1$ - private Version versionArg = new Version("3.4.0.i0305"); //$NON-NLS-1$ + private Version versionArg = Version.create("3.4.0.i0305"); //$NON-NLS-1$ private Collection<IRootIUAdvice> rootIUAdviceCollection; public void testNullAdvice() throws Exception { @@ -230,7 +229,7 @@ public class RootIUActionTest extends ActionTest { } private void setupFilterAdvice(int testSpec) { - Query query = null; + IQuery query = null; rootIUAdviceCollection = new ArrayList(); if ((testSpec & CONTAINS_A) > 0) { query = new MatchQuery() { @@ -272,9 +271,9 @@ public class RootIUActionTest extends ActionTest { IInstallableUnit iu = (IInstallableUnit) ius.get(0); assertTrue(iu != null); assertTrue(iu.getVersion().equals(versionArg)); - IRequiredCapability[] required = iu.getRequiredCapabilities(); + Collection<IRequirement> required = iu.getRequiredCapabilities(); if ((testSpec & EMPTY) > 0) - assertEquals(required.length, 0); + assertEquals(required.size(), 0); String confirmedIUs = ""; //$NON-NLS-1$ int numConfirmed = 0; @@ -288,7 +287,7 @@ public class RootIUActionTest extends ActionTest { confirmedIUs += iu_B; numConfirmed++; } - if (numConfirmed != required.length) { + if (numConfirmed != required.size()) { debug("Not all required ius present / accounted for."); //$NON-NLS-1$ fail(); } @@ -298,10 +297,12 @@ public class RootIUActionTest extends ActionTest { debug("Confirmed \t\t Empty"); //$NON-NLS-1$ } - private boolean contains(IRequiredCapability[] required, String iu) { - for (int i = 0; i < required.length; i++) - if (required[i].getName().equalsIgnoreCase(iu)) + private boolean contains(Collection<IRequirement> required, String iu) { + for (Iterator iterator = required.iterator(); iterator.hasNext();) { + IRequiredCapability req = (IRequiredCapability) iterator.next(); + if (req.getName().equalsIgnoreCase(iu)) return true; + } return false; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/VersionAdviceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/VersionAdviceTest.java index 07b986cb4..579fb145e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/VersionAdviceTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/VersionAdviceTest.java @@ -9,7 +9,7 @@ ******************************************************************************/ package org.eclipse.equinox.p2.tests.publisher.actions; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import junit.framework.TestCase; import org.eclipse.equinox.p2.publisher.actions.VersionAdvice; @@ -29,18 +29,18 @@ public class VersionAdviceTest extends TestCase { String versionAdviceFoo = TestData.getFile("publisher", "versionadvicefoo.prop").toString(); VersionAdvice versionAdvice = new VersionAdvice(); versionAdvice.load(null, versionAdviceFoo); - assertEquals("1.0", new Version("1.6.4.thisisastring"), versionAdvice.getVersion("foo", "org.apache.http")); - assertEquals("2.0", new Version("1.3.1"), versionAdvice.getVersion("null", "org.eclipse.cdt")); - assertEquals("3.0", new Version("1.4.0"), versionAdvice.getVersion(null, "org.eclipse.tptp")); + assertEquals("1.0", Version.create("1.6.4.thisisastring"), versionAdvice.getVersion("foo", "org.apache.http")); + assertEquals("2.0", Version.create("1.3.1"), versionAdvice.getVersion("null", "org.eclipse.cdt")); + assertEquals("3.0", Version.create("1.4.0"), versionAdvice.getVersion(null, "org.eclipse.tptp")); } public void testLoadNullVersionAdvice2() throws Exception { String versionAdviceFoo = TestData.getFile("publisher", "versionadvicefoo.prop").toString(); VersionAdvice versionAdvice = new VersionAdvice(); versionAdvice.load("null", versionAdviceFoo); - assertEquals("1.0", new Version("1.6.4.thisisastring"), versionAdvice.getVersion("foo", "org.apache.http")); - assertEquals("2.0", new Version("1.3.1"), versionAdvice.getVersion("null", "org.eclipse.cdt")); - assertEquals("3.0", new Version("1.4.0"), versionAdvice.getVersion(null, "org.eclipse.tptp")); + assertEquals("1.0", Version.create("1.6.4.thisisastring"), versionAdvice.getVersion("foo", "org.apache.http")); + assertEquals("2.0", Version.create("1.3.1"), versionAdvice.getVersion("null", "org.eclipse.cdt")); + assertEquals("3.0", Version.create("1.4.0"), versionAdvice.getVersion(null, "org.eclipse.tptp")); } public void testOverloadNull() throws Exception { @@ -49,19 +49,19 @@ public class VersionAdviceTest extends TestCase { VersionAdvice versionAdvice = new VersionAdvice(); versionAdvice.load(null, versionAdviceFoo); versionAdvice.load(null, versionAdviceBar); - assertEquals("1.0", new Version("1.6.4.thisisastring"), versionAdvice.getVersion("foo", "org.apache.http")); - assertEquals("1.0", new Version("1.6.4.thisisastring"), versionAdvice.getVersion("foo", "org.apache.commons")); - assertEquals("2.0", new Version("2.3.1"), versionAdvice.getVersion("null", "org.eclipse.cdt")); - assertEquals("3.0", new Version("1.5.0"), versionAdvice.getVersion(null, "org.eclipse.tptp")); + assertEquals("1.0", Version.create("1.6.4.thisisastring"), versionAdvice.getVersion("foo", "org.apache.http")); + assertEquals("1.0", Version.create("1.6.4.thisisastring"), versionAdvice.getVersion("foo", "org.apache.commons")); + assertEquals("2.0", Version.create("2.3.1"), versionAdvice.getVersion("null", "org.eclipse.cdt")); + assertEquals("3.0", Version.create("1.5.0"), versionAdvice.getVersion(null, "org.eclipse.tptp")); } public void testLoadVersionAdviceFoo() throws Exception { String versionAdviceFoo = TestData.getFile("publisher", "versionadvicefoo.prop").toString(); VersionAdvice versionAdvice = new VersionAdvice(); versionAdvice.load("foo", versionAdviceFoo); - assertEquals("1.0", new Version("1.6.4.thisisastring"), versionAdvice.getVersion("foo", "org.apache.http")); - assertEquals("2.0", new Version("1.3.1"), versionAdvice.getVersion("foo", "org.eclipse.cdt")); - assertEquals("3.0", new Version("1.4.0"), versionAdvice.getVersion("foo", "org.eclipse.tptp")); + assertEquals("1.0", Version.create("1.6.4.thisisastring"), versionAdvice.getVersion("foo", "org.apache.http")); + assertEquals("2.0", Version.create("1.3.1"), versionAdvice.getVersion("foo", "org.eclipse.cdt")); + assertEquals("3.0", Version.create("1.4.0"), versionAdvice.getVersion("foo", "org.eclipse.tptp")); assertEquals("4.0", null, versionAdvice.getVersion(null, "org.eclipse.tptp")); } @@ -70,9 +70,9 @@ public class VersionAdviceTest extends TestCase { VersionAdvice versionAdvice = new VersionAdvice(); versionAdvice.load("bar", versionAdviceBar); assertEquals("1.0", null, versionAdvice.getVersion("bar", "org.apache.http")); - assertEquals("2.0", new Version("1.6.4.thisisastring"), versionAdvice.getVersion("bar", "org.apache.commons")); - assertEquals("3.0", new Version("2.3.1"), versionAdvice.getVersion("bar", "org.eclipse.cdt")); - assertEquals("4.0", new Version("1.5.0"), versionAdvice.getVersion("bar", "org.eclipse.tptp")); + assertEquals("2.0", Version.create("1.6.4.thisisastring"), versionAdvice.getVersion("bar", "org.apache.commons")); + assertEquals("3.0", Version.create("2.3.1"), versionAdvice.getVersion("bar", "org.eclipse.cdt")); + assertEquals("4.0", Version.create("1.5.0"), versionAdvice.getVersion("bar", "org.eclipse.tptp")); } public void testLoadVersionAdviceFooBar() throws Exception { @@ -81,13 +81,13 @@ public class VersionAdviceTest extends TestCase { VersionAdvice versionAdvice = new VersionAdvice(); versionAdvice.load("foo", versionAdviceFoo); versionAdvice.load("bar", versionAdviceBar); - assertEquals("1.0", new Version("1.6.4.thisisastring"), versionAdvice.getVersion("foo", "org.apache.http")); - assertEquals("2.0", new Version("1.3.1"), versionAdvice.getVersion("foo", "org.eclipse.cdt")); - assertEquals("3.0", new Version("1.4.0"), versionAdvice.getVersion("foo", "org.eclipse.tptp")); + assertEquals("1.0", Version.create("1.6.4.thisisastring"), versionAdvice.getVersion("foo", "org.apache.http")); + assertEquals("2.0", Version.create("1.3.1"), versionAdvice.getVersion("foo", "org.eclipse.cdt")); + assertEquals("3.0", Version.create("1.4.0"), versionAdvice.getVersion("foo", "org.eclipse.tptp")); assertEquals("4.0", null, versionAdvice.getVersion("bar", "org.apache.http")); - assertEquals("5.0", new Version("1.6.4.thisisastring"), versionAdvice.getVersion("bar", "org.apache.commons")); - assertEquals("6.0", new Version("2.3.1"), versionAdvice.getVersion("bar", "org.eclipse.cdt")); - assertEquals("7.0", new Version("1.5.0"), versionAdvice.getVersion("bar", "org.eclipse.tptp")); + assertEquals("5.0", Version.create("1.6.4.thisisastring"), versionAdvice.getVersion("bar", "org.apache.commons")); + assertEquals("6.0", Version.create("2.3.1"), versionAdvice.getVersion("bar", "org.eclipse.cdt")); + assertEquals("7.0", Version.create("1.5.0"), versionAdvice.getVersion("bar", "org.eclipse.tptp")); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/AllTests.java new file mode 100644 index 000000000..78b7fb83d --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/AllTests.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2007, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ql; + +import junit.framework.*; + +/** + * Performs all automated director tests. + */ +public class AllTests extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(AllTests.class.getName()); + suite.addTestSuite(EvaluatorTest.class); + suite.addTestSuite(PerformanceTest.class); + suite.addTestSuite(TestQueryReimplementation.class); + return suite; + } + +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java new file mode 100644 index 000000000..facafa400 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java @@ -0,0 +1,338 @@ +/******************************************************************************* + * Copyright (c) 2009 Cloudsmith Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cloudsmith Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ql; + +import java.io.File; +import java.net.URI; +import java.util.*; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; +import org.eclipse.equinox.internal.p2.director.QueryableArray; +import org.eclipse.equinox.internal.p2.director.app.Activator; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.expression.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.publisher.PublisherInfo; +import org.eclipse.equinox.p2.publisher.PublisherResult; +import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.ql.*; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.query.MatchQuery; +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.AbstractProvisioningTest; +import org.eclipse.equinox.p2.tests.TestActivator; +import org.osgi.framework.Filter; + +public class EvaluatorTest extends AbstractProvisioningTest { + private static final IQLParser parser = QL.newParser(); + private static final IQLFactory factory = QL.getFactory(); + + public void testArguments() throws Exception { + IExpression expr = parser.parse("'a' == $0 && 'b' == $1 && 'c' == $2"); + assertEquals(Boolean.TRUE, expr.evaluate(factory.createContext("a", "b", "c"))); + } + + public void testAnonymousMember() throws Exception { + IExpression expr = parser.parse("$0.class == $1"); + assertEquals(Boolean.TRUE, expr.evaluate(factory.createContext("a", String.class))); + } + + public void testInstanceOf() throws Exception { + // Explicit instanceof when rhs is a class + IExpression expr = parser.parse("$0 ~= $1"); + assertEquals(Boolean.TRUE, expr.evaluate(factory.createContext(new Integer(4), Number.class))); + } + + public void testArray() throws Exception { + IExpression expr = parser.parse("['a', 'b', 'c'].exists(x | x == 'b') && ['a', 'b', 'c'].all(x | 'd' > x)"); + IEvaluationContext ctx = factory.createContext(); + assertEquals(Boolean.TRUE, expr.evaluate(ctx)); + expr = parser.parse("['d', 'e', 'f'].exists(x | ['a', 'b', 'c'].exists(y | x > y))"); + assertEquals(Boolean.TRUE, expr.evaluate(ctx)); + expr = parser.parse("[['d', 'e', 'f'], ['h', 'i', 'j']].exists(x | x.all(y | ['a', 'b', 'c'].all(z | y > z)))"); + assertEquals(Boolean.TRUE, expr.evaluate(ctx)); + expr = parser.parse("[['d', 'e', 'f'], ['h', '3', 'j']].exists(x | x.all(y | ['a', 'b', 'c'].exists(z | y > z)))"); + assertEquals(Boolean.TRUE, expr.evaluate(ctx)); + expr = parser.parse("[['d', 'e', 'f'], ['h', 'i', 'j']].all(x | x.all(y | ['a', 'b', 'c'].all(z | y > z)))"); + assertEquals(Boolean.TRUE, expr.evaluate(ctx)); + expr = parser.parse("[['d', 'e', 'f'], ['h', '3', 'j']].all(x | x.all(y | ['a', 'b', 'c'].all(z | y > z)))"); + assertEquals(Boolean.FALSE, expr.evaluate(ctx)); // 3 < 'b' + } + + public void testLatest() throws Exception { + IMetadataRepository repo = getMDR("/testData/metadataRepo/multipleversions1"); + IQueryResult result = repo.query(new QLContextQuery(IInstallableUnit.class, "latest(x | x.id == $0)", "test.bundle"), new NullProgressMonitor()); + assertTrue(queryResultSize(result) == 1); + } + + public void testRange() throws Exception { + IMetadataRepository repo = getMDR("/testData/metadataRepo/multipleversions1"); + IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnit.class, "version ~= $0", new VersionRange("2.0.0")), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 2); + } + + public void testProperty() throws Exception { + IMetadataRepository repo = getMDR("/testData/metadataRepo/multipleversions1"); + + IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnit.class, "properties.exists(p | boolean(p.value))"), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 3); + + result = repo.query(new QLMatchQuery(IInstallableUnit.class, "boolean(properties['org.eclipse.equinox.p2.type.group'])"), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 3); + + Filter filter = TestActivator.context.createFilter("(org.eclipse.equinox.p2.type.group=true)"); + result = repo.query(new QLMatchQuery(IInstallableUnit.class, "properties ~= $0", filter), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 3); + } + + public void testToString() throws Exception { + String exprString = "select(x | x.id == $0 && (x.version == $1 || x.version == $2)).traverse(set(), _, {requirementsCache, parent | select(" + // + "parent.requiredCapabilities.unique(requirementsCache).select(rc | rc.filter == null || $2 ~= filter(rc.filter)), _, " + // + "{rcs, child | rcs.exists(rc | child ~= rc)})}).limit(10)"; + + IContextExpression expr = factory.contextExpression(IInstallableUnit.class, parser.parseQuery(exprString)); + System.out.println(expr.toString()); + assertEquals(exprString, expr.toString()); + } + + public void testSomeAPI() throws Exception { + // Create some expressions. Note the use of identifiers instead of + // indexes for the parameters + + IExpression item = factory.variable("item"); + IExpression cmp1 = factory.equals(factory.member(item, "id"), factory.indexedParameter(0)); + IExpression cmp2 = factory.equals(factory.at(factory.member(item, "properties"), factory.indexedParameter(1)), factory.indexedParameter(2)); + + IExpression lambda = factory.lambda(item, factory.and(cmp1, cmp2)); + IExpression latest = factory.latest(factory.select(factory.variable("everything"), lambda)); + + // Create the query + IContextExpression e3 = factory.contextExpression(IInstallableUnit.class, latest, "test.bundle", "org.eclipse.equinox.p2.type.group", "true"); + IMetadataRepository repo = getMDR("/testData/metadataRepo/multipleversions1"); + IQueryResult result = repo.query(new QLContextQuery(e3), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 1); + } + + public void testMember() throws Exception { + IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo"); + IProvidedCapability pc = MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.eclipse.type", "source", null); + IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnitFragment.class, "host.exists(h | $0.name == h.name && $0.namespace == h.namespace)", new Object[] {pc}), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 1); + } + + public void testPatch() throws Exception { + IRequiredCapability[][] applicability = new IRequiredCapability[2][2]; + applicability[0][0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "javax.wsdl", null, null, false, false); + applicability[0][1] = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.eclipse.type", "bundle", null, null, false, false); + applicability[1][0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "tooling.source.default", null, null, false, false); + applicability[1][1] = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.flavor", "tooling", null, null, false, false); + + IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo"); + IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnit.class, "$0.exists(rcs | rcs.all(rc | this ~= rc))", (Object) applicability), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 3); + } + + public void testPattern() throws Exception { + IProvidedCapability pc = MetadataFactory.createProvidedCapability("org.eclipse.equinox.p2.eclipse.type", "source", null); + IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo"); + IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnit.class, "id ~= /tooling.*.default/", pc), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 3); + } + + public void testLimit() throws Exception { + IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo"); + IQueryResult result = repo.query(new QLContextQuery(IInstallableUnit.class, "select(x | x.id ~= /tooling.*/).limit(1)"), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 1); + + result = repo.query(new QLContextQuery(IInstallableUnit.class, "select(x | x.id ~= /tooling.*/).limit($0)", new Integer(2)), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 2); + } + + public void testNot() throws Exception { + IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo"); + IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnit.class, "!(id ~= /tooling.*/)"), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 4); + } + + public void testArtifactQuery() throws Exception { + URI artifactRepo = getTestData("1.1", "/testData/artifactRepo/simple").toURI(); + + IArtifactRepositoryManager artifactManager = getArtifactRepositoryManager(); + assertNotNull(artifactManager); + + IArtifactRepository repo = artifactManager.loadRepository(artifactRepo, new NullProgressMonitor()); + IQueryResult result = repo.query(new QLMatchQuery(IArtifactKey.class, "classifier ~= /*/"), new NullProgressMonitor()); + assertTrue(queryResultSize(result) > 1); + Iterator itor = result.iterator(); + while (itor.hasNext()) + assertTrue(itor.next() instanceof IArtifactKey); + + result = repo.descriptorQueryable().query(new QLMatchQuery(IArtifactDescriptor.class, "artifactKey.classifier ~= /*/"), new NullProgressMonitor()); + assertTrue(queryResultSize(result) > 1); + itor = result.iterator(); + while (itor.hasNext()) + assertTrue(itor.next() instanceof IArtifactDescriptor); + } + + public void testClassConstructor() throws Exception { + IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo"); + IQueryResult result = repo.query(new QLContextQuery(IInstallableUnit.class, // + "select(x | x ~= class('org.eclipse.equinox.p2.metadata.IInstallableUnitFragment'))"), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 4); + repo = getMDR("/testData/galileoM7"); + } + + public void testTraverseWithoutIndex() throws Exception { + IMetadataRepository repo = getMDR("/testData/galileoM7"); + IQueryResult result = repo.query(new QLContextQuery(IInstallableUnit.class, // + "select(x | x.id == $0 && x.version == $1).traverse(parent | select(" + // + "child | parent.requiredCapabilities.exists(rc | child ~= rc)))", // + "org.eclipse.sdk.feature.group", Version.create("3.5.0.v20090423-7Q7bA7DPR-wM38__Q4iRsmx9z0KOjbpx3AbyvXd-Uq7J2")), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 463); + } + + public void testTraverseWithIndex() throws Exception { + IMetadataRepository repo = getMDR("/testData/galileoM7"); + IQueryResult result = repo.query(// + new QLContextQuery(IInstallableUnit.class, "" + // + "select(x | x.id == $0 && x.version == $1).traverse(capabilityIndex(everything), _, { index, parent |" + // + "index.satisfiesAny(parent.requiredCapabilities)})", // + "org.eclipse.sdk.feature.group",// + Version.create("3.5.0.v20090423-7Q7bA7DPR-wM38__Q4iRsmx9z0KOjbpx3AbyvXd-Uq7J2")),// + new NullProgressMonitor()); + assertEquals(queryResultSize(result), 463); + } + + public void testTraverseWithIndexAndFilter() throws Exception { + // Add some filtering of requirements + Map env = new Hashtable(); + env.put("osgi.os", "linux"); + env.put("osgi.ws", "gtk"); + env.put("osgi.arch", "x86"); + + IContextExpression expr = factory.contextExpression(IInstallableUnit.class, parser.parseQuery("" + // + "select(x | x.id == $0 && x.version == $1).traverse(capabilityIndex(everything), _, { index, parent |" + // + "index.satisfiesAny(parent.requiredCapabilities.select(rc | rc.filter == null || $2 ~= rc.filter))})"), "org.eclipse.sdk.feature.group", Version.create("3.5.0.v20090423-7Q7bA7DPR-wM38__Q4iRsmx9z0KOjbpx3AbyvXd-Uq7J2"), env); + + QLContextQuery query = new QLContextQuery(expr); + IMetadataRepository repo = getMDR("/testData/galileoM7"); + IQueryResult result = repo.query(query, new NullProgressMonitor()); + assertEquals(queryResultSize(result), 411); + } + + public void testCommonRequirements() throws Exception { + // Add some filtering of requirements + + IMetadataRepository repo = getMDR("/testData/galileoM7"); + QLContextQuery indexQuery = new QLContextQuery(IInstallableUnit.class, "capabilityIndex(everything)"); + Object index = indexQuery.query(QL.newQueryContext(repo)); + + Map env = new Hashtable(); + env.put("osgi.os", "linux"); + env.put("osgi.ws", "gtk"); + env.put("osgi.arch", "x86"); + + IContextExpression expr = factory.contextExpression(IInstallableUnit.class, parser.parseQuery("" + // + "select(x | x.id == $0 && x.version == $1).traverse(parent |" + // + "$5.satisfiesAny(parent.requiredCapabilities.select(rc | rc.filter == null || $4 ~= rc.filter))).intersect(" + // + "select(x | x.id == $2 && x.version == $3).traverse(parent |" + // + "$5.satisfiesAny(parent.requiredCapabilities.select(rc | rc.filter == null || $4 ~= rc.filter))))"), // + "org.eclipse.pde.feature.group", // + Version.create("3.5.0.v20090123-7Z7YF8NFE-z0VXhWU26Hu8gY"), // + "org.eclipse.gmf.feature.group", // + Version.create("1.1.1.v20090114-0940-7d8B0FXwkKwFanGNHeHHq8ymBgZ"), // + env,// + index); + + QLContextQuery query = new QLContextQuery(expr); + IQueryResult result = repo.query(query, new NullProgressMonitor()); + assertEquals(queryResultSize(result), 184); + } + + public void testMatchQueryInjectionInPredicate() throws Exception { + IMetadataRepository repo = getMDR("/testData/galileoM7"); + IMatchExpression expr = factory.matchExpression(parser.parse("iquery($0) || iquery($1)"), new MatchQuery() { + @Override + public boolean isMatch(Object candidate) { + return "true".equals(((IInstallableUnit) candidate).getProperty("org.eclipse.equinox.p2.type.category")); + } + }, new MatchQuery() { + @Override + public boolean isMatch(Object candidate) { + return "true".equals(((IInstallableUnit) candidate).getProperty("org.eclipse.equinox.p2.type.group")); + } + }); + IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnit.class, expr), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 497); + } + + public void testMatchQueryInjectionInContext() throws Exception { + IMetadataRepository repo = getMDR("/testData/galileoM7"); + IContextExpression expr = factory.contextExpression(IInstallableUnit.class, parser.parseQuery("select(x | iquery($0, x) || iquery($1, x)).latest()"), new MatchQuery() { + @Override + public boolean isMatch(Object candidate) { + return "true".equals(((IInstallableUnit) candidate).getProperty("org.eclipse.equinox.p2.type.category")); + } + }, new MatchQuery() { + @Override + public boolean isMatch(Object candidate) { + return "true".equals(((IInstallableUnit) candidate).getProperty("org.eclipse.equinox.p2.type.group")); + } + }); + IQueryResult result = repo.query(new QLContextQuery(expr), new NullProgressMonitor()); + assertEquals(queryResultSize(result), 497); + } + + public void testTranslations() { + File foo_fragment = new File(TestActivator.getTestDataFolder(), "FragmentPublisherTest/foo.fragment");//$NON-NLS-1$ + File foo = new File(TestActivator.getTestDataFolder(), "FragmentPublisherTest/foo");//$NON-NLS-1$ + BundlesAction bundlesAction = new BundlesAction(new File[] {foo_fragment}); + PublisherInfo info = new PublisherInfo(); + PublisherResult results = new PublisherResult(); + + bundlesAction.perform(info, results, new NullProgressMonitor()); + Collection ius = results.getIUs(null, null); + assertEquals("1.0", 1, ius.size()); + + info = new PublisherInfo(); + results = new PublisherResult(); + bundlesAction = new BundlesAction(new File[] {foo}); + bundlesAction.perform(info, results, new NullProgressMonitor()); + + bundlesAction = new BundlesAction(new File[] {foo_fragment}); + bundlesAction.perform(info, results, new NullProgressMonitor()); + ius = results.getIUs(null, null); + assertEquals("2.0", 3, ius.size()); + QueryableArray queryableArray = new QueryableArray((IInstallableUnit[]) ius.toArray(new IInstallableUnit[ius.size()])); + IQueryResult result = queryableArray.query(new InstallableUnitQuery("foo"), null); + assertEquals("2.1", 1, queryResultSize(result)); + + QLMatchQuery lq = new QLMatchQuery(IInstallableUnit.class, "translations['org.eclipse.equinox.p2.name'] ~= /German*/"); + lq.setLocale(Locale.GERMAN); + Iterator itr = queryableArray.query(lq, new NullProgressMonitor()).iterator(); + assertTrue(itr.hasNext()); + assertEquals("2.8", "foo", ((IInstallableUnit) itr.next()).getId()); + assertFalse(itr.hasNext()); + } + + private IMetadataRepository getMDR(String uri) throws Exception { + URI metadataRepo = getTestData("1.1", uri).toURI(); + + IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); + assertNotNull(metadataManager); + + return metadataManager.loadRepository(metadataRepo, new NullProgressMonitor()); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java new file mode 100644 index 000000000..bcc264b43 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java @@ -0,0 +1,187 @@ +/******************************************************************************* + * Copyright (c) 2009 Cloudsmith Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cloudsmith Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ql; + +import java.net.URI; +import java.util.*; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; +import org.eclipse.equinox.internal.p2.director.QueryableArray; +import org.eclipse.equinox.internal.p2.director.Slicer; +import org.eclipse.equinox.internal.p2.director.app.Activator; +import org.eclipse.equinox.internal.p2.metadata.query.IUPropertyQuery; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.ExpressionQuery; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.ql.*; +import org.eclipse.equinox.p2.query.*; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +public class PerformanceTest extends AbstractProvisioningTest { + public void testCapabilityQueryPerformance() throws Exception { + + IMetadataRepository repo = getMDR("/testData/galileoM7"); + + IRequirement capability = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.eclipse.type", "feature", new VersionRange("[1.0.0,2.0.0)"), null, false, false); + QLMatchQuery predicateQuery = new QLMatchQuery(IInstallableUnit.class, "this ~= $0", capability); + IQuery capabilityQuery = new ExpressionQuery(IInstallableUnit.class, capability.getMatches()); + IQueryResult result; + long tradQueryMS = 0; + long exprQueryMS = 0; + + for (int i = 0; i < 5; ++i) { + long start = System.currentTimeMillis(); + for (int idx = 0; idx < 80; ++idx) { + result = repo.query(capabilityQuery, new NullProgressMonitor()); + assertEquals(queryResultSize(result), 487); + } + tradQueryMS += (System.currentTimeMillis() - start); + + start = System.currentTimeMillis(); + for (int idx = 0; idx < 80; ++idx) { + result = repo.query(predicateQuery, new NullProgressMonitor()); + assertEquals(queryResultSize(result), 487); + } + exprQueryMS += (System.currentTimeMillis() - start); + } + System.out.println("CapabilityQuery took: " + tradQueryMS + " milliseconds"); + System.out.println("PredicateQuery took: " + exprQueryMS + " milliseconds"); + System.out.println(); + } + + public void testCapabilityQueryPerformance2() throws Exception { + + IMetadataRepository repo = getMDR("/testData/galileoM7"); + IQueryable qaRepo = new QueryableArray(gatherAvailableInstallableUnits(repo)); + + IRequirement capability = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.eclipse.type", "feature", new VersionRange("[1.0.0,2.0.0)"), null, false, false); + QLContextQuery exprQuery = new QLContextQuery(IInstallableUnit.class, "capabilityIndex(everything)"); + IQuery capabilityQuery = new ExpressionQuery(IInstallableUnit.class, capability.getMatches()); + exprQuery = new QLContextQuery(IInstallableUnit.class, "$0.satisfiesAny([$1])", exprQuery.query(QL.newQueryContext(qaRepo)), capability); + IQueryResult result; + long tradQueryMS = 0; + long exprQueryMS = 0; + + for (int i = 0; i < 5; ++i) { + long start = System.currentTimeMillis(); + for (int idx = 0; idx < 80; ++idx) { + result = qaRepo.query(capabilityQuery, new NullProgressMonitor()); + assertEquals(queryResultSize(result), 487); + } + tradQueryMS += (System.currentTimeMillis() - start); + + start = System.currentTimeMillis(); + for (int idx = 0; idx < 80; ++idx) { + result = qaRepo.query(exprQuery, new NullProgressMonitor()); + assertEquals(queryResultSize(result), 487); + } + exprQueryMS += (System.currentTimeMillis() - start); + } + System.out.println("CapabilityQuery took: " + tradQueryMS + " milliseconds"); + System.out.println("PredicateQuery took: " + exprQueryMS + " milliseconds"); + System.out.println(); + } + + public void testIUPropertyQueryPerformance() throws Exception { + + IMetadataRepository repo = getMDR("/testData/galileoM7"); + + IUPropertyQuery propertyQuery = new IUPropertyQuery("df_LT.providerName", "Eclipse.org"); + QLMatchQuery predicateQuery = new QLMatchQuery(IInstallableUnit.class, "properties[$0] == $1", "df_LT.providerName", "Eclipse.org"); + IQueryResult result; + long tradQueryMS = 0; + long exprQueryMS = 0; + + for (int i = 0; i < 5; ++i) { + long start = System.currentTimeMillis(); + for (int idx = 0; idx < 80; ++idx) { + result = repo.query(propertyQuery, new NullProgressMonitor()); + assertEquals(queryResultSize(result), 965); + } + tradQueryMS += (System.currentTimeMillis() - start); + + start = System.currentTimeMillis(); + for (int idx = 0; idx < 80; ++idx) { + result = repo.query(predicateQuery, new NullProgressMonitor()); + assertEquals(queryResultSize(result), 965); + } + exprQueryMS += (System.currentTimeMillis() - start); + } + System.out.println("IUPropertyQuery took: " + tradQueryMS + " milliseconds"); + System.out.println("PredicateQuery took: " + exprQueryMS + " milliseconds"); + System.out.println(); + } + + public void testSlicerPerformance() throws Exception { + Hashtable env = new Hashtable(); + env.put("osgi.os", "linux"); + env.put("osgi.ws", "gtk"); + env.put("osgi.arch", "x86"); + + IMetadataRepository repo = getMDR("/testData/galileoM7"); + IQueryResult r = repo.query(new InstallableUnitQuery("org.eclipse.sdk.feature.group", Version.create("3.5.0.v20090423-7Q7bA7DPR-wM38__Q4iRsmx9z0KOjbpx3AbyvXd-Uq7J2")), new NullProgressMonitor()); + Iterator itor = r.iterator(); + assertTrue(itor.hasNext()); + IInstallableUnit[] roots = new IInstallableUnit[] {(IInstallableUnit) itor.next()}; + + IQuery query = new QLContextQuery(IInstallableUnit.class, "" + // + "$0.traverse(set(), capabilityIndex(everything), _, {rqCache, index, parent | " + // + "index.satisfiesAny(parent.requiredCapabilities.unique(rqCache).select(rc | rc.filter == null || $1 ~= rc.filter))})", roots, env); + + long sliceTime = 0; + long traverseTime = 0; + IQueryable slice = null; + for (int idx = 0; idx < 100; ++idx) { + long startTime = System.currentTimeMillis(); + r = repo.query(query, new NullProgressMonitor()); + traverseTime += (System.currentTimeMillis() - startTime); + assertEquals(queryResultSize(r), 411); + + startTime = System.currentTimeMillis(); + Slicer slicer = new Slicer(new QueryableArray(gatherAvailableInstallableUnits(repo)), env, false); + slice = slicer.slice(roots, new NullProgressMonitor()); + sliceTime += (System.currentTimeMillis() - startTime); + } + // Check the size of the last slice to verify that it's the same as the traverse size + r = slice.query(new MatchQuery() { + public boolean isMatch(Object value) { + return true; + } + }, new NullProgressMonitor()); + assertEquals(queryResultSize(r), 411); + + System.out.print("100 * Slicing took: "); + System.out.println(sliceTime); + System.out.print("100 * Indexed Traverse expression took: "); + System.out.println(traverseTime); + System.out.println(); + } + + private IMetadataRepository getMDR(String uri) throws Exception { + URI metadataRepo = getTestData("1.1", uri).toURI(); + + IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); + assertNotNull(metadataManager); + + return metadataManager.loadRepository(metadataRepo, new NullProgressMonitor()); + } + + private IInstallableUnit[] gatherAvailableInstallableUnits(IQueryable queryable) { + ArrayList list = new ArrayList(); + IQueryResult matches = queryable.query(InstallableUnitQuery.ANY, null); + for (Iterator it = matches.iterator(); it.hasNext();) + list.add(it.next()); + return (IInstallableUnit[]) list.toArray(new IInstallableUnit[list.size()]); + } +} diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/TestQueryReimplementation.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/TestQueryReimplementation.java new file mode 100644 index 000000000..9a51eda88 --- /dev/null +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/TestQueryReimplementation.java @@ -0,0 +1,146 @@ +/******************************************************************************* + * Copyright (c) 2009 Cloudsmith Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Cloudsmith Inc. - initial API and implementation + *******************************************************************************/ +package org.eclipse.equinox.p2.tests.ql; + +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.expression.IExpression; +import org.eclipse.equinox.p2.metadata.expression.IExpressionParser; +import org.eclipse.equinox.p2.ql.*; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; + +public class TestQueryReimplementation extends AbstractProvisioningTest { + + public static class UpdateQuery extends QLMatchQuery { + private static final IExpression expr1; + private static final IExpression expr2; + + static { + IQLParser parser = QL.newParser(); + + // This expression is used in case the updateFrom is an IInstallableUnitPatch + // + expr1 = parser.parse("$0 ~= updateDescriptor && ($0.id != id || $0.version < version)"); + + // When updateFrom is not an IInstallableUnitPatch, we need to do one of two things depending + // on if the current item is an InstallableUnitPatch or not. + // + expr2 = parser.parse("this ~= class('org.eclipse.equinox.p2.metadata.IInstallableUnitPatch')" + // + "? $0 ~= lifeCycle" + // + ": $0 ~= updateDescriptor && ($0.id != id || $0.version < version)"); + } + + public UpdateQuery(IInstallableUnit updateFrom) { + super(IInstallableUnit.class, QL.getFactory().matchExpression(updateFrom instanceof IInstallableUnitPatch ? expr1 : expr2, updateFrom, IInstallableUnitPatch.class)); + } + } + + public static class IUPropertyQuery extends QLMatchQuery { + private static final IExpression expr = QL.newParser().parse("properties[$0] == $1"); + + public IUPropertyQuery(String propertyName, String propertyValue) { + super(IInstallableUnit.class, QL.getFactory().matchExpression(expr, propertyName, propertyValue)); + } + } + + public static class InstallableUnitQuery extends QLMatchQuery { + /** + * A convenience query that will match any {@link IInstallableUnit} + * it encounters. + */ + public static final QLMatchQuery ANY = new QLMatchQuery(IInstallableUnit.class, ""); + + private static final IExpression idVersionQuery; + private static final IExpression idRangeQuery; + + static { + IExpressionParser parser = QL.newParser(); + idVersionQuery = parser.parse("($0 == null || $0 == id) && ($1 == null || $1 == version)"); + idRangeQuery = parser.parse("($0 == null || $0 == id) && ($1 == null || version ~= $1)"); + } + + /** + * Creates a query that will match any {@link IInstallableUnit} with the given + * id, regardless of version. + * + * @param id The installable unit id to match, or <code>null</code> to match any id + */ + public InstallableUnitQuery(String id) { + this(id, (Version) null); + } + + /** + * Creates a query that will match any {@link IInstallableUnit} with the given + * id, and whose version falls in the provided range. + * + * @param id The installable unit id to match, or <code>null</code> to match any id + * @param range The version range to match + */ + public InstallableUnitQuery(String id, VersionRange range) { + super(IInstallableUnit.class, QL.getFactory().matchExpression(idRangeQuery, id, range)); + } + + /** + * Creates a query that will match any {@link IInstallableUnit} with the given + * id and version. + * + * @param id The installable unit id to match, or <code>null</code> to match any id + * @param version The precise version that a matching unit must have + */ + public InstallableUnitQuery(String id, Version version) { + super(IInstallableUnit.class, QL.getFactory().matchExpression(idVersionQuery, id, version)); + } + + /** + * Creates a query that will match any {@link IInstallableUnit} with the given + * id and version. + * + * @param versionedId The precise id/version combination that a matching unit must have + */ + public InstallableUnitQuery(IVersionedId versionedId) { + this(versionedId.getId(), versionedId.getVersion()); + } + } + + private IInstallableUnit a1; + private IInstallableUnit updateOfA; + private IInstallableUnit a11; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + a1 = createIU("A", Version.create("2.0.0")); + IUpdateDescriptor update = MetadataFactory.createUpdateDescriptor("A", new VersionRange("[2.0.0, 2.0.0]"), 0, "update description"); + updateOfA = createIU("UpdateA", Version.createOSGi(1, 0, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, null, NO_TP_DATA, false, update, NO_REQUIRES); + a11 = createIUUpdate(); + } + + public void testUpdateWithDifferentId() { + IMetadataRepository repo = createTestMetdataRepository(new IInstallableUnit[] {a1, updateOfA}); + IQueryResult c = repo.query(new UpdateQuery(a1), null); + assertEquals(1, queryResultSize(c)); + assertEquals(updateOfA, c.iterator().next()); + } + + public void testWithSuperiorVersion() { + IMetadataRepository repo2 = createTestMetdataRepository(new IInstallableUnit[] {a11, a1}); + IQueryResult c2 = repo2.query(new UpdateQuery(a1), null); + assertEquals(1, queryResultSize(c2)); + assertEquals(a11, c2.iterator().next()); + } + + private IInstallableUnit createIUUpdate() { + return createIU("A", Version.create("2.1.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, MetadataFactory.createUpdateDescriptor("A", new VersionRange("[2.0.0, 2.1.0]"), 0, "update description"), null); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractReconcilerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractReconcilerTest.java index d81126d8e..1305a11f0 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractReconcilerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractReconcilerTest.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.reconciler.dropins; +import org.eclipse.equinox.p2.metadata.Version; + import java.io.*; import java.net.MalformedURLException; import java.net.URL; @@ -20,12 +22,11 @@ import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry; import org.eclipse.equinox.internal.p2.engine.SurrogateProfileHandler; import org.eclipse.equinox.internal.p2.update.*; import org.eclipse.equinox.internal.p2.updatesite.Activator; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.engine.IProfile; +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.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.eclipse.osgi.service.datalocation.Location; @@ -164,7 +165,7 @@ public class AbstractReconcilerTest extends AbstractProvisioningTest { File file = null; if (propertyToPlatformArchive != null) { property = getValueFor(propertyToPlatformArchive); - String message = "Need to set the " + "\"" + property + "\" system property with a valid path to the platform binary drop or copy the archive to be a sibling of the install folder."; + String message = "Need to set the " + "\"" + propertyToPlatformArchive + "\" system property with a valid path to the platform binary drop or copy the archive to be a sibling of the install folder."; if (property == null) { fail(message); } @@ -528,8 +529,8 @@ public class AbstractReconcilerTest extends AbstractProvisioningTest { SimpleProfileRegistry registry = new SimpleProfileRegistry(location, new SurrogateProfileHandler(), false); IProfile[] profiles = registry.getProfiles(); assertEquals("1.0 Should only be one profile in registry.", 1, profiles.length); - Collector collector = profiles[0].query(new InstallableUnitQuery(id, new Version(version)), new Collector(), null); - return !collector.isEmpty(); + IQueryResult queryResult = profiles[0].query(new InstallableUnitQuery(id, Version.create(version)), null); + return !queryResult.isEmpty(); } public IInstallableUnit getRemoteIU(String id, String version) { @@ -537,9 +538,9 @@ public class AbstractReconcilerTest extends AbstractProvisioningTest { SimpleProfileRegistry registry = new SimpleProfileRegistry(location, new SurrogateProfileHandler(), false); IProfile[] profiles = registry.getProfiles(); assertEquals("1.0 Should only be one profile in registry.", 1, profiles.length); - Collector collector = profiles[0].query(new InstallableUnitQuery(id, new Version(version)), new Collector(), null); - assertEquals("1.1 Should not have more than one IU wth the same ID and version.", 1, collector.size()); - return (IInstallableUnit) collector.iterator().next(); + IQueryResult queryResult = profiles[0].query(new InstallableUnitQuery(id, Version.create(version)), null); + assertEquals("1.1 Should not have more than one IU wth the same ID and version.", 1, queryResultSize(queryResult)); + return (IInstallableUnit) queryResult.iterator().next(); } public int runInitialize(String message) { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/BasicTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/BasicTests.java index 9e9f316b8..a1e8785f2 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/BasicTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/BasicTests.java @@ -13,7 +13,7 @@ package org.eclipse.equinox.p2.tests.reconciler.dropins; import java.io.File; import junit.framework.Test; import junit.framework.TestSuite; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; //- add new //- remove only diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ConfigurationTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ConfigurationTests.java index 71d8dcecd..bf1cbfd0c 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ConfigurationTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ConfigurationTests.java @@ -15,7 +15,7 @@ import java.util.Iterator; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.equinox.internal.p2.update.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; /* * Tests related to the platform configuration before and after reconciliation. diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/NTLMTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/NTLMTest.java index e6f1d4227..de683f732 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/NTLMTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/NTLMTest.java @@ -11,8 +11,8 @@ package org.eclipse.equinox.p2.tests.repository; import java.net.URI; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.tests.TestActivator; import org.eclipse.equinox.p2.tests.testserver.helper.AbstractTestServerClientCase; import org.osgi.framework.ServiceReference; @@ -27,7 +27,7 @@ public class NTLMTest extends AbstractTestServerClientCase { public void setUp() throws Exception { super.setUp(); - ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.class.getName()); + ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.SERVICE_NAME); mgr = (IMetadataRepositoryManager) TestActivator.context.getService(sr2); if (mgr == null) { throw new RuntimeException("Repository manager could not be loaded"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/TimeoutTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/TimeoutTest.java index b7a98d8bf..dacbeb2af 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/TimeoutTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/TimeoutTest.java @@ -14,7 +14,7 @@ import java.security.cert.Certificate; import org.eclipse.core.runtime.*; import org.eclipse.equinox.internal.p2.repository.RepositoryTransport; import org.eclipse.equinox.internal.provisional.p2.core.IServiceUI; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; +import org.eclipse.equinox.p2.core.ProvisionException; import org.eclipse.equinox.p2.tests.metadata.repository.AllServerTests; import org.eclipse.equinox.p2.tests.testserver.helper.AbstractTestServerClientCase; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddJVMArgumentActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddJVMArgumentActionTest.java index 4b620deaa..6e51a033a 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddJVMArgumentActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddJVMArgumentActionTest.java @@ -15,8 +15,8 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstant import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.AddJVMArgumentAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class AddJVMArgumentActionTest extends AbstractProvisioningTest { @@ -39,10 +39,11 @@ public class AddJVMArgumentActionTest extends AbstractProvisioningTest { tempDir.mkdirs(); parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); Properties profileProperties = new Properties(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, getTempFolder().toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); InstallableUnitOperand operand = new InstallableUnitOperand(null, createIU("test")); touchpoint.initializePhase(null, profile, "test", parameters); parameters.put("iu", operand.second()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddProgramArgumentActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddProgramArgumentActionTest.java index 3653f7553..e3d0d6465 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddProgramArgumentActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddProgramArgumentActionTest.java @@ -17,13 +17,13 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.AddProgramArgumentAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -40,10 +40,11 @@ public class AddProgramArgumentActionTest extends AbstractProvisioningTest { public void testExecuteUndo() { Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); Properties profileProperties = new Properties(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, getTempFolder().toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); InstallableUnitOperand operand = new InstallableUnitOperand(null, createIU("test")); touchpoint.initializePhase(null, profile, "test", parameters); parameters.put("iu", operand.second()); @@ -68,9 +69,9 @@ public class AddProgramArgumentActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -84,6 +85,7 @@ public class AddProgramArgumentActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -120,9 +122,9 @@ public class AddProgramArgumentActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -136,6 +138,7 @@ public class AddProgramArgumentActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -178,9 +181,9 @@ public class AddProgramArgumentActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -194,6 +197,7 @@ public class AddProgramArgumentActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -230,9 +234,9 @@ public class AddProgramArgumentActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -246,6 +250,7 @@ public class AddProgramArgumentActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java index 4a663fc7a..70ffe003e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java @@ -10,31 +10,29 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.touchpoint.eclipse; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.preferences.IPreferencesService; import org.eclipse.equinox.internal.p2.core.helpers.LogHelper; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.metadata.TouchpointInstruction; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; +import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.AddRepositoryAction; -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.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.repository.IRepository; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +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.ITouchpointData; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; -import org.eclipse.equinox.p2.tests.TestActivator; import org.osgi.service.prefs.Preferences; /** @@ -73,6 +71,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { public void testInvalidEnablement() { Map args = getValidArguments(); + addAgent(args); args.put("enabled", "bogus enablement"); IStatus result = action.execute(args); //Any value other than "true" for enablement results in a disabled repository @@ -80,8 +79,13 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { assertTrue("1.1", !getArtifactRepositoryManager().isEnabled(locationURI)); } + private void addAgent(Map args) { + args.put(ActionConstants.PARM_AGENT, getAgent()); + } + public void testInvalidLocation() { Map args = getValidArguments(); + addAgent(args); args.put("location", "bogus location"); IStatus result = action.execute(args); assertTrue("1.0", !result.isOK()); @@ -89,6 +93,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { public void testInvalidType() { Map args = getValidArguments(); + addAgent(args); args.put("type", "bogus type"); IStatus result = action.execute(args); assertTrue("1.0", !result.isOK()); @@ -97,6 +102,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { public void testMissingEnablement() { //note enablement is optional, defaults to true Map args = getValidArguments(); + addAgent(args); args.remove("enabled"); IStatus result = action.execute(args); assertTrue("1.0", result.isOK()); @@ -104,6 +110,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { public void testMissingType() { Map args = getValidArguments(); + addAgent(args); args.remove("type"); IStatus result = action.execute(args); assertTrue("1.0", !result.isOK()); @@ -116,6 +123,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { public void testUndo() { Map args = getValidArguments(); + addAgent(args); IStatus result = action.execute(args); assertTrue("1.0", result.isOK()); @@ -125,6 +133,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { public void testMultipleActionAdd() { Map args = getValidArguments(); + addAgent(args); IStatus result = action.execute(args); assertTrue("1.0", result.isOK()); @@ -146,6 +155,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { } Map args = getValidArguments(); + addAgent(args); IStatus result = action.execute(args); assertTrue("1.0", result.isOK()); @@ -160,7 +170,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { */ public void testFullInstall() { String id = "AddRepositoryActionTest.testFullInstall"; - Version version = new Version(1, 0, 0); + Version version = Version.createOSGi(1, 0, 0); Map instructions = new HashMap(); instructions.put("configure", TouchpointInstruction.encodeAction("addRepository", getValidArguments())); ITouchpointData tpData = MetadataFactory.createTouchpointData(instructions); @@ -177,10 +187,8 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { //check that profile property is set profile = getProfile(id); // Get Preference node associated with the profile - IPreferencesService prefService = (IPreferencesService) ServiceHelper.getService(TestActivator.getContext(), IPreferencesService.class.getName()); - Preferences pref = prefService.getRootNode().node("/profile/" + profile.getProfileId() + "/org.eclipse.equinox.p2.artifact.repository/repositories/" + getKey(TEST_LOCATION)); //$NON-NLS-1$ //$NON-NLS-2$ + Preferences pref = new ProfileScope(getAgentLocation(), profile.getProfileId()).getNode("org.eclipse.equinox.p2.artifact.repository/repositories/" + getKey(TEST_LOCATION)); String value = pref.get(KEY_URI, null); - assertEquals("2.0", value, TEST_LOCATION); } @@ -195,7 +203,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { //install the old IU String id = "AddRepositoryActionTest.testUpdate"; - Version version = new Version(1, 0, 0); + Version version = Version.createOSGi(1, 0, 0); IInstallableUnit oldIU = createIU(id, version); IProfile profile = createProfile(id); ProfileChangeRequest request = new ProfileChangeRequest(profile); @@ -207,7 +215,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { assertTrue("1.1", !getArtifactRepositoryManager().contains(locationURI)); //define new IU - version = new Version(1, 1, 0); + version = Version.createOSGi(1, 1, 0); Map instructions = new HashMap(); instructions.put("configure", TouchpointInstruction.encodeAction("addRepository", getValidArguments())); ITouchpointData tpData = MetadataFactory.createTouchpointData(instructions); @@ -215,7 +223,7 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { //perform the update and install an ordinary bundle IMetadataRepository repo = getMetadataRepositoryManager().loadRepository(site, getMonitor()); - IInstallableUnit bundle = (IInstallableUnit) repo.query(new InstallableUnitQuery("aBundle"), new Collector(), getMonitor()).iterator().next(); + IInstallableUnit bundle = (IInstallableUnit) repo.query(new InstallableUnitQuery("aBundle"), getMonitor()).iterator().next(); request = new ProfileChangeRequest(profile); final IInstallableUnit[] newIUs = new IInstallableUnit[] {newIU, bundle}; request.addInstallableUnits(newIUs); @@ -227,14 +235,13 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { //check that the artifact is still there profile = getProfile(id); - IArtifactRepository artifacts = getArtifactRepositoryManager().loadRepository(Util.getBundlePoolLocation(profile), getMonitor()); - assertEquals("3.0", 1, artifacts.getArtifactKeys().length); + IArtifactRepository artifacts = getArtifactRepositoryManager().loadRepository(Util.getBundlePoolLocation(getAgent(), profile), getMonitor()); + assertEquals("3.0", 1, getArtifactKeyCount(artifacts)); //check that profile property is set assertProfileContains("3.1", profile, newIUs); // Get Preference node associated with the profile - IPreferencesService prefService = (IPreferencesService) ServiceHelper.getService(TestActivator.getContext(), IPreferencesService.class.getName()); - Preferences pref = prefService.getRootNode().node("/profile/" + profile.getProfileId() + "/org.eclipse.equinox.p2.artifact.repository/repositories/" + getKey(TEST_LOCATION)); //$NON-NLS-1$ //$NON-NLS-2$ + Preferences pref = new ProfileScope(getAgentLocation(), profile.getProfileId()).getNode("org.eclipse.equinox.p2.artifact.repository/repositories/" + getKey(TEST_LOCATION)); String value = pref.get(KEY_URI, null); assertEquals("3.2", value, TEST_LOCATION); @@ -252,12 +259,8 @@ public class AddRepositoryActionTest extends AbstractProvisioningTest { } private boolean locationExists(IProfile profile, String location) { - IPreferencesService prefService = (IPreferencesService) ServiceHelper.getService(TestActivator.getContext(), IPreferencesService.class.getName()); - Preferences pref; - if (profile != null) - pref = prefService.getRootNode().node("/profile/" + profile.getProfileId() + "/org.eclipse.equinox.p2.artifactRepositories/repositories/" + getKey(location)); - else - pref = prefService.getRootNode().node("/profile/_SELF_/org.eclipse.equinox.p2.artifact.repository/repositories/" + getKey(location)); + final String profileId = profile != null ? profile.getProfileId() : IProfileRegistry.SELF; + Preferences pref = new ProfileScope(getAgentLocation(), profileId).getNode("org.eclipse.equinox.p2.artifact.repository/repositories/" + getKey(location)); if (location.equals(pref.get(KEY_URI, null))) return true; return false; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddSourceBundleActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddSourceBundleActionTest.java index 45915d137..98b36bbe5 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddSourceBundleActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddSourceBundleActionTest.java @@ -18,13 +18,13 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.*; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.AddSourceBundleAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -44,9 +44,9 @@ public class AddSourceBundleActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi.source_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -60,6 +60,7 @@ public class AddSourceBundleActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java index a963f6db9..c2edb992d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008-2009 IBM Corporation and others. + * Copyright (c) 2008, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,7 +13,7 @@ package org.eclipse.equinox.p2.tests.touchpoint.eclipse; import junit.framework.*; /** - * Performs all automated director tests. + * Performs all automated touchpoint tests. */ public class AllTests extends TestCase { diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CheckTrustActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CheckTrustActionTest.java index 2047afed0..a34899291 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CheckTrustActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CheckTrustActionTest.java @@ -12,18 +12,18 @@ package org.eclipse.equinox.p2.tests.touchpoint.eclipse; import java.io.File; import java.util.*; +import org.eclipse.equinox.internal.p2.engine.phases.CheckTrust; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.CheckTrustAction; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.engine.phases.CheckTrust; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -43,9 +43,9 @@ public class CheckTrustActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -59,6 +59,7 @@ public class CheckTrustActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); parameters.put(CheckTrust.PARM_ARTIFACT_FILES, new ArrayList()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/ChmodActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/ChmodActionTest.java index 2674d9c46..e2473ff4e 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/ChmodActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/ChmodActionTest.java @@ -18,13 +18,13 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ChmodAction; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -43,7 +43,7 @@ public class ChmodActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("testExecuteUndo", null, profileProperties); + IProfile profile = createProfile("testExecuteUndo", profileProperties); File zipSource = getTestData("1.0", "/testData/nativeTouchpoint/a.zip"); File zipTarget = new File(installFolder, "a.zip"); @@ -54,6 +54,7 @@ public class ChmodActionTest extends AbstractProvisioningTest { copy("3.0", zipSource, zipTarget2); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "testExecuteUndo", parameters); @@ -108,9 +109,9 @@ public class ChmodActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File dirBundleSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/directoryBased_1.0.0"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -124,6 +125,7 @@ public class ChmodActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -185,9 +187,9 @@ public class ChmodActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File dirBundleSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/directoryBased_1.0.0"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -201,6 +203,7 @@ public class ChmodActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CollectActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CollectActionTest.java index 46ff1201b..858b53db7 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CollectActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CollectActionTest.java @@ -12,17 +12,17 @@ package org.eclipse.equinox.p2.tests.touchpoint.eclipse; import java.io.File; import java.util.*; +import org.eclipse.equinox.internal.p2.engine.phases.Collect; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.CollectAction; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.engine.phases.Collect; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -41,10 +41,10 @@ public class CollectActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); // still want side-effect - Util.getBundlePoolRepository(profile); + Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); @@ -60,8 +60,9 @@ public class CollectActionTest extends AbstractProvisioningTest { IInstallableUnit iu = createBundleIU(bundleDescription, osgiTarget.isDirectory(), key); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); - parameters.put(Collect.PARM_ARTIFACT_REQUESTS, new ArrayList()); + parameters.put(Collect.PARM_ARTIFACT_REQUESTS, new ArrayList<IArtifactRequest[]>()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); InstallableUnitOperand operand = new InstallableUnitOperand(null, iu); @@ -70,7 +71,7 @@ public class CollectActionTest extends AbstractProvisioningTest { parameters.put(ActionConstants.PARM_OPERAND, operand); parameters = Collections.unmodifiableMap(parameters); - List requests = (List) parameters.get(Collect.PARM_ARTIFACT_REQUESTS); + List<IArtifactRequest[]> requests = (List<IArtifactRequest[]>) parameters.get(Collect.PARM_ARTIFACT_REQUESTS); assertFalse(hasRequest(requests, key)); CollectAction action = new CollectAction(); action.execute(parameters); @@ -80,9 +81,8 @@ public class CollectActionTest extends AbstractProvisioningTest { assertTrue(hasRequest(requests, key)); } - private boolean hasRequest(List requests, IArtifactKey key) { - for (Iterator iterator = requests.iterator(); iterator.hasNext();) { - IArtifactRequest[] request = (IArtifactRequest[]) iterator.next(); + private boolean hasRequest(List<IArtifactRequest[]> requests, IArtifactKey key) { + for (IArtifactRequest[] request : requests) { for (int i = 0; i < request.length; i++) { if (key.equals(request[i].getArtifactKey())) return true; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/EclipseTouchpointTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/EclipseTouchpointTest.java index ee708dac8..a2ea89d1d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/EclipseTouchpointTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/EclipseTouchpointTest.java @@ -16,17 +16,18 @@ import java.util.*; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.*; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -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.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.p2.touchpoint.eclipse.actions.ActionConstants; +import org.eclipse.equinox.internal.provisional.p2.director.IPlanner; +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.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; @@ -48,6 +49,7 @@ public class EclipseTouchpointTest extends AbstractProvisioningTest { Map parameters = new HashMap(); IProfile profile = createProfile("test"); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); touchpoint.initializePhase(null, profile, "test", parameters); Object manipulator = parameters.get(EclipseTouchpoint.PARM_MANIPULATOR); @@ -58,6 +60,7 @@ public class EclipseTouchpointTest extends AbstractProvisioningTest { // checking that the manipulator is carried from phases to phase parameters.clear(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); touchpoint.initializePhase(null, profile, "test2", parameters); Object testManipulator = parameters.get(EclipseTouchpoint.PARM_MANIPULATOR); assertEquals(manipulator, testManipulator); @@ -66,6 +69,7 @@ public class EclipseTouchpointTest extends AbstractProvisioningTest { // re: "uninstall" this is necessary for now for coverage until we have formal commit and rollback events // this test should be revisited then parameters.clear(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); touchpoint.initializePhase(null, profile, "uninstall", parameters); testManipulator = parameters.get(EclipseTouchpoint.PARM_MANIPULATOR); assertEquals(manipulator, testManipulator); @@ -96,8 +100,8 @@ public class EclipseTouchpointTest extends AbstractProvisioningTest { URL location = site.toURL(); properties.put("org.eclipse.equinox.p2.cache.extensions", location.toString() + "|" + spacesLocation.toString()); - IProfile profile = createProfile("testBug262073", null, properties); - AggregatedBundleRepository repo = (AggregatedBundleRepository) Util.getAggregatedBundleRepository(profile); + IProfile profile = createProfile("testBug262073", properties); + AggregatedBundleRepository repo = (AggregatedBundleRepository) Util.getAggregatedBundleRepository(getAgent(), profile); Collection repos = repo.testGetBundleRepositories(); assertEquals("1.0", 3, repos.size()); } @@ -118,9 +122,9 @@ public class EclipseTouchpointTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -132,7 +136,7 @@ public class EclipseTouchpointTest extends AbstractProvisioningTest { IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, osgiTarget); bundlePool.addDescriptor(descriptor); - Properties extraProperties = new Properties(); + Map<String, String> extraProperties = new HashMap<String, String>(); extraProperties.put(IInstallableUnit.PROP_PARTIAL_IU, Boolean.TRUE.toString()); Dictionary mockManifest = new Properties(); @@ -147,7 +151,7 @@ public class EclipseTouchpointTest extends AbstractProvisioningTest { IInstallableUnit iu = bundleIUs[0]; assertTrue(Boolean.valueOf(iu.getProperty(IInstallableUnit.PROP_PARTIAL_IU)).booleanValue()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); - IInstallableUnit fullIU = touchpoint.prepareIU(iu, key, profile); + IInstallableUnit fullIU = touchpoint.prepareIU(getAgent(), profile, iu, key); assertFalse(Boolean.valueOf(fullIU.getProperty(IInstallableUnit.PROP_PARTIAL_IU)).booleanValue()); } @@ -156,9 +160,9 @@ public class EclipseTouchpointTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -170,7 +174,7 @@ public class EclipseTouchpointTest extends AbstractProvisioningTest { IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, osgiTarget); bundlePool.addDescriptor(descriptor); - Properties extraProperties = new Properties(); + Map<String, String> extraProperties = new HashMap<String, String>(); extraProperties.put(IInstallableUnit.PROP_PARTIAL_IU, Boolean.TRUE.toString()); Dictionary mockManifest = new Properties(); @@ -185,22 +189,20 @@ public class EclipseTouchpointTest extends AbstractProvisioningTest { IInstallableUnit iu = bundleIUs[0]; assertTrue(Boolean.valueOf(iu.getProperty(IInstallableUnit.PROP_PARTIAL_IU)).booleanValue()); - Iterator iterator = profile.query(new InstallableUnitQuery(iu.getId()), new Collector(), null).iterator(); + Iterator iterator = profile.query(new InstallableUnitQuery(iu.getId()), null).iterator(); assertFalse(iterator.hasNext()); - PhaseSet phaseSet = new DefaultPhaseSet(); - InstallableUnitOperand op = new InstallableUnitOperand(null, iu); InstallableUnitOperand[] operands = new InstallableUnitOperand[] {op}; ServiceReference engineRef = TestActivator.getContext().getServiceReference(IEngine.SERVICE_NAME); IEngine engine = (IEngine) TestActivator.getContext().getService(engineRef); - IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor()); + IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor()); assertTrue(result.isOK()); engine = null; TestActivator.getContext().ungetService(engineRef); - iterator = profile.query(new InstallableUnitQuery(iu.getId()), new Collector(), null).iterator(); + iterator = profile.query(new InstallableUnitQuery(iu.getId()), null).iterator(); assertTrue(iterator.hasNext()); IInstallableUnit installedIU = (IInstallableUnit) iterator.next(); assertTrue(installedIU.getId().equals(iu.getId())); @@ -213,25 +215,25 @@ public class EclipseTouchpointTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); URI site = getTestData("0.1", "/testData/updatesite/site").toURI(); getMetadataRepositoryManager().addRepository(site); getArtifactRepositoryManager().addRepository(site); IMetadataRepository repo = getMetadataRepositoryManager().loadRepository(site, getMonitor()); - IInstallableUnit iu = (IInstallableUnit) repo.query(new InstallableUnitQuery("test.bundle"), new Collector(), getMonitor()).iterator().next(); + IInstallableUnit iu = (IInstallableUnit) repo.query(new InstallableUnitQuery("test.bundle"), getMonitor()).iterator().next(); assertNotNull(iu); - profile = createProfile("test", null, profileProperties); + profile = createProfile("test", profileProperties); ProfileChangeRequest request = new ProfileChangeRequest(profile); final IInstallableUnit[] newIUs = new IInstallableUnit[] {iu}; request.addInstallableUnits(newIUs); IPlanner planner = createPlanner(); - ProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), new NullProgressMonitor()); + IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), new NullProgressMonitor()); assertTrue("1.0", plan.getStatus().isOK()); - IStatus result = createEngine().perform(profile, new DefaultPhaseSet(), plan.getOperands(), new ProvisioningContext(), getMonitor()); + IStatus result = createEngine().perform(plan, getMonitor()); assertFalse("2.0", result.isOK()); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallBundleActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallBundleActionTest.java index 4feb061ce..82039e1be 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallBundleActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallBundleActionTest.java @@ -19,13 +19,13 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstant import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.InstallBundleAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -45,9 +45,9 @@ public class InstallBundleActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -61,6 +61,7 @@ public class InstallBundleActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallFeatureActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallFeatureActionTest.java index 3e3a7725a..9e8df53c8 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallFeatureActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallFeatureActionTest.java @@ -12,18 +12,20 @@ import java.io.File; import java.net.URI; import java.util.*; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor; import org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureParser; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.*; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.InstallFeatureAction; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.PublisherInfo; import org.eclipse.equinox.p2.publisher.eclipse.Feature; import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; @@ -42,9 +44,9 @@ public class InstallFeatureActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File featureSource = getTestData("1.0", "/testData/eclipseTouchpoint/features/org.eclipse.rcp_3.3.0.v20070607-8y8eE8NEbsN3X_fjWS8HPNG"); File targetPlugins = new File(installFolder, "features"); assertTrue(targetPlugins.mkdir()); @@ -55,13 +57,14 @@ public class InstallFeatureActionTest extends AbstractProvisioningTest { Feature feature = parser.parse(featureTarget); IArtifactKey key = FeaturesAction.createFeatureArtifactKey(feature.getId(), feature.getVersion()); - IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, featureTarget); - ((ArtifactDescriptor) descriptor).setRepositoryProperty("artifact.folder", Boolean.TRUE.toString()); + IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(bundlePool, key, featureTarget); + ((SimpleArtifactDescriptor) descriptor).setRepositoryProperty("artifact.folder", Boolean.TRUE.toString()); IInstallableUnit iu = FeaturesAction.createFeatureJarIU(feature, new PublisherInfo()); bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -92,9 +95,9 @@ public class InstallFeatureActionTest extends AbstractProvisioningTest { File installFolder = new File(getTempFolder(), "with space"); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File featureSource = getTestData("1.0", "/testData/eclipseTouchpoint/features/org.eclipse.rcp_3.3.0.v20070607-8y8eE8NEbsN3X_fjWS8HPNG"); File targetPlugins = new File(installFolder, "features"); assertTrue(targetPlugins.mkdir()); @@ -105,13 +108,14 @@ public class InstallFeatureActionTest extends AbstractProvisioningTest { Feature feature = parser.parse(featureTarget); IArtifactKey key = FeaturesAction.createFeatureArtifactKey(feature.getId(), feature.getVersion()); - IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, featureTarget); - ((ArtifactDescriptor) descriptor).setRepositoryProperty("artifact.folder", Boolean.TRUE.toString()); + IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(bundlePool, key, featureTarget); + ((SimpleArtifactDescriptor) descriptor).setRepositoryProperty("artifact.folder", Boolean.TRUE.toString()); IInstallableUnit iu = FeaturesAction.createFeatureJarIU(feature, new PublisherInfo()); bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/JVMArgumentActionLogicTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/JVMArgumentActionLogicTest.java index 0128758d4..570d3c646 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/JVMArgumentActionLogicTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/JVMArgumentActionLogicTest.java @@ -17,8 +17,8 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.*; import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class JVMArgumentActionLogicTest extends AbstractProvisioningTest { @@ -33,10 +33,11 @@ public class JVMArgumentActionLogicTest extends AbstractProvisioningTest { tempDir.mkdirs(); parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); Properties profileProperties = new Properties(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, getTempFolder().toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); InstallableUnitOperand operand = new InstallableUnitOperand(null, createIU("test")); touchpoint.initializePhase(null, profile, "test", parameters); parameters.put("iu", operand.second()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/LinkActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/LinkActionTest.java index a500d0949..374def60f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/LinkActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/LinkActionTest.java @@ -16,13 +16,13 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.LinkAction; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.ArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; +import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -41,13 +41,14 @@ public class LinkActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); File zipSource = getTestData("1.0", "/testData/nativeTouchpoint/a.zip"); File zipTarget = new File(installFolder, "a.zip"); copy("2.0", zipSource, zipTarget); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -71,9 +72,9 @@ public class LinkActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File dirBundleSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/directoryBased_1.0.0"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -88,6 +89,7 @@ public class LinkActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -115,9 +117,9 @@ public class LinkActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File dirBundleSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/directoryBased_1.0.0"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -132,6 +134,7 @@ public class LinkActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java index 3e9393493..01affcd21 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java @@ -19,13 +19,13 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstant import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.MarkStartedAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -45,9 +45,9 @@ public class MarkStartedActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -61,6 +61,7 @@ public class MarkStartedActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -90,9 +91,9 @@ public class MarkStartedActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -106,6 +107,7 @@ public class MarkStartedActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -138,9 +140,9 @@ public class MarkStartedActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi.fragment_1.0.0.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -154,6 +156,7 @@ public class MarkStartedActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveJVMArgumentActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveJVMArgumentActionTest.java index b6fc1813d..b4ade84a9 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveJVMArgumentActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveJVMArgumentActionTest.java @@ -13,8 +13,8 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.RemoveJVMArgumentAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class RemoveJVMArgumentActionTest extends AbstractProvisioningTest { @@ -29,10 +29,11 @@ public class RemoveJVMArgumentActionTest extends AbstractProvisioningTest { public void testExecuteUndo() { Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); Properties profileProperties = new Properties(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, getTempFolder().toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); InstallableUnitOperand operand = new InstallableUnitOperand(null, createIU("test")); touchpoint.initializePhase(null, profile, "test", parameters); parameters.put("iu", operand.second()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveProgramArgumentActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveProgramArgumentActionTest.java index 61fe448be..d8741c2ec 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveProgramArgumentActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveProgramArgumentActionTest.java @@ -17,13 +17,13 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.RemoveProgramArgumentAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -40,10 +40,11 @@ public class RemoveProgramArgumentActionTest extends AbstractProvisioningTest { public void testExecuteUndo() { Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); Properties profileProperties = new Properties(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, getTempFolder().toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); InstallableUnitOperand operand = new InstallableUnitOperand(null, createIU("test")); touchpoint.initializePhase(null, profile, "test", parameters); parameters.put("iu", operand.second()); @@ -70,9 +71,9 @@ public class RemoveProgramArgumentActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -86,6 +87,7 @@ public class RemoveProgramArgumentActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -119,15 +121,15 @@ public class RemoveProgramArgumentActionTest extends AbstractProvisioningTest { keyAction.undo(keyParameters); assertTrue(Arrays.asList(manipulator.getLauncherData().getProgramArgs()).contains(resolvedArtifact)); } - + public void testExecuteUndoWithArtifactLocation() { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -141,6 +143,7 @@ public class RemoveProgramArgumentActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveRepositoryActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveRepositoryActionTest.java index 47be8b652..bf11c9bde 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveRepositoryActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveRepositoryActionTest.java @@ -14,8 +14,9 @@ import java.net.URI; import java.util.HashMap; import java.util.Map; import org.eclipse.core.runtime.IStatus; +import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.RemoveRepositoryAction; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.IRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** @@ -31,6 +32,7 @@ public class RemoveRepositoryActionTest extends AbstractProvisioningTest { */ private Map getValidArguments() { Map args = new HashMap(); + args.put(ActionConstants.PARM_AGENT, getAgent()); args.put("location", TEST_LOCATION); args.put("type", Integer.toString(IRepository.TYPE_ARTIFACT)); args.put("enabled", "true"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveSourceBundleActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveSourceBundleActionTest.java index c21322a94..e62dde8cb 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveSourceBundleActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveSourceBundleActionTest.java @@ -18,13 +18,13 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.*; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.RemoveSourceBundleAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -44,9 +44,9 @@ public class RemoveSourceBundleActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi.source_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -60,6 +60,7 @@ public class RemoveSourceBundleActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetFrameworkDependentPropertyActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetFrameworkDependentPropertyActionTest.java index bb6413cc4..fd3f3a0ef 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetFrameworkDependentPropertyActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetFrameworkDependentPropertyActionTest.java @@ -15,8 +15,8 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.SetProgramPropertyAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SetFrameworkDependentPropertyActionTest extends AbstractProvisioningTest { @@ -31,10 +31,11 @@ public class SetFrameworkDependentPropertyActionTest extends AbstractProvisionin public void testExecuteUndo() { Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); Properties profileProperties = new Properties(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, getTempFolder().toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); InstallableUnitOperand operand = new InstallableUnitOperand(null, createIU("test")); touchpoint.initializePhase(null, profile, "test", parameters); parameters.put("iu", operand.second()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetFrameworkIndependentPropertyActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetFrameworkIndependentPropertyActionTest.java index 0e6035650..81def3ffa 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetFrameworkIndependentPropertyActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetFrameworkIndependentPropertyActionTest.java @@ -15,8 +15,8 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.SetProgramPropertyAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SetFrameworkIndependentPropertyActionTest extends AbstractProvisioningTest { @@ -31,10 +31,11 @@ public class SetFrameworkIndependentPropertyActionTest extends AbstractProvision public void testExecuteUndo() { Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); Properties profileProperties = new Properties(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, getTempFolder().toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); InstallableUnitOperand operand = new InstallableUnitOperand(null, createIU("test")); touchpoint.initializePhase(null, profile, "test", parameters); parameters.put("iu", operand.second()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetLauncherNameActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetLauncherNameActionTest.java index e441465cb..8e7c5622d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetLauncherNameActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetLauncherNameActionTest.java @@ -15,8 +15,8 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstant import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.SetLauncherNameAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class SetLauncherNameActionTest extends AbstractProvisioningTest { @@ -31,10 +31,11 @@ public class SetLauncherNameActionTest extends AbstractProvisioningTest { public void testExecuteUndo() { Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); Properties profileProperties = new Properties(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, getTempFolder().toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); InstallableUnitOperand operand = new InstallableUnitOperand(null, createIU("test")); touchpoint.initializePhase(null, profile, "test", parameters); parameters.put(ActionConstants.PARM_PROFILE, profile); @@ -57,13 +58,14 @@ public class SetLauncherNameActionTest extends AbstractProvisioningTest { public void testEmptyName() { Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); File tempFolder = getTempFolder(); Properties profileProperties = new Properties(); profileProperties.put(IProfile.PROP_INSTALL_FOLDER, tempFolder.toString()); profileProperties.put(IProfile.PROP_ENVIRONMENTS, "osgi.ws=cocoa,osgi.os=macosx,osgi.arch=x86"); - IProfile profile = createProfile("launcherNameProfile", null, profileProperties); + IProfile profile = createProfile("launcherNameProfile", profileProperties); InstallableUnitOperand operand = new InstallableUnitOperand(null, createIU("test")); touchpoint.initializePhase(null, profile, "test", parameters); @@ -87,7 +89,7 @@ public class SetLauncherNameActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); profileProperties.put(IProfile.PROP_INSTALL_FOLDER, tempFolder.toString()); profileProperties.put(IProfile.PROP_ENVIRONMENTS, "osgi.ws=win32,osgi.os=win32,osgi.arch=x86"); - IProfile profile = createProfile("changeNameProfile", null, profileProperties); + IProfile profile = createProfile("changeNameProfile", profileProperties); //profile will start using "eclipse" by default, give it some content and see if it //survives a name change. @@ -98,6 +100,7 @@ public class SetLauncherNameActionTest extends AbstractProvisioningTest { writeBuffer(eclipseIni, ini); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); InstallableUnitOperand operand = new InstallableUnitOperand(null, createIU("test")); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetProgramPropertyActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetProgramPropertyActionTest.java index d8fe777ea..b7b1a7112 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetProgramPropertyActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetProgramPropertyActionTest.java @@ -17,13 +17,13 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.SetProgramPropertyAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -40,10 +40,11 @@ public class SetProgramPropertyActionTest extends AbstractProvisioningTest { public void testExecuteUndo() { Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); Properties profileProperties = new Properties(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, getTempFolder().toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); InstallableUnitOperand operand = new InstallableUnitOperand(null, createIU("test")); touchpoint.initializePhase(null, profile, "test", parameters); parameters.put("iu", operand.second()); @@ -70,9 +71,9 @@ public class SetProgramPropertyActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -86,6 +87,7 @@ public class SetProgramPropertyActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -126,9 +128,9 @@ public class SetProgramPropertyActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -142,6 +144,7 @@ public class SetProgramPropertyActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java index af5b7f8f5..a86555eb2 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java @@ -19,13 +19,13 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstant import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.SetStartLevelAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -45,9 +45,9 @@ public class SetStartLevelActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -61,6 +61,7 @@ public class SetStartLevelActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -90,9 +91,9 @@ public class SetStartLevelActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -106,6 +107,7 @@ public class SetStartLevelActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); @@ -138,9 +140,9 @@ public class SetStartLevelActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi.fragment_1.0.0.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -154,6 +156,7 @@ public class SetStartLevelActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallBundleActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallBundleActionTest.java index 0f1dca7d1..14c380d54 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallBundleActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallBundleActionTest.java @@ -19,13 +19,13 @@ import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstant import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.UninstallBundleAction; import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo; import org.eclipse.equinox.internal.provisional.frameworkadmin.Manipulator; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.service.resolver.BundleDescription; @@ -45,9 +45,9 @@ public class UninstallBundleActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File osgiSource = getTestData("1.0", "/testData/eclipseTouchpoint/bundles/org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar"); File targetPlugins = new File(installFolder, "plugins"); assertTrue(targetPlugins.mkdir()); @@ -61,6 +61,7 @@ public class UninstallBundleActionTest extends AbstractProvisioningTest { bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallFeatureActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallFeatureActionTest.java index 8ba22cc83..51a182a9f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallFeatureActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallFeatureActionTest.java @@ -11,19 +11,21 @@ package org.eclipse.equinox.p2.tests.touchpoint.eclipse; import java.io.File; import java.net.URI; import java.util.*; +import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor; import org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureParser; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.*; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.UninstallFeatureAction; import org.eclipse.equinox.internal.p2.update.Site; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.publisher.PublisherInfo; import org.eclipse.equinox.p2.publisher.eclipse.Feature; import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction; +import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; +import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; @@ -46,9 +48,9 @@ public class UninstallFeatureActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); profileProperties.setProperty(IProfile.PROP_CACHE, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); - IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(profile); + IFileArtifactRepository bundlePool = Util.getBundlePoolRepository(getAgent(), profile); File featureSource = getTestData("1.0", "/testData/eclipseTouchpoint/features/org.eclipse.rcp_3.3.0.v20070607-8y8eE8NEbsN3X_fjWS8HPNG"); File targetPlugins = new File(installFolder, "features"); assertTrue(targetPlugins.mkdir()); @@ -59,13 +61,14 @@ public class UninstallFeatureActionTest extends AbstractProvisioningTest { Feature feature = parser.parse(featureTarget); IArtifactKey key = FeaturesAction.createFeatureArtifactKey(feature.getId(), feature.getVersion()); - IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, featureTarget); - ((ArtifactDescriptor) descriptor).setRepositoryProperty("artifact.folder", Boolean.TRUE.toString()); + IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(bundlePool, key, featureTarget); + ((SimpleArtifactDescriptor) descriptor).setRepositoryProperty("artifact.folder", Boolean.TRUE.toString()); IInstallableUnit iu = FeaturesAction.createFeatureJarIU(feature, new PublisherInfo()); bundlePool.addDescriptor(descriptor); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); EclipseTouchpoint touchpoint = new EclipseTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UtilTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UtilTest.java index e1b3bfe17..1b46c577f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UtilTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UtilTest.java @@ -12,19 +12,17 @@ package org.eclipse.equinox.p2.tests.touchpoint.eclipse; import java.io.File; import java.net.MalformedURLException; -import java.net.URISyntaxException; import java.util.Collections; import java.util.Properties; import junit.framework.Test; import junit.framework.TestSuite; -import org.eclipse.core.runtime.URIUtil; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Activator; import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util; -import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.ITouchpointData; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; +import org.eclipse.equinox.p2.core.IAgentLocation; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.ITouchpointData; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; /** @@ -47,24 +45,20 @@ public class UtilTest extends AbstractProvisioningTest { public void testDefaultBundlePool() { IProfile profile = createProfile("test"); - AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(Activator.getContext(), AgentLocation.class.getName()); - try { - assertEquals(URIUtil.toURI(agentLocation.getDataArea("org.eclipse.equinox.p2.touchpoint.eclipse")), Util.getBundlePoolLocation(profile)); - } catch (URISyntaxException e) { - fail("0.99", e); - } + IAgentLocation agentLocation = (IAgentLocation) ServiceHelper.getService(Activator.getContext(), IAgentLocation.class.getName()); + assertEquals(agentLocation.getDataArea("org.eclipse.equinox.p2.touchpoint.eclipse"), Util.getBundlePoolLocation(getAgent(), profile)); } public void testExplicitBundlePool() throws MalformedURLException { Properties props = new Properties(); File cacheDir = new File(System.getProperty("java.io.tmpdir"), "cache"); props.put(IProfile.PROP_CACHE, cacheDir.toString()); - IProfile profile = createProfile("test", null, props); - assertEquals(cacheDir.toURL().toExternalForm(), Util.getBundlePoolLocation(profile).toString()); + IProfile profile = createProfile("test", props); + assertEquals(cacheDir.toURL().toExternalForm(), Util.getBundlePoolLocation(getAgent(), profile).toString()); } public void testMissingManifest() { ITouchpointData emptyData = MetadataFactory.createTouchpointData(Collections.EMPTY_MAP); - assertNull(Util.getManifest(new ITouchpointData[] {emptyData})); + assertNull(Util.getManifest(Collections.singletonList(emptyData))); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/ChmodActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/ChmodActionTest.java index a929fbc32..f567c88a3 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/ChmodActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/ChmodActionTest.java @@ -17,7 +17,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.touchpoint.natives.NativeTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ChmodAction; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class ChmodActionTest extends AbstractProvisioningTest { @@ -34,7 +34,7 @@ public class ChmodActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("testExecuteUndo", null, profileProperties); + IProfile profile = createProfile("testExecuteUndo", profileProperties); File zipSource = getTestData("1.0", "/testData/nativeTouchpoint/a.zip"); File zipTarget = new File(installFolder, "a.zip"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CleanupzipActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CleanupzipActionTest.java index 14c1d9400..403013abb 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CleanupzipActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CleanupzipActionTest.java @@ -15,10 +15,12 @@ import java.util.*; import org.eclipse.equinox.internal.p2.touchpoint.natives.IBackupStore; import org.eclipse.equinox.internal.p2.touchpoint.natives.NativeTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.*; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; @@ -45,7 +47,7 @@ public class CleanupzipActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("testExecuteUndo", null, profileProperties); + IProfile profile = createProfile("testExecuteUndo", profileProperties); File zipSource = getTestData("1.0", "/testData/nativeTouchpoint/a.zip"); File zipTarget = new File(installFolder, "a.zip"); @@ -92,7 +94,7 @@ public class CleanupzipActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("testExecuteUndoWhereInstallFolderIsDifferent", null, profileProperties); + IProfile profile = createProfile("testExecuteUndoWhereInstallFolderIsDifferent", profileProperties); File zipSource = getTestData("1.0", "/testData/nativeTouchpoint/a.zip"); File zipTarget = new File(installFolder, "a.zip"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CollectActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CollectActionTest.java index a9c30171f..4adaf372f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CollectActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CollectActionTest.java @@ -12,15 +12,17 @@ package org.eclipse.equinox.p2.tests.touchpoint.natives; import java.io.File; import java.util.*; +import org.eclipse.equinox.internal.p2.engine.phases.Collect; import org.eclipse.equinox.internal.p2.touchpoint.natives.NativeTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.CollectAction; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.engine.phases.Collect; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; @@ -38,7 +40,7 @@ public class CollectActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); // File zipSource = getTestData("1.0", "/testData/nativeTouchpoint/a.zip"); // File zipTarget = new File(installFolder, "a.zip"); @@ -53,8 +55,9 @@ public class CollectActionTest extends AbstractProvisioningTest { IInstallableUnit iu = MetadataFactory.createInstallableUnit(iuDesc); Map parameters = new HashMap(); + parameters.put(ActionConstants.PARM_AGENT, getAgent()); parameters.put(ActionConstants.PARM_PROFILE, profile); - parameters.put(Collect.PARM_ARTIFACT_REQUESTS, new ArrayList()); + parameters.put(Collect.PARM_ARTIFACT_REQUESTS, new ArrayList<IArtifactRequest[]>()); NativeTouchpoint touchpoint = new NativeTouchpoint(); touchpoint.initializePhase(null, profile, "test", parameters); InstallableUnitOperand operand = new InstallableUnitOperand(null, iu); @@ -63,7 +66,7 @@ public class CollectActionTest extends AbstractProvisioningTest { parameters.put(ActionConstants.PARM_OPERAND, operand); parameters = Collections.unmodifiableMap(parameters); - List requests = (List) parameters.get(Collect.PARM_ARTIFACT_REQUESTS); + List<IArtifactRequest[]> requests = (List<IArtifactRequest[]>) parameters.get(Collect.PARM_ARTIFACT_REQUESTS); assertFalse(hasRequest(requests, key)); CollectAction action = new CollectAction(); action.execute(parameters); @@ -73,9 +76,8 @@ public class CollectActionTest extends AbstractProvisioningTest { assertTrue(hasRequest(requests, key)); } - private boolean hasRequest(List requests, IArtifactKey key) { - for (Iterator iterator = requests.iterator(); iterator.hasNext();) { - IArtifactRequest[] request = (IArtifactRequest[]) iterator.next(); + private boolean hasRequest(List<IArtifactRequest[]> requests, IArtifactKey key) { + for (IArtifactRequest[] request : requests) { for (int i = 0; i < request.length; i++) { if (key.equals(request[i].getArtifactKey())) return true; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CopyActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CopyActionTest.java index 23b6c3f89..09f20a924 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CopyActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CopyActionTest.java @@ -15,10 +15,12 @@ import java.util.*; import org.eclipse.equinox.internal.p2.touchpoint.natives.NativeTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.CopyAction; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; @@ -204,7 +206,7 @@ public class CopyActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); File source = getTestData("1.0", sourceName); File target = new File(installFolder, targetName); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/LinkActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/LinkActionTest.java index 65f219657..c194ad143 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/LinkActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/LinkActionTest.java @@ -15,7 +15,7 @@ import java.util.*; import org.eclipse.equinox.internal.p2.touchpoint.natives.NativeTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.LinkAction; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class LinkActionTest extends AbstractProvisioningTest { @@ -32,7 +32,7 @@ public class LinkActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); File zipSource = getTestData("1.0", "/testData/nativeTouchpoint/a.zip"); File zipTarget = new File(installFolder, "a.zip"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/MkdirActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/MkdirActionTest.java index 85a709e3a..f69301c96 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/MkdirActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/MkdirActionTest.java @@ -13,7 +13,7 @@ import java.util.*; import org.eclipse.equinox.internal.p2.touchpoint.natives.NativeTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.MkdirAction; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class MkdirActionTest extends AbstractProvisioningTest { @@ -30,7 +30,7 @@ public class MkdirActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); Map parameters = new HashMap(); parameters.put(ActionConstants.PARM_PROFILE, profile); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/NativeTouchpointTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/NativeTouchpointTest.java index 0247557e1..f91d3571b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/NativeTouchpointTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/NativeTouchpointTest.java @@ -13,7 +13,7 @@ package org.eclipse.equinox.p2.tests.touchpoint.natives; import java.io.File; import java.util.*; import org.eclipse.equinox.internal.p2.touchpoint.natives.NativeTouchpoint; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class NativeTouchpointTest extends AbstractProvisioningTest { @@ -39,7 +39,7 @@ public class NativeTouchpointTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - profile = createProfile("test", null, profileProperties); + profile = createProfile("test", profileProperties); touchpoint.initializePhase(null, profile, "test", parameters); touchpoint.completePhase(null, profile, "test", parameters); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/RemoveActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/RemoveActionTest.java index 1191675e9..b3a96cae9 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/RemoveActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/RemoveActionTest.java @@ -17,7 +17,7 @@ import org.eclipse.equinox.internal.p2.touchpoint.natives.IBackupStore; import org.eclipse.equinox.internal.p2.touchpoint.natives.NativeTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.RemoveAction; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class RemoveActionTest extends AbstractProvisioningTest { @@ -34,7 +34,7 @@ public class RemoveActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("testExecuteUndo", null, profileProperties); + IProfile profile = createProfile("testExecuteUndo", profileProperties); Map parameters = new HashMap(); parameters.put(ActionConstants.PARM_PROFILE, profile); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/RmdirActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/RmdirActionTest.java index 862fa4ef8..be31d0cb6 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/RmdirActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/RmdirActionTest.java @@ -17,7 +17,7 @@ import org.eclipse.equinox.internal.p2.touchpoint.natives.IBackupStore; import org.eclipse.equinox.internal.p2.touchpoint.natives.NativeTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.RmdirAction; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class RmdirActionTest extends AbstractProvisioningTest { @@ -34,7 +34,7 @@ public class RmdirActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("testExecuteUndo", null, profileProperties); + IProfile profile = createProfile("testExecuteUndo", profileProperties); Map parameters = new HashMap(); parameters.put(ActionConstants.PARM_PROFILE, profile); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/UnzipActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/UnzipActionTest.java index e5f8c9d1f..4e2411e44 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/UnzipActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/UnzipActionTest.java @@ -14,10 +14,12 @@ import org.eclipse.equinox.internal.p2.touchpoint.natives.IBackupStore; import org.eclipse.equinox.internal.p2.touchpoint.natives.NativeTouchpoint; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.ActionConstants; import org.eclipse.equinox.internal.p2.touchpoint.natives.actions.UnzipAction; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; +import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory; import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.engine.InstallableUnitOperand; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; @@ -44,7 +46,7 @@ public class UnzipActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("test", null, profileProperties); + IProfile profile = createProfile("test", profileProperties); File zipSource = getTestData("1.0", "/testData/nativeTouchpoint/a.zip"); File zipTarget = new File(installFolder, "a.zip"); @@ -86,7 +88,7 @@ public class UnzipActionTest extends AbstractProvisioningTest { Properties profileProperties = new Properties(); File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); - IProfile profile = createProfile("testExecuteUndoBackup", null, profileProperties); + IProfile profile = createProfile("testExecuteUndoBackup", profileProperties); File zipSource = getTestData("1.0", "/testData/nativeTouchpoint/a.zip"); File zipTarget = new File(installFolder, "a.zip"); @@ -147,7 +149,7 @@ public class UnzipActionTest extends AbstractProvisioningTest { File installFolder = getTempFolder(); profileProperties.setProperty(IProfile.PROP_INSTALL_FOLDER, installFolder.toString()); final String profileId = "Test:With\\Sym/bols"; - IProfile profile = createProfile(profileId, null, profileProperties); + IProfile profile = createProfile(profileId, profileProperties); File zipSource = getTestData("1.0", "/testData/nativeTouchpoint/a.zip"); File zipTarget = new File(installFolder, "a.zip"); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatechecker/UpdateCheckerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatechecker/UpdateCheckerTest.java index d59e18846..92bf37739 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatechecker/UpdateCheckerTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatechecker/UpdateCheckerTest.java @@ -10,21 +10,20 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.updatechecker; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.core.runtime.IStatus; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.publisher.Activator; import org.eclipse.equinox.internal.provisional.p2.director.IDirector; import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest; -import org.eclipse.equinox.internal.provisional.p2.engine.IProfile; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.internal.provisional.p2.updatechecker.IUpdateChecker; import org.eclipse.equinox.internal.provisional.p2.updatechecker.UpdateEvent; +import org.eclipse.equinox.p2.engine.IProfile; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; -import org.osgi.framework.Bundle; /** * Tests for API of {@link IUpdateChecker}. @@ -42,11 +41,11 @@ public class UpdateCheckerTest extends AbstractProvisioningTest { @Override protected void setUp() throws Exception { super.setUp(); - TestActivator.getBundle("org.eclipse.equinox.p2.updatechecker").start(Bundle.START_TRANSIENT); + startBundle(TestActivator.getBundle("org.eclipse.equinox.p2.updatechecker")); String id = "toInstall." + getName(); - toInstallIU = createIU(id, new Version(1, 0, 0)); - IUpdateDescriptor updateDescriptor = createUpdateDescriptor(id, new Version(2, 0, 0)); - update = createIU(id, new Version(2, 0, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, true, updateDescriptor, null); + toInstallIU = createIU(id, Version.createOSGi(1, 0, 0)); + IUpdateDescriptor updateDescriptor = createUpdateDescriptor(id, Version.createOSGi(2, 0, 0)); + update = createIU(id, Version.createOSGi(2, 0, 0), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, true, updateDescriptor, null); IInstallableUnit[] allUnits = new IInstallableUnit[] {toInstallIU, update}; IInstallableUnit[] toInstallArray = new IInstallableUnit[] {toInstallIU}; diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryXMLActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryXMLActionTest.java index 1ef0aa252..1adb31c54 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryXMLActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryXMLActionTest.java @@ -11,14 +11,13 @@ package org.eclipse.equinox.p2.tests.updatesite; import java.io.File; import java.net.URI; -import java.util.Collection; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.updatesite.CategoryXMLAction; -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.IUPropertyQuery; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.CategoryQuery; import org.eclipse.equinox.p2.publisher.*; import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction; +import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.tests.*; /** @@ -46,11 +45,9 @@ public class CategoryXMLActionTest extends AbstractProvisioningTest { } public void testCategoryCreation() throws Exception { - IUPropertyQuery categoryQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_CATEGORY, Boolean.TRUE.toString()); - Collection result = actionResult.query(categoryQuery, new Collector(), new NullProgressMonitor()).toCollection(); - assertEquals("1.0", 1, result.size()); + IQueryResult result = actionResult.query(new CategoryQuery(), new NullProgressMonitor()); + assertEquals("1.0", 1, queryResultSize(result)); IInstallableUnit iu = (IInstallableUnit) result.iterator().next(); assertEquals("1.1", "Test Category Label", iu.getProperty(IInstallableUnit.PROP_NAME)); } - } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/DoesNotCacheStaleData.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/DoesNotCacheStaleData.java index 7d1dbc9eb..c25f90b1b 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/DoesNotCacheStaleData.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/DoesNotCacheStaleData.java @@ -14,13 +14,13 @@ import java.io.File; import java.net.URI; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.URIUtil; +import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepositoryFactory; +import org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory; import org.eclipse.equinox.internal.p2.updatesite.artifact.UpdateSiteArtifactRepositoryFactory; import org.eclipse.equinox.internal.p2.updatesite.metadata.UpdateSiteMetadataRepositoryFactory; -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.repository.IMetadataRepository; -import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.SimpleArtifactRepositoryFactory; -import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.SimpleMetadataRepositoryFactory; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; public class DoesNotCacheStaleData extends AbstractProvisioningTest { @@ -39,7 +39,9 @@ public class DoesNotCacheStaleData extends AbstractProvisioningTest { assertNotNull(e); assertTrue(new File(URIUtil.toFile(UpdateSiteMetadataRepositoryFactory.getLocalRepositoryLocation(siteURI)), "content.xml").exists()); try { - IMetadataRepository repo = new SimpleMetadataRepositoryFactory().load(f.toURI(), 0, new NullProgressMonitor()); + final SimpleMetadataRepositoryFactory simpleFactory = new SimpleMetadataRepositoryFactory(); + simpleFactory.setAgent(getAgent()); + IMetadataRepository repo = simpleFactory.load(f.toURI(), 0, new NullProgressMonitor()); assertEquals("0", repo.getProperties().get("site.checksum")); } catch (ProvisionException e1) { fail("3.0", e1); @@ -60,7 +62,9 @@ public class DoesNotCacheStaleData extends AbstractProvisioningTest { assertNotNull(e); assertTrue(new File(URIUtil.toFile(UpdateSiteMetadataRepositoryFactory.getLocalRepositoryLocation(siteURI)), "artifacts.xml").exists()); try { - IArtifactRepository repo = new SimpleArtifactRepositoryFactory().load(f.toURI(), 0, new NullProgressMonitor()); + final SimpleArtifactRepositoryFactory simpleFactory = new SimpleArtifactRepositoryFactory(); + simpleFactory.setAgent(getAgent()); + IArtifactRepository repo = simpleFactory.load(f.toURI(), 0, new NullProgressMonitor()); assertEquals("0", repo.getProperties().get("site.checksum")); } catch (ProvisionException e1) { fail("3.0", e1); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/LocalUpdatesiteTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/LocalUpdatesiteTest.java index 0075da28c..ea5a1a9ed 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/LocalUpdatesiteTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/LocalUpdatesiteTest.java @@ -14,10 +14,11 @@ import java.io.IOException; import java.util.Iterator; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.equinox.internal.p2.updatesite.UpdateSitePublisherApplication; -import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; -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.p2.core.ProvisionException; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.query.CategoryQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestData; @@ -39,7 +40,6 @@ public class LocalUpdatesiteTest extends AbstractProvisioningTest { } public void testCategoryQualifier() throws IOException, ProvisionException { - Query categoryQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_CATEGORY, Boolean.toString(true)); File siteSource = TestData.getFile("updatesite", "SiteXMLActionTest"); UpdateSitePublisherApplication application = new UpdateSitePublisherApplication(); try { @@ -48,8 +48,8 @@ public class LocalUpdatesiteTest extends AbstractProvisioningTest { fail("0.99"); } IMetadataRepository repository = getMetadataRepositoryManager().loadRepository(repoLocation.toURI(), new NullProgressMonitor()); - Collector results = repository.query(categoryQuery, new Collector(), new NullProgressMonitor()); - assertEquals("1.0", 1, results.size()); + IQueryResult results = repository.query(new CategoryQuery(), new NullProgressMonitor()); + assertEquals("1.0", 1, queryResultSize(results)); Iterator iter = results.iterator(); while (iter.hasNext()) { IInstallableUnit unit = (IInstallableUnit) iter.next(); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java index 71bc55d14..a2249c29d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java @@ -17,13 +17,14 @@ import java.util.Iterator; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.URIUtil; import org.eclipse.equinox.internal.p2.updatesite.SiteXMLAction; -import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.internal.provisional.p2.metadata.IProvidedCapability; -import org.eclipse.equinox.internal.provisional.p2.metadata.query.*; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepository; -import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.RepositoryReference; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.equinox.p2.metadata.IProvidedCapability; +import org.eclipse.equinox.p2.metadata.query.CategoryQuery; import org.eclipse.equinox.p2.publisher.*; import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction; +import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.spi.RepositoryReference; import org.eclipse.equinox.p2.tests.*; /** @@ -50,8 +51,7 @@ public class SiteXMLActionTest extends AbstractProvisioningTest { } public void testQualifier() { - Query categoryQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_CATEGORY, Boolean.toString(true)); - Collector results = actionResult.query(categoryQuery, new Collector(), new NullProgressMonitor()); + IQueryResult results = actionResult.query(new CategoryQuery(), new NullProgressMonitor()); Iterator iter = results.iterator(); while (iter.hasNext()) { IInstallableUnit unit = (IInstallableUnit) iter.next(); @@ -59,10 +59,10 @@ public class SiteXMLActionTest extends AbstractProvisioningTest { assertTrue("1.0", unit.getId().startsWith(sitelocation)); assertEquals("2.0", "Test Category Label", unit.getProperty(IInstallableUnit.PROP_NAME)); - IProvidedCapability[] provided = unit.getProvidedCapabilities(); - assertEquals(1, provided.length); - assertTrue(provided[0].getName().startsWith(sitelocation)); - assertEquals(provided[0].getVersion(), unit.getVersion()); + Collection<IProvidedCapability> provided = unit.getProvidedCapabilities(); + assertEquals(1, provided.size()); + assertTrue(provided.iterator().next().getName().startsWith(sitelocation)); + assertEquals(provided.iterator().next().getVersion(), unit.getVersion()); } } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java index c343c09b2..a2d07dd06 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java @@ -10,14 +10,14 @@ *******************************************************************************/ package org.eclipse.equinox.p2.tests.updatesite; -import org.eclipse.equinox.internal.provisional.p2.metadata.Version; -import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange; +import org.eclipse.equinox.p2.metadata.Version; +import org.eclipse.equinox.p2.metadata.VersionRange; import java.io.*; import java.lang.reflect.Field; import java.net.URI; import java.net.URISyntaxException; -import java.util.Map; +import java.util.*; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import junit.framework.Test; @@ -28,19 +28,21 @@ import org.eclipse.equinox.internal.p2.artifact.repository.RawMirrorRequest; import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.metadata.ArtifactKey; +import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; import org.eclipse.equinox.internal.p2.updatesite.SiteFeature; import org.eclipse.equinox.internal.p2.updatesite.UpdateSite; import org.eclipse.equinox.internal.p2.updatesite.artifact.UpdateSiteArtifactRepository; -import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*; -import org.eclipse.equinox.internal.provisional.p2.core.*; -import org.eclipse.equinox.internal.provisional.p2.metadata.*; -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.provisional.p2.repository.IRepository; -import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager; -import org.eclipse.equinox.internal.provisional.spi.p2.repository.AbstractRepository; +import org.eclipse.equinox.p2.core.ProvisionException; +import org.eclipse.equinox.p2.metadata.*; +import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery; +import org.eclipse.equinox.p2.query.IQueryResult; +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.metadata.IMetadataRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; +import org.eclipse.equinox.p2.repository.spi.AbstractRepository; import org.eclipse.equinox.p2.tests.AbstractProvisioningTest; import org.eclipse.equinox.p2.tests.TestActivator; import org.w3c.dom.*; @@ -575,7 +577,7 @@ public class UpdateSiteTest extends AbstractProvisioningTest { } public void testRepoWithFeatureWithNullUpdateURL() { - IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); assertNotNull(repoMan); File site = getTestData("Update site", "/testData/updatesite/missingUpdateURLFeature/"); IMetadataRepository metadataRepo = null; @@ -584,16 +586,16 @@ public class UpdateSiteTest extends AbstractProvisioningTest { } catch (ProvisionException e) { fail("Can't load repository missingUpdateURLFeature"); } - InstallableUnitQuery query = new InstallableUnitQuery("test.featurewithmissingupdateurl.feature.group", new Version("1.0.0")); - Collector result = metadataRepo.query(query, new Collector(), null); - assertEquals("1.0", 1, result.size()); + InstallableUnitQuery query = new InstallableUnitQuery("test.featurewithmissingupdateurl.feature.group", Version.create("1.0.0")); + IQueryResult result = metadataRepo.query(query, null); + assertEquals("1.0", 1, queryResultSize(result)); } /** * Tests that a feature requiring a bundle with no range is converted correctly. */ public void testBug243422() { - IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); assertNotNull(repoMan); File site = getTestData("Update site", "/testData/updatesite/UpdateSite243422/"); IMetadataRepository metadataRepo = null; @@ -602,20 +604,21 @@ public class UpdateSiteTest extends AbstractProvisioningTest { } catch (ProvisionException e) { fail("Can't load repository UpdateSite243422"); } - InstallableUnitQuery query = new InstallableUnitQuery("org.eclipse.jdt.astview.feature.feature.group", new Version("1.0.1")); - Collector result = metadataRepo.query(query, new Collector(), null); - assertEquals("1.0", 1, result.size()); + InstallableUnitQuery query = new InstallableUnitQuery("org.eclipse.jdt.astview.feature.feature.group", Version.create("1.0.1")); + IQueryResult result = metadataRepo.query(query, null); + assertEquals("1.0", 1, queryResultSize(result)); IInstallableUnit featureIU = (IInstallableUnit) result.iterator().next(); - IRequiredCapability[] required = featureIU.getRequiredCapabilities(); - for (int i = 0; i < required.length; i++) { - if (required[i].getName().equals("org.eclipse.ui.ide")) { - assertEquals("2.0", VersionRange.emptyRange, required[i].getRange()); + Collection<IRequirement> required = featureIU.getRequiredCapabilities(); + for (Iterator iterator = required.iterator(); iterator.hasNext();) { + IRequiredCapability req = (IRequiredCapability) iterator.next(); + if (req.getName().equals("org.eclipse.ui.ide")) { + assertEquals("2.0", VersionRange.emptyRange, req.getRange()); } } } public void testShortenVersionNumberInFeature() { - IArtifactRepositoryManager repoMan = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.class.getName()); + IArtifactRepositoryManager repoMan = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.SERVICE_NAME); assertNotNull(repoMan); File site = getTestData("Update site", "/testData/updatesite/240121/UpdateSite240121/"); IArtifactRepository artifactRepo = null; @@ -624,14 +627,12 @@ public class UpdateSiteTest extends AbstractProvisioningTest { } catch (ProvisionException e) { fail("Can't load repository UpdateSite240121"); } - IArtifactKey[] keys = artifactRepo.getArtifactKeys(); - for (int i = 0; i < keys.length; i++) { - if (keys[i].getId().equals("Plugin240121")) { - IStatus status = artifactRepo.getArtifact(artifactRepo.getArtifactDescriptors(keys[i])[0], new ByteArrayOutputStream(500), new NullProgressMonitor()); - if (!status.isOK()) - fail("Can't get the expected artifact:" + keys[i]); - } - } + IQueryResult keys = artifactRepo.query(new ArtifactKeyQuery(null, "Plugin240121", null), null); + assertEquals(1, queryResultSize(keys)); + IArtifactKey key = (IArtifactKey) keys.iterator().next(); + IStatus status = artifactRepo.getArtifact(artifactRepo.getArtifactDescriptors(key)[0], new ByteArrayOutputStream(500), new NullProgressMonitor()); + if (!status.isOK()) + fail("Can't get the expected artifact:" + key); } /** @@ -639,7 +640,7 @@ public class UpdateSiteTest extends AbstractProvisioningTest { * unzipping the feature on install. */ public void testFeatureJarUnzipInstruction() { - IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); File site = getTestData("0.1", "/testData/updatesite/site"); URI location = null; location = site.toURI(); @@ -650,12 +651,12 @@ public class UpdateSiteTest extends AbstractProvisioningTest { fail("1.99", e); return; } - Collector result = repository.query(new InstallableUnitQuery("test.feature.feature.jar"), new Collector(), getMonitor()); + IQueryResult result = repository.query(new InstallableUnitQuery("test.feature.feature.jar"), getMonitor()); assertTrue("1.0", !result.isEmpty()); IInstallableUnit unit = (IInstallableUnit) result.iterator().next(); - ITouchpointData[] data = unit.getTouchpointData(); - assertEquals("1.1", 1, data.length); - Map instructions = data[0].getInstructions(); + List<ITouchpointData> data = unit.getTouchpointData(); + assertEquals("1.1", 1, data.size()); + Map instructions = data.get(0).getInstructions(); assertEquals("1.2", 1, instructions.size()); assertEquals("1.3", "true", ((ITouchpointInstruction) instructions.get("zipped")).getBody()); } @@ -669,7 +670,7 @@ public class UpdateSiteTest extends AbstractProvisioningTest { URI testUpdateSite = new URI("http://download.eclipse.org/test/updatesite/"); URI testDiscoverySite = new URI("http://download.eclipse.org/test/discoverysite"); - IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); assertNotNull(manager); manager.removeRepository(testUpdateSite); manager.removeRepository(testDiscoverySite); @@ -691,7 +692,7 @@ public class UpdateSiteTest extends AbstractProvisioningTest { File site = getTestData("0.1", "/testData/updatesite/site"); URI siteURI = site.toURI(); - IMetadataRepositoryManager metadataRepoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName()); + IMetadataRepositoryManager metadataRepoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.SERVICE_NAME); assertNotNull(metadataRepoMan); URI[] knownRepos = metadataRepoMan.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL); @@ -717,7 +718,7 @@ public class UpdateSiteTest extends AbstractProvisioningTest { File site = getTestData("0.1", "/testData/updatesite/site"); URI siteURI = site.toURI(); - IArtifactRepositoryManager artifactRepoMan = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.class.getName()); + IArtifactRepositoryManager artifactRepoMan = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.SERVICE_NAME); assertNotNull(artifactRepoMan); URI[] knownRepos = artifactRepoMan.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL); @@ -750,12 +751,12 @@ public class UpdateSiteTest extends AbstractProvisioningTest { } catch (ProvisionException e) { fail("0.2", e); } - IArtifactKey key = new ArtifactKey("org.eclipse.update.feature", "test.feature", new Version("1.0.0")); + IArtifactKey key = new ArtifactKey("org.eclipse.update.feature", "test.feature", Version.create("1.0.0")); IArtifactDescriptor[] descriptors = repo.getArtifactDescriptors(key); // Should have a packed & canonical version assertEquals(2, descriptors.length); - IArtifactDescriptor desc = "packed".equals(descriptors[0].getProperty("format")) ? descriptors[0] : descriptors[1]; + IArtifactDescriptor desc = IArtifactDescriptor.FORMAT_PACKED.equals(descriptors[0].getProperty(IArtifactDescriptor.FORMAT)) ? descriptors[0] : descriptors[1]; OutputStream out = null; try { out = new FileOutputStream(output); @@ -783,7 +784,7 @@ public class UpdateSiteTest extends AbstractProvisioningTest { File targetLocation = null; URI siteURI = getTestData("0.1", testDataLocation).toURI(); try { - IArtifactKey key = new ArtifactKey("osgi.bundle", "test.fragment", new Version("1.0.0")); + IArtifactKey key = new ArtifactKey("osgi.bundle", "test.fragment", Version.create("1.0.0")); // Load source repository IArtifactRepository sourceRepo = getArtifactRepositoryManager().loadRepository(siteURI, getMonitor()); @@ -800,7 +801,7 @@ public class UpdateSiteTest extends AbstractProvisioningTest { IArtifactDescriptor[] descriptors = sourceRepo.getArtifactDescriptors(key); IArtifactDescriptor descriptor = null; for (int i = 0; i < descriptors.length && descriptor == null; i++) - if ("packed".equals(descriptors[i].getProperty("format"))) + if (IArtifactDescriptor.FORMAT_PACKED.equals(descriptors[i].getProperty(IArtifactDescriptor.FORMAT))) descriptor = descriptors[i]; if (descriptor == null) |