Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hallgren2009-12-21 15:53:56 +0000
committerThomas Hallgren2009-12-21 15:53:56 +0000
commit15e3ce986978bc652bef61d34b54db2e262847f9 (patch)
tree0cf6f7f9fce9f4f64bc1bcab6c417f5f0fa5ab0a
parent3f81d92597298bcaff44455f6841ee4c415d2685 (diff)
downloadrt.equinox.p2-15e3ce986978bc652bef61d34b54db2e262847f9.tar.gz
rt.equinox.p2-15e3ce986978bc652bef61d34b54db2e262847f9.tar.xz
rt.equinox.p2-15e3ce986978bc652bef61d34b54db2e262847f9.zip
298023: Simplify the IQueryResult
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.common/src/org/eclipse/equinox/p2/common/TranslationSupport.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/AttachmentHelper.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/OperationGenerator.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/QueryableArray.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java62
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/rollback/FormerState.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java31
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Profile.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileWriter.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ISurrogateProfileHandler.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningPlan.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/LDAPQuery.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Collector.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQuery.java84
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQueryable.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/ContextQuery.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LatestIUVersionQuery.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LimitQuery.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/MatchQuery.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/PipedQuery.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQuery.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQueryResult.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherResult.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/QueryableFilterAdvice.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUResultFilterAdvice.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/RepositoryAnalyzer.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/All p2 UI tests.launch9
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementWrapperTest.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryDescriptorTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/TranslationSupportTests.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractAntProvisioningTest.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java95
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/MockQueryable.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/MirrorTaskTest.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/RepoTasksTests.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/AggregateQueryTest.java107
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CollectorTest.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java100
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery2.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/QueryTest.java78
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileMetadataRepositoryTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LatestIUTest.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest2.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AddIUProperty.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOrbit.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252682.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug254481dataSet1.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug254481dataSet2.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug255984.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271067.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271954.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug272251.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug278668.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationLargeConflict.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUProperties.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUPropertyRemoval.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/InclusionRuleTest.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/InclusionRuleTest2.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleSingleton.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NegationTesting.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState2.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PermissiveSlicerTest.java38
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ProvisioningPlanQueryTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SWTFragment.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/UpdateQueryTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java44
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/TestQueryReimplementation.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractReconcilerTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryXMLActionTest.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/LocalUpdatesiteTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ElementQueryDescriptor.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryableRepositoryManager.java49
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryLocationQuery.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ExistingIUInProfileAction.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SizeComputingWizardPage.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableProfileRegistry.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java10
140 files changed, 971 insertions, 894 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
index ec75e8051..79c5f1f4f 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
@@ -981,16 +981,15 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
}
public synchronized IQueryResult query(IQuery query, IProgressMonitor monitor) {
- Collector queryResult = new Collector();
if (monitor != null && monitor.isCanceled())
- return queryResult;
+ return Collector.EMPTY_COLLECTOR;
boolean excludeKeys = Boolean.TRUE.equals(query.getProperty(IArtifactRepository.QUERY_EXCLUDE_KEYS));
boolean excludeDescriptors = Boolean.TRUE.equals(query.getProperty(IArtifactRepository.QUERY_EXCLUDE_DESCRIPTORS));
if (excludeKeys && excludeDescriptors)
- return queryResult;
+ return Collector.EMPTY_COLLECTOR;
Iterator iterator = !excludeDescriptors ? new MappedCollectionIterator(artifactMap, !excludeKeys) : artifactMap.keySet().iterator();
- return query.perform(iterator, queryResult);
+ return query.perform(iterator);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.common/src/org/eclipse/equinox/p2/common/TranslationSupport.java b/bundles/org.eclipse.equinox.p2.common/src/org/eclipse/equinox/p2/common/TranslationSupport.java
index cb60d5a4b..a3ea2d835 100644
--- a/bundles/org.eclipse.equinox.p2.common/src/org/eclipse/equinox/p2/common/TranslationSupport.java
+++ b/bundles/org.eclipse.equinox.p2.common/src/org/eclipse/equinox/p2/common/TranslationSupport.java
@@ -177,7 +177,7 @@ public class TranslationSupport {
};
IQuery iuQuery = new PipedQuery(new IQuery[] {new FragmentQuery(), hostLocalizationQuery});
- Collector collected = iuQuery.perform(localizationFragments.iterator(), new Collector());
+ IQueryResult collected = iuQuery.perform(localizationFragments.iterator());
if (!collected.isEmpty()) {
String translation = null;
for (Iterator iter = collected.iterator(); iter.hasNext() && translation == null;) {
@@ -220,7 +220,7 @@ public class TranslationSupport {
private synchronized IQueryResult getLocalizationFragments(List localeVariants) {
if (fragmentSource == null) {
LogHelper.log(new Status(IStatus.ERROR, Activator.ID, "Profile registry unavailable. Default language will be used.", new RuntimeException())); //$NON-NLS-1$
- return new Collector();
+ return Collector.EMPTY_COLLECTOR;
}
SoftReference queryResultReference = (SoftReference) LocaleCollectorCache.get(locale);
diff --git a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
index b53aa9fab..8300d7f59 100644
--- a/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
+++ b/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java
@@ -19,7 +19,6 @@ import org.eclipse.equinox.internal.provisional.p2.director.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
import org.eclipse.equinox.p2.engine.*;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.query.IQuery;
import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
@@ -161,7 +160,7 @@ public class ProvisioningHelper {
}
if (queryable != null)
return queryable.query(query, monitor);
- return new Collector();
+ return Collector.EMPTY_COLLECTOR;
}
public static URI[] getMetadataRepositories() {
@@ -201,10 +200,9 @@ public class ProvisioningHelper {
IEngine engine = (IEngine) ServiceHelper.getService(Activator.getContext(), IEngine.SERVICE_NAME);
if (engine == null)
throw new ProvisionException("No director service found.");
- IInstallableUnit[] toInstall = (IInstallableUnit[]) units.toArray(IInstallableUnit.class);
ProvisioningContext context = new ProvisioningContext();
ProfileChangeRequest request = new ProfileChangeRequest(profile);
- request.addInstallableUnits(toInstall);
+ request.addInstallableUnits(units);
IProvisioningPlan result = planner.getProvisioningPlan(request, context, progress);
return PlanExecutionHelper.executePlan(result, engine, context, progress);
}
@@ -301,10 +299,9 @@ public class ProvisioningHelper {
IEngine engine = (IEngine) ServiceHelper.getService(Activator.getContext(), IEngine.SERVICE_NAME);
if (engine == null)
throw new ProvisionException("No engine service found.");
- IInstallableUnit[] toUninstall = (IInstallableUnit[]) units.toArray(IInstallableUnit.class);
ProvisioningContext context = new ProvisioningContext();
ProfileChangeRequest request = new ProfileChangeRequest(profile);
- request.removeInstallableUnits(toUninstall);
+ request.removeInstallableUnits(units);
IProvisioningPlan result = planner.getProvisioningPlan(request, context, progress);
return PlanExecutionHelper.executePlan(result, engine, context, progress);
}
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java
index 9cb6e50ae..14759ee99 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/Application.java
@@ -96,9 +96,9 @@ public class Application implements IApplication {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
markRoots(request, roots);
if (install) {
- request.addInstallableUnits((IInstallableUnit[]) roots.toArray(IInstallableUnit.class));
+ request.addInstallableUnits(roots);
} else {
- request.removeInstallableUnits((IInstallableUnit[]) roots.toArray(IInstallableUnit.class));
+ request.removeInstallableUnits(roots);
}
return request;
}
@@ -178,7 +178,7 @@ public class Application implements IApplication {
IProvisioningAgentProvider provider = (IProvisioningAgentProvider) ServiceHelper.getService(Activator.getContext(), IProvisioningAgentProvider.SERVICE_NAME);
agent = provider.createAgent(null);
}
- artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);;
+ artifactManager = (IArtifactRepositoryManager) agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
}
if (artifactManager == null) {
if (throwException)
@@ -413,9 +413,9 @@ public class Application implements IApplication {
IProfile profile = initializeProfile();
query = new InstallableUnitQuery(root, version == null ? VersionRange.emptyRange : new VersionRange(version, true, version, true));
roots = collectRootIUs(metadataRepositoryLocations, new PipedQuery(new IQuery[] {query, new LatestIUVersionQuery()}));
- if (roots.size() <= 0)
- roots.addAll(profile.query(query, new NullProgressMonitor()));
- if (roots.size() <= 0) {
+ if (roots.isEmpty())
+ roots = profile.query(query, new NullProgressMonitor());
+ if (roots.isEmpty()) {
System.out.println(NLS.bind(Messages.Missing_IU, root));
logFailure(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.Missing_IU, root)));
return EXIT_ERROR;
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
index b59d6e0b0..8bab64db9 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
@@ -248,19 +248,21 @@ public class DirectorApplication implements IApplication {
IVersionedId rootName = (IVersionedId) rootNames.get(i);
Version v = rootName.getVersion();
IQuery query = new InstallableUnitQuery(rootName.getId(), Version.emptyVersion.equals(v) ? VersionRange.emptyRange : new VersionRange(v, true, v, true));
- IQueryResult roots;
+ IQueryResult roots = null;
if (forInstall)
roots = collectRootIUs(new PipedQuery(new IQuery[] {query, new LatestIUVersionQuery()}));
- else
- roots = new Collector();
- if (roots.size() <= 0)
- roots.addAll(profile.query(query, new NullProgressMonitor()));
- if (roots.size() <= 0)
+
+ if (roots == null || roots.isEmpty())
+ roots = profile.query(query, new NullProgressMonitor());
+
+ Iterator itor = roots.iterator();
+ if (!itor.hasNext())
throw new CoreException(new Status(IStatus.ERROR, org.eclipse.equinox.internal.p2.director.app.Activator.ID, NLS.bind(Messages.Missing_IU, rootName)));
- allRoots.addAll(roots.toCollection());
+ do {
+ allRoots.add(itor.next());
+ } while (itor.hasNext());
}
return (IInstallableUnit[]) allRoots.toArray(new IInstallableUnit[allRoots.size()]);
-
}
synchronized Bundle getBundle(String symbolicName) {
@@ -462,16 +464,18 @@ public class DirectorApplication implements IApplication {
ArrayList allRoots = new ArrayList();
if (rootsToList.size() == 0) {
- IQueryResult roots = collectRootIUs(InstallableUnitQuery.ANY);
- allRoots.addAll(roots.toCollection());
+ Iterator roots = collectRootIUs(InstallableUnitQuery.ANY).iterator();
+ while (roots.hasNext())
+ allRoots.add(roots.next());
} else {
Iterator r = rootsToList.iterator();
while (r.hasNext()) {
IVersionedId rootName = (IVersionedId) r.next();
Version v = rootName.getVersion();
IQuery query = new InstallableUnitQuery(rootName.getId(), Version.emptyVersion.equals(v) ? VersionRange.emptyRange : new VersionRange(v, true, v, true));
- IQueryResult roots = collectRootIUs(query);
- allRoots.addAll(roots.toCollection());
+ Iterator roots = collectRootIUs(query).iterator();
+ while (roots.hasNext())
+ allRoots.add(roots.next());
}
}
@@ -702,7 +706,7 @@ public class DirectorApplication implements IApplication {
context.ungetService(packageAdminRef);
}
- public Object run(String[] args) throws CoreException {
+ public Object run(String[] args) {
long time = System.currentTimeMillis();
try {
@@ -786,7 +790,7 @@ public class DirectorApplication implements IApplication {
}
if (queryable != null)
return queryable.query(query, monitor);
- return new Collector();
+ return Collector.EMPTY_COLLECTOR;
}
private void deeplyPrint(CoreException ce, PrintStream strm, int level) {
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/AttachmentHelper.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/AttachmentHelper.java
index cfa7ce375..bccf51be2 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/AttachmentHelper.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/AttachmentHelper.java
@@ -21,7 +21,7 @@ import org.eclipse.equinox.p2.metadata.query.FragmentQuery;
public class AttachmentHelper {
private static final IInstallableUnitFragment[] NO_FRAGMENTS = new IInstallableUnitFragment[0];
- public static Collection attachFragments(Collection toAttach, Map fragmentsToIUs) {
+ public static Collection attachFragments(Iterator toAttach, Map fragmentsToIUs) {
Map fragmentBindings = new HashMap();
//Build a map inverse of the one provided in input (host --> List of fragments)
Map iusToFragment = new HashMap(fragmentsToIUs.size());
@@ -85,9 +85,9 @@ public class AttachmentHelper {
fragmentBindings.put(hostIU, theFragment);
}
//build the collection of resolved IUs
- Collection result = new HashSet(toAttach.size());
- for (Iterator iterator = toAttach.iterator(); iterator.hasNext();) {
- IInstallableUnit iu = (IInstallableUnit) iterator.next();
+ Collection result = new HashSet();
+ while (toAttach.hasNext()) {
+ IInstallableUnit iu = (IInstallableUnit) toAttach.next();
if (iu == null)
continue;
//just return fragments as they are
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/OperationGenerator.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/OperationGenerator.java
index 099fbe9b1..b1042905e 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/OperationGenerator.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/OperationGenerator.java
@@ -14,7 +14,6 @@ import java.util.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnitFragment;
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.engine.InstallableUnitOperand;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -158,7 +157,7 @@ public class OperationGenerator {
//when the ui we update from is in the new state, skip (for example FROM is A, C, B & TO is C (update of
InstallableUnitQuery updateQuery = new InstallableUnitQuery(iuTo.getUpdateDescriptor().getId(), iuTo.getUpdateDescriptor().getRange());
- Iterator updates = updateQuery.perform(fromIdIndexList.iterator(), new Collector()).iterator();
+ Iterator updates = updateQuery.perform(fromIdIndexList.iterator()).iterator();
if (!updates.hasNext()) { //Nothing to update from.
continue;
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
index a281fece0..53b91ea0d 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
@@ -139,7 +139,7 @@ public class Projector {
}
protected boolean isInstalled(IInstallableUnit iu) {
- return lastState.query(new InstallableUnitQuery(iu), null).size() == 0 ? false : true;
+ return !lastState.query(new InstallableUnitQuery(iu), null).isEmpty();
}
public void encode(IInstallableUnit entryPointIU, IInstallableUnit[] alreadyExistingRoots, IQueryable installedIUs, IInstallableUnit[] newRoots, IProgressMonitor monitor) {
@@ -411,7 +411,7 @@ public class Projector {
IQueryResult applicablePatches = getApplicablePatches(iu);
expandLifeCycle(iu, isRootIU);
//No patches apply, normal code path
- if (applicablePatches.size() == 0) {
+ if (applicablePatches.isEmpty()) {
expandRequirements(getRequiredCapabilities(iu), iu, isRootIU);
} else {
//Patches are applicable to the IU
@@ -570,12 +570,12 @@ public class Projector {
for (Iterator iterator = unchangedRequirements.entrySet().iterator(); iterator.hasNext();) {
Entry entry = (Entry) iterator.next();
List patchesApplied = (List) entry.getValue();
- List allPatches = new ArrayList(applicablePatches.toCollection());
- allPatches.removeAll(patchesApplied);
+ Iterator allPatches = applicablePatches.iterator();
List requiredPatches = new ArrayList();
- for (Iterator iterator2 = allPatches.iterator(); iterator2.hasNext();) {
- IInstallableUnitPatch patch = (IInstallableUnitPatch) iterator2.next();
- requiredPatches.add(patch);
+ while (allPatches.hasNext()) {
+ IInstallableUnitPatch patch = (IInstallableUnitPatch) allPatches.next();
+ if (!patchesApplied.contains(patch))
+ requiredPatches.add(patch);
}
IRequirement req = (IRequirement) entry.getKey();
List matches = getApplicableMatches(req);
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/QueryableArray.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/QueryableArray.java
index 5393ac757..a0ce70368 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/QueryableArray.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/QueryableArray.java
@@ -39,10 +39,9 @@ public class QueryableArray implements IQueryable {
}
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- Collector collector = new Collector();
if (query instanceof IRequiredCapability)
- return queryCapability((IRequiredCapability) query, collector, monitor);
- return query.perform(dataSet.iterator(), collector);
+ return queryCapability((IRequiredCapability) query, new Collector(), monitor);
+ return query.perform(dataSet.iterator());
}
private Collector queryCapability(IRequiredCapability query, Collector collector, IProgressMonitor monitor) {
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
index 977715789..24556a20e 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java
@@ -94,13 +94,13 @@ public class SimplePlanner implements IPlanner {
}
//Compute the side effect changes (e.g. things installed optionally going away)
- Collection includedIUs = new HashSet(changeRequest.getProfile().query(new IUProfilePropertyQuery(INCLUSION_RULES, null), null).toCollection());
- Map sideEffectStatus = new HashMap(includedIUs.size());
- includedIUs.removeAll(toState);
- for (Iterator iterator = includedIUs.iterator(); iterator.hasNext();) {
- IInstallableUnit removal = (IInstallableUnit) iterator.next();
- if (!requestStatus.containsKey(removal))
+ Iterator includedIUs = changeRequest.getProfile().query(new IUProfilePropertyQuery(INCLUSION_RULES, null), null).iterator();
+ Map sideEffectStatus = new HashMap();
+ while (includedIUs.hasNext()) {
+ IInstallableUnit removal = (IInstallableUnit) includedIUs.next();
+ if (!toState.contains(removal) && !requestStatus.containsKey(removal)) {
sideEffectStatus.put(removal, new RequestStatus(removal, RequestStatus.REMOVED, IStatus.INFO, null));
+ }
}
return new Map[] {requestStatus, sideEffectStatus};
}
@@ -198,7 +198,7 @@ public class SimplePlanner implements IPlanner {
ProvisioningContext context = new ProvisioningContext(new URI[0]);
if (context.getProperty(INCLUDE_PROFILE_IUS) == null)
context.setProperty(INCLUDE_PROFILE_IUS, Boolean.FALSE.toString());
- context.setExtraIUs(new ArrayList(targetProfile.available(InstallableUnitQuery.ANY, null).toCollection()));
+ context.setExtraIUs(Arrays.asList(targetProfile.available(InstallableUnitQuery.ANY, null).toArray(IInstallableUnit.class)));
return getProvisioningPlan(profileChangeRequest, context, sub.newChild(ExpandWork / 2));
} finally {
sub.done();
@@ -307,8 +307,11 @@ public class SimplePlanner implements IPlanner {
List extraIUs = new ArrayList(Arrays.asList(profileChangeRequest.getAddedInstallableUnits()));
extraIUs.addAll(Arrays.asList(profileChangeRequest.getRemovedInstallableUnits()));
- if (context == null || context.getProperty(INCLUDE_PROFILE_IUS) == null || context.getProperty(INCLUDE_PROFILE_IUS).equalsIgnoreCase(Boolean.TRUE.toString()))
- extraIUs.addAll(profile.available(InstallableUnitQuery.ANY, null).toCollection());
+ if (context == null || context.getProperty(INCLUDE_PROFILE_IUS) == null || context.getProperty(INCLUDE_PROFILE_IUS).equalsIgnoreCase(Boolean.TRUE.toString())) {
+ Iterator itor = profile.available(InstallableUnitQuery.ANY, null).iterator();
+ while (itor.hasNext())
+ extraIUs.add(itor.next());
+ }
IInstallableUnit[] availableIUs = gatherAvailableInstallableUnits((IInstallableUnit[]) extraIUs.toArray(new IInstallableUnit[extraIUs.size()]), metadataRepositories, context, sub.newChild(ExpandWork / 4));
@@ -356,7 +359,7 @@ public class SimplePlanner implements IPlanner {
Collection newState = ((Projector) resolutionResult).extractSolution();
Collection fullState = new ArrayList();
fullState.addAll(newState);
- newState = AttachmentHelper.attachFragments(newState, ((Projector) resolutionResult).getFragmentAssociation());
+ newState = AttachmentHelper.attachFragments(newState.iterator(), ((Projector) resolutionResult).getFragmentAssociation());
ProvisioningPlan temporaryPlan = generatePlan((Projector) resolutionResult, newState, profileChangeRequest, context);
@@ -370,12 +373,12 @@ public class SimplePlanner implements IPlanner {
}
private IProvisioningPlan generateAbsoluteProvisioningPlan(ProfileChangeRequest profileChangeRequest, ProvisioningContext context, IProgressMonitor monitor) {
- Collection toState = new HashSet(profileChangeRequest.getProfile().query(InstallableUnitQuery.ANY, null).toCollection());
-
+ Set toState = profileChangeRequest.getProfile().query(InstallableUnitQuery.ANY, null).toSet();
+ HashSet fromState = new HashSet(toState);
toState.removeAll(Arrays.asList(profileChangeRequest.getRemovedInstallableUnits()));
toState.addAll(Arrays.asList(profileChangeRequest.getAddedInstallableUnits()));
- InstallableUnitOperand[] iuOperands = generateOperations(profileChangeRequest.getProfile().query(InstallableUnitQuery.ANY, null).toCollection(), toState);
+ InstallableUnitOperand[] iuOperands = generateOperations(fromState, toState);
PropertyOperand[] propertyOperands = generatePropertyOperations(profileChangeRequest);
Operand[] operands = new Operand[iuOperands.length + propertyOperands.length];
@@ -465,9 +468,9 @@ public class SimplePlanner implements IPlanner {
IInstallableUnit previousActionsIU = getPreviousIUForMetaRequirements(agentProfile, getActionGatheringIUId(targetedProfile), sub);
ProfileChangeRequest agentRequest = new ProfileChangeRequest(agentProfile);
- agentRequest.addInstallableUnits(new IInstallableUnit[] {actionsIU});
+ agentRequest.addInstallableUnit(actionsIU);
if (previousActionsIU != null)
- agentRequest.removeInstallableUnits(new IInstallableUnit[] {previousActionsIU});
+ agentRequest.removeInstallableUnit(previousActionsIU);
Object externalInstallerPlan = getSolutionFor(agentRequest, initialContext, sub.newChild(10));
if (externalInstallerPlan instanceof IProvisioningPlan && ((IProvisioningPlan) externalInstallerPlan).getStatus().getSeverity() == IStatus.ERROR) {
MultiStatus externalInstallerStatus = new MultiStatus(DirectorActivator.PI_DIRECTOR, 0, Messages.Planner_can_not_install_preq, null);
@@ -510,8 +513,8 @@ public class SimplePlanner implements IPlanner {
}
if (previousMetaRequirementIU != null)
- agentRequest.removeInstallableUnits(new IInstallableUnit[] {previousMetaRequirementIU});
- agentRequest.addInstallableUnits(new IInstallableUnit[] {metaRequirementIU});
+ agentRequest.removeInstallableUnit(previousMetaRequirementIU);
+ agentRequest.addInstallableUnit(metaRequirementIU);
ProvisioningContext agentCtx = new ProvisioningContext(new URI[0]);
ArrayList extraIUs = new ArrayList(unattachedState);
@@ -526,7 +529,7 @@ public class SimplePlanner implements IPlanner {
//Compute the installer plan. It is the difference between what is currently in the profile and the solution we just computed
Collection agentState = ((Projector) agentSolution).extractSolution();
agentState.remove(metaRequirementIU); //Remove the fake IU
- agentState = AttachmentHelper.attachFragments(agentState, ((Projector) agentSolution).getFragmentAssociation());
+ agentState = AttachmentHelper.attachFragments(agentState.iterator(), ((Projector) agentSolution).getFragmentAssociation());
ProvisioningContext noRepoContext = createNoRepoContext(initialRequest);
//...This computes the attachment of what is currently in the profile
@@ -535,8 +538,8 @@ public class SimplePlanner implements IPlanner {
LogHelper.log(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, "The resolution of the previous state contained in profile " + initialRequest.getProfile().getProfileId() + " version " + initialRequest.getProfile().getTimestamp() + " failed.")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
return (ProvisioningPlan) initialSolution;
}
- Collection initialState = initialRequest.getProfile().query(InstallableUnitQuery.ANY, null).toCollection();
- initialState = AttachmentHelper.attachFragments(initialState, ((Projector) initialSolution).getFragmentAssociation());
+ Iterator profileState = initialRequest.getProfile().query(InstallableUnitQuery.ANY, null).iterator();
+ Collection initialState = AttachmentHelper.attachFragments(profileState, ((Projector) initialSolution).getFragmentAssociation());
IProvisioningPlan agentPlan = generateProvisioningPlan(initialState, agentState, initialRequest, null, initialContext);
@@ -549,7 +552,7 @@ public class SimplePlanner implements IPlanner {
//Compute the attachment of the new state if not provided
if (newState == null) {
newState = newSolution.extractSolution();
- newState = AttachmentHelper.attachFragments(newState, newSolution.getFragmentAssociation());
+ newState = AttachmentHelper.attachFragments(newState.iterator(), newSolution.getFragmentAssociation());
}
ProvisioningContext noRepoContext = createNoRepoContext(request);
@@ -559,8 +562,8 @@ public class SimplePlanner implements IPlanner {
LogHelper.log(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, "The resolution of the previous state contained in profile " + request.getProfile().getProfileId() + " version " + request.getProfile().getTimestamp() + " failed.")); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
return (ProvisioningPlan) initialSolution;
}
- Collection initialState = request.getProfile().query(InstallableUnitQuery.ANY, null).toCollection();
- initialState = AttachmentHelper.attachFragments(initialState, ((Projector) initialSolution).getFragmentAssociation());
+ Iterator profileState = request.getProfile().query(InstallableUnitQuery.ANY, null).iterator();
+ Collection initialState = AttachmentHelper.attachFragments(profileState, ((Projector) initialSolution).getFragmentAssociation());
//Generate the plan
return generateProvisioningPlan(initialState, newState, request, null, context);
@@ -570,17 +573,15 @@ public class SimplePlanner implements IPlanner {
ProvisioningContext noRepoContext = new ProvisioningContext(new URI[0]);
noRepoContext.setArtifactRepositories(new URI[0]);
noRepoContext.setProperty(INCLUDE_PROFILE_IUS, Boolean.FALSE.toString());
- ArrayList extraIUs = new ArrayList();
- extraIUs.addAll(request.getProfile().query(InstallableUnitQuery.ANY, new NullProgressMonitor()).toCollection());
- noRepoContext.setExtraIUs(extraIUs);
+ noRepoContext.setExtraIUs(new ArrayList(request.getProfile().query(InstallableUnitQuery.ANY, new NullProgressMonitor()).unmodifiableSet()));
return noRepoContext;
}
private IInstallableUnit getPreviousIUForMetaRequirements(IProfile profile, String iuId, IProgressMonitor monitor) {
IQueryResult c = profile.query(new InstallableUnitQuery(iuId), monitor);
- if (c.size() == 0)
+ if (c.isEmpty())
return null;
- return (IInstallableUnit) c.toArray(IInstallableUnit.class)[0];
+ return (IInstallableUnit) c.iterator().next();
}
private String getActionGatheringIUId(IProfile profile) {
@@ -617,8 +618,7 @@ public class SimplePlanner implements IPlanner {
//It returns at index 0 a meta IU representing everything that needs to be installed
//It returns at index 1 all the IUs that are in the profile after the removal have been done, but before the addition have been done
private Object[] updatePlannerInfo(ProfileChangeRequest profileChangeRequest, ProvisioningContext context) {
- Collection includedIUs = profileChangeRequest.getProfile().query(new IUProfilePropertyQuery(INCLUSION_RULES, null), null).toCollection();
- Collection alreadyInstalled = new HashSet(includedIUs);
+ IQueryResult alreadyInstalled = profileChangeRequest.getProfile().query(new IUProfilePropertyQuery(INCLUSION_RULES, null), null);
IInstallableUnit[] added = profileChangeRequest.getAddedInstallableUnits();
IInstallableUnit[] removed = profileChangeRequest.getRemovedInstallableUnits();
@@ -676,7 +676,7 @@ public class SimplePlanner implements IPlanner {
//Now add any other requirement that we need to see satisfied
if (context != null && context.getAdditionalRequirements() != null)
gatheredRequirements.addAll(context.getAdditionalRequirements());
- return new Object[] {createIURepresentingTheProfile(gatheredRequirements), (IInstallableUnit[]) alreadyInstalled.toArray(new IInstallableUnit[alreadyInstalled.size()])};
+ return new Object[] {createIURepresentingTheProfile(gatheredRequirements), (IInstallableUnit[]) alreadyInstalled.toArray(IInstallableUnit.class)};
}
private IRequirement createRequirement(IInstallableUnit iu, String rule) {
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/rollback/FormerState.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/rollback/FormerState.java
index 335c03f9c..c348551d5 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/rollback/FormerState.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/rollback/FormerState.java
@@ -31,10 +31,17 @@ public class FormerState {
}
private static void synchronizeAllIUProperties(ProfileChangeRequest request, IProfile current, IProfile target) {
- Collection currentIUs = current.query(InstallableUnitQuery.ANY, null).toCollection();
- Collection targetIUs = target.query(InstallableUnitQuery.ANY, null).toCollection();
- List iusToAdd = new ArrayList(targetIUs);
- iusToAdd.remove(currentIUs);
+ Set currentIUset = current.query(InstallableUnitQuery.ANY, null).unmodifiableSet();
+ Iterator targetIUs = target.query(InstallableUnitQuery.ANY, null).iterator();
+ List iusToAdd = new ArrayList();
+ List iusToUpdate = new ArrayList();
+ while (targetIUs.hasNext()) {
+ Object nxt = targetIUs.next();
+ if (currentIUset.contains(nxt))
+ iusToUpdate.add(nxt);
+ else
+ iusToAdd.add(nxt);
+ }
//additions
for (Iterator iterator = iusToAdd.iterator(); iterator.hasNext();) {
@@ -48,8 +55,6 @@ public class FormerState {
}
// updates
- List iusToUpdate = new ArrayList(targetIUs);
- iusToUpdate.remove(iusToAdd);
for (Iterator iterator = iusToUpdate.iterator(); iterator.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iterator.next();
Map propertiesToSet = new HashMap(target.getInstallableUnitProperties(iu));
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java
index 064bf1d01..59e22ee61 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/ProfileChangeRequest.java
@@ -16,6 +16,7 @@ import org.eclipse.equinox.internal.p2.director.*;
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.IQueryResult;
public class ProfileChangeRequest implements Cloneable {
@@ -61,18 +62,36 @@ public class ProfileChangeRequest implements Cloneable {
return result;
}
- public void addInstallableUnits(IInstallableUnit[] toInstall) {
+ public void addInstallableUnit(IInstallableUnit toInstall) {
if (iusToAdd == null)
- iusToAdd = new ArrayList(toInstall.length);
+ iusToAdd = new ArrayList();
+ iusToAdd.add(toInstall);
+ }
+
+ public void addInstallableUnits(IQueryResult toInstall) {
+ for (Iterator itor = toInstall.iterator(); itor.hasNext();)
+ addInstallableUnit((IInstallableUnit) itor.next());
+ }
+
+ public void addInstallableUnits(IInstallableUnit[] toInstall) {
for (int i = 0; i < toInstall.length; i++)
- iusToAdd.add(toInstall[i]);
+ addInstallableUnit(toInstall[i]);
}
- public void removeInstallableUnits(IInstallableUnit[] toUninstall) {
+ public void removeInstallableUnit(IInstallableUnit toUninstall) {
if (iusToRemove == null)
- iusToRemove = new ArrayList(toUninstall.length);
+ iusToRemove = new ArrayList();
+ iusToRemove.add(toUninstall);
+ }
+
+ public void removeInstallableUnits(IInstallableUnit[] toUninstall) {
for (int i = 0; i < toUninstall.length; i++)
- iusToRemove.add(toUninstall[i]);
+ removeInstallableUnit(toUninstall[i]);
+ }
+
+ public void removeInstallableUnits(IQueryResult toUninstall) {
+ for (Iterator itor = toUninstall.iterator(); itor.hasNext();)
+ removeInstallableUnit((IInstallableUnit) itor.next());
}
public void setProfileProperty(String key, Object value) {
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository.java
index f99b632e3..962404da7 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/CachingArtifactRepository.java
@@ -9,8 +9,6 @@
******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.directorywatcher;
-import org.eclipse.equinox.p2.metadata.query.IQueryResult;
-
import java.io.File;
import java.io.OutputStream;
import java.net.URI;
@@ -20,6 +18,7 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.MappedCollectionIterator;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
@@ -238,20 +237,18 @@ public class CachingArtifactRepository implements IArtifactRepository, IFileArti
}
public synchronized IQueryResult query(IQuery query, IProgressMonitor monitor) {
- Collector collector = new Collector();
if (monitor != null && monitor.isCanceled())
- return collector;
+ return Collector.EMPTY_COLLECTOR;
final boolean excludeKeys = Boolean.TRUE.equals(query.getProperty(IArtifactRepository.QUERY_EXCLUDE_KEYS));
final boolean excludeDescriptors = Boolean.TRUE.equals(query.getProperty(IArtifactRepository.QUERY_EXCLUDE_DESCRIPTORS));
if (excludeKeys && excludeDescriptors)
- return collector;
+ return Collector.EMPTY_COLLECTOR;
IQueryable cached = new IQueryable() {
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- Collector collector = new Collector();
Iterator i = !excludeDescriptors ? new MappedCollectionIterator(artifactMap, !excludeKeys) : artifactMap.keySet().iterator();
- return query.perform(i, collector);
+ return query.perform(i);
}
};
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Profile.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Profile.java
index ba90779a8..8ec228038 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Profile.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Profile.java
@@ -13,7 +13,8 @@ import java.util.Map.Entry;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.ICompositeQuery;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.ISurrogateProfileHandler;
import org.eclipse.equinox.p2.engine.query.IUProfilePropertyQuery;
@@ -163,12 +164,11 @@ public class Profile implements IQueryable, IProfile {
* @see org.eclipse.equinox.internal.provisional.p2.engine.IProfile#query(org.eclipse.equinox.internal.provisional.p2.query.Query, org.eclipse.equinox.internal.provisional.p2.query.Collector, org.eclipse.core.runtime.IProgressMonitor)
*/
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- Collector collector = new Collector();
propagateProfileContext(query);
if (query instanceof IUProfilePropertyQuery) {
- return query.perform(iuProperties.keySet().iterator(), collector);
+ return query.perform(iuProperties.keySet().iterator());
}
- return query.perform(ius.iterator(), collector);
+ return query.perform(ius.iterator());
}
private void propagateProfileContext(IQuery query) {
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileWriter.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileWriter.java
index 2743bdf30..85eb289fd 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileWriter.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/ProfileWriter.java
@@ -17,7 +17,6 @@ import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataWriter;
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.IQueryResult;
public class ProfileWriter extends MetadataWriter implements ProfileXMLConstants {
@@ -30,8 +29,7 @@ public class ProfileWriter extends MetadataWriter implements ProfileXMLConstants
attribute(ID_ATTRIBUTE, profile.getProfileId());
attribute(TIMESTAMP_ATTRIBUTE, Long.toString(profile.getTimestamp()));
writeProperties(profile.getProperties());
- IQueryResult queryResult = profile.query(InstallableUnitQuery.ANY, null);
- ArrayList ius = new ArrayList(queryResult.toCollection());
+ ArrayList ius = new ArrayList(profile.query(InstallableUnitQuery.ANY, null).unmodifiableSet());
Collections.sort(ius, new Comparator() {
public int compare(Object o1, Object o2) {
IInstallableUnit iu1 = (IInstallableUnit) o1;
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java
index 5cd04823d..9a36c7498 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SurrogateProfileHandler.java
@@ -177,12 +177,14 @@ public class SurrogateProfileHandler implements ISurrogateProfileHandler {
/* (non-Javadoc)
* @see org.eclipse.equinox.internal.p2.engine.ISurrogateProfileHandler#queryProfile(org.eclipse.equinox.internal.provisional.p2.engine.IProfile, org.eclipse.equinox.internal.provisional.p2.query.Query, org.eclipse.equinox.internal.provisional.p2.query.Collector, org.eclipse.core.runtime.IProgressMonitor)
*/
- public Collector queryProfile(IProfile profile, IQuery query, IProgressMonitor monitor) {
+ public IQueryResult queryProfile(IProfile profile, IQuery query, IProgressMonitor monitor) {
IProfile sharedProfile = getSharedProfile(profile.getProfileId());
- Collector result = new Collector();
- if (sharedProfile != null)
- result.addAll(sharedProfile.query(query, monitor));
+ if (sharedProfile == null)
+ return profile.query(query, monitor);
+ // TODO: Should consider using a sequenced iterator here instead of collecting
+ Collector result = new Collector();
+ result.addAll(sharedProfile.query(query, monitor));
result.addAll(profile.query(query, monitor));
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ISurrogateProfileHandler.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ISurrogateProfileHandler.java
index 72e5ca856..2d45cce45 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ISurrogateProfileHandler.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ISurrogateProfileHandler.java
@@ -11,8 +11,8 @@
package org.eclipse.equinox.p2.engine;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
/**
* @since 2.0
@@ -23,7 +23,7 @@ public interface ISurrogateProfileHandler {
public abstract boolean isSurrogate(IProfile profile);
- public abstract Collector queryProfile(IProfile profile, IQuery query, IProgressMonitor monitor);
+ public abstract IQueryResult queryProfile(IProfile profile, IQuery query, IProgressMonitor monitor);
public abstract boolean updateProfile(IProfile selfProfile);
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningPlan.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningPlan.java
index 3e1cf6546..cd2380581 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningPlan.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/p2/engine/ProvisioningPlan.java
@@ -10,14 +10,13 @@
*******************************************************************************/
package org.eclipse.equinox.p2.engine;
-import org.eclipse.equinox.p2.metadata.query.IQueryResult;
-
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
/**
* @since 2.0
@@ -54,7 +53,7 @@ public class ProvisioningPlan implements IProvisioningPlan {
if (futureState == null) {
futureState = new IQueryable() {
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- return new Collector();
+ return Collector.EMPTY_COLLECTOR;
}
};
}
@@ -129,9 +128,8 @@ public class ProvisioningPlan implements IProvisioningPlan {
}
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- Collector collector = new Collector();
if (operands == null || status.getSeverity() == IStatus.ERROR)
- return collector;
+ return Collector.EMPTY_COLLECTOR;
Collection list = new ArrayList();
for (int i = 0; i < operands.length; i++) {
if (!(operands[i] instanceof InstallableUnitOperand))
@@ -141,7 +139,7 @@ public class ProvisioningPlan implements IProvisioningPlan {
if (iu != null)
list.add(iu);
}
- return query.perform(list.iterator(), collector);
+ return query.perform(list.iterator());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java b/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java
index b942d446c..cd55840cd 100644
--- a/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java
+++ b/bundles/org.eclipse.equinox.p2.installer/src/org/eclipse/equinox/internal/p2/installer/InstallUpdateProductOperation.java
@@ -22,13 +22,13 @@ import org.eclipse.equinox.internal.provisional.p2.installer.IInstallOperation;
import org.eclipse.equinox.internal.provisional.p2.installer.InstallDescription;
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.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.engine.IProfileRegistry;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IVersionedId;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
@@ -75,8 +75,8 @@ public class InstallUpdateProductOperation implements IInstallOperation {
/**
* This profile is being updated; return the units to uninstall from the profile.
*/
- private IInstallableUnit[] computeUnitsToUninstall(IProfile p) {
- return (IInstallableUnit[]) p.query(InstallableUnitQuery.ANY, null).toArray(IInstallableUnit.class);
+ private IQueryResult computeUnitsToUninstall(IProfile p) {
+ return p.query(InstallableUnitQuery.ANY, null);
}
/**
@@ -118,7 +118,7 @@ public class InstallUpdateProductOperation implements IInstallOperation {
s = director.provision(request, null, monitor.newChild(90));
} else {
monitor.setTaskName(NLS.bind(Messages.Op_Updating, installDescription.getProductName()));
- IInstallableUnit[] toUninstall = computeUnitsToUninstall(p);
+ IQueryResult toUninstall = computeUnitsToUninstall(p);
request.removeInstallableUnits(toUninstall);
request.addInstallableUnits(toInstall);
s = director.provision(request, null, monitor.newChild(90));
@@ -154,7 +154,6 @@ public class InstallUpdateProductOperation implements IInstallOperation {
if (version != null && !version.equals(Version.emptyVersion))
range = new VersionRange(version, true, version, true);
IQuery query = new InstallableUnitQuery(id, range);
- Collector collector = new Collector();
Iterator matches = metadataRepoMan.query(query, null).iterator();
// pick the newest match
IInstallableUnit newest = null;
diff --git a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java
index 0270bb7c1..ac95dac37 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.generator/src/org/eclipse/equinox/internal/provisional/p2/metadata/generator/Generator.java
@@ -641,7 +641,6 @@ public class Generator {
if (!generateRootIU && data == null)
continue;
IQuery query = new InstallableUnitQuery(bundle.getSymbolicName());
- Collector collector = new Collector();
IMetadataRepository metadataRepository = info.getMetadataRepository();
if (metadataRepository == null)
continue;
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java
index 586d8eeca..407f86b9e 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/CompositeMetadataRepository.java
@@ -22,7 +22,8 @@ import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.persistence.CompositeRepositoryIO;
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.query.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.CompoundQueryable;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -126,18 +127,16 @@ public class CompositeMetadataRepository extends AbstractMetadataRepository impl
}
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- IQueryResult queryResult = new Collector();
if (monitor == null)
monitor = new NullProgressMonitor();
try {
// Query all the all the repositories this composite repo contains
CompoundQueryable queryable = new CompoundQueryable((IQueryable[]) loadedRepos.toArray(new IQueryable[loadedRepos.size()]));
- queryResult = queryable.query(query, monitor);
+ return queryable.query(query, monitor);
} finally {
if (monitor != null)
monitor.done();
}
- return queryResult;
}
private void addChild(URI childURI, boolean save) {
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java
index c629f0086..8e976553d 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/IUMap.java
@@ -14,6 +14,7 @@ import java.util.*;
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.IQueryResult;
/**
* A map that stores {@link IInstallableUnit} instances in a way that is efficient to query
@@ -75,19 +76,18 @@ public class IUMap {
return new MapIterator();
}
- public Collector query(InstallableUnitQuery query) {
+ public IQueryResult query(InstallableUnitQuery query) {
//iterate over the entire map, or just the IU's with the given id
- Collector result = new Collector();
Iterator candidates;
if (query.getId() == null)
candidates = iterator();
else {
Collection bucket = ((Collection) units.get(query.getId()));
if (bucket == null)
- return result;
+ return Collector.EMPTY_COLLECTOR;
candidates = bucket.iterator();
}
- return query.perform(candidates, result);
+ return query.perform(candidates);
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
index c7445d897..3cc5a9558 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
@@ -21,7 +21,6 @@ import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
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.eventbus.IProvisioningEventBus;
-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.repository.RepositoryEvent;
import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository;
@@ -148,7 +147,7 @@ public class LocalMetadataRepository extends AbstractMetadataRepository {
public synchronized IQueryResult query(IQuery query, IProgressMonitor monitor) {
if (query instanceof InstallableUnitQuery)
return units.query((InstallableUnitQuery) query);
- return query.perform(units.iterator(), new Collector());
+ return query.perform(units.iterator());
}
public synchronized void removeAll() {
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java
index b70074172..148cc2e0c 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/MetadataRepositoryIO.java
@@ -31,7 +31,6 @@ import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.Abstr
import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.RepositoryReference;
import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository.RepositoryState;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
@@ -133,11 +132,12 @@ public class MetadataRepositoryIO {
attributeOptional(DESCRIPTION_ATTRIBUTE, repository.getDescription()); // TODO: could be cdata?
writeProperties(repository.getProperties());
- IQueryResult units = repository.query(InstallableUnitQuery.ANY, null);
if (repository instanceof LocalMetadataRepository) {
Set references = ((LocalMetadataRepository) repository).repositories;
writeRepositoryReferences(references.iterator(), references.size());
}
+ // The size attribute is a problematic since it forces the use of a collection.
+ Set units = repository.query(InstallableUnitQuery.ANY, null).unmodifiableSet();
writeInstallableUnits(units.iterator(), units.size());
end(REPOSITORY_ELEMENT);
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java
index d06b2e8a4..5caec190b 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/URLMetadataRepository.java
@@ -15,7 +15,6 @@ import java.net.URI;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.URIUtil;
-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.metadata.repository.AbstractMetadataRepository;
import org.eclipse.equinox.p2.metadata.query.IQuery;
@@ -82,6 +81,6 @@ public class URLMetadataRepository extends AbstractMetadataRepository {
public synchronized IQueryResult query(IQuery query, IProgressMonitor monitor) {
if (query instanceof InstallableUnitQuery)
return units.query((InstallableUnitQuery) query);
- return query.perform(units.iterator(), new Collector());
+ return query.perform(units.iterator());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java
index 8a5b7476f..aa28742c2 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/io/MetadataWriter.java
@@ -11,8 +11,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.repository.io;
-import org.eclipse.equinox.p2.metadata.ICopyright;
-
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
@@ -44,6 +42,8 @@ public abstract class MetadataWriter extends XMLWriter implements XMLConstants {
if (size == 0)
return;
start(INSTALLABLE_UNITS_ELEMENT);
+
+ // The size is a bummer. Is it really needed? It forces the use of a collect
attribute(COLLECTION_SIZE_ATTRIBUTE, size);
while (units.hasNext())
writeInstallableUnit((IInstallableUnit) units.next());
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/LDAPQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/LDAPQuery.java
index 17523227c..2e2a99dbc 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/LDAPQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/LDAPQuery.java
@@ -1,8 +1,8 @@
package org.eclipse.equinox.internal.p2.metadata;
import java.util.Iterator;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
public class LDAPQuery implements IQuery {
private String filter;
@@ -15,7 +15,7 @@ public class LDAPQuery implements IQuery {
return filter;
}
- public Collector perform(Iterator iterator, Collector result) {
+ public IQueryResult perform(Iterator iterator) {
throw new IllegalStateException();
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Collector.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Collector.java
index e8ca53c40..92bbc7d14 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Collector.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/Collector.java
@@ -31,6 +31,12 @@ import org.eclipse.equinox.p2.metadata.query.IQueryResult;
public class Collector implements IQueryResult {
private Set collected = null;
+ public static final Collector EMPTY_COLLECTOR = new Collector() {
+ public boolean accept(Object val) {
+ return false;
+ }
+ };
+
/**
* Creates a new collector.
*/
@@ -67,7 +73,7 @@ public class Collector implements IQueryResult {
}
/**
- * Returns the collection that is being used to collect results. Unlike {@linkplain #toCollection()},
+ * Returns the collection that is being used to collect results. Unlike {@linkplain #toSet()},
* this returns the actual modifiable collection that is being used to store results. The
* return value is only intended to be used within subclasses and should not be exposed
* outside of a collection class.
@@ -122,29 +128,37 @@ public class Collector implements IQueryResult {
}
/**
- * Returns the collected objects as an immutable collection.
+ * Returns a copy of the collected objects.
*
* @return An unmodifiable collection of the collected objects
*/
- public Collection toCollection() {
- return collected == null ? Collections.EMPTY_SET : Collections.unmodifiableSet(collected);
+ public Set toSet() {
+ return collected == null ? new HashSet() : new HashSet(collected);
}
/**
* Performs a query on this results of this collector.
*/
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- Collector collector = new Collector();
- Iterator iter = toCollection().iterator();
+ IQueryResult result;
if (monitor == null)
monitor = new NullProgressMonitor();
try {
monitor.beginTask(Messages.performing_subquery, 1);
- collector = query.perform(iter, collector);
+ result = query.perform(iterator());
monitor.worked(1);
} finally {
monitor.done();
}
- return collector;
+ return result;
+ }
+
+ /**
+ * Returns the collected objects as an immutable collection.
+ *
+ * @return An unmodifiable collection of the collected objects
+ */
+ public Set unmodifiableSet() {
+ return collected == null ? Collections.EMPTY_SET : Collections.unmodifiableSet(collected);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQuery.java
index 8b3b30a57..9932af3bb 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQuery.java
@@ -11,8 +11,11 @@
*******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.metadata.query;
+import java.lang.reflect.Array;
import java.util.*;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
/**
* A query that combines a group of sub-queries.<P>
@@ -130,8 +133,9 @@ public abstract class CompoundQuery implements IQuery, ICompositeQuery {
* Performs this query on the given iterator, passing all objects in the iterator
* that match the criteria of this query to the given result.
*/
- public final Collector perform(Iterator iterator, Collector result) {
+ public final IQueryResult perform(Iterator iterator) {
prePerform();
+ Collector result = new Collector();
try {
while (iterator.hasNext()) {
Object candidate = iterator.next();
@@ -171,48 +175,72 @@ public abstract class CompoundQuery implements IQuery, ICompositeQuery {
/*
* A collector that takes the set to puts the elements in.
*/
- class SetCollector extends Collector {
- Set s = null;
+ static class SetCollector implements IQueryResult {
+ private final Set s;
public SetCollector(Set s) {
this.s = s;
}
- public boolean accept(Object object) {
- s.add(object);
- return true;
+ public boolean isEmpty() {
+ return s.isEmpty();
}
- }
- public Collector perform(Iterator iterator, Collector result) {
- if (queries.length < 1)
- return result;
+ public Iterator iterator() {
+ return s.iterator();
+ }
- Collection data = new LinkedList();
+ public Object[] toArray(Class clazz) {
+ return s.toArray((Object[]) Array.newInstance(clazz, s.size()));
+ }
- while (iterator.hasNext()) {
- data.add(iterator.next());
+ public IQueryResult query(IQuery query, IProgressMonitor monitor) {
+ return query.perform(iterator());
}
- Set[] resultSets = new Set[queries.length];
- for (int i = 0; i < queries.length; i++) {
- resultSets[i] = new HashSet();
- queries[i].perform(data.iterator(), new SetCollector(resultSets[i]));
+ public Set toSet() {
+ return new HashSet(s);
}
- Set set = resultSets[0];
- for (int i = 1; i < resultSets.length; i++) {
- if (isAnd())
- set.retainAll(resultSets[i]);
- else
- set.addAll(resultSets[i]);
+ public Set unmodifiableSet() {
+ return Collections.unmodifiableSet(s);
}
+ }
- Iterator resultIterator = set.iterator();
- boolean gatherResults = true;
- while (resultIterator.hasNext() && gatherResults)
- gatherResults = result.accept(resultIterator.next());
- return result;
+ public IQueryResult perform(Iterator iterator) {
+ if (queries.length < 1)
+ return Collector.EMPTY_COLLECTOR;
+
+ if (queries.length == 1)
+ return queries[0].perform(iterator);
+
+ Collection data = new ArrayList();
+ while (iterator.hasNext())
+ data.add(iterator.next());
+
+ Set result;
+ if (isAnd()) {
+ result = queries[0].perform(data.iterator()).unmodifiableSet();
+ for (int i = 1; i < queries.length && result.size() > 0; i++) {
+ HashSet retained = new HashSet();
+ Iterator itor = queries[i].perform(data.iterator()).iterator();
+ while (itor.hasNext()) {
+ Object nxt = itor.next();
+ if (result.contains(nxt))
+ retained.add(nxt);
+ }
+ result = retained;
+ }
+ } else {
+ result = queries[0].perform(data.iterator()).toSet();
+ for (int i = 1; i < queries.length; i++) {
+ Iterator itor = queries[i].perform(data.iterator()).iterator();
+ while (itor.hasNext()) {
+ result.add(itor.next());
+ }
+ }
+ }
+ return new SetCollector(result);
}
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQueryable.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQueryable.java
index d87348acd..27a4dd0a2 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQueryable.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/CompoundQueryable.java
@@ -28,7 +28,6 @@ public class CompoundQueryable implements IQueryable {
}
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- IQueryResult results = new Collector();
IQueryResult subResults = null;
if (monitor == null) {
monitor = new NullProgressMonitor();
@@ -38,11 +37,14 @@ public class CompoundQueryable implements IQueryable {
try {
SubMonitor subMonitor = SubMonitor.convert(monitor, totalWork * 10);
+ Collector results;
if (!isMatchQuery) {
// If it is not a match query, then collect the results
// as a list, we will query this list for the final results
results = new ListCollector();
- }
+ } else
+ results = new Collector();
+
for (int i = 0; i < queryables.length; i++) {
if (subMonitor.isCanceled())
break;
@@ -50,16 +52,14 @@ public class CompoundQueryable implements IQueryable {
results.addAll(subResults);
}
- if (!isMatchQuery) {
- // If it is not a MatchQuery then we must query the results.
- results = results.query(query, subMonitor.newChild(10));
- } else
- results = results;
+ if (isMatchQuery)
+ return results;
+
+ // If it is not a MatchQuery then we must query the results.
+ return results.query(query, subMonitor.newChild(10));
} finally {
monitor.done();
}
-
- return results;
}
/**
@@ -111,8 +111,8 @@ public class CompoundQueryable implements IQueryable {
*
* @return An unmodifiable collection of the collected objects
*/
- public Collection toCollection() {
- return collected == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(collected);
+ public Set toSet() {
+ return collected == null ? Collections.EMPTY_SET : new HashSet(collected);
}
public Iterator iterator() {
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/ContextQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/ContextQuery.java
index 4d366484e..6faee7266 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/ContextQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/ContextQuery.java
@@ -11,6 +11,7 @@ package org.eclipse.equinox.internal.provisional.p2.metadata.query;
import java.util.Iterator;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
/**
* ContextQuery is the abstract superclass for Queries that require the entire
@@ -22,7 +23,7 @@ import org.eclipse.equinox.p2.metadata.query.IQuery;
* need for a non-transitive query, please see:
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=261403
* <p>
- * Users of this query must call {@link #perform(Iterator, Collector)} to compute
+ * Users of this query must call {@link #perform(Iterator)} to compute
* the results. <P>
* This class may be subclassed by clients. Subclasses should specify the type
* of object they support querying on. Subclasses are also encouraged to clearly
@@ -37,12 +38,10 @@ public abstract class ContextQuery implements IQuery {
* Evaluates the query for a specific input.
*
* @param iterator The elements for which to evaluate the query on
- * @param result A collector to collect the results. For each element accepted
- * by the query,{@link Collector#accept(Object)} must be called.
* @return The results of the query. The collector returned must be
* the collector passed in.
*/
- public abstract Collector perform(Iterator iterator, Collector result);
+ public abstract IQueryResult perform(Iterator iterator);
/**
* Gets the ID for this Query.
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LatestIUVersionQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LatestIUVersionQuery.java
index f9fa67a87..f1baa98bd 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LatestIUVersionQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LatestIUVersionQuery.java
@@ -9,9 +9,9 @@
******************************************************************************/
package org.eclipse.equinox.internal.provisional.p2.metadata.query;
-
import java.util.*;
import org.eclipse.equinox.p2.metadata.IVersionedId;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
/**
* This query returns the latest version for each unique VersionedID.
@@ -22,7 +22,7 @@ public class LatestIUVersionQuery extends ContextQuery {
/**
* Performs the LatestIUVersionQuery
*/
- public Collector perform(Iterator iterator, Collector result) {
+ public IQueryResult perform(Iterator iterator) {
HashMap greatestIUVersion = new HashMap();
while (iterator.hasNext()) {
Object next = iterator.next();
@@ -43,6 +43,7 @@ public class LatestIUVersionQuery extends ContextQuery {
Iterator valuesIterator = values.iterator();
boolean continueGather = true;
+ Collector result = new Collector();
while (valuesIterator.hasNext() && continueGather) {
IVersionedId nextIU = (IVersionedId) valuesIterator.next();
continueGather = result.accept(nextIU);
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LimitQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LimitQuery.java
index 1991d9114..ba96e611e 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LimitQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/LimitQuery.java
@@ -11,6 +11,7 @@ package org.eclipse.equinox.internal.provisional.p2.metadata.query;
import java.util.Iterator;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
/**
* A limit query can be used to limit the number of query results returned. Once
@@ -21,39 +22,32 @@ public class LimitQuery extends ContextQuery implements ICompositeQuery {
private final IQuery query;
private final int limit;
- private class LimitCollector extends Collector {
- private final Collector subCollector;
- private final int collectionLimit;
- private int collected = 0;
-
- public LimitCollector(int collectionLimit, Collector subCollector) {
- this.collectionLimit = collectionLimit;
- this.subCollector = subCollector;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector#accept(java.lang.Object)
- */
- public boolean accept(Object object) {
- if (collected >= collectionLimit)
- return false;
- if (!subCollector.accept(object))
- return false;
- collected++;
- if (collected >= collectionLimit)
- return false;
- return true;
- }
- }
-
public LimitQuery(IQuery query, int limit) {
this.query = query;
this.limit = limit;
}
- public Collector perform(Iterator iterator, Collector result) {
- LimitCollector limitCollector = new LimitCollector(limit, result);
- query.perform(iterator, limitCollector);
+ public IQueryResult perform(Iterator iterator) {
+ if (limit == 0)
+ return Collector.EMPTY_COLLECTOR;
+
+ int count = 0;
+ Collector result = new Collector();
+ if (query instanceof IMatchQuery) {
+ IMatchQuery matchQuery = (IMatchQuery) query;
+ while (iterator.hasNext()) {
+ Object candidate = iterator.next();
+ if (matchQuery.isMatch(candidate)) {
+ result.accept(candidate);
+ if (++count >= limit)
+ break;
+ }
+ }
+ } else {
+ iterator = query.perform(iterator).iterator();
+ while (++count <= limit && iterator.hasNext())
+ result.accept(iterator.next());
+ }
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/MatchQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/MatchQuery.java
index c387c8ba7..0b1b89bdd 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/MatchQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/MatchQuery.java
@@ -11,6 +11,7 @@
package org.eclipse.equinox.internal.provisional.p2.metadata.query;
import java.util.Iterator;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
/**
* This class represents the superclass of most of p2's queries. Every element
@@ -34,7 +35,7 @@ public abstract class MatchQuery implements IMatchQuery {
* of this query, and <code>false</code> otherwise
*
* @noreference This method is not intended to be referenced by clients.
- * Clients should call {@link #perform(Iterator, Collector)}
+ * Clients should call {@link #perform(Iterator)}
*/
public abstract boolean isMatch(Object candidate);
@@ -57,7 +58,8 @@ public abstract class MatchQuery implements IMatchQuery {
* Performs this query on the given iterator, passing all objects in the iterator
* that match the criteria of this query to the given result.
*/
- public final Collector perform(Iterator iterator, Collector result) {
+ public final IQueryResult perform(Iterator iterator) {
+ Collector result = new Collector();
prePerform();
try {
while (iterator.hasNext()) {
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/PipedQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/PipedQuery.java
index 737e85580..6f1e0cf45 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/PipedQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/provisional/p2/metadata/query/PipedQuery.java
@@ -11,6 +11,7 @@ package org.eclipse.equinox.internal.provisional.p2.metadata.query;
import java.util.Iterator;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
/**
* A PipedQuery is an aggregate query in which each sub-query
@@ -54,18 +55,15 @@ public class PipedQuery implements IQuery, ICompositeQuery {
return queries;
}
- public Collector perform(Iterator iterator, Collector result) {
- Collector collector;
- Iterator iter = iterator;
- for (int i = 0; i < queries.length; i++) {
- // Take the results of the previous query and using them
- // to drive the next one (i.e. composing queries)
- collector = queries[i].perform(iter, new Collector());
- iter = collector.iterator();
+ public IQueryResult perform(Iterator iterator) {
+ IQueryResult last = Collector.EMPTY_COLLECTOR;
+ if (queries.length > 0) {
+ last = queries[0].perform(iterator);
+ for (int i = 1; i < queries.length; i++)
+ // Take the results of the previous query and using them
+ // to drive the next one (i.e. composing queries)
+ last = queries[i].perform(last.iterator());
}
- boolean gatherResults = true;
- while (iter.hasNext() && gatherResults)
- gatherResults = result.accept(iter.next());
- return result;
+ return last;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQuery.java
index 41de77a7c..d440a5ae0 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQuery.java
@@ -12,7 +12,6 @@
package org.eclipse.equinox.p2.metadata.query;
import java.util.Iterator;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
/**
@@ -29,12 +28,10 @@ public interface IQuery {
* Evaluates the query for a specific input.
*
* @param iterator The elements for which to evaluate the query on
- * @param result A collector to collect the results. For each element accepted
- * by the query,{@link Collector#accept(Object)} must be called.
* @return The results of the query. The collector returned must be
* the collector passed in.
*/
- public abstract Collector perform(Iterator iterator, Collector result);
+ public abstract IQueryResult perform(Iterator iterator);
/**
* Gets the ID for this Query.
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQueryResult.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQueryResult.java
index 2a0c0f5d2..351851f3b 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQueryResult.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/query/IQueryResult.java
@@ -9,8 +9,8 @@
******************************************************************************/
package org.eclipse.equinox.p2.metadata.query;
-import java.util.Collection;
import java.util.Iterator;
+import java.util.Set;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
/**
@@ -19,13 +19,6 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
*
*/
public interface IQueryResult extends IQueryable {
-
- /**
- * Adds the elements from one QueryResult to this one
- * @param queryResult A QueryResult from which the elements should be retrieved
- */
- public void addAll(IQueryResult queryResult);
-
/**
* Returns whether this QueryResult is empty.
* @return <code>true</code> if this QueryResult has accepted any results,
@@ -41,11 +34,6 @@ public interface IQueryResult extends IQueryable {
public Iterator iterator();
/**
- * Returns the number of collected objects.
- */
- public int size();
-
- /**
* Returns the collected objects as an array
*
* @param clazz The type of array to return
@@ -56,10 +44,15 @@ public interface IQueryResult extends IQueryable {
public Object[] toArray(Class clazz);
/**
- * Returns the collected objects as an immutable collection.
- *
- * @return An unmodifiable collection of the collected objects
+ * Creates a new Set copy with the contents of this query result. The
+ * copy can be altered without any side effects on its origin.
+ * @return A detached copy of the result.
*/
- public Collection toCollection();
+ public Set toSet();
+ /**
+ * Returns a Set backed by this query result. The set is immutable.
+ * @return A Set backed by this query result.
+ */
+ public Set unmodifiableSet();
}
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java
index 11e3962ce..7332079ff 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/InstallOperation.java
@@ -78,7 +78,7 @@ public class InstallOperation extends ProfileChangeOperation {
// TODO ideally we should only do this check if the iu is a singleton, but in practice many iu's that should
// be singletons are not, so we don't check this (yet)
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=230878
- if (alreadyInstalled.size() > 0) { // && installedIU.isSingleton()
+ if (!alreadyInstalled.isEmpty()) { // && installedIU.isSingleton()
IInstallableUnit installedIU = (IInstallableUnit) alreadyInstalled.iterator().next();
int compareTo = toInstall[i].getVersion().compareTo(installedIU.getVersion());
// If the iu is a newer version of something already installed, consider this an
@@ -93,8 +93,8 @@ public class InstallOperation extends ProfileChangeOperation {
// iu should not be updated
status.merge(PlanAnalyzer.getStatus(IStatusCodes.ALTERED_IGNORED_IMPLIED_UPDATE, toInstall[i]));
} else {
- request.addInstallableUnits(new IInstallableUnit[] {toInstall[i]});
- request.removeInstallableUnits(new IInstallableUnit[] {installedIU});
+ request.addInstallableUnit(toInstall[i]);
+ request.removeInstallableUnit(installedIU);
// Add a status informing the user that the update has been inferred
status.merge(PlanAnalyzer.getStatus(IStatusCodes.ALTERED_IMPLIED_UPDATE, toInstall[i]));
// Mark it as a root if it hasn't been already
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java
index 0aa816050..637b1cf20 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java
@@ -183,7 +183,14 @@ public class ProvisioningSession {
}
private int countPlanElements(IProvisioningPlan plan) {
- return new CompoundQueryable(new IQueryable[] {plan.getAdditions(), plan.getRemovals()}).query(InstallableUnitQuery.ANY, null).size();
+ IQueryResult result = new CompoundQueryable(new IQueryable[] {plan.getAdditions(), plan.getRemovals()}).query(InstallableUnitQuery.ANY, null);
+ int cnt = 0;
+ Iterator itor = result.iterator();
+ while (itor.hasNext()) {
+ itor.next();
+ ++cnt;
+ }
+ return cnt;
}
/**
@@ -218,7 +225,7 @@ public class ProvisioningSession {
// we will be able to get everything else.
ProfileChangeRequest downloadRequest = new ProfileChangeRequest(profile);
downloadRequest.setAbsoluteMode(true);
- downloadRequest.addInstallableUnits((IInstallableUnit[]) new CompoundQueryable(new IQueryable[] {plan.getAdditions(), plan.getInstallerPlan().getAdditions()}).query(InstallableUnitQuery.ANY, null).toArray(IInstallableUnit.class));
+ downloadRequest.addInstallableUnits(new CompoundQueryable(new IQueryable[] {plan.getAdditions(), plan.getInstallerPlan().getAdditions()}).query(InstallableUnitQuery.ANY, null));
PhaseSet download = new DownloadPhaseSet();
IProvisioningPlan downloadPlan = getPlanner().getProvisioningPlan(downloadRequest, context, mon.newChild(100));
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java
index 96de15c13..662d7ef64 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java
@@ -242,13 +242,13 @@ public class UpdateOperation extends ProfileChangeOperation {
if (!defaultUpdates.contains(update))
defaultUpdates.add(update);
}
- request.addInstallableUnits(new IInstallableUnit[] {theUpdate});
+ request.addInstallableUnit(theUpdate);
// if (rootMarkerKey != null)
request.setInstallableUnitProfileProperty(theUpdate, IProfile.PROP_PROFILE_ROOT_IU, Boolean.toString(true));
if (PatchQuery.isPatch(theUpdate)) {
request.setInstallableUnitInclusionRules(theUpdate, PlannerHelper.createOptionalInclusionRule(theUpdate));
} else {
- request.removeInstallableUnits(new IInstallableUnit[] {update.toUpdate});
+ request.removeInstallableUnit(update.toUpdate);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java
index d41b319f4..980e85853 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/AbstractPublisherAction.java
@@ -525,7 +525,7 @@ public abstract class AbstractPublisherAction implements IPublisherAction {
*/
protected IInstallableUnit queryForIU(IPublisherResult publisherResult, String iuId, Version version) {
IQuery query = null;
- Collector collector = new Collector();
+ IQueryResult collector = Collector.EMPTY_COLLECTOR;
if (version != null && !Version.emptyVersion.equals(version)) {
query = new LimitQuery(new InstallableUnitQuery(iuId, version), 1);
} else {
@@ -534,11 +534,11 @@ public abstract class AbstractPublisherAction implements IPublisherAction {
NullProgressMonitor progress = new NullProgressMonitor();
if (publisherResult != null)
- collector.addAll(publisherResult.query(query, progress));
+ collector = publisherResult.query(query, progress);
if (collector.isEmpty() && info.getMetadataRepository() != null)
- collector.addAll(info.getMetadataRepository().query(query, progress));
+ collector = info.getMetadataRepository().query(query, progress);
if (collector.isEmpty() && info.getContextMetadataRepository() != null)
- collector.addAll(info.getContextMetadataRepository().query(query, progress));
+ collector = info.getContextMetadataRepository().query(query, progress);
if (!collector.isEmpty())
return (IInstallableUnit) collector.iterator().next();
@@ -552,9 +552,9 @@ public abstract class AbstractPublisherAction implements IPublisherAction {
* @param versionRange the version range to consider
* @return The the IUs with the matching ids in the given range
*/
- protected IInstallableUnit[] queryForIUs(IPublisherResult publisherResult, String iuId, VersionRange versionRange) {
+ protected IQueryResult queryForIUs(IPublisherResult publisherResult, String iuId, VersionRange versionRange) {
IQuery query = null;
- IQueryResult queryResult = new Collector();
+ IQueryResult queryResult = Collector.EMPTY_COLLECTOR;
query = new InstallableUnitQuery(iuId, versionRange);
NullProgressMonitor progress = new NullProgressMonitor();
if (publisherResult != null)
@@ -563,10 +563,7 @@ public abstract class AbstractPublisherAction implements IPublisherAction {
queryResult = info.getMetadataRepository().query(query, progress);
if (queryResult.isEmpty() && info.getContextMetadataRepository() != null)
queryResult = info.getContextMetadataRepository().query(query, progress);
-
- if (!queryResult.isEmpty())
- return (IInstallableUnit[]) queryResult.toArray(IInstallableUnit.class);
- return new IInstallableUnit[0];
+ return queryResult;
}
public abstract IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor);
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherResult.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherResult.java
index 35390bff3..0898b5806 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherResult.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/PublisherResult.java
@@ -133,7 +133,7 @@ public class PublisherResult implements IPublisherResult {
}
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- return query.perform(flatten(this.map.values()).iterator(), new Collector());
+ return query.perform(flatten(this.map.values()).iterator());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/QueryableFilterAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/QueryableFilterAdvice.java
index cb8acab3c..a36950573 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/QueryableFilterAdvice.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/QueryableFilterAdvice.java
@@ -35,8 +35,9 @@ public class QueryableFilterAdvice implements IFilterAdvice {
return ((LDAPQuery) ((IInstallableUnit) result.iterator().next()).getFilter()).getFilter();
if (exact)
return null;
+
query = new InstallableUnitQuery(id);
- result.addAll(queryable.query(query, null));
+ result = queryable.query(query, null);
if (!result.isEmpty())
return ((LDAPQuery) ((IInstallableUnit) result.iterator().next()).getFilter()).getFilter();
return null;
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUResultFilterAdvice.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUResultFilterAdvice.java
index b99dc179a..4e65d9ba4 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUResultFilterAdvice.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/actions/RootIUResultFilterAdvice.java
@@ -9,8 +9,9 @@
******************************************************************************/
package org.eclipse.equinox.p2.publisher.actions;
+import java.util.Arrays;
import java.util.Collection;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.query.IQuery;
import org.eclipse.equinox.p2.publisher.AbstractAdvice;
import org.eclipse.equinox.p2.publisher.IPublisherResult;
@@ -26,6 +27,6 @@ public class RootIUResultFilterAdvice extends AbstractAdvice implements IRootIUA
Collection value = result.getIUs(null, IPublisherResult.ROOT);
if (query == null)
return value;
- return query.perform(value.iterator(), new Collector()).toCollection();
+ return Arrays.asList(query.perform(value.iterator()).toArray(IInstallableUnit.class));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
index 664c56848..4059a7bf7 100644
--- a/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
+++ b/bundles/org.eclipse.equinox.p2.publisher/src/org/eclipse/equinox/p2/publisher/eclipse/BundlesAction.java
@@ -29,6 +29,7 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
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.*;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.publisher.actions.*;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
@@ -696,13 +697,13 @@ public class BundlesAction extends AbstractPublisherAction {
// TODO: Need a test case for multiple hosts
String hostId = bd.getHost().getName();
VersionRange hostVersionRange = VersionRange.fromOSGiVersionRange(bd.getHost().getVersionRange());
- IInstallableUnit[] hosts = queryForIUs(result, hostId, hostVersionRange);
+ IQueryResult hosts = queryForIUs(result, hostId, hostVersionRange);
- for (int j = 0; j < hosts.length; j++) {
+ for (Iterator itor = hosts.iterator(); itor.hasNext();) {
String fragmentId = makeHostLocalizationFragmentId(bd.getSymbolicName());
fragment = queryForIU(result, fragmentId, Version.fromOSGiVersion(bd.getVersion()));
if (fragment == null) {
- String[] externalizedStrings = getExternalizedStrings(hosts[j]);
+ String[] externalizedStrings = getExternalizedStrings((IInstallableUnit) itor.next());
fragment = createHostLocalizationFragment(bundleIU, bd, hostId, externalizedStrings);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
index 8b290e814..b79c95f4a 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
@@ -99,7 +99,7 @@ public class ProfileSynchronizer {
if (status.getSeverity() == IStatus.ERROR || status.getSeverity() == IStatus.CANCEL)
return status;
- if (plan.getAdditions().query(InstallableUnitQuery.ANY, null).size() + plan.getRemovals().query(InstallableUnitQuery.ANY, null).size() == 0) {
+ if (plan.getAdditions().query(InstallableUnitQuery.ANY, null).isEmpty() && plan.getRemovals().query(InstallableUnitQuery.ANY, null).isEmpty()) {
writeTimestamps();
return status;
}
@@ -295,10 +295,10 @@ public class ProfileSynchronizer {
List toRemove = new ArrayList();
boolean foundIUsToAdd = false;
- Collection profileIUs = new HashSet(profile.query(InstallableUnitQuery.ANY, null).toCollection());
+ Set profileIUs = profile.query(InstallableUnitQuery.ANY, null).unmodifiableSet();
// we use IProfile.available(...) here so that we also gather any shared IUs
- Collection availableProfileIUs = new HashSet(profile.available(InstallableUnitQuery.ANY, null).toCollection());
+ Set availableProfileIUs = profile.available(InstallableUnitQuery.ANY, null).unmodifiableSet();
// get all IUs from all our repos (toAdd)
Collector allIUs = getAllIUsFromRepos();
@@ -324,7 +324,7 @@ public class ProfileSynchronizer {
// get all IUs from profile with marked property (existing)
IQueryResult dropinIUs = profile.query(new IUProfilePropertyQuery(PROP_FROM_DROPINS, Boolean.toString(true)), null);
- Collection all = new HashSet(allIUs.toCollection());
+ Set all = allIUs.unmodifiableSet();
for (Iterator iter = dropinIUs.iterator(); iter.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iter.next();
// the STRICT policy is set when we install things via the UI, we use it to differentiate between IUs installed
@@ -402,6 +402,7 @@ public class ProfileSynchronizer {
}
private Collector getAllIUsFromRepos() {
+ // TODO: Should consider using a sequenced iterator here instead of collecting
Collector allRepos = new Collector();
for (Iterator it = repositoryMap.entrySet().iterator(); it.hasNext();) {
Entry entry = (Entry) it.next();
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java
index 5f69beb18..732b93733 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/MirrorApplication.java
@@ -197,7 +197,7 @@ public class MirrorApplication extends AbstractApplication implements IApplicati
private IStatus mirrorArtifacts(IQueryable slice, IProgressMonitor monitor) throws ProvisionException {
// Obtain ArtifactKeys from IUs
IQueryResult ius = slice.query(InstallableUnitQuery.ANY, monitor);
- ArrayList keys = new ArrayList(ius.size());
+ ArrayList keys = new ArrayList();
for (Iterator iterator = ius.iterator(); iterator.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iterator.next();
IArtifactKey[] iuKeys = iu.getArtifacts();
@@ -265,13 +265,15 @@ public class MirrorApplication extends AbstractApplication implements IApplicati
for (int i = 0; i < rootIUs.length; i++) {
String[] segments = getArrayArgsFromString(rootIUs[i], "/"); //$NON-NLS-1$
VersionRange range = segments.length > 1 ? new VersionRange(segments[i]) : null;
- IQueryResult queryResult = metadataRepo.query(new InstallableUnitQuery(segments[i], range), null);
- sourceIUs.addAll(queryResult.toCollection());
+ Iterator queryResult = metadataRepo.query(new InstallableUnitQuery(segments[i], range), null).iterator();
+ while (queryResult.hasNext())
+ sourceIUs.add(queryResult.next());
}
} else if (sourceIUs == null || sourceIUs.isEmpty()) {
sourceIUs = new ArrayList();
- IQueryResult queryResult = metadataRepo.query(InstallableUnitQuery.ANY, null);
- sourceIUs.addAll(queryResult.toCollection());
+ Iterator queryResult = metadataRepo.query(InstallableUnitQuery.ANY, null).iterator();
+ while (queryResult.hasNext())
+ sourceIUs.add(queryResult.next());
/* old metadata mirroring app did not throw an exception here */
if (sourceIUs.size() == 0 && destinationMetadataRepository != null && metadataOrArtifacts == null)
throw new ProvisionException(Messages.MirrorApplication_no_IUs);
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java
index 4772d6e44..ba2494613 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/Repo2Runnable.java
@@ -172,7 +172,9 @@ public class Repo2Runnable extends AbstractApplication implements IApplication {
if (!hasMetadataSources())
throw new ProvisionException(Messages.exception_needIUsOrNonEmptyRepo);
- processedIUs.addAll(getAllIUs(getCompositeMetadataRepository(), monitor).toCollection());
+ Iterator itor = getAllIUs(getCompositeMetadataRepository(), monitor).iterator();
+ while (itor.hasNext())
+ processedIUs.add(itor.next());
if (processedIUs.isEmpty())
throw new ProvisionException(Messages.exception_needIUsOrNonEmptyRepo);
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java
index e6f07588e..87c228953 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/analyzer/HostCheckAnalyzer.java
@@ -37,7 +37,7 @@ public class HostCheckAnalyzer extends IUAnalyzer {
theHost = (IRequiredCapability) hosts[i];
if (theHost.getNamespace().equals("osgi.bundle")) {
IQueryResult results = repository.query(new InstallableUnitQuery(theHost.getName(), theHost.getRange()), new NullProgressMonitor());
- if (results.size() == 0) {
+ if (results.isEmpty()) {
error(iu, "IU Fragment: " + iu.getId() + " cannot find host" + theHost.getName() + " : " + theHost.getRange());
return;
}
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/RepositoryAnalyzer.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/RepositoryAnalyzer.java
index c77f30b6b..4d32d1c2d 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/RepositoryAnalyzer.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/repository/tools/analyzer/RepositoryAnalyzer.java
@@ -37,7 +37,7 @@ public class RepositoryAnalyzer {
for (int i = 0; i < repositories.length; i++) {
IQueryResult queryResult = repositories[i].query(InstallableUnitQuery.ANY, sub);
- SubMonitor repositoryMonitor = SubMonitor.convert(sub, queryResult.size());
+ SubMonitor repositoryMonitor = SubMonitor.convert(sub, IProgressMonitor.UNKNOWN);
for (int j = 0; j < config.length; j++) {
try {
IIUAnalyzer verifier = (IIUAnalyzer) config[j].createExecutableExtension("class"); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java
index 9912d0e53..de45bb783 100644
--- a/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java
+++ b/bundles/org.eclipse.equinox.p2.repository.tools/src_ant/org/eclipse/equinox/p2/internal/repository/tools/tasks/AbstractRepositoryTask.java
@@ -20,7 +20,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.p2.internal.repository.tools.*;
import org.eclipse.equinox.p2.metadata.query.IQuery;
-import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.osgi.util.NLS;
@@ -167,11 +166,12 @@ public abstract class AbstractRepositoryTask extends Task {
IUDescription iu = (IUDescription) iter.next();
IQuery iuQuery = iu.createQuery();
- IQueryResult queryResult = repository.query(iuQuery, null);
+ Iterator queryResult = repository.query(iuQuery, null).iterator();
- if (iu.isRequired() && queryResult.isEmpty())
+ if (iu.isRequired() && !queryResult.hasNext())
throw new BuildException(NLS.bind(Messages.AbstractRepositoryTask_unableToFind, iu.toString()));
- result.addAll(queryResult.toCollection());
+ while (queryResult.hasNext())
+ result.add(queryResult.next());
}
return result;
}
diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
index d88fcf971..a52eae1fb 100644
--- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/AbstractRepositoryManager.java
@@ -20,7 +20,8 @@ import org.eclipse.equinox.internal.p2.core.helpers.*;
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.metadata.query.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.CompoundQueryable;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
import org.eclipse.equinox.p2.core.IAgentLocation;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
@@ -1076,7 +1077,6 @@ public abstract class AbstractRepositoryManager implements IRepositoryManager, P
* @return A collector containing the results of the query
*/
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- IQueryResult queryResult = new Collector();
URI[] locations = getKnownRepositories(REPOSITORIES_ALL);
List queryables = new ArrayList(locations.length); // use a list since we don't know exactly how many will load
SubMonitor sub = SubMonitor.convert(monitor, locations.length * 10);
@@ -1092,10 +1092,9 @@ public abstract class AbstractRepositoryManager implements IRepositoryManager, P
try {
IQueryable[] queryablesArray = (IQueryable[]) queryables.toArray(new IQueryable[queryables.size()]);
CompoundQueryable compoundQueryable = new CompoundQueryable(queryablesArray);
- queryResult = compoundQueryable.query(query, sub.newChild(locations.length * 1));
+ return compoundQueryable.query(query, sub.newChild(locations.length * 1));
} finally {
sub.done();
}
- return queryResult;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/All p2 UI tests.launch b/bundles/org.eclipse.equinox.p2.tests.ui/All p2 UI tests.launch
index 3ae17e864..04ba3f074 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/All p2 UI tests.launch
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/All p2 UI tests.launch
@@ -40,7 +40,7 @@
</listAttribute>
<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
<booleanAttribute key="default" value="false"/>
-<stringAttribute key="deselected_workspace_plugins" value="org.eclipse.equinox.p2.examples.rcp.sdkui*1.0.0.qualifier,org.eclipse.ui.examples.fieldassist,org.eclipse.pde.ui.tests,test271339,org.eclipse.equinox.p2.tests.optimizers,JobTest,org.eclipse.pde.build.tests,org.eclipse.ui.workbench,RCPMail,org.eclipse.update.ui,org.eclipse.equinox.p2.examples.rcp.sdkbundlevisibility,org.eclipse.equinox.p2.examples.rcp.cloud,org.eclipse.equinox.internal.p2.ui.analysis,org.eclipse.equinox.p2.testserver,org.eclipse.equinox.p2.ui.admin,org.eclipse.equinox.p2.examples.rcp.sdkui*1.0.0.qualifier,org.eclipse.update.scheduler,org.eclipse.ui.examples.undo,org.eclipse.ui.examples.job,org.eclipse.ui.forms,org.eclipse.equinox.p2.examples.rcp.sdknoautoupdates,org.eclipse.equinox.http,Snippets,org.eclipse.equinox.p2.examples.rcp.prestartupdate,org.eclipse.ui.console,org.eclipse.ui.workbench.texteditor,org.eclipse.ui.editors,org.eclipse.equinox.p2.ui.admin.rcp,org.eclipse.wst.server.discovery"/>
+<stringAttribute key="deselected_workspace_plugins" value="org.eclipse.equinox.p2.ui.admin,org.eclipse.equinox.http,org.eclipse.equinox.p2.tests.optimizers,org.eclipse.equinox.p2.ui.admin.rcp,org.eclipse.equinox.p2.testserver"/>
<booleanAttribute key="generateProfile" value="true"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
@@ -53,8 +53,7 @@
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.6.0_07"/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.equinox.p2.tests.ui.AutomatedTests"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -console -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.equinox.p2.tests.ui"/>
@@ -62,8 +61,8 @@
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
-<stringAttribute key="selected_target_plugins" value="org.eclipse.equinox.ds@1:true,org.eclipse.pde.api.tools.ui@default:default,org.junit*3.8.2.v20090203-1005@default:default,javax.servlet@default:default,org.apache.jasper@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.debug.core@default:default,org.eclipse.jdt.core.manipulation@default:default,org.eclipse.core.filebuffers@default:default,org.sat4j.pb*2.1.1.v20090825@default:default,org.eclipse.pde.ui@default:default,org.eclipse.equinox.jsp.jasper@default:default,org.eclipse.jdt.junit4.runtime@default:default,org.eclipse.pde@default:default,org.eclipse.equinox.security.ui@default:default,org.eclipse.core.externaltools@default:default,org.eclipse.pde.ua.ui@default:default,org.eclipse.jdt.debug@default:default,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.ui.presentations.r21@default:default,org.sat4j.core*2.1.1.v20090825@default:default,org.eclipse.rcp@default:default,org.eclipse.core.filesystem@default:default,org.eclipse.pde.ds.ui@default:default,org.eclipse.help.ui@default:default,org.apache.commons.codec@default:default,org.eclipse.equinox.app@default:default,com.ibm.icu@default:default,org.apache.commons.el@default:default,org.apache.lucene.analysis@default:default,org.hamcrest.core@default:default,org.eclipse.swt.win32.win32.x86@default:false,org.eclipse.core.jobs@default:default,org.eclipse.ui.views@default:default,org.eclipse.cvs@default:default,org.eclipse.pde.core@default:default,org.eclipse.ui.net@default:default,org.mortbay.jetty.util@default:default,org.eclipse.jface@default:default,org.eclipse.team.core@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.ant.launching@default:default,org.eclipse.equinox.launcher.win32.win32.x86@default:false,org.eclipse.ui.navigator.resources@default:default,org.eclipse.jdt.apt.core@default:default,javax.servlet.jsp@default:default,org.eclipse.core.net@default:default,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,org.eclipse.pde.ds.core@default:default,org.apache.ant@default:default,org.apache.commons.logging@default:default,org.eclipse.compare@default:default,org.eclipse.pde.doc.user@default:default,org.eclipse.team.cvs.ui@default:default,org.eclipse.osgi@-1:true,org.eclipse.ui.editors@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.equinox.event@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.core.net.win32.x86@default:false,org.eclipse.jsch.ui@default:default,org.eclipse.ui.console@default:default,org.eclipse.sdk@default:default,org.mortbay.jetty.server@default:default,org.eclipse.swt@default:default,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.jdt.launching@default:default,org.eclipse.equinox.util@default:default,org.eclipse.osgi.util@default:default,org.eclipse.jdt.doc.user@default:default,org.apache.lucene@default:default,org.eclipse.equinox.security.win32.x86@default:false,org.eclipse.ui.forms@default:default,org.eclipse.core.runtime@default:true,org.eclipse.ui@default:default,org.eclipse.help@default:default,org.eclipse.core.expressions@default:default,org.apache.commons.httpclient@default:default,org.eclipse.pde.ui.templates@default:default,org.eclipse.compare.win32@default:default,org.eclipse.update.configurator@3:true,org.eclipse.pde.runtime@default:default,org.junit*4.7.0.v20091118-1515@default:default,org.eclipse.team.ui@default:default,org.eclipse.ui.ide@default:default,org.eclipse.pde.api.tools@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.resources.win32.x86@default:false,org.objectweb.asm@default:default,org.eclipse.osgi.services@default:default,org.eclipse.jdt.compiler.tool@default:false,org.eclipse.equinox.security@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.ui.externaltools@default:default,org.eclipse.jdt.core@default:default,org.eclipse.core.resources@default:default,org.eclipse.update.core.win32@default:false,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.help.appserver@default:default,org.eclipse.ui.intro.universal@default:default,org.eclipse.ui.navigator@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.core.variables@default:default,org.eclipse.update.core@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.equinox.jsp.jasper.registry@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.junit4@default:default,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.jsch.core@default:default,org.eclipse.update.scheduler@default:default,org.eclipse.pde.launching@default:default,org.eclipse.releng.tools@default:default,org.eclipse.jdt.compiler.apt@default:false,org.eclipse.core.databinding@default:default,org.eclipse.jdt@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.filesystem.win32.x86@default:false,org.eclipse.equinox.http.registry@default:default,com.jcraft.jsch@default:default,org.eclipse.equinox.launcher@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.ui.intro@default:default,org.eclipse.text@default:default,org.eclipse.pde.ua.core@default:default,org.eclipse.help.base@default:default,org.eclipse.search@default:default,org.eclipse.jdt.apt.ui@default:default,org.eclipse.ui.workbench.compatibility@default:false,org.eclipse.jface.text@default:default,org.eclipse.ui.views.log@default:default,org.eclipse.pde.junit.runtime@default:default,org.eclipse.jdt.doc.isv@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.jdt.junit.runtime@default:default,org.eclipse.help.webapp@default:default,org.eclipse.platform@default:default,org.eclipse.team.cvs.ssh2@default:default,org.eclipse.jdt.junit@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui.browser@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.update.ui@default:default,org.eclipse.ant.core@default:default,org.eclipse.ecf@default:default,org.eclipse.ui.win32@default:false,org.eclipse.jdt.apt.pluggable.core@default:default,org.eclipse.team.cvs.core@default:default,org.eclipse.debug.ui@default:default,org.eclipse.ui.cheatsheets@default:default,org.eclipse.pde.build@default:default,org.eclipse.ui.ide.application@default:default,org.eclipse.jdt.junit.core@default:default,org.eclipse.core.boot@default:default,org.eclipse.compare.core@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.jdt.debug.ui@default:default,org.eclipse.equinox.http.jetty@default:default,org.eclipse.ant.ui@default:default,org.eclipse.jdt.ui@default:default,org.eclipse.core.runtime.compatibility@default:default"/>
-<stringAttribute key="selected_workspace_plugins" value="org.eclipse.equinox.p2.ui.sdk.scheduler@default:default,org.eclipse.equinox.p2.console@default:default,org.sat4j.core*2.1.0.v20090520@default:default,org.sat4j.pb*2.1.1.v20090825@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.equinox.p2.artifact.processors@default:default,org.eclipse.equinox.p2.extensionlocation@default:default,org.eclipse.equinox.p2.tests@default:default,org.eclipse.platform@default:default,org.sat4j.core*2.1.1.v20090825@default:default,org.eclipse.equinox.p2.tests.ui@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.p2.ui.sdk@default:default,org.eclipse.ui.tests@default:default,org.eclipse.equinox.p2.sar@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.frameworkadmin.test@default:default,org.eclipse.core.databinding@default:default,org.eclipse.equinox.p2.updatechecker@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.pde.core@default:default,org.eclipse.equinox.p2.repository.tools@default:default,org.eclipse.equinox.common@2:true,org.eclipse.core.filebuffers@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.equinox.p2.ql@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.pde.build@default:default,org.eclipse.core.commands@default:default,org.eclipse.equinox.p2.weblistener@default:default,org.eclipse.equinox.p2.repository@default:default,ie.wombat.jbdiff@default:default,org.eclipse.equinox.p2.directorywatcher@default:default,org.eclipse.equinox.p2.director.app@default:default,org.eclipse.text@default:default,org.eclipse.equinox.p2.diagnostic@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.search@default:default,org.eclipse.pde.ui@default:default,org.eclipse.core.runtime@default:true,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.ui.ide@default:default,org.eclipse.equinox.p2.operations@default:default,org.eclipse.equinox.p2.metadata.generator@default:default,org.eclipse.equinox.p2.afterthefact@default:default,org.sat4j.pb*2.1.0.v20090520@default:default,org.eclipse.test.performance@default:default,org.eclipse.jdt.core@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.tests.verifier@default:default,org.easymock@default:default,org.eclipse.jface.text@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.jface@default:default,org.eclipse.core.expressions@default:default,org.eclipse.equinox.p2.director@default:default,org.eclipse.core.tests.harness@default:default,org.eclipse.platform.doc.isv@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.sdk@default:default,org.eclipse.equinox.p2.reconciler.dropins@default:default,org.eclipse.core.net@default:default,org.eclipse.equinox.p2.exemplarysetup@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.touchpoint.osgi@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.equinox.p2.installer@default:default,org.apache.xml.resolver@default:default,org.eclipse.equinox.p2.updatesite@default:default,org.eclipse.equinox.p2.common@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.p2.artifact.optimizers@default:default,org.eclipse.ui.tests.harness@default:default,org.eclipse.ui@default:default,org.eclipse.osgi@-1:true,org.eclipse.equinox.p2.ui@default:default,org.eclipse.platform.doc.user@default:default"/>
+<stringAttribute key="selected_target_plugins" value="org.eclipse.jface.text@default:default,org.eclipse.rcp@default:default,org.apache.commons.logging@default:default,org.mortbay.jetty.util@default:default,org.apache.ant@default:default,org.eclipse.ui.navigator.resources@default:default,org.eclipse.compare@default:default,org.eclipse.core.net@default:default,org.eclipse.jdt.junit.core@default:default,org.eclipse.update.configurator@3:true,org.eclipse.equinox.security.ui@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.ui.presentations.r21@default:default,org.eclipse.osgi.services@default:default,org.eclipse.core.resources@default:default,org.eclipse.equinox.app@default:default,org.eclipse.jsch.ui@default:default,org.eclipse.pde.build@default:default,org.eclipse.jdt.core.manipulation@default:default,org.eclipse.team.cvs.core@default:default,org.eclipse.ui.intro@default:default,org.hamcrest.core@default:default,org.eclipse.ui.editors@default:default,org.eclipse.ui.views@default:default,org.eclipse.jdt.launching@default:default,org.apache.commons.httpclient@default:default,org.eclipse.ui.ide.application@default:default,org.mortbay.jetty.server@default:default,org.eclipse.pde.api.tools.ui@default:default,org.eclipse.pde.junit.runtime@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.help@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.ui.net@default:default,org.eclipse.ui.cheatsheets@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.apache.lucene@default:default,javax.servlet.jsp@default:default,org.eclipse.ecf@default:default,org.sat4j.pb@default:default,org.eclipse.debug.ui@default:default,org.eclipse.jdt.junit4.runtime@default:default,org.eclipse.equinox.util@default:default,org.eclipse.pde.api.tools@default:default,org.eclipse.jdt.compiler.tool@default:false,org.eclipse.core.runtime.compatibility@default:default,org.junit4@default:default,org.eclipse.search@default:default,org.eclipse.equinox.ds@1:true,org.junit*4.7.0.v20091118-1515@default:default,org.eclipse.equinox.jsp.jasper@default:default,org.eclipse.jdt.junit@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.update.core@default:default,org.eclipse.ant.core@default:default,org.eclipse.sdk@default:default,org.eclipse.osgi.util@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.help.ui@default:default,org.eclipse.pde.doc.user@default:default,org.eclipse.team.ui@default:default,org.eclipse.core.databinding@default:default,com.jcraft.jsch@default:default,org.eclipse.core.commands@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui.views.log@default:default,org.eclipse.ui.browser@default:default,org.junit*3.8.2.v20090203-1005@default:default,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,org.eclipse.core.expressions@default:default,org.eclipse.ant.ui@default:default,org.eclipse.jdt@default:default,org.eclipse.core.jobs@default:default,org.eclipse.jdt.debug@default:default,org.eclipse.pde.ds.core@default:default,org.eclipse.pde@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.pde.ua.ui@default:default,org.eclipse.ui.console@default:default,org.eclipse.debug.core@default:default,org.eclipse.platform@default:default,org.sat4j.core@default:default,org.eclipse.pde.ui@default:default,org.eclipse.equinox.http.jetty@default:default,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.jdt.apt.ui@default:default,org.eclipse.osgi@-1:true,org.eclipse.ecf.filetransfer@default:default,org.eclipse.help.base@default:default,org.eclipse.ui.intro.universal@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.runtime@default:true,org.apache.jasper@default:default,org.eclipse.jdt.junit.runtime@default:default,org.eclipse.ui@default:default,org.eclipse.core.variables@default:default,org.eclipse.jdt.debug.ui@default:default,org.eclipse.team.core@default:default,org.eclipse.jdt.apt.core@default:default,org.eclipse.pde.runtime@default:default,org.eclipse.update.scheduler@default:default,org.eclipse.jdt.ui@default:default,org.eclipse.pde.ds.ui@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.update.ui@default:default,org.eclipse.ui.navigator@default:default,org.eclipse.ui.externaltools@default:default,org.eclipse.text@default:default,org.apache.commons.el@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.ant.launching@default:default,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.help.webapp@default:default,org.eclipse.pde.ui.templates@default:default,org.eclipse.pde.launching@default:default,org.eclipse.pde.ua.core@default:default,org.eclipse.swt@default:default,com.ibm.icu@default:default,org.eclipse.cvs@default:default,org.eclipse.ui.forms@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.equinox.jsp.jasper.registry@default:default,org.eclipse.jface@default:default,org.eclipse.ui.workbench.compatibility@default:false,org.eclipse.team.cvs.ssh2@default:default,org.apache.commons.codec@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.help.appserver@default:default,org.eclipse.ui.ide@default:default,org.eclipse.team.cvs.ui@default:default,org.eclipse.jsch.core@default:default,org.eclipse.core.externaltools@default:default,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.swt.gtk.linux.x86_64@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.jdt.core@default:default,org.eclipse.equinox.security@default:default,org.eclipse.jdt.doc.user@default:default,org.eclipse.equinox.event@default:default,org.eclipse.equinox.common@2:true,org.eclipse.pde.core@default:default,org.objectweb.asm@default:default,org.apache.lucene.analysis@default:default,org.eclipse.core.boot@default:default,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.jdt.compiler.apt@default:false,org.eclipse.equinox.registry@default:default,org.eclipse.jdt.apt.pluggable.core@default:default,org.eclipse.core.filebuffers@default:default,javax.servlet@default:default,org.eclipse.equinox.http.registry@default:default,org.eclipse.jdt.doc.isv@default:default"/>
+<stringAttribute key="selected_workspace_plugins" value="org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.frameworkadmin.test@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.p2.artifact.optimizers@default:default,org.eclipse.equinox.p2.ui.sdk.scheduler@default:default,org.eclipse.equinox.p2.artifact.processors@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.diagnostic@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.equinox.p2.installer@default:default,org.eclipse.equinox.p2.ui@default:default,org.eclipse.equinox.p2.updatesite@default:default,org.eclipse.equinox.p2.repository.tools@default:default,org.eclipse.equinox.p2.director.app@default:default,org.easymock@default:default,org.eclipse.equinox.p2.extensionlocation@default:default,org.eclipse.equinox.p2.afterthefact@default:default,org.eclipse.equinox.p2.common@default:default,org.eclipse.equinox.p2.tests@default:default,org.eclipse.equinox.p2.ui.sdk@default:default,org.eclipse.equinox.p2.tests.verifier@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.equinox.p2.director@default:default,ie.wombat.jbdiff.test@default:default,org.eclipse.equinox.p2.updatechecker@default:default,org.eclipse.equinox.p2.operations@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.exemplarysetup@default:default,org.eclipse.equinox.p2.console@default:default,org.eclipse.equinox.p2.sar@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.touchpoint.osgi@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.osgi@-1:true,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.equinox.p2.tags@default:default,org.eclipse.equinox.p2.ql@default:default,org.eclipse.equinox.p2.tests.ui@default:default,org.eclipse.test.performance@default:default,org.eclipse.equinox.p2.directorywatcher@default:default,org.eclipse.equinox.p2.metadata.generator@default:default,org.eclipse.equinox.p2.weblistener@default:default,ie.wombat.jbdiff@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.reconciler.dropins@default:default,org.eclipse.core.tests.harness@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useDefaultConfig" value="true"/>
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java
index 6efa9d747..12677efa8 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/AnyRequiredCapabilityTest.java
@@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.equinox.internal.p2.ui.QueryableMetadataRepositoryManager;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.metadata.query.IQueryResult;
@@ -33,8 +32,8 @@ public class AnyRequiredCapabilityTest extends AbstractQueryTest {
items.add(noMatch);
items.add(new Object());
items.add(requires);
- Collector result = requires.getMatches().perform(items.iterator(), new Collector());
- assertEquals("1.0", 1, result.size());
+ IQueryResult result = requires.getMatches().perform(items.iterator());
+ assertEquals("1.0", 1, queryResultSize(result));
assertEquals("1.1", match, result.iterator().next());
}
@@ -51,7 +50,7 @@ public class AnyRequiredCapabilityTest extends AbstractQueryTest {
QueryableMetadataRepositoryManager manager = new QueryableMetadataRepositoryManager(ProvisioningUI.getDefaultUI(), false);
IRequirement requires = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.iu", "test.bundle", ANY_VERSION, null, false, false);
IQueryResult result = manager.query(requires.getMatches(), getMonitor());
- assertEquals("1.0", 1, result.size());
+ assertEquals("1.0", 1, queryResultSize(result));
IInstallableUnit iu = (IInstallableUnit) result.iterator().next();
assertEquals("1.1", "test.bundle", iu.getId());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementWrapperTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementWrapperTest.java
index f99179e6a..0aad76c68 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementWrapperTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/LatestIUVersionElementWrapperTest.java
@@ -11,12 +11,13 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ui.query;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.equinox.internal.p2.ui.model.IIUElement;
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.LatestIUVersionQuery;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
/**
* Tests for {@link LatestIUVersionQuery}. This has all the tests of the superclass,
@@ -42,8 +43,8 @@ public class LatestIUVersionElementWrapperTest extends AvailableIUWrapperTest {
Object object = new Object();
List list = new ArrayList();
list.add(object);
- Collector collector = latestIuVersionElementQuery.perform(list.iterator(), new Collector());
- assertEquals("1.0", 0, collector.size());
+ IQueryResult collector = latestIuVersionElementQuery.perform(list.iterator());
+ assertTrue("1.0", collector.isEmpty());
}
/**
@@ -56,8 +57,8 @@ public class LatestIUVersionElementWrapperTest extends AvailableIUWrapperTest {
List listOfIUs = new ArrayList();
listOfIUs.add(unit1);
listOfIUs.add(unit2);
- Collector collector = latestIuVersionElementQuery.perform(listOfIUs.iterator(), new Collector());
- assertEquals("1.0", 1, collector.size());
+ IQueryResult collector = latestIuVersionElementQuery.perform(listOfIUs.iterator());
+ assertEquals("1.0", 1, queryResultSize(collector));
IInstallableUnit collectedIU = getIU(collector.iterator().next());
assertEquals("1.1", unit2, collectedIU);
}
@@ -77,14 +78,13 @@ public class LatestIUVersionElementWrapperTest extends AvailableIUWrapperTest {
listOfIUs.add(unit3);
listOfIUs.add(unit4);
listOfIUs.add(unit5);
- Collector collector = latestIuVersionElementQuery.perform(listOfIUs.iterator(), new Collector());
+ IQueryResult collector = latestIuVersionElementQuery.perform(listOfIUs.iterator());
// Should be 3 units
- assertEquals("1.0", 3, collector.size());
- Collection reslts = collector.toCollection();
- assertTrue("1.2", reslts.contains(unit2));
- assertTrue("1.3", reslts.contains(unit3));
- assertTrue("1.4", reslts.contains(unit5));
+ assertEquals("1.0", 3, queryResultSize(collector));
+ assertContains("1.2", collector, unit2);
+ assertContains("1.3", collector, unit3);
+ assertContains("1.4", collector, unit5);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryDescriptorTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryDescriptorTest.java
index 5e30b2c02..1dcbc84f1 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryDescriptorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryDescriptorTest.java
@@ -29,7 +29,7 @@ public class QueryDescriptorTest extends TestCase {
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
Collector collector = new Collector();
- return query.perform(elements.iterator(), collector);
+ return query.perform(elements.iterator());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java
index 0b789934f..0c4005836 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableArtifactRepositoryManagerTest.java
@@ -44,7 +44,7 @@ public class QueryableArtifactRepositoryManagerTest extends AbstractQueryTest {
QueryableArtifactRepositoryManager manager = getQueryableManager();
IQueryResult result = manager.query(new RepositoryLocationQuery(), getMonitor());
- assertTrue(result.size() == repoCount);
+ assertTrue(queryResultSize(result) == repoCount);
}
private QueryableArtifactRepositoryManager getQueryableManager() {
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java
index 94f11bc77..7d44982f4 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/QueryableMetadataRepositoryManagerTest.java
@@ -109,7 +109,7 @@ public class QueryableMetadataRepositoryManagerTest extends AbstractQueryTest {
QueryableMetadataRepositoryManager manager = getQueryableManager();
IQueryResult result = manager.query(new InstallableUnitQuery("test.bundle", Version.createOSGi(1, 0, 0)), new CancelingProgressMonitor());
- assertEquals("1.0", 0, result.size());
+ assertTrue("1.0", result.isEmpty());
}
public void testExistingRepository() {
@@ -178,23 +178,22 @@ public class QueryableMetadataRepositoryManagerTest extends AbstractQueryTest {
QueryableMetadataRepositoryManager manager = getQueryableManager();
IQueryResult result = manager.query(new InstallableUnitQuery("test.bundle", Version.createOSGi(1, 0, 0)), getMonitor());
- assertEquals("1.0", 1, result.size());
+ assertEquals("1.0", 1, queryResultSize(result));
IInstallableUnit iu = (IInstallableUnit) result.iterator().next();
assertEquals("1.1", "test.bundle", iu.getId());
//RepoLocationQuery collects repository URLs
result = manager.query(new RepositoryLocationQuery(), getMonitor());
- assertEquals("2.0", 3, result.size());
- Collection resultCollection = result.toCollection();
- assertTrue("2.1", resultCollection.contains(existing));
- assertTrue("2.1", resultCollection.contains(nonExisting));
- assertTrue("2.1", resultCollection.contains(broken));
+ assertEquals("2.0", 3, queryResultSize(result));
+ assertContains("2.1", result, existing);
+ assertContains("2.1", result, nonExisting);
+ assertContains("2.1", result, broken);
// null IUPropertyQuery collects all IUs
result = manager.query(new InstallableUnitQuery((String) null), getMonitor());
- int iuCount = result.size();
+ int iuCount = queryResultSize(result);
result = manager.query(new IUPropertyQuery(null, null), getMonitor());
- assertEquals("2.2", iuCount, result.size());
+ assertEquals("2.2", iuCount, queryResultSize(result));
}
public void testNonLatestInMultipleRepositories() {
diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/TranslationSupportTests.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/TranslationSupportTests.java
index 9798496fd..3ae35fb67 100644
--- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/TranslationSupportTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/query/TranslationSupportTests.java
@@ -14,8 +14,7 @@ package org.eclipse.equinox.p2.tests.ui.query;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Locale;
+import java.util.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.engine.Profile;
import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry;
@@ -82,6 +81,7 @@ public class TranslationSupportTests extends AbstractQueryTest {
iuDescription.setId("some IU");
iuDescription.setVersion(Version.createOSGi(1, 0, 0));
iuDescription.setLicenses(new ILicense[] {MetadataFactory.createLicense(new URI("http://example.com"), "%license")});
+ iuDescription.addProvidedCapabilities(Collections.singleton(MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "some IU", Version.createOSGi(1, 0, 0))));
IInstallableUnit iu = MetadataFactory.createInstallableUnit(iuDescription);
// Create a bunch of fragments which spec our IU as their host
diff --git a/bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch b/bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch
index b7f4c3c31..3cd757414 100644
--- a/bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch
+++ b/bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
<booleanAttribute key="append.args" value="true"/>
<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/>
@@ -52,7 +52,7 @@
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.equinox.p2.tests.AutomatedTests"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consolelog -console"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.equinox.p2.tests"/>
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 723e2a862..8ab3276d2 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
@@ -21,7 +21,6 @@ import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.internal.p2.persistence.XMLWriter;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery;
@@ -253,7 +252,7 @@ public class AbstractAntProvisioningTest extends AbstractProvisioningTest {
try {
IArtifactRepository repo = getArtifactRepositoryManager().loadRepository(artifactRepositoryLocation, null);
List fromIUs = getArtifactKeys(ius);
- Collection fromRepo = repo.query(ArtifactKeyQuery.ALL_KEYS, null).toCollection();
+ Iterator fromRepo = repo.query(ArtifactKeyQuery.ALL_KEYS, null).iterator();
assertContains(message, fromIUs, fromRepo);
assertContains(message, fromRepo, fromIUs);
} catch (ProvisionException e) {
@@ -262,25 +261,8 @@ public class AbstractAntProvisioningTest extends AbstractProvisioningTest {
}
- protected 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, destinationCollector.size());
- assertTrue(message, sourceIU.equals(destinationCollector.iterator().next()));
- }
- }
-
- protected static void assertContains(String message, Collection fromIUs, Collection fromRepo) {
- for (Iterator iter = fromIUs.iterator(); iter.hasNext();)
- assertTrue(message, fromRepo.contains(iter.next()));
- }
-
protected static List getArtifactKeys(IQueryResult ius) {
- List keys = new ArrayList(ius.size());
+ List keys = new ArrayList();
for (Iterator iter = ius.iterator(); iter.hasNext();)
keys.addAll(Arrays.asList(((InstallableUnit) iter.next()).getArtifacts()));
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 83a23c6ac..9328dc838 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
@@ -632,6 +632,30 @@ 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);
@@ -801,7 +825,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
IQueryResult queryResult = repository.query(new InstallableUnitQuery(name), null);
IInstallableUnit unit = null;
- if (queryResult.size() > 0)
+ if (!queryResult.isEmpty())
unit = (IInstallableUnit) queryResult.iterator().next();
return unit;
@@ -901,17 +925,17 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
protected static void assertInstallOperand(IProvisioningPlan plan, IInstallableUnit iu) {
- if (plan.getAdditions().query(new InstallableUnitQuery(iu), null).size() == 0)
+ if (plan.getAdditions().query(new InstallableUnitQuery(iu), null).isEmpty())
fail("Can't find " + iu + " in the plan");
}
protected static void assertUninstallOperand(IProvisioningPlan plan, IInstallableUnit iu) {
- if (plan.getRemovals().query(new InstallableUnitQuery(iu), null).size() == 0)
+ 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).size() + plan.getAdditions().query(new InstallableUnitQuery(iu), null).size() != 0)
+ 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.");
}
@@ -1181,7 +1205,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
while (it.hasNext()) {
IInstallableUnit sourceIU = (IInstallableUnit) it.next();
IQueryResult destinationCollector = destinationRepo.query(new InstallableUnitQuery(sourceIU), null);
- assertEquals(message, 1, destinationCollector.size());
+ assertEquals(message, 1, queryResultSize(destinationCollector));
assertEquals(message, sourceIU, (IInstallableUnit) destinationCollector.iterator().next());
}
}
@@ -1195,6 +1219,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.
@@ -1349,7 +1428,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
protected int getArtifactKeyCount(IArtifactRepository repo) {
- return repo.query(ArtifactKeyQuery.ALL_KEYS, null).size();
+ return queryResultSize(repo.query(ArtifactKeyQuery.ALL_KEYS, null));
}
protected int getArtifactDescriptorCount(URI location) {
@@ -1357,7 +1436,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
try {
IArtifactRepository repo = getArtifactRepositoryManager().loadRepository(location, null);
IQueryResult descriptors = repo.query(ArtifactDescriptorQuery.ALL_DESCRIPTORS, null);
- return descriptors.size();
+ return queryResultSize(descriptors);
} catch (ProvisionException e) {
fail("Failed to load repository " + URIUtil.toUnencodedString(location) + " for ArtifactDescriptor count");
}
@@ -1365,6 +1444,6 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
public int countPlanElements(IProvisioningPlan plan) {
- return new CompoundQueryable(new IQueryable[] {plan.getAdditions(), plan.getRemovals()}).query(InstallableUnitQuery.ANY, null).size();
+ return queryResultSize(new CompoundQueryable(new IQueryable[] {plan.getAdditions(), plan.getRemovals()}).query(InstallableUnitQuery.ANY, null));
}
}
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
index 402cffd28..4858e1f86 100644
--- 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
@@ -126,7 +126,7 @@ public class IUPropertyUtils {
};
IQuery iuQuery = new PipedQuery(new IQuery[] {new FragmentQuery(), hostLocalizationQuery});
- Collector collected = iuQuery.perform(localizationFragments.iterator(), new Collector());
+ IQueryResult collected = iuQuery.perform(localizationFragments.iterator());
if (!collected.isEmpty()) {
String translation = null;
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 898f5aa63..7428f4755 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,6 @@ 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.Collector;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
import org.eclipse.equinox.p2.metadata.query.IQuery;
import org.eclipse.equinox.p2.metadata.query.IQueryResult;
@@ -39,7 +38,7 @@ public class MockQueryable implements IQueryable {
}
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- return query.perform(items.iterator(), new Collector());
+ return query.perform(items.iterator());
}
}
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 a23dfe7a0..8c69e6187 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
@@ -16,12 +16,12 @@ import java.util.*;
import junit.framework.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
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.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.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
@@ -70,8 +70,8 @@ public class TestMetadataRepository extends AbstractMetadataRepository {
return null;
}
- public Collector query(IQuery query, IProgressMonitor monitor) {
- return query.perform(units.iterator(), new 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/MirrorTaskTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/MirrorTaskTest.java
index f5831eee2..cb75b7d95 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
@@ -315,7 +315,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 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));
@@ -344,7 +344,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 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) {
@@ -373,7 +373,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 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) {
@@ -401,7 +401,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 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) {
@@ -433,7 +433,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 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) {
@@ -465,7 +465,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 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) {
@@ -498,7 +498,7 @@ 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 NullProgressMonitor()).size(), getIUCount(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 NullProgressMonitor()), destinationRepo);
@@ -762,7 +762,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
*/
protected int getIUCount(URI location) {
try {
- return getMetadataRepositoryManager().loadRepository(location, null).query(InstallableUnitQuery.ANY, 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;
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 b7f4e2e93..54b4a1c17 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,7 +12,6 @@ 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.core.ProvisionException;
@@ -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 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);
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 5388e0b9f..ee94e277f 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
@@ -65,7 +65,7 @@ public class RepoTasksTests extends AbstractAntProvisioningTest {
IArtifactRepository artifacts = getArtifactRepositoryManager().loadRepository(destinationRepo, null);
IQueryResult keys = artifacts.query(new ArtifactKeyQuery(null, "anotherplugin", null), null);
- assertEquals(keys.size(), 0);
+ 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/repository/CompositeArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java
index f475176fa..c710217aa 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
@@ -363,7 +363,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
//get the keys
IQueryResult keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null);
- assertTrue("Error retreaiving artifact keys", keys.size() > 0);
+ assertTrue("Error retreaiving artifact keys", !keys.isEmpty());
//test for existing key
assertTrue("Asserting key is in composite repo", compRepo.contains((IArtifactKey) keys.iterator().next()));
@@ -391,7 +391,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
//get the descriptors
IQueryResult keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null);
- assertTrue("Error retreaiving artifact keys", keys.size() > 0);
+ assertTrue("Error retreaiving artifact keys", !keys.isEmpty());
IArtifactDescriptor[] descriptors = repo.getArtifactDescriptors((IArtifactKey) keys.iterator().next());
assertTrue("Error retreaiving artifact descriptors", descriptors.length > 0);
@@ -422,7 +422,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
}
IQueryResult keys = compRepo.query(ArtifactKeyQuery.ALL_KEYS, null);
- assertTrue("Error retreaiving artifact keys", keys.size() > 0);
+ 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);
@@ -507,7 +507,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
//create a request for a descriptor from repo1
IQueryResult keys1 = repo1.query(ArtifactKeyQuery.ALL_KEYS, null);
IArtifactKey key1 = (IArtifactKey) keys1.iterator().next();
- assertTrue("Error retreaiving artifact keys", keys1.size() > 0);
+ 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]));
@@ -522,7 +522,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
//create a request for a descriptor from repo2
IQueryResult keys2 = repo2.query(ArtifactKeyQuery.ALL_KEYS, null);
IArtifactKey key2 = (IArtifactKey) keys2.iterator().next();
- assertTrue("Error retreaiving artifact keys", keys2.size() > 0);
+ 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]));
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 0c53e9c5d..304ea1148 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
@@ -91,14 +91,14 @@ public class FoldersRepositoryTest extends TestCase {
repo.addDescriptor(descriptor);
}
IQueryResult keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null);
- assertEquals(2, keys.size());
+ assertEquals(2, AbstractProvisioningTest.queryResultSize(keys));
for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
IArtifactKey key = (IArtifactKey) iterator.next();
repo.removeDescriptor(key);
}
keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null);
- assertEquals(0, keys.size());
+ 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/MirrorRequestTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java
index 4e7f208b3..3e04f8fe6 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
@@ -136,7 +136,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
source.setSequence(seq);
// Grab an ArtifactKey to mirror, doesn't matter which
IQueryResult keys = source.query(ArtifactKeyQuery.ALL_KEYS, null);
- assertTrue("Unable to obtain artifact keys", keys != null && keys.size() > 0);
+ assertTrue("Unable to obtain artifact keys", keys != null && !keys.isEmpty());
IArtifactKey key = (IArtifactKey) keys.iterator().next();
MirrorRequest req = new MirrorRequest(key, targetRepository, null, null);
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 62ab04276..87032c610 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
@@ -365,15 +365,15 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
repo.addDescriptor(d3);
IQueryResult result = repo.query(new ArtifactDescriptorQuery("a", null, null), null);
- assertEquals(3, result.size());
+ assertEquals(3, queryResultSize(result));
result = repo.query(new ArtifactDescriptorQuery(null, new VersionRange("[2.0.0, 3.0.0)"), null), null);
- assertEquals(2, result.size());
- assertFalse(result.toCollection().contains(d1));
+ assertEquals(2, queryResultSize(result));
+ assertNotContains(result, d1);
result = repo.query(new ArtifactDescriptorQuery(null, null, IArtifactDescriptor.FORMAT_PACKED), null);
- assertEquals(1, result.size());
- assertTrue(result.toCollection().contains(d3));
+ assertEquals(1, queryResultSize(result));
+ assertContains(result, d3);
}
public void testArtifactIterator() throws Exception {
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 226aa55d4..416bd45cf 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
@@ -13,6 +13,8 @@ import java.util.*;
import junit.framework.TestCase;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
* This tests both Compound and Composite queries
@@ -30,7 +32,7 @@ public class AggregateQueryTest extends TestCase {
public void testEmptyCompositeQuery() {
PipedQuery query = new PipedQuery(new IQuery[0]);
- query.perform(getABCDE().iterator(), new Collector());
+ query.perform(getABCDE().iterator());
// We should not throw an exception. No guarantee on what perform
// will return in this case
}
@@ -38,7 +40,8 @@ public class AggregateQueryTest extends TestCase {
public void testSymmetry() {
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());
@@ -51,7 +54,8 @@ public class AggregateQueryTest extends TestCase {
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"))
@@ -62,20 +66,20 @@ public class AggregateQueryTest extends TestCase {
};
CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {getLatest, getAllBut3}, true);
- Collector result = compoundQuery.perform(get123().iterator(), new Collector());
- assertEquals(0, result.size());
+ IQueryResult result = compoundQuery.perform(get123().iterator());
+ assertEquals(0, AbstractProvisioningTest.queryResultSize(result));
compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {getAllBut3, getLatest}, true);
- result = compoundQuery.perform(get123().iterator(), new Collector());
- assertEquals(0, result.size());
+ result = compoundQuery.perform(get123().iterator());
+ assertEquals(0, AbstractProvisioningTest.queryResultSize(result));
compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {getLatest, getAllBut3}, false);
- result = compoundQuery.perform(get123().iterator(), new Collector());
- assertEquals(3, result.size());
+ result = compoundQuery.perform(get123().iterator());
+ assertEquals(3, AbstractProvisioningTest.queryResultSize(result));
compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {getAllBut3, getLatest}, false);
- result = compoundQuery.perform(get123().iterator(), new Collector());
- assertEquals(3, result.size());
+ result = compoundQuery.perform(get123().iterator());
+ assertEquals(3, AbstractProvisioningTest.queryResultSize(result));
}
@@ -86,7 +90,8 @@ public class AggregateQueryTest extends TestCase {
public void testNonSymmetry() {
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());
@@ -99,7 +104,9 @@ public class AggregateQueryTest extends TestCase {
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"))
@@ -110,13 +117,13 @@ public class AggregateQueryTest extends TestCase {
};
PipedQuery compoundQuery = new PipedQuery(new IQuery[] {getLatest, getAllBut3});
- Collector result = compoundQuery.perform(get123().iterator(), new Collector());
- assertEquals(0, result.size());
+ IQueryResult result = compoundQuery.perform(get123().iterator());
+ assertEquals(0, AbstractProvisioningTest.queryResultSize(result));
compoundQuery = new PipedQuery(new IQuery[] {getAllBut3, getLatest});
- result = compoundQuery.perform(get123().iterator(), new Collector());
- assertEquals(1, result.size());
- assertEquals("2", result.toCollection().iterator().next());
+ result = compoundQuery.perform(get123().iterator());
+ assertEquals(1, AbstractProvisioningTest.queryResultSize(result));
+ assertEquals("2", result.iterator().next());
}
@@ -151,7 +158,7 @@ public class AggregateQueryTest extends TestCase {
}
};
IQuery B = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ public Collector perform(Iterator iterator) {
// TODO Auto-generated method stub
return null;
}
@@ -171,19 +178,19 @@ public class AggregateQueryTest extends TestCase {
public void testCompoundNoMatchQueries() {
IQuery A = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ public Collector perform(Iterator iterator) {
// TODO Auto-generated method stub
return null;
}
};
IQuery B = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ public Collector perform(Iterator iterator) {
// TODO Auto-generated method stub
return null;
}
};
IQuery C = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ public Collector perform(Iterator iterator) {
// TODO Auto-generated method stub
return null;
}
@@ -214,15 +221,16 @@ public class AggregateQueryTest extends TestCase {
};
CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {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"));
+ 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() {
IQuery ABC = 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("A") || o.equals("B") || o.equals("C"))
@@ -233,7 +241,8 @@ public class AggregateQueryTest extends TestCase {
};
IQuery BCDE = 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("B") || o.equals("C") || o.equals("D") || o.equals("E"))
@@ -244,10 +253,10 @@ public class AggregateQueryTest extends TestCase {
};
CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {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"));
+ 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() {
@@ -268,18 +277,19 @@ public class AggregateQueryTest extends TestCase {
};
CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {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"));
+ 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() {
IQuery ABC = 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("A") || o.equals("B") || o.equals("C"))
@@ -290,7 +300,8 @@ public class AggregateQueryTest extends TestCase {
};
IQuery BCDE = 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("B") || o.equals("C") || o.equals("D") || o.equals("E"))
@@ -301,12 +312,12 @@ public class AggregateQueryTest extends TestCase {
};
CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {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"));
+ 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 fd2aa834e..b299ba7b6 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
@@ -68,14 +68,13 @@ public class CollectorTest extends AbstractProvisioningTest {
return false;
}
};
- IQueryResult queryResult = numeric.perform(list.iterator(), new Collector());
- assertEquals("1.0", 7, queryResult.toCollection().size());
+ IQueryResult queryResult = numeric.perform(list.iterator());
+ assertEquals("1.0", 7, queryResultSize(queryResult));
queryResult = queryResult.query(fourOrFiveOrABC, null);
- Collection collection = queryResult.toCollection();
- assertEquals("2.0", 2, collection.size());
- assertTrue("2.1", collection.contains("4"));
- assertTrue("2.2", collection.contains("5"));
+ assertEquals("2.0", 2, queryResultSize(queryResult));
+ assertContains("2.1", queryResult, "4");
+ assertContains("2.2", queryResult, "5");
}
public void testSameCollector() {
@@ -99,11 +98,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.addAll(collector.query(fourOrFiveOrABC, null));
- Collection collection = collector.toCollection();
+ Collection collection = collector.unmodifiableSet();
assertEquals("2.0", 7, collection.size());
}
@@ -131,17 +131,16 @@ public class CollectorTest extends AbstractProvisioningTest {
return false;
}
};
- IQueryResult queryResult = eightOrNine.perform(list.iterator(), new Collector());
- assertEquals("1.0", 0, queryResult.toCollection().size());
+ IQueryResult queryResult = eightOrNine.perform(list.iterator());
+ assertTrue("1.0", queryResult.isEmpty());
queryResult = queryResult.query(fourOrFiveOrABC, null);
- Collection collection = queryResult.toCollection();
- assertEquals("2.0", 0, collection.size());
+ 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 {
@@ -153,7 +152,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 5f437f0ec..00e12f081 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,13 +9,15 @@
******************************************************************************/
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.metadata.query.IQuery;
import org.eclipse.equinox.p2.metadata.query.IQueryResult;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
* Tests the compound queryable
@@ -59,10 +61,10 @@ public class CompoundQueryableTest extends TestCase {
Integer[] elements = new Integer[] {1, 2, 3, 4, 5};
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- Collector collector = new Collector();
+ IQueryResult collector;
try {
monitor.beginTask("", 10);
- collector = query.perform(createIterator(elements), collector);
+ collector = query.perform(createIterator(elements));
monitor.worked(10);
} finally {
monitor.done();
@@ -75,10 +77,10 @@ public class CompoundQueryableTest extends TestCase {
Integer[] elements = new Integer[] {4, 6, 8, 10, 12};
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- Collector collector = new Collector();
+ IQueryResult collector;
try {
monitor.beginTask("", 10);
- collector = query.perform(createIterator(elements), collector);
+ collector = query.perform(createIterator(elements));
monitor.worked(10);
} finally {
monitor.done();
@@ -91,10 +93,10 @@ public class CompoundQueryableTest extends TestCase {
Integer[] elements = new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- Collector collector = new Collector();
+ IQueryResult collector;
try {
monitor.beginTask("", 10);
- collector = query.perform(createIterator(elements), collector);
+ collector = query.perform(createIterator(elements));
monitor.worked(10);
} finally {
monitor.done();
@@ -128,7 +130,8 @@ public class CompoundQueryableTest extends TestCase {
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) {
@@ -141,7 +144,8 @@ public class CompoundQueryableTest extends TestCase {
};
IQuery greatestNumberQuery = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ public Collector perform(Iterator iterator) {
+ Collector result = new Collector();
int greatest = Integer.MIN_VALUE;
while (iterator.hasNext()) {
int item = ((Integer) iterator.next()).intValue();
@@ -159,67 +163,61 @@ public class CompoundQueryableTest extends TestCase {
CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
IQueryResult queryResult = cQueryable.query(matchQuery, monitor);
- assertEquals("1.0", 6, queryResult.size());
- Collection collection = queryResult.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));
+ 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});
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
IQueryResult queryResult = cQueryable.query(matchQuery, monitor);
- assertEquals("1.0", 2, queryResult.size());
- Collection collection = queryResult.toCollection();
- assertTrue("1.1", collection.contains(2));
- assertTrue("1.2", collection.contains(4));
+ 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});
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
IQueryResult queryResult = cQueryable.query(greatestNumberQuery, monitor);
- assertEquals("1.0", 1, queryResult.size());
- Collection collection = queryResult.toCollection();
- assertTrue("1.1", collection.contains(5));
+ assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(queryResult));
+ AbstractProvisioningTest.assertContains("1.1", queryResult, 5);
}
public void testMultipleContextQueries() {
CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
IQueryResult queryResult = cQueryable.query(greatestNumberQuery, monitor);
- assertEquals("1.0", 1, queryResult.size());
- Collection collection = queryResult.toCollection();
- assertTrue("1.1", collection.contains(12));
+ assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(queryResult));
+ AbstractProvisioningTest.assertContains("1.1", queryResult, 12);
}
public void testCompoundMatchAndQuery() {
CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
IQueryResult queryResult = cQueryable.query(CompoundQuery.createCompoundQuery(new IQuery[] {matchQuery, matchMod4query}, true), monitor);
- assertEquals("1.0", 3, queryResult.size());
- Collection collection = queryResult.toCollection();
- assertTrue("1.2", collection.contains(4));
- assertTrue("1.4", collection.contains(8));
- assertTrue("1.6", collection.contains(12));
+ 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});
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
IQueryResult queryResult = cQueryable.query(CompoundQuery.createCompoundQuery(new IQuery[] {matchQuery, matchMod4query}, false), monitor);
- assertEquals("1.0", 6, queryResult.size());
- Collection collection = queryResult.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));
+ 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() {
@@ -266,15 +264,14 @@ public class CompoundQueryableTest extends TestCase {
CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {cQueryable1, queryable1});
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
IQueryResult queryResult = cQueryable.query(CompoundQuery.createCompoundQuery(new IQuery[] {contextQuery, greatestNumberQuery}, false), monitor);
- assertEquals("1.0", 7, queryResult.size());
- Collection collection = queryResult.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));
+ 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());
}
@@ -284,9 +281,8 @@ public class CompoundQueryableTest extends TestCase {
CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {cQueryable1, queryable1});
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
IQueryResult queryResult = cQueryable.query(new PipedQuery(new IQuery[] {contextQuery, greatestNumberQuery}), monitor);
- assertEquals("1.0", 1, queryResult.size());
- Collection collection = queryResult.toCollection();
- assertTrue("1.2", collection.contains(12));
+ 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/PropertyLookupQuery2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery2.java
index 7564cc633..6fc112e9e 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
@@ -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 93c7455c7..143200530 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,10 +10,13 @@
*******************************************************************************/
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.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
* Tests for the {@link org.eclipse.equinox.internal.provisional.p2.query.Query} class.
@@ -69,13 +72,11 @@ public class QueryTest extends TestCase {
public void testPerformSimple() {
List items = Arrays.asList("red", "green", "blue");
IQuery 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"));
+ 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");
}
/**
@@ -84,20 +85,17 @@ public class QueryTest extends TestCase {
public void testPerformSomeMatches() {
List items = Arrays.asList(new Object(), "green", new Object());
IQuery 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"));
+ 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());
@@ -137,11 +135,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
}
@@ -152,7 +149,6 @@ 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 IQuery[] {query1, query2}, true);
@@ -160,7 +156,7 @@ public class QueryTest extends TestCase {
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());
@@ -171,7 +167,6 @@ 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 IQuery[] {query1, query2}, false);
@@ -179,7 +174,7 @@ public class QueryTest extends TestCase {
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());
@@ -190,7 +185,6 @@ 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();
PipedQuery cQuery = new PipedQuery(new IQuery[] {query1, query2});
@@ -198,7 +192,7 @@ public class QueryTest extends TestCase {
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());
@@ -209,7 +203,6 @@ 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 IQuery[] {query1, query2}, true);
@@ -218,7 +211,7 @@ public class QueryTest extends TestCase {
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
@@ -233,7 +226,6 @@ 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();
PipedQuery cQuery = new PipedQuery(new IQuery[] {query1, query2});
@@ -242,7 +234,7 @@ public class QueryTest extends TestCase {
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
@@ -259,42 +251,38 @@ public class QueryTest extends TestCase {
List items = Arrays.asList("red", "green", "blue");
IQuery query = new AnyStringQuery();
IQuery limitQuery = new LimitQuery(query, 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"));
+ 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);
- Collector collector = limitQuery.perform(items.iterator(), new Collector());
- Collection result = collector.toCollection();
- assertEquals("1.0", 2, result.size());
- assertTrue("1.1", result.contains("red"));
- assertTrue("1.2", result.contains("green"));
+ 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);
- Collector collector = limitQuery.perform(items.iterator(), new 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"));
+ 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);
- Collector collector = limitQuery.perform(items.iterator(), new Collector());
- Collection result = collector.toCollection();
- assertEquals("1.0", 0, result.size());
+ IQueryResult collector = limitQuery.perform(items.iterator());
+ assertEquals("1.0", 0, AbstractProvisioningTest.queryResultSize(collector));
}
// public void testPipedLimitQuery() {
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 522849fe4..745ee0d30 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
@@ -11,8 +11,6 @@
package org.eclipse.equinox.p2.tests.director;
import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.director.DirectorActivator;
@@ -25,6 +23,7 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUni
import org.eclipse.equinox.p2.core.IAgentLocation;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.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;
@@ -114,9 +113,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, 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);
@@ -126,10 +125,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, 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]);
@@ -137,10 +136,10 @@ 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, 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() {
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 c03947502..7ef126b57 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
@@ -87,7 +87,7 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest {
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() {
@@ -118,7 +118,7 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest {
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 {
@@ -161,7 +161,7 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest {
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/ProfileRegistryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java
index 91b34e4dd..0a25e2844 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
@@ -137,21 +137,21 @@ 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, null).size());
+ assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty());
profile.addInstallableUnit(createIU("test"));
- assertEquals(1, profile.query(InstallableUnitQuery.ANY, 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, null).size());
+ assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null)));
profile.removeInstallableUnit(createIU("test"));
- assertEquals(0, profile.query(InstallableUnitQuery.ANY, 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, null).size());
+ assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty());
registry.removeProfile(PROFILE_NAME);
restart();
assertNull(registry.getProfile(PROFILE_NAME));
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 35382a5e7..0921eed7a 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
@@ -23,6 +23,7 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUni
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.osgi.framework.BundleContext;
import org.xml.sax.*;
@@ -84,7 +85,7 @@ public class ProfileTest extends AbstractProvisioningTest {
Profile profile = (Profile) registry.addProfile(PROFILE_NAME);
assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty());
profile.addInstallableUnit(createIU("test"));
- assertEquals(1, profile.query(InstallableUnitQuery.ANY, null).size());
+ assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null)));
profile.removeInstallableUnit(createIU("test"));
assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty());
registry.removeProfile(PROFILE_NAME);
@@ -97,9 +98,9 @@ public class ProfileTest extends AbstractProvisioningTest {
Profile profile = (Profile) registry.addProfile(PROFILE_NAME);
assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty());
profile.addInstallableUnit(createIU("test"));
- assertEquals(1, profile.query(InstallableUnitQuery.ANY, null).size());
+ assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null)));
profile.addInstallableUnit(createIU("test"));
- assertEquals(1, profile.query(InstallableUnitQuery.ANY, null).size());
+ assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null)));
registry.removeProfile(PROFILE_NAME);
assertNull(registry.getProfile(PROFILE_NAME));
}
@@ -118,7 +119,7 @@ public class ProfileTest extends AbstractProvisioningTest {
assertEquals("test", profile.getInstallableUnitProperty(createIU("test"), "test"));
profile.removeInstallableUnitProperty(createIU("test"), "test");
assertNull(profile.getInstallableUnitProperty(createIU("test"), "test"));
- assertEquals(1, profile.query(InstallableUnitQuery.ANY, null).size());
+ assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null)));
registry.removeProfile(PROFILE_NAME);
assertNull(registry.getProfile(PROFILE_NAME));
}
@@ -129,7 +130,7 @@ public class ProfileTest extends AbstractProvisioningTest {
Profile profile = (Profile) registry.addProfile(PROFILE_NAME);
assertTrue(profile.available(InstallableUnitQuery.ANY, null).isEmpty());
profile.addInstallableUnit(createIU("test"));
- assertEquals(1, profile.available(InstallableUnitQuery.ANY, null).size());
+ assertEquals(1, queryResultSize(profile.available(InstallableUnitQuery.ANY, null)));
profile.setSurrogateProfileHandler(new ISurrogateProfileHandler() {
public IProfile createProfile(String id) {
return null;
@@ -139,7 +140,7 @@ public class ProfileTest extends AbstractProvisioningTest {
return false;
}
- public Collector queryProfile(IProfile profile, IQuery query, IProgressMonitor monitor) {
+ public IQueryResult queryProfile(IProfile profile, IQuery query, IProgressMonitor monitor) {
return new Collector();
}
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 414ce2155..a63a180c5 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,7 +11,6 @@
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.*;
@@ -83,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, null).size());
- assertEquals(1, surrogateProfile.available(InstallableUnitQuery.ANY, null).size());
+ assertEquals(0, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null)));
+ assertEquals(1, queryResultSize(surrogateProfile.available(InstallableUnitQuery.ANY, null)));
}
public void testUpdateProfile() throws ProvisionException {
@@ -93,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, null).size());
+ assertEquals(1, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null)));
// HashSet used here to eliminate duplicates
- assertEquals(1, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, null).toCollection()).size());
+ assertEquals(1, queryResultUniqueSize(surrogateProfile.available(InstallableUnitQuery.ANY, null)));
handler.updateProfile(surrogateProfile);
- assertEquals(1, surrogateProfile.query(InstallableUnitQuery.ANY, null).size());
+ assertEquals(1, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null)));
// HashSet used here to eliminate duplicates
- assertEquals(1, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, 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, null).size());
+ assertEquals(2, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null)));
// HashSet used here to eliminate duplicates
- assertEquals(2, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, 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, null).size());
+ assertEquals(2, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null)));
// HashSet used here to eliminate duplicates
- assertEquals(3, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, 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, null).size());
+ assertEquals(3, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null)));
// HashSet used here to eliminate duplicates
- assertEquals(3, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, 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/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java
index d59588788..b76afd775 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
@@ -163,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, null).toCollection().size() != 3)
+ if (queryResultSize(repo.query(InstallableUnitQuery.ANY, null)) != 3)
fail("2.99");
} catch (ProvisionException ex) {
fail("2.0");
@@ -179,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, null).toCollection().size() != 2)
+ if (queryResultSize(repo.query(InstallableUnitQuery.ANY, null)) != 2)
fail("3.0");
} catch (ProvisionException ex) {
fail("2.0");
@@ -195,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, null).toCollection().size() != 1)
+ if (queryResultSize(repo.query(InstallableUnitQuery.ANY, null)) != 1)
fail("3.0");
} catch (ProvisionException ex) {
fail("2.0");
@@ -209,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, 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/End2EndTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
index c00469494..5af9ebf16 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
@@ -112,18 +112,18 @@ public class End2EndTest extends AbstractProvisioningTest {
private void attemptToUninstallRCP35(IProfile profile2, File installFolder) {
IQueryResult collect = profile2.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
- assertEquals(1, collect.size());
+ 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 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");
IQueryResult collect = profile2.query(new InstallableUnitQuery("org.eclipse.platform.ide"), new NullProgressMonitor());
- assertEquals(1, collect.size());
+ 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()});
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 270952581..25f16053e 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
@@ -10,7 +10,6 @@
package org.eclipse.equinox.p2.tests.metadata;
import java.net.URI;
-import java.util.Collection;
import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.LatestIUVersionQuery;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
@@ -36,9 +35,8 @@ public class LatestIUTest extends AbstractProvisioningTest {
metadataRepositoryManager.addRepository(location);
IQueryResult query = metadataRepositoryManager.query(new LatestIUVersionQuery(), null);
- Collection collection = query.toCollection();
- assertEquals("1.0", 1, collection.size());
- assertEquals("1.1", Version.createOSGi(2, 1, 0), ((IInstallableUnit) collection.iterator().next()).getVersion());
+ 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,9 +51,8 @@ public class LatestIUTest extends AbstractProvisioningTest {
metadataRepositoryManager.addRepository(location);
IQueryResult query = metadataRepositoryManager.query(new LatestIUVersionQuery(), null);
- Collection collection = query.toCollection();
- assertEquals("1.0", 1, collection.size());
- assertEquals("1.1", Version.createOSGi(3, 0, 0), ((IInstallableUnit) collection.iterator().next()).getVersion());
+ 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,8 +70,7 @@ public class LatestIUTest extends AbstractProvisioningTest {
metadataRepositoryManager.addRepository(location2);
IQueryResult queryResult = metadataRepositoryManager.query(new LatestIUVersionQuery(), null);
- Collection collection = queryResult.toCollection();
- assertEquals("1.0", 1, collection.size());
- assertEquals("1.1", Version.createOSGi(3, 0, 0), ((IInstallableUnit) collection.iterator().next()).getVersion());
+ 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/repository/CompositeMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java
index d776df72c..4c1d3ea69 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
@@ -267,7 +267,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, null), repo2.query(InstallableUnitQuery.ANY, null)), compRepo.query(InstallableUnitQuery.ANY, 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() {
@@ -459,9 +459,8 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest {
compositeRepo.addChild(location1);
compositeRepo.addChild(location2);
IQueryResult queryResult = compositeRepo.query(new LatestIUVersionQuery(), monitor);
- Collection collection = queryResult.toCollection();
- assertEquals("1.0", 1, collection.size());
- assertEquals("1.1", Version.createOSGi(3, 0, 0), ((IInstallableUnit) collection.iterator().next()).getVersion());
+ 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());
}
@@ -491,9 +490,8 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest {
}
}, new LatestIUVersionQuery()});
IQueryResult queryResult = compositeRepo.query(cQuery, monitor);
- Collection collection = queryResult.toCollection();
- assertEquals("1.0", 1, collection.size());
- assertEquals("1.1", Version.createOSGi(2, 2, 0), ((IInstallableUnit) collection.iterator().next()).getVersion());
+ 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());
}
@@ -537,7 +535,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, null), repo2.query(InstallableUnitQuery.ANY, null)), compRepo.query(InstallableUnitQuery.ANY, 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) {
@@ -563,8 +561,8 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest {
* Needed to verify that only the appropriate number of files have been transfered by the mirror application
*/
private int getNumUnique(IQueryResult c1, IQueryResult c2) {
- Object[] repo1 = c1.toCollection().toArray();
- Object[] repo2 = c2.toCollection().toArray();
+ 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;
@@ -636,7 +634,7 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest {
List children = repository.getChildren();
assertEquals("2.0", 2, children.size());
IQueryResult queryResult = repository.query(InstallableUnitQuery.ANY, getMonitor());
- assertEquals("2.1", 2, queryResult.size());
+ assertEquals("2.1", 2, queryResultSize(queryResult));
// ensure the child URIs are stored as relative
CompositeRepositoryState state = repository.toState();
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 a62073108..5dd8937ad 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
@@ -125,7 +125,7 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest {
IInstallableUnit iu = createIU("foo");
repo.addInstallableUnits(new IInstallableUnit[] {iu});
IQueryResult result = repo.query(new InstallableUnitQuery((String) null), getMonitor());
- assertTrue("1.0", result.size() == 1);
+ assertEquals("1.0", 1, queryResultSize(result));
repo.removeAll();
result = repo.query(new InstallableUnitQuery((String) null), getMonitor());
assertTrue("1.1", result.isEmpty());
@@ -138,10 +138,10 @@ public class LocalMetadataRepositoryTest extends AbstractProvisioningTest {
IInstallableUnit iu2 = createIU("bar");
repo.addInstallableUnits(new IInstallableUnit[] {iu, iu2});
IQueryResult result = repo.query(new InstallableUnitQuery((String) null), getMonitor());
- assertTrue("1.0", result.size() == 2);
+ assertEquals("1.0", 2, queryResultSize(result));
repo.removeInstallableUnits(new IInstallableUnit[] {iu}, getMonitor());
result = repo.query(new InstallableUnitQuery((String) null), getMonitor());
- assertTrue("1.1", result.size() == 1);
+ 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());
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 cf25a469c..4dcbc595a 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
@@ -410,7 +410,7 @@ public class MetadataRepositoryManagerTest extends AbstractProvisioningTest {
try {
IMetadataRepository repository = manager.loadRepository(location, getMonitor());
IQueryResult result = repository.query(new InstallableUnitQuery("test.bundle"), getMonitor());
- assertEquals("1.0", 1, result.size());
+ 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/SPIMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java
index fdff1e13e..a7e844eea 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
@@ -637,18 +637,16 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
IQueryResult queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor());
- Collection collection = queryResult.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);
queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor());
- collection = queryResult.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);
}
/**
@@ -672,10 +670,9 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
IQueryResult queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor());
- Collection collection = queryResult.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);
@@ -683,10 +680,9 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
repo = manager.refreshRepository(repoLocation.toURI(), null);
queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor());
- collection = queryResult.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);
@@ -717,20 +713,18 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
IQueryResult queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor());
- Collection collection = queryResult.toCollection();
- assertEquals(1, collection.size());
+ assertEquals(1, queryResultSize(queryResult));
- IInstallableUnit unit = (IInstallableUnit) collection.iterator().next();
+ IInstallableUnit unit = (IInstallableUnit) queryResult.iterator().next();
assertEquals(unit.getRequiredCapabilities().length, 1);
assertTrue(unit.getRequiredCapabilities()[0] instanceof SPIRequiredCapability);
repo = manager.refreshRepository(repoLocation.toURI(), null);
queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor());
- collection = queryResult.toCollection();
- assertEquals(1, collection.size());
+ assertEquals(1, queryResultSize(queryResult));
- unit = (IInstallableUnit) collection.iterator().next();
+ unit = (IInstallableUnit) queryResult.iterator().next();
assertEquals(unit.getRequiredCapabilities().length, 1);
assertTrue(unit.getRequiredCapabilities()[0] instanceof RequiredCapability);
assertTrue(((IRequiredCapability) unit.getRequiredCapabilities()[0]).getName().equals("bar"));
@@ -785,9 +779,8 @@ public class SPIMetadataRepositoryTest extends AbstractProvisioningTest {
repo = manager.refreshRepository(repoLocation.toURI(), null);
IQueryResult queryResult = repo.query(new AllAcceptingQuery(), new NullProgressMonitor());
- Collection collection = queryResult.toCollection();
- assertEquals(2, collection.size());
- Iterator iterator = collection.iterator();
+ assertEquals(2, queryResultSize(queryResult));
+ Iterator iterator = queryResult.iterator();
IInstallableUnit unit = null;
IInstallableUnitPatch patchUnit = null;
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 ec1a2083b..7ecf6e742 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
@@ -109,8 +109,8 @@ public class MetadataMirrorApplicationTest extends AbstractProvisioningTest {
* Needed to verify that only the appropriate number of files have been transfered by the mirror application
*/
private int getNumUnique(IQueryResult c1, IQueryResult c2) {
- Object[] repo1 = c1.toCollection().toArray();
- Object[] repo2 = c2.toCollection().toArray();
+ Object[] repo1 = c1.toArray(IInstallableUnit.class);
+ Object[] repo2 = c2.toArray(IInstallableUnit.class);
//initialize to the size of both query results
int numKeys = repo1.length + repo2.length;
@@ -362,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, null), getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, 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);
}
@@ -467,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, null), getMetadataRepositoryManager().loadRepository(sourceRepo3Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, 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);
}
@@ -652,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, null), getMetadataRepositoryManager().loadRepository(sourceRepo4Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, 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);
}
@@ -938,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, null), getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, 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/NewMirrorApplicationMetadataTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java
index 22a584da8..aca4f08f0 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
@@ -136,8 +136,8 @@ public class NewMirrorApplicationMetadataTest extends AbstractProvisioningTest {
* Needed to verify that only the appropriate number of files have been transfered by the mirror application
*/
private int getNumUnique(IQueryResult c1, IQueryResult c2) {
- Object[] repo1 = c1.toCollection().toArray();
- Object[] repo2 = c2.toCollection().toArray();
+ Object[] repo1 = c1.toArray(IInstallableUnit.class);
+ Object[] repo2 = c2.toArray(IInstallableUnit.class);
//initialize to the size of both QueryResults
int numKeys = repo1.length + repo2.length;
@@ -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, null), getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, 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, null), getMetadataRepositoryManager().loadRepository(sourceRepo3Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, 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, null), getMetadataRepositoryManager().loadRepository(sourceRepo4Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, 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, null), getMetadataRepositoryManager().loadRepository(sourceRepo2Location.toURI(), null).query(InstallableUnitQuery.ANY, null)), getMetadataRepositoryManager().loadRepository(destRepoLocation.toURI(), null).query(InstallableUnitQuery.ANY, 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/planner/ActualChangeRequestTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest.java
index e259c5409..a0280b0c3 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
@@ -52,7 +52,7 @@ public class ActualChangeRequestTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
engine.perform(plan, null);
assertProfileContainsAll("B is missing", profile1, new IInstallableUnit[] {b});
- assertEquals(1, profile1.query(InstallableUnitQuery.ANY, null).size());
+ assertEquals(1, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null)));
//Install A
ProfileChangeRequest req2 = new ProfileChangeRequest(profile1);
@@ -67,7 +67,7 @@ public class ActualChangeRequestTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan2.getRequestStatus(a).getSeverity());
engine.perform(plan2, null);
assertProfileContainsAll("A is missing", profile1, new IInstallableUnit[] {a, b});
- assertEquals(2, profile1.query(InstallableUnitQuery.ANY, null).size());
+ assertEquals(2, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null)));
//Uninstall B
ProfileChangeRequest req3 = new ProfileChangeRequest(profile1);
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 8e0fc7499..c5ea541f2 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
@@ -56,7 +56,7 @@ public class ActualChangeRequestTest2 extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
engine.perform(plan, null);
assertProfileContainsAll("B is missing", profile1, new IInstallableUnit[] {a, b});
- assertEquals(2, profile1.query(InstallableUnitQuery.ANY, null).size());
+ assertEquals(2, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null)));
//Install B2
ProfileChangeRequest req2 = new ProfileChangeRequest(profile1);
@@ -74,7 +74,7 @@ public class ActualChangeRequestTest2 extends AbstractProvisioningTest {
assertEquals(RequestStatus.REMOVED, ((RequestStatus) m.get(a)).getInitialRequestType());
engine.perform(plan2, null);
assertProfileContainsAll("A is missing", profile1, new IInstallableUnit[] {b2});
- assertEquals(1, profile1.query(InstallableUnitQuery.ANY, null).size());
+ assertEquals(1, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null)));
//Try to Install A
ProfileChangeRequest req3 = new ProfileChangeRequest(profile1);
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 e91a03b72..9fbcf2ef8 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
@@ -65,7 +65,7 @@ public class AddIUProperty extends AbstractProvisioningTest {
engine.perform(plan, null);
assertProfileContainsAll("A1 is missing", profile, new IInstallableUnit[] {a1});
IQueryResult allProfileIUs = profile.query(InstallableUnitQuery.ANY, null);
- assertEquals(allProfileIUs.size(), 1);
+ assertEquals(queryResultSize(allProfileIUs), 1);
//Add a2 with a1. This is an error
ProfileChangeRequest req4 = ProfileChangeRequest.createByProfileId(profile.getProfileId());
@@ -85,10 +85,10 @@ public class AddIUProperty extends AbstractProvisioningTest {
profile = getProfile(profile.getProfileId());
assertProfileContainsAll("A2 is missing", profile, new IInstallableUnit[] {a2});
allProfileIUs = profile.query(InstallableUnitQuery.ANY, null);
- assertEquals(allProfileIUs.size(), 1);
+ assertEquals(queryResultSize(allProfileIUs), 1);
IQueryResult iuProfileProperties = profile.query(new IUProfilePropertyQuery(SimplePlanner.INCLUSION_RULES, null), null);
- assertEquals(iuProfileProperties.size(), 1);
+ assertEquals(queryResultSize(iuProfileProperties), 1);
//Remove a1 optionality - should be a no-op
ProfileChangeRequest req3 = ProfileChangeRequest.createByProfileId(profile.getProfileId());
@@ -98,6 +98,6 @@ public class AddIUProperty extends AbstractProvisioningTest {
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/AgentPlanTestInExternalInstance.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java
index 737121f7a..ee82c37f4 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
@@ -277,7 +277,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1, act1b, act2});
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), null).size());
+ assertTrue(getProfile("installation").query(new InstallableUnitQuery("Action1", DEFAULT_VERSION), null).isEmpty());
assertEquals(getProfile("agent").getProfileId(), plan.getInstallerPlan().getProfile().getProfileId());
//uninstall A
@@ -303,7 +303,7 @@ public class AgentPlanTestInExternalInstance extends AbstractProvisioningTest {
requestForD.addInstallableUnits(new IInstallableUnit[] {d});
IProvisioningPlan planForD = planner.getProvisioningPlan(requestForD, ctx, new NullProgressMonitor());
assertNotNull(planForD.getInstallerPlan());
- assertEquals(1, planForD.getInstallerPlan().getRemovals().query(new InstallableUnitQuery(act1b.getId()), null).size());
+ 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(planForD, null));
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 cf75f7400..8dfab3212 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
@@ -277,7 +277,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
assertProfileContainsAll("Checking profile after install of actions", getProfile("agent"), new IInstallableUnit[] {act1, act1b, act2});
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), null).size());
+ assertTrue(getProfile("installation").query(new InstallableUnitQuery("Action1", DEFAULT_VERSION), null).isEmpty());
assertEquals(getProfile("agent").getProfileId(), plan.getInstallerPlan().getProfile().getProfileId());
//uninstall A
@@ -303,7 +303,7 @@ public class AgentPlanTestInExternalInstanceForCohostedMode extends AbstractProv
requestForD.addInstallableUnits(new IInstallableUnit[] {d});
IProvisioningPlan planForD = planner.getProvisioningPlan(requestForD, ctx, new NullProgressMonitor());
assertNotNull(planForD.getInstallerPlan());
- assertEquals(1, planForD.getInstallerPlan().getRemovals().query(new InstallableUnitQuery(act1b.getId()), null).size());
+ 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(planForD, null));
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 2b5365475..000fcc143 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
@@ -283,7 +283,7 @@ public class AgentPlanTestInRunningInstance extends AbstractProvisioningTest {
assertProfileContainsAll("Checking profile after install of actions", getProfile(IProfileRegistry.SELF), new IInstallableUnit[] {act1, act1b});
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), null).size());
+ assertTrue(getProfile(IProfileRegistry.SELF).query(new InstallableUnitQuery("Action1", DEFAULT_VERSION), null).isEmpty());
//uninstall A
ProfileChangeRequest request3 = new ProfileChangeRequest(getProfile(IProfileRegistry.SELF));
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 912ebc660..10165fa4b 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
@@ -57,7 +57,7 @@ public class AllOrbit extends AbstractProvisioningTest {
//Install everything except com.ibm.icu
ProfileChangeRequest req1 = new ProfileChangeRequest(profile1);
IQueryResult allIUs = repo.query(InstallableUnitQuery.ANY, null);
- ArrayList toInstall = new ArrayList(allIUs.size());
+ ArrayList toInstall = new ArrayList();
int removed = 0;
for (Iterator iterator = allIUs.iterator(); iterator.hasNext();) {
IInstallableUnit toAdd = (IInstallableUnit) iterator.next();
@@ -77,7 +77,7 @@ public class AllOrbit extends AbstractProvisioningTest {
//Install everything optionaly (except com.ibm.icu that we don't install at all)
ProfileChangeRequest req1 = new ProfileChangeRequest(profile1);
IQueryResult allIUs = repo.query(InstallableUnitQuery.ANY, null);
- ArrayList toInstall = new ArrayList(allIUs.size());
+ ArrayList toInstall = new ArrayList();
int removed = 0;
for (Iterator iterator = allIUs.iterator(); iterator.hasNext();) {
IInstallableUnit toAdd = (IInstallableUnit) iterator.next();
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 3c2005fff..5b8ab22b8 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
@@ -46,7 +46,7 @@ public class Bug252682 extends AbstractProvisioningTest {
IInstallableUnit p2Feature = (IInstallableUnit) profile.query(new InstallableUnitQuery("org.eclipse.equinox.p2.user.ui.feature.group"), new NullProgressMonitor()).iterator().next();
System.out.println(p2Feature);
IQueryResult c = profile.query(new InstallableUnitQuery("org.eclipse.equinox.p2.core.patch"), new NullProgressMonitor());
- assertEquals(1, c.size());
+ assertEquals(1, queryResultSize(c));
ProvisioningContext ctx = new ProvisioningContext();
ctx.setExtraIUs(newIUs);
IInstallableUnit patch = (IInstallableUnit) c.iterator().next();
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 75a3aa51f..4ca3c0587 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
@@ -45,7 +45,7 @@ public class Bug254481dataSet1 extends AbstractProvisioningTest {
public void testInstallFeaturePatch() {
IQueryResult c = repo.query(new InstallableUnitQuery("RPT_ARM_TEST.feature.group"), new NullProgressMonitor());
- assertEquals(1, c.size());
+ assertEquals(1, queryResultSize(c));
IInstallableUnit patch = (IInstallableUnit) c.iterator().next();
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {patch});
@@ -54,10 +54,10 @@ public class Bug254481dataSet1 extends AbstractProvisioningTest {
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"), 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"), 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"), 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 e06022516..ebd43cf6b 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
@@ -45,7 +45,7 @@ public class Bug254481dataSet2 extends AbstractProvisioningTest {
public void testInstallFeaturePatch() {
IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.jdt.feature.patch.feature.group"), new NullProgressMonitor());
- assertEquals(1, c.size());
+ assertEquals(1, queryResultSize(c));
IInstallableUnit patch = (IInstallableUnit) c.iterator().next();
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {patch});
@@ -53,7 +53,7 @@ public class Bug254481dataSet2 extends AbstractProvisioningTest {
IPlanner planner = createPlanner();
IProvisioningPlan plan = planner.getProvisioningPlan(request, null, new NullProgressMonitor());
assertInstallOperand(plan, patch);
- assertEquals(1, plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.jdt.core"), null).size());
- assertEquals(1, plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.jdt.core.manipulation"), 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 853e14673..1b99f236f 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
@@ -52,7 +52,7 @@ public class Bug255984 extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
engine.perform(plan, null);
assertProfileContainsAll("B is missing", profile1, new IInstallableUnit[] {b});
- assertEquals(1, profile1.query(InstallableUnitQuery.ANY, null).size());
+ assertEquals(1, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null)));
//Install A
ProfileChangeRequest req2 = new ProfileChangeRequest(profile1);
@@ -63,7 +63,7 @@ public class Bug255984 extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan2.getStatus().getSeverity());
engine.perform(plan2, null);
assertProfileContainsAll("A is missing", profile1, new IInstallableUnit[] {a, b});
- assertEquals(2, profile1.query(InstallableUnitQuery.ANY, null).size());
+ assertEquals(2, queryResultSize(profile1.query(InstallableUnitQuery.ANY, null)));
//Uninstall B
ProfileChangeRequest req3 = new ProfileChangeRequest(profile1);
@@ -73,7 +73,7 @@ public class Bug255984 extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan3.getStatus().getSeverity());
engine.perform(plan3, null);
assertProfileContainsAll("A is missing", profile1, new IInstallableUnit[] {a, b});
- assertEquals(1, profile1.query(new IUProfilePropertyQuery("foo", "bar"), new NullProgressMonitor()).size());
- assertEquals(2, profile1.query(InstallableUnitQuery.ANY, 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/Bug271067.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271067.java
index fd31d8b5d..c82c1a95f 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
@@ -68,7 +68,7 @@ public class Bug271067 extends AbstractProvisioningTest {
IInstallableUnit getIU(IMetadataRepository source, String id, String version) {
IQueryResult c = repo.query(new InstallableUnitQuery(id, Version.create(version)), new NullProgressMonitor());
- assertEquals(1, c.size());
+ assertEquals(1, queryResultSize(c));
return (IInstallableUnit) c.iterator().next();
}
@@ -93,7 +93,7 @@ public class Bug271067 extends AbstractProvisioningTest {
IProvisioningPlan feature1Plan = createPlanner().getProvisioningPlan(installFeature1, new ProvisioningContext(), null);
assertOK("installation of feature1 and patch", createEngine().perform(feature1Plan, new NullProgressMonitor()));
- assertEquals(1, getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor()).size());
+ 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,7 +107,7 @@ public class Bug271067 extends AbstractProvisioningTest {
IProvisioningPlan feature2Plan = createPlanner().getProvisioningPlan(installFeature2, new ProvisioningContext(), null);
assertOK("installation of feature2", createEngine().perform(feature2Plan, new NullProgressMonitor()));
- assertEquals(1, getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor()).size());
+ assertEquals(1, queryResultSize(getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor())));
}
public void testInstallFeaturePatchReverseOrder() {
@@ -123,7 +123,7 @@ public class Bug271067 extends AbstractProvisioningTest {
IProvisioningPlan feature2Plan = createPlanner().getProvisioningPlan(installFeature2, new ProvisioningContext(), null);
assertOK("installation of feature2", createEngine().perform(feature2Plan, new NullProgressMonitor()));
- assertEquals(1, getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", Version.create("1.0.2")), new NullProgressMonitor()).size());
+ 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,7 +144,7 @@ public class Bug271067 extends AbstractProvisioningTest {
IProvisioningPlan feature1Plan = createPlanner().getProvisioningPlan(installFeature1, new ProvisioningContext(), null);
assertOK("installation of feature1 and patch", createEngine().perform(feature1Plan, new NullProgressMonitor()));
- assertEquals(1, getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor()).size());
+ assertEquals(1, queryResultSize(getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor())));
}
public void installTogether() {
@@ -174,6 +174,6 @@ public class Bug271067 extends AbstractProvisioningTest {
IProvisioningPlan plan = createPlanner().getProvisioningPlan(installEverything, new ProvisioningContext(), null);
assertOK("installation of feature1 and patch", createEngine().perform(plan, new NullProgressMonitor()));
- assertEquals(1, getProfile(profileLoadedId).query(new InstallableUnitQuery("hello", Version.create("1.0.0.1")), new NullProgressMonitor()).size());
+ 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 f0d8d1007..89558b54a 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
@@ -75,7 +75,7 @@ public class Bug271954 extends AbstractProvisioningTest {
public void testUninstallMyBundle() {
IQueryResult c = profile.available(new InstallableUnitQuery("A"), new NullProgressMonitor());
- assertEquals(1, c.size());
+ assertEquals(1, queryResultSize(c));
ProfileChangeRequest req = new ProfileChangeRequest(profile);
req.removeInstallableUnits((IInstallableUnit[]) c.toArray(IInstallableUnit.class));
@@ -83,11 +83,11 @@ public class Bug271954 extends AbstractProvisioningTest {
ctx.setArtifactRepositories(new URI[0]);
IProvisioningPlan plan = createPlanner().getProvisioningPlan(req, ctx, new NullProgressMonitor());
assertOK("Uninstall plan for myBundle", plan.getStatus());
- assertEquals(0, plan.getInstallerPlan().getAdditions().query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size());
- assertEquals(0, plan.getInstallerPlan().getRemovals().query(InstallableUnitQuery.ANY, 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 NullProgressMonitor()).size());
- assertEquals(1, plan.getRemovals().query(new InstallableUnitQuery("A", Version.createOSGi(1, 0, 0)), new NullProgressMonitor()).size());
- assertEquals(1, plan.getRemovals().query(new InstallableUnitQuery("Action1", Version.createOSGi(1, 0, 0)), 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 beec0fbf1..ec0f618a7 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
@@ -46,9 +46,9 @@ public class Bug272251 extends AbstractProvisioningTest {
public void testInstallFeaturePatch() {
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, c.size());
+ 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, expectedIU.size());
+ assertEquals(1, queryResultSize(expectedIU));
IInstallableUnit patch = (IInstallableUnit) c.iterator().next();
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {patch});
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 034f85805..ba698ab92 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
@@ -65,9 +65,9 @@ public class Bug278668 extends AbstractProvisioningTest {
public void testInstallFeaturePatch() {
IQueryResult c = repo.query(new InstallableUnitQuery("com.borland.tg.modeling.8.2.0.hotfixexp.patch.feature.group"), new NullProgressMonitor());
- assertEquals(1, c.size());
+ 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, c2.size());
+ assertEquals(1, queryResultSize(c2));
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {(IInstallableUnit) c.iterator().next()});
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 dacec8dfc..f05a39421 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
@@ -52,11 +52,11 @@ public class ExplanationLargeConflict extends AbstractProvisioningTest {
//Here we verify that two version of JDT can't be installed together. The SDKProfile is not used
IProfile profile = createProfile("TestProfile." + getName());
IQueryResult c = repo1.query(new InstallableUnitQuery("org.eclipse.jdt.feature.group"), null);
- assertEquals(1, c.size());
+ assertEquals(1, queryResultSize(c));
IInstallableUnit jdt1 = (IInstallableUnit) c.iterator().next();
IQueryResult c2 = repo2.query(new InstallableUnitQuery("org.eclipse.jdt.feature.group"), null);
- assertEquals(1, c2.size());
+ assertEquals(1, queryResultSize(c2));
IInstallableUnit jdt2 = (IInstallableUnit) c2.iterator().next();
assertNotSame(jdt1, jdt2);
@@ -104,7 +104,7 @@ public class ExplanationLargeConflict extends AbstractProvisioningTest {
long sTime = System.currentTimeMillis();
//Test large conflict. We are trying to install an inappropriate version of CVS over the already installed SDK
IQueryResult c = repo2.query(new InstallableUnitQuery("org.eclipse.cvs.feature.group"), null);
- assertEquals(1, c.size());
+ assertEquals(1, queryResultSize(c));
IInstallableUnit cvs = (IInstallableUnit) c.iterator().next();
ProfileChangeRequest pcr = new ProfileChangeRequest(SDKprofile);
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 a26a0a75d..9de2304d5 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
@@ -60,7 +60,7 @@ public class IUProperties extends AbstractProvisioningTest {
if (!s.isOK())
LogHelper.log(s);
IQueryResult queryResult = getProfile(profileId).query(new IUProfilePropertyQuery("FOO", null), null);
- assertEquals(1, queryResult.size());
+ assertEquals(1, queryResultSize(queryResult));
ProfileChangeRequest req2 = new ProfileChangeRequest(profile);
req2.removeInstallableUnitProfileProperty(b1, "FOO");
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 a410a42bf..bc1657725 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
@@ -51,7 +51,7 @@ public class IUPropertyRemoval extends AbstractProvisioningTest {
assertEquals(IStatus.OK, pp1.getStatus().getSeverity());
engine.perform(pp1, null);
IQueryResult res = getProfile(profileId).query(new IUProfilePropertyQuery("FOO", null), null);
- assertEquals(2, res.size());
+ assertEquals(2, queryResultSize(res));
ProfileChangeRequest req2 = new ProfileChangeRequest(profile);
req2.removeInstallableUnitProfileProperty(b1, "FOO");
@@ -59,6 +59,6 @@ public class IUPropertyRemoval extends AbstractProvisioningTest {
assertEquals(1, pp2.getOperands().length);
engine.perform(pp2, null);
IQueryResult res2 = getProfile(profileId).query(new IUProfilePropertyQuery("FOO", null), null);
- assertEquals(1, res2.size());
+ assertEquals(1, queryResultSize(res2));
}
}
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 101132f99..9ad56e41b 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
@@ -49,7 +49,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
engine.perform(plan, null);
assertProfileContainsAll("A1 is missing", profile1, new IInstallableUnit[] {a1});
- assertEquals(profile1.query(InstallableUnitQuery.ANY, null).size(), 1);
+ assertEquals(queryResultSize(profile1.query(InstallableUnitQuery.ANY, null)), 1);
//Make a1 optional.
ProfileChangeRequest req2 = new ProfileChangeRequest(profile1);
@@ -58,7 +58,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan2.getStatus().getSeverity());
engine.perform(plan2, null);
assertProfileContainsAll("A1 is missing", profile1, new IInstallableUnit[] {a1});
- assertEquals(profile1.query(InstallableUnitQuery.ANY, 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);
@@ -67,7 +67,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan3.getStatus().getSeverity());
engine.perform(plan3, null);
assertProfileContainsAll("A1 or B1 is missing", profile1, new IInstallableUnit[] {a1, b1});
- assertEquals(profile1.query(InstallableUnitQuery.ANY, null).size(), 2);
+ assertEquals(queryResultSize(profile1.query(InstallableUnitQuery.ANY, null)), 2);
//Add a2, this removes a1.
ProfileChangeRequest req4 = new ProfileChangeRequest(profile1);
@@ -77,7 +77,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
engine.perform(plan4, null);
assertProfileContainsAll("A2 is missing", profile1, new IInstallableUnit[] {a2});
assertNotIUs(new IInstallableUnit[] {a1}, profile1.query(InstallableUnitQuery.ANY, null).iterator());
- assertEquals(profile1.query(InstallableUnitQuery.ANY, null).size(), 2);
+ 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);
@@ -95,7 +95,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
engine.perform(plan, null);
assertProfileContainsAll("A1 is missing", profile2, new IInstallableUnit[] {a1});
- assertEquals(profile2.query(InstallableUnitQuery.ANY, null).size(), 1);
+ assertEquals(queryResultSize(profile2.query(InstallableUnitQuery.ANY, null)), 1);
//Make a1 optional.
ProfileChangeRequest req2 = new ProfileChangeRequest(profile2);
@@ -104,7 +104,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan2.getStatus().getSeverity());
engine.perform(plan2, null);
assertProfileContainsAll("A1 is missing", profile2, new IInstallableUnit[] {a1});
- assertEquals(profile2.query(InstallableUnitQuery.ANY, 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);
@@ -114,7 +114,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
engine.perform(plan3, null);
profile2 = getProfile(profile2.getProfileId());
assertProfileContainsAll("A1 or B1 is missing", profile2, new IInstallableUnit[] {a1, b1});
- assertEquals(profile2.query(InstallableUnitQuery.ANY, 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);
@@ -124,7 +124,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
engine.perform(plan5, null);
profile2 = getProfile(profile2.getProfileId());
assertProfileContainsAll("A1 or B1 is missing", profile2, new IInstallableUnit[] {a1, b1});
- assertEquals(profile2.query(InstallableUnitQuery.ANY, null).size(), 2);
+ assertEquals(queryResultSize(profile2.query(InstallableUnitQuery.ANY, null)), 2);
}
public void testRemoveIUandInclusionRule() {
@@ -135,7 +135,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
engine.perform(plan, null);
assertProfileContainsAll("A1 is missing", profile3, new IInstallableUnit[] {a1});
- assertEquals(profile3.query(InstallableUnitQuery.ANY, null).size(), 1);
+ assertEquals(queryResultSize(profile3.query(InstallableUnitQuery.ANY, null)), 1);
//Make a1 optional.
ProfileChangeRequest req2 = new ProfileChangeRequest(profile3);
@@ -144,7 +144,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan2.getStatus().getSeverity());
engine.perform(plan2, null);
assertProfileContainsAll("A1 is missing", profile3, new IInstallableUnit[] {a1});
- assertEquals(profile3.query(InstallableUnitQuery.ANY, 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);
@@ -153,7 +153,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan3.getStatus().getSeverity());
engine.perform(plan3, null);
assertProfileContainsAll("A1 or B1 is missing", profile3, new IInstallableUnit[] {a1, b1});
- assertEquals(profile3.query(InstallableUnitQuery.ANY, null).size(), 2);
+ assertEquals(queryResultSize(profile3.query(InstallableUnitQuery.ANY, null)), 2);
//Remove the a1 and its inclusion rule
ProfileChangeRequest req5 = new ProfileChangeRequest(profile3);
@@ -163,7 +163,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan5.getStatus().getSeverity());
engine.perform(plan5, null);
assertProfileContainsAll("bB1 is missing", profile3, new IInstallableUnit[] {b1});
- assertEquals(profile3.query(InstallableUnitQuery.ANY, null).size(), 1);
+ assertEquals(queryResultSize(profile3.query(InstallableUnitQuery.ANY, null)), 1);
}
public void testAdditionWithInclusionRule() {
@@ -182,7 +182,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
engine.perform(plan, null);
assertProfileContainsAll("A2 is missing", profile4, new IInstallableUnit[] {a2});
- assertEquals(profile4.query(InstallableUnitQuery.ANY, 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);
@@ -191,7 +191,7 @@ public class InclusionRuleTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan2.getStatus().getSeverity());
engine.perform(plan2, null);
assertProfileContainsAll("A2 is missing", profile4, new IInstallableUnit[] {a2});
- assertEquals(profile4.query(InstallableUnitQuery.ANY, null).size(), 1);
+ assertEquals(queryResultSize(profile4.query(InstallableUnitQuery.ANY, null)), 1);
//Install a1, this is expected to fail
ProfileChangeRequest req3 = new ProfileChangeRequest(profile4);
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 48aa67cc2..89409fd9d 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
@@ -54,7 +54,7 @@ public class InclusionRuleTest2 extends AbstractProvisioningTest {
IProfileRegistry profileRegistry = getProfileRegistry();
profile = profileRegistry.getProfile(profile.getProfileId());
IQueryResult c = profile.query(new UserVisibleRootQuery(), null);
- assertEquals(c.size(), 1);
+ assertEquals(queryResultSize(c), 1);
System.gc();
ProfileChangeRequest req2 = ProfileChangeRequest.createByProfileId(profile.getProfileId());
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 1b0fc3ca0..22d03e81c 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
@@ -72,7 +72,7 @@ public class MultipleSingleton extends AbstractProvisioningTest {
ProfileChangeRequest req = new ProfileChangeRequest(profile);
req.addInstallableUnits(new IInstallableUnit[] {x});
ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(req, null, null);
- assertEquals(1, plan.getCompleteState().query(new InstallableUnitQuery("X"), null).size());
+ assertEquals(1, queryResultSize(plan.getCompleteState().query(new InstallableUnitQuery("X"), null)));
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
}
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 624be496d..b2d5c21bb 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
@@ -76,7 +76,7 @@ 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 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());
@@ -84,8 +84,8 @@ public class NegationTesting extends AbstractProvisioningTest {
ProfileChangeRequest changeRequest = new ProfileChangeRequest(profile);
changeRequest.addInstallableUnits(new IInstallableUnit[] {iu1});
ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(changeRequest, null, null);
- assertEquals(0, plan.getCompleteState().query(new InstallableUnitQuery("ProviderOf1_1_1"), null).size());
- assertEquals(2, plan.getCompleteState().query(InstallableUnitQuery.ANY, null).size());
+ 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);
@@ -131,8 +131,8 @@ 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 NullProgressMonitor()).size());
- assertEquals(2, slice.query(InstallableUnitQuery.ANY, 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() {
@@ -163,8 +163,8 @@ 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 NullProgressMonitor()).size());
- assertEquals(2, slice.query(InstallableUnitQuery.ANY, 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());
@@ -172,8 +172,8 @@ public class NegationTesting extends AbstractProvisioningTest {
ProfileChangeRequest changeRequest = new ProfileChangeRequest(profile);
changeRequest.addInstallableUnits(new IInstallableUnit[] {iu1});
ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(changeRequest, null, null);
- assertEquals(0, plan.getCompleteState().query(new InstallableUnitQuery("ProviderOf1_1_1"), null).size());
- assertEquals(2, plan.getCompleteState().query(InstallableUnitQuery.ANY, null).size());
+ 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.
@@ -217,7 +217,7 @@ 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 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());
@@ -225,8 +225,8 @@ public class NegationTesting extends AbstractProvisioningTest {
ProfileChangeRequest changeRequest = new ProfileChangeRequest(profile);
changeRequest.addInstallableUnits(new IInstallableUnit[] {iu1});
ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(changeRequest, null, null);
- assertEquals(0, plan.getCompleteState().query(new InstallableUnitQuery("ProviderOf1_1_1"), null).size());
- assertEquals(2, plan.getCompleteState().query(InstallableUnitQuery.ANY, null).size());
+ 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);
@@ -283,12 +283,12 @@ 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 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 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());
@@ -296,8 +296,8 @@ public class NegationTesting extends AbstractProvisioningTest {
ProfileChangeRequest changeRequest = new ProfileChangeRequest(profile);
changeRequest.addInstallableUnits(new IInstallableUnit[] {iu1});
ProvisioningPlan plan = (ProvisioningPlan) planner.getProvisioningPlan(changeRequest, null, null);
- assertEquals(0, plan.getCompleteState().query(new InstallableUnitQuery("ProviderOf1_1_1"), null).size());
- assertEquals(2, plan.getCompleteState().query(InstallableUnitQuery.ANY, null).size());
+ 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);
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 295e6bf4a..890cee9d7 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
@@ -49,7 +49,7 @@ public class NonMinimalState extends AbstractProvisioningTest {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
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"), 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");
@@ -62,7 +62,7 @@ public class NonMinimalState extends AbstractProvisioningTest {
ProvisioningContext ctx = new ProvisioningContext(new URI[0]);
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"), null).size());
+ assertTrue(plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.agentcontroller"), null).isEmpty());
}
private void why(String id) {
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 777c71403..2cf6dae89 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
@@ -39,8 +39,8 @@ public class NonMinimalState2 extends AbstractProvisioningTest {
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"), null).size());
- assertEquals(0, plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.iac.administrator"), 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() {
@@ -64,8 +64,8 @@ public class NonMinimalState2 extends AbstractProvisioningTest {
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"), null).size());
- assertEquals(0, plan.getAdditions().query(new InstallableUnitQuery("org.eclipse.tptp.platform.iac.administrator"), 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/PermissiveSlicerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PermissiveSlicerTest.java
index 0c43c8de9..8bb921d56 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
@@ -39,9 +39,9 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest {
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
assertNotNull(result);
- result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size();
- assertEquals(66, result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size());
- assertEquals(1, result.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), 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());
}
@@ -52,8 +52,8 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest {
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
assertNotNull(result);
- result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size();
- assertEquals(64, result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size());
+ queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()));
+ assertEquals(64, queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())));
// assertOK("1.0", slicer.getStatus());
}
@@ -63,8 +63,8 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest {
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
assertNotNull(result);
- result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size();
- assertEquals(64, result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size());
+ queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()));
+ assertEquals(64, queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())));
// assertOK("1.0", slicer.getStatus());
}
@@ -78,9 +78,9 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest {
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
assertNotNull(result);
- result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size();
- assertEquals(0, result.query(new InstallableUnitQuery("org.eclipse.swt.motif.linux.x86"), new NullProgressMonitor()).size());
- assertEquals(34, result.query(InstallableUnitQuery.ANY, 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());
}
@@ -94,9 +94,9 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest {
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
assertNotNull(result);
- result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size();
- assertEquals(0, result.query(new InstallableUnitQuery("org.eclipse.ecf"), new NullProgressMonitor()).size());
- assertEquals(29, result.query(InstallableUnitQuery.ANY, 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());
}
@@ -106,9 +106,9 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest {
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
assertNotNull(result);
- result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size();
- assertEquals(32, result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size());
- assertEquals(1, result.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), 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());
}
@@ -121,7 +121,7 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest {
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"), null).size());
+ assertEquals(1, queryResultSize(result.query(new InstallableUnitQuery("Action1"), null)));
}
public void testValidateIU() {
@@ -154,7 +154,7 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest {
IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
IQueryResult resultCollector = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor()).query(InstallableUnitQuery.ANY, new NullProgressMonitor());
- assertEquals(3, resultCollector.size());
+ assertEquals(3, queryResultSize(resultCollector));
}
public void testExtractOnlyPlatformSpecific() {
@@ -163,7 +163,7 @@ public class PermissiveSlicerTest extends AbstractProvisioningTest {
IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
IQueryResult resultCollector = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor()).query(InstallableUnitQuery.ANY, new NullProgressMonitor());
- assertEquals(35, resultCollector.size());
+ 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 359ac9a48..9d659179a 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
@@ -26,21 +26,21 @@ public class ProvisioningPlanQueryTest extends AbstractProvisioningTest {
public void testAddition() {
Operand[] ops = new Operand[] {new InstallableUnitOperand(null, createIU("A"))};
IQueryResult c = new ProvisioningPlan(null, ops, null).getAdditions().query(InstallableUnitQuery.ANY, new NullProgressMonitor());
- assertEquals(1, c.size());
- assertEquals(0, new ProvisioningPlan(null, ops, null).getRemovals().query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size());
+ 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)};
IQueryResult c = new ProvisioningPlan(null, ops, null).getRemovals().query(InstallableUnitQuery.ANY, new NullProgressMonitor());
- assertEquals(1, c.size());
- assertEquals(0, new ProvisioningPlan(null, ops, null).getAdditions().query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size());
+ 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"))};
IQueryResult c = new ProvisioningPlan(null, ops, null).getRemovals().query(InstallableUnitQuery.ANY, new NullProgressMonitor());
- assertEquals(1, c.size());
- assertEquals(1, new ProvisioningPlan(null, ops, null).getAdditions().query(InstallableUnitQuery.ANY, new NullProgressMonitor()).size());
+ 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/SWTFragment.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SWTFragment.java
index f854d2dce..45bac5819 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
@@ -14,11 +14,11 @@ 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.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class SWTFragment extends AbstractProvisioningTest {
@@ -49,7 +49,8 @@ public class SWTFragment extends AbstractProvisioningTest {
req.addInstallableUnits(new IInstallableUnit[] {swt});
IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null);
assertOK("plan", plan.getStatus());
- IQueryResult c = plan.getAdditions().query(new InstallableUnitQuery("SWT"), 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/SimulatedSharedInstallTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java
index 15f5b831c..f09918d8f 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
@@ -53,14 +53,15 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest {
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());
- assertTrue(profile.query(InstallableUnitQuery.ANY, null).toCollection().contains(a1));
+ assertContains(profile.query(InstallableUnitQuery.ANY, null), a1);
ProfileChangeRequest req = new ProfileChangeRequest(profile);
req.removeInstallableUnits(new IInstallableUnit[] {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());
- assertFalse(profile.query(InstallableUnitQuery.ANY, null).toCollection().contains(a1));
+ assertNotContains(profile.query(InstallableUnitQuery.ANY, null), a1);
}
public void testAvailableVsQueryInProfile() {
@@ -71,17 +72,18 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest {
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());
- assertTrue(profile.query(InstallableUnitQuery.ANY, null).toCollection().contains(c1));
+ assertContains(profile.query(InstallableUnitQuery.ANY, null), c1);
IProfile availableWrapper = new IProfile() {
- public Collector available(IQuery query, IProgressMonitor 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
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
index 7c7499760..9603e7ede 100644
--- 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
@@ -25,14 +25,14 @@ public class UpdateQueryTest extends AbstractProvisioningTest {
public void testUpdateWithDifferentId() {
IMetadataRepository repo = createTestMetdataRepository(new IInstallableUnit[] {a1, updateOfA});
IQueryResult c = repo.query(new UpdateQuery(a1), null);
- assertEquals(1, c.size());
+ 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, c2.size());
+ assertEquals(1, queryResultSize(c2));
assertEquals(a11, c2.iterator().next());
}
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 3246c0a25..57515096f 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
@@ -9,8 +9,6 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.publisher;
-import org.eclipse.equinox.p2.metadata.query.IQueryResult;
-
import java.io.*;
import java.net.URI;
import java.util.*;
@@ -25,6 +23,7 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
import org.eclipse.equinox.internal.provisional.p2.repository.IStateful;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.equinox.p2.tests.TestActivator;
@@ -306,10 +305,10 @@ public class TestArtifactRepository implements IArtifactRepository {
IArtifactDescriptor descriptor = (IArtifactDescriptor) iterator.next();
result.add(descriptor.getArtifactKey());
}
- collector = query.perform(result.iterator(), collector);
+ collector.addAll(query.perform(result.iterator()));
}
if (!excludeDescriptors)
- collector = query.perform(repo.keySet().iterator(), collector);
+ collector.addAll(query.perform(repo.keySet().iterator()));
return collector;
}
} \ No newline at end of file
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 ba08abed7..f1cf46a68 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
@@ -118,7 +118,7 @@ public class BundlesActionTest extends ActionTest {
assertEquals("2.0", 1, ius.size());
QueryableArray queryableArray = new QueryableArray((IInstallableUnit[]) ius.toArray(new IInstallableUnit[ius.size()]));
IQueryResult result = queryableArray.query(new InstallableUnitQuery("foo"), null);
- assertEquals("3.1", 1, result.size());
+ 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));
@@ -129,7 +129,7 @@ public class BundlesActionTest extends ActionTest {
assertEquals("2.0", 3, ius.size());
queryableArray = new QueryableArray((IInstallableUnit[]) ius.toArray(new IInstallableUnit[ius.size()]));
result = queryableArray.query(new InstallableUnitQuery("foo"), null);
- assertEquals("2.1", 1, result.size());
+ 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));
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 19b28db0d..715993915 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
@@ -179,7 +179,7 @@ public class ProductActionTest extends ActionTest {
action2.perform(info, results, new NullProgressMonitor());
IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + configSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
- assertEquals("1.0", 1, queryResult.size());
+ assertEquals("1.0", 1, queryResultSize(queryResult));
}
public void testMultiPlatformCUs_DifferentPlatforms() throws Exception {
@@ -202,10 +202,10 @@ public class ProductActionTest extends ActionTest {
action.perform(info, results, new NullProgressMonitor());
IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
- assertEquals("1.0", 0, queryResult.size());
+ assertEquals("1.0", 0, queryResultSize(queryResult));
queryResult = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
- assertEquals("2.0", 0, queryResult.size());
+ assertEquals("2.0", 0, queryResultSize(queryResult));
}
public void testMultiPlatformCUs_SamePlatforms() throws Exception {
@@ -228,10 +228,10 @@ public class ProductActionTest extends ActionTest {
action.perform(info, results, new NullProgressMonitor());
IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
- assertEquals("1.0", 1, queryResult.size());
+ assertEquals("1.0", 1, queryResultSize(queryResult));
queryResult = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
- assertEquals("2.0", 0, queryResult.size());
+ assertEquals("2.0", 0, queryResultSize(queryResult));
}
public void testMultiPlatformCUs_SamePlatforms_NoVersion() throws Exception {
@@ -253,10 +253,10 @@ public class ProductActionTest extends ActionTest {
action.perform(info, results, new NullProgressMonitor());
IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
- assertEquals("1.0", 1, queryResult.size());
+ assertEquals("1.0", 1, queryResultSize(queryResult));
queryResult = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
- assertEquals("2.0", 0, queryResult.size());
+ assertEquals("2.0", 0, queryResultSize(queryResult));
}
public void testMultiPlatformCUs_SamePlatforms_BoundedVersions() throws Exception {
@@ -279,10 +279,10 @@ public class ProductActionTest extends ActionTest {
action.perform(info, results, new NullProgressMonitor());
IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
- assertEquals("1.0", 1, queryResult.size());
+ assertEquals("1.0", 1, queryResultSize(queryResult));
queryResult = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
- assertEquals("2.0", 0, queryResult.size());
+ assertEquals("2.0", 0, queryResultSize(queryResult));
}
public void testCUsHost() throws Exception {
@@ -304,7 +304,7 @@ public class ProductActionTest extends ActionTest {
action.perform(info, results, new NullProgressMonitor());
IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
- assertEquals("1.0", 1, queryResult.size());
+ assertEquals("1.0", 1, queryResultSize(queryResult));
IInstallableUnitFragment fragment = (IInstallableUnitFragment) queryResult.iterator().next();
assertEquals("1.1", "org.eclipse.core.runtime", ((IRequiredCapability) fragment.getHost()[0].getMatches()).getName());
assertEquals("1.2", Version.create("4.0.0"), ((IRequiredCapability) fragment.getHost()[0].getMatches()).getRange().getMinimum());
@@ -325,10 +325,10 @@ public class ProductActionTest extends ActionTest {
action.perform(info, results, new NullProgressMonitor());
IQueryResult queryResult = results.query(new InstallableUnitQuery(flavorArg + linuxConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
- assertEquals("1.0", 0, queryResult.size());
+ assertEquals("1.0", 0, queryResultSize(queryResult));
queryResult = results.query(new InstallableUnitQuery(flavorArg + windowsConfigSpec + "org.eclipse.core.runtime"), new NullProgressMonitor());
- assertEquals("2.0", 0, queryResult.size());
+ 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/ProductActionWithAdviceFileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java
index 457138013..6fd35da74 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
@@ -81,7 +81,7 @@ public class ProductActionWithAdviceFileTest extends ActionTest {
testAction.perform(info, publisherResult, null);
IQueryResult results = publisherResult.query(new IUQuery("org.eclipse.platform.ide", Version.create("3.5.0.I20081118")), null);
- assertEquals("1.0", 1, results.size());
+ assertEquals("1.0", 1, queryResultSize(results));
IInstallableUnit unit = (IInstallableUnit) results.iterator().next();
IRequirement[] requiredCapabilities = unit.getRequiredCapabilities();
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
index ed34f880a..413281dce 100644
--- 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
@@ -72,27 +72,27 @@ public class EvaluatorTest extends AbstractProvisioningTest {
public void testLatest() throws Exception {
IMetadataRepository repo = getMDR("/testData/metadataRepo/multipleversions1");
IQueryResult result = repo.query(new QLContextQuery("latest(x | x.id == $0)", "test.bundle"), new NullProgressMonitor());
- assertTrue(result.size() == 1);
+ assertTrue(queryResultSize(result) == 1);
}
public void testRange() throws Exception {
IMetadataRepository repo = getMDR("/testData/metadataRepo/multipleversions1");
IQueryResult result = repo.query(new QLMatchQuery("version ~= $0", new VersionRange("2.0.0")), new NullProgressMonitor());
- assertEquals(result.size(), 2);
+ assertEquals(queryResultSize(result), 2);
}
public void testProperty() throws Exception {
IMetadataRepository repo = getMDR("/testData/metadataRepo/multipleversions1");
IQueryResult result = repo.query(new QLMatchQuery("properties.exists(p | boolean(p.value))"), new NullProgressMonitor());
- assertEquals(result.size(), 3);
+ assertEquals(queryResultSize(result), 3);
result = repo.query(new QLMatchQuery("boolean(properties['org.eclipse.equinox.p2.type.group'])"), new NullProgressMonitor());
- assertEquals(result.size(), 3);
+ assertEquals(queryResultSize(result), 3);
Filter filter = TestActivator.context.createFilter("(org.eclipse.equinox.p2.type.group=true)");
result = repo.query(new QLMatchQuery("properties ~= $0", filter), new NullProgressMonitor());
- assertEquals(result.size(), 3);
+ assertEquals(queryResultSize(result), 3);
}
public void testToString() throws Exception {
@@ -128,14 +128,14 @@ public class EvaluatorTest extends AbstractProvisioningTest {
// Create the query
IMetadataRepository repo = getMDR("/testData/metadataRepo/multipleversions1");
IQueryResult result = repo.query(new QLContextQuery(IInstallableUnit.class, e3, new Object[] {args}), new NullProgressMonitor());
- assertEquals(result.size(), 1);
+ 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 ~= h)", new Object[] {pc}), new NullProgressMonitor());
- assertEquals(result.size(), 1);
+ assertEquals(queryResultSize(result), 1);
}
public void testPatch() throws Exception {
@@ -147,29 +147,29 @@ public class EvaluatorTest extends AbstractProvisioningTest {
IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo");
IQueryResult result = repo.query(new QLMatchQuery("$0.exists(rcs | rcs.all(rc | item ~= rc))", applicability), new NullProgressMonitor());
- assertEquals(result.size(), 3);
+ 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("id ~= /tooling.*.default/", pc), new NullProgressMonitor());
- assertEquals(result.size(), 3);
+ assertEquals(queryResultSize(result), 3);
}
public void testLimit() throws Exception {
IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo");
IQueryResult result = repo.query(new QLContextQuery("select(x | x.id ~= /tooling.*/).limit(1)"), new NullProgressMonitor());
- assertEquals(result.size(), 1);
+ assertEquals(queryResultSize(result), 1);
result = repo.query(new QLContextQuery("select(x | x.id ~= /tooling.*/).limit($0)", new Integer(2)), new NullProgressMonitor());
- assertEquals(result.size(), 2);
+ assertEquals(queryResultSize(result), 2);
}
public void testNot() throws Exception {
IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo");
IQueryResult result = repo.query(new QLMatchQuery("!(id ~= /tooling.*/)"), new NullProgressMonitor());
- assertEquals(result.size(), 4);
+ assertEquals(queryResultSize(result), 4);
}
public void testArtifactQuery() throws Exception {
@@ -180,13 +180,13 @@ public class EvaluatorTest extends AbstractProvisioningTest {
IArtifactRepository repo = artifactManager.loadRepository(artifactRepo, new NullProgressMonitor());
IQueryResult result = repo.query(new QLMatchQuery(IArtifactKey.class, "classifier ~= /*/", null), new NullProgressMonitor());
- assertTrue(result.size() > 1);
+ assertTrue(queryResultSize(result) > 1);
Iterator itor = result.iterator();
while (itor.hasNext())
assertTrue(itor.next() instanceof IArtifactKey);
result = repo.query(new QLMatchQuery(IArtifactDescriptor.class, "artifactKey.classifier ~= /*/", null), new NullProgressMonitor());
- assertTrue(result.size() > 1);
+ assertTrue(queryResultSize(result) > 1);
itor = result.iterator();
while (itor.hasNext())
assertTrue(itor.next() instanceof IArtifactDescriptor);
@@ -196,7 +196,7 @@ public class EvaluatorTest extends AbstractProvisioningTest {
IMetadataRepository repo = getMDR("/testData/metadataRepo/wsdlTestRepo");
IQueryResult result = repo.query(new QLContextQuery(//
"select(x | x ~= class('org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnitFragment'))"), new NullProgressMonitor());
- assertEquals(result.size(), 4);
+ assertEquals(queryResultSize(result), 4);
repo = getMDR("/testData/galileoM7");
}
@@ -206,7 +206,7 @@ public class EvaluatorTest extends AbstractProvisioningTest {
"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(result.size(), 463);
+ assertEquals(queryResultSize(result), 463);
}
public void testTraverseWithIndex() throws Exception {
@@ -218,7 +218,7 @@ public class EvaluatorTest extends AbstractProvisioningTest {
"org.eclipse.sdk.feature.group",//
Version.create("3.5.0.v20090423-7Q7bA7DPR-wM38__Q4iRsmx9z0KOjbpx3AbyvXd-Uq7J2")),//
new NullProgressMonitor());
- assertEquals(result.size(), 463);
+ assertEquals(queryResultSize(result), 463);
}
public void testTraverseWithIndexAndFilter() throws Exception {
@@ -235,7 +235,7 @@ public class EvaluatorTest extends AbstractProvisioningTest {
IMetadataRepository repo = getMDR("/testData/galileoM7");
IQueryResult result = repo.query(query, new NullProgressMonitor());
- assertEquals(result.size(), 411);
+ assertEquals(queryResultSize(result), 411);
}
public void testCommonRequirements() throws Exception {
@@ -265,7 +265,7 @@ public class EvaluatorTest extends AbstractProvisioningTest {
index});
IQueryResult result = repo.query(query, new NullProgressMonitor());
- assertEquals(result.size(), 184);
+ assertEquals(queryResultSize(result), 184);
}
public void testMatchQueryInjectionInPredicate() throws Exception {
@@ -284,7 +284,7 @@ public class EvaluatorTest extends AbstractProvisioningTest {
}
};
IQueryResult result = repo.query(new QLMatchQuery(IInstallableUnit.class, expr, new Object[] {q1, q2}), new NullProgressMonitor());
- assertEquals(result.size(), 497);
+ assertEquals(queryResultSize(result), 497);
}
public void testMatchQueryInjectionInContext() throws Exception {
@@ -303,7 +303,7 @@ public class EvaluatorTest extends AbstractProvisioningTest {
}
};
IQueryResult result = repo.query(new QLContextQuery(IInstallableUnit.class, expr, new Object[] {q1, q2}), new NullProgressMonitor());
- assertEquals(result.size(), 497);
+ assertEquals(queryResultSize(result), 497);
}
public void testTranslations() {
@@ -328,7 +328,7 @@ public class EvaluatorTest extends AbstractProvisioningTest {
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, result.size());
+ assertEquals("2.1", 1, queryResultSize(result));
QLMatchQuery lq = new QLMatchQuery("translations['org.eclipse.equinox.p2.name'] ~= /German*/");
lq.setLocale(Locale.GERMAN);
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
index f0122a381..166050407 100644
--- 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
@@ -43,14 +43,14 @@ public class PerformanceTest extends AbstractProvisioningTest {
long start = System.currentTimeMillis();
for (int idx = 0; idx < 80; ++idx) {
result = repo.query(capability, new NullProgressMonitor());
- assertEquals(result.size(), 487);
+ 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(result.size(), 487);
+ assertEquals(queryResultSize(result), 487);
}
exprQueryMS += (System.currentTimeMillis() - start);
}
@@ -75,14 +75,14 @@ public class PerformanceTest extends AbstractProvisioningTest {
long start = System.currentTimeMillis();
for (int idx = 0; idx < 80; ++idx) {
result = qaRepo.query(capability, new NullProgressMonitor());
- assertEquals(result.size(), 487);
+ 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(result.size(), 487);
+ assertEquals(queryResultSize(result), 487);
}
exprQueryMS += (System.currentTimeMillis() - start);
}
@@ -105,14 +105,14 @@ public class PerformanceTest extends AbstractProvisioningTest {
long start = System.currentTimeMillis();
for (int idx = 0; idx < 80; ++idx) {
result = repo.query(propertyQuery, new NullProgressMonitor());
- assertEquals(result.size(), 965);
+ 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(result.size(), 965);
+ assertEquals(queryResultSize(result), 965);
}
exprQueryMS += (System.currentTimeMillis() - start);
}
@@ -144,7 +144,7 @@ public class PerformanceTest extends AbstractProvisioningTest {
long startTime = System.currentTimeMillis();
r = repo.query(query, new NullProgressMonitor());
traverseTime += (System.currentTimeMillis() - startTime);
- assertEquals(r.size(), 411);
+ assertEquals(queryResultSize(r), 411);
startTime = System.currentTimeMillis();
Slicer slicer = new Slicer(new QueryableArray(gatherAvailableInstallableUnits(repo)), env, false);
@@ -157,7 +157,7 @@ public class PerformanceTest extends AbstractProvisioningTest {
return true;
}
}, new NullProgressMonitor());
- assertEquals(r.size(), 411);
+ assertEquals(queryResultSize(r), 411);
System.out.print("100 * Slicing took: ");
System.out.println(sliceTime);
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
index ecf4a30b0..dc0e84197 100644
--- 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
@@ -128,14 +128,14 @@ public class TestQueryReimplementation extends AbstractProvisioningTest {
public void testUpdateWithDifferentId() {
IMetadataRepository repo = createTestMetdataRepository(new IInstallableUnit[] {a1, updateOfA});
IQueryResult c = repo.query(new UpdateQuery(a1), null);
- assertEquals(1, c.size());
+ 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, c2.size());
+ assertEquals(1, queryResultSize(c2));
assertEquals(a11, c2.iterator().next());
}
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 80e52cde1..0c7d81730 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
@@ -538,7 +538,7 @@ public class AbstractReconcilerTest extends AbstractProvisioningTest {
IProfile[] profiles = registry.getProfiles();
assertEquals("1.0 Should only be one profile in registry.", 1, profiles.length);
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, queryResult.size());
+ assertEquals("1.1 Should not have more than one IU wth the same ID and version.", 1, queryResultSize(queryResult));
return (IInstallableUnit) queryResult.iterator().next();
}
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 f903e00e2..58f99d1c3 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,11 +11,11 @@ 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.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.query.CategoryQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.publisher.*;
import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction;
import org.eclipse.equinox.p2.tests.*;
@@ -45,10 +45,9 @@ public class CategoryXMLActionTest extends AbstractProvisioningTest {
}
public void testCategoryCreation() throws Exception {
- Collection result = actionResult.query(new CategoryQuery(), 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/LocalUpdatesiteTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/LocalUpdatesiteTest.java
index 7540b483f..35f249639 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
@@ -49,7 +49,7 @@ public class LocalUpdatesiteTest extends AbstractProvisioningTest {
}
IMetadataRepository repository = getMetadataRepositoryManager().loadRepository(repoLocation.toURI(), new NullProgressMonitor());
IQueryResult results = repository.query(new CategoryQuery(), new NullProgressMonitor());
- assertEquals("1.0", 1, results.size());
+ 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/UpdateSiteTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java
index 38aaaffff..1262cf3f6 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
@@ -586,7 +586,7 @@ public class UpdateSiteTest extends AbstractProvisioningTest {
}
InstallableUnitQuery query = new InstallableUnitQuery("test.featurewithmissingupdateurl.feature.group", Version.create("1.0.0"));
IQueryResult result = metadataRepo.query(query, null);
- assertEquals("1.0", 1, result.size());
+ assertEquals("1.0", 1, queryResultSize(result));
}
/**
@@ -604,7 +604,7 @@ public class UpdateSiteTest extends AbstractProvisioningTest {
}
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, result.size());
+ assertEquals("1.0", 1, queryResultSize(result));
IInstallableUnit featureIU = (IInstallableUnit) result.iterator().next();
IRequirement[] required = featureIU.getRequiredCapabilities();
for (int i = 0; i < required.length; i++) {
@@ -625,7 +625,7 @@ public class UpdateSiteTest extends AbstractProvisioningTest {
fail("Can't load repository UpdateSite240121");
}
IQueryResult keys = artifactRepo.query(new ArtifactKeyQuery(null, "Plugin240121", null), null);
- assertEquals(1, keys.size());
+ 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())
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ElementQueryDescriptor.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ElementQueryDescriptor.java
index b358b571e..96acd3524 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ElementQueryDescriptor.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ElementQueryDescriptor.java
@@ -65,7 +65,7 @@ public class ElementQueryDescriptor {
// This allows the wrapper to modify the results with explanations.
if (wrapper != null)
return wrapper.getElements(results);
- return results.toCollection();
+ return results.unmodifiableSet();
}
public boolean hasCollector() {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryableRepositoryManager.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryableRepositoryManager.java
index ae418ea85..c537f530a 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryableRepositoryManager.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/QueryableRepositoryManager.java
@@ -70,8 +70,7 @@ public abstract class QueryableRepositoryManager implements IQueryable {
IRepositoryManager manager = getRepositoryManager();
if (monitor == null)
monitor = new NullProgressMonitor();
- Collector result = query(getRepoLocations(manager), query, monitor);
- return result;
+ return query(getRepoLocations(manager), query, monitor);
}
protected URI[] getRepoLocations(IRepositoryManager manager) {
@@ -138,33 +137,31 @@ public abstract class QueryableRepositoryManager implements IQueryable {
*/
protected abstract IRepository doLoadRepository(IRepositoryManager manager, URI location, IProgressMonitor monitor) throws ProvisionException;
- protected Collector query(URI uris[], IQuery query, IProgressMonitor monitor) {
- Collector collector = new Collector();
+ protected IQueryResult query(URI uris[], IQuery query, IProgressMonitor monitor) {
if (query instanceof RepositoryLocationQuery) {
- query.perform(Arrays.asList(uris).iterator(), collector);
- monitor.done();
- } else {
- SubMonitor sub = SubMonitor.convert(monitor, (uris.length + 1) * 100);
- ArrayList loadedRepos = new ArrayList(uris.length);
- for (int i = 0; i < uris.length; i++) {
- IRepository repo = null;
- try {
- repo = loadRepository(getRepositoryManager(), uris[i], sub.newChild(100));
- } catch (ProvisionException e) {
- tracker.reportLoadFailure(uris[i], e);
- } catch (OperationCanceledException e) {
- // user has canceled
- repo = null;
- }
- if (repo != null)
- loadedRepos.add(repo);
- }
- if (loadedRepos.size() > 0) {
- IQueryable[] queryables = (IQueryable[]) loadedRepos.toArray(new IQueryable[loadedRepos.size()]);
- collector.addAll(new CompoundQueryable(queryables).query(query, sub.newChild(100)));
+ return query.perform(Arrays.asList(uris).iterator());
+ }
+
+ SubMonitor sub = SubMonitor.convert(monitor, (uris.length + 1) * 100);
+ ArrayList loadedRepos = new ArrayList(uris.length);
+ for (int i = 0; i < uris.length; i++) {
+ IRepository repo = null;
+ try {
+ repo = loadRepository(getRepositoryManager(), uris[i], sub.newChild(100));
+ } catch (ProvisionException e) {
+ tracker.reportLoadFailure(uris[i], e);
+ } catch (OperationCanceledException e) {
+ // user has canceled
+ repo = null;
}
+ if (repo != null)
+ loadedRepos.add(repo);
+ }
+ if (loadedRepos.size() > 0) {
+ IQueryable[] queryables = (IQueryable[]) loadedRepos.toArray(new IQueryable[loadedRepos.size()]);
+ return new CompoundQueryable(queryables).query(query, sub.newChild(100));
}
- return collector;
+ return Collector.EMPTY_COLLECTOR;
}
public void setRespositoryFlags(int flags) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryLocationQuery.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryLocationQuery.java
index 0aa29b0c4..fde79672e 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryLocationQuery.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/RepositoryLocationQuery.java
@@ -16,6 +16,7 @@ import java.util.Iterator;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.QueryHelpers;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.repository.IRepository;
/**
@@ -43,7 +44,8 @@ public class RepositoryLocationQuery implements IQuery {
return QueryHelpers.getProperty(this, property);
}
- public Collector perform(Iterator iterator, Collector result) {
+ public IQueryResult perform(Iterator iterator) {
+ Collector result = new Collector();
while (iterator.hasNext()) {
Object candidate = iterator.next();
URI location = getLocation(candidate);
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ExistingIUInProfileAction.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ExistingIUInProfileAction.java
index 6af7075ee..66b8380b7 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ExistingIUInProfileAction.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/actions/ExistingIUInProfileAction.java
@@ -91,9 +91,7 @@ public abstract class ExistingIUInProfileAction extends ProfileModificationActio
int lock = getLock(profile, iu);
if ((lock & getLockConstant()) == getLockConstant())
return false;
- if (profile.query(new PipedQuery(new IQuery[] {new InstallableUnitQuery(iu), getPolicy().getVisibleInstalledIUQuery()}), null).size() == 0)
- return false;
- return true;
+ return !profile.query(new PipedQuery(new IQuery[] {new InstallableUnitQuery(iu), getPolicy().getVisibleInstalledIUQuery()}), null).isEmpty();
}
protected abstract int getLockConstant();
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SizeComputingWizardPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SizeComputingWizardPage.java
index 83dee5a81..989c5a0f4 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SizeComputingWizardPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/SizeComputingWizardPage.java
@@ -76,12 +76,12 @@ public abstract class SizeComputingWizardPage extends ResolutionResultsWizardPag
sizingJob.setUser(false);
sizingJob.setSystem(true);
sizingJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_AUTHENTICATION_JOB_MARKER, Boolean.toString(true));
- sizingJob.schedule();
sizingJob.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
sizingJob = null;
}
});
+ sizingJob.schedule();
}
protected void createSizingInfo(Composite parent) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java
index ed048a28d..b7eef3861 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/model/AvailableUpdateElement.java
@@ -42,8 +42,8 @@ public class AvailableUpdateElement extends AvailableIUElement {
protected IProvisioningPlan getSizingPlan(IProgressMonitor monitor) {
ProfileChangeRequest request = ProfileChangeRequest.createByProfileId(profileID);
if (iuToBeUpdated.getId().equals(getIU().getId()))
- request.removeInstallableUnits(new IInstallableUnit[] {iuToBeUpdated});
- request.addInstallableUnits(new IInstallableUnit[] {getIU()});
+ request.removeInstallableUnit(iuToBeUpdated);
+ request.addInstallableUnit(getIU());
return ProvUIActivator.getDefault().getSession().getPlanner().getProvisioningPlan(request, new ProvisioningContext(), monitor);
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableProfileRegistry.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableProfileRegistry.java
index fc07c3d0a..b9ae9a8b4 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableProfileRegistry.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableProfileRegistry.java
@@ -11,16 +11,14 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.query;
-import org.eclipse.equinox.p2.metadata.query.IQueryResult;
-
import java.util.Arrays;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
/**
@@ -35,14 +33,12 @@ public class QueryableProfileRegistry implements IQueryable {
}
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- Collector result = new Collector();
IProfile[] profiles = ui.getSession().getProfileRegistry().getProfiles();
SubMonitor sub = SubMonitor.convert(monitor, ProvUIMessages.QueryableProfileRegistry_QueryProfileProgress, profiles.length);
try {
- query.perform(Arrays.asList(profiles).iterator(), result);
+ return query.perform(Arrays.asList(profiles).iterator());
} finally {
sub.done();
}
- return result;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java
index 07c96124d..29874d348 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java
@@ -11,8 +11,6 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.query;
-import org.eclipse.equinox.p2.metadata.query.IQueryResult;
-
import java.util.ArrayList;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
@@ -22,6 +20,7 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.query.IQueryable;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.query.IQuery;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
/**
@@ -38,7 +37,6 @@ public class QueryableUpdates implements IQueryable {
}
public IQueryResult query(IQuery query, IProgressMonitor monitor) {
- Collector result = new Collector();
if (monitor == null)
monitor = new NullProgressMonitor();
int totalWork = 2000;
@@ -48,17 +46,17 @@ public class QueryableUpdates implements IQueryable {
ArrayList allUpdates = new ArrayList();
for (int i = 0; i < iusToUpdate.length; i++) {
if (monitor.isCanceled())
- return result;
+ return Collector.EMPTY_COLLECTOR;
IInstallableUnit[] updates = planner.updatesFor(iusToUpdate[i], new ProvisioningContext(), new SubProgressMonitor(monitor, totalWork / 2 / iusToUpdate.length));
for (int j = 0; j < updates.length; j++)
allUpdates.add(updates[j]);
}
- query.perform(allUpdates.iterator(), result);
+ return query.perform(allUpdates.iterator());
} catch (OperationCanceledException e) {
// Nothing more to do, return result
+ return Collector.EMPTY_COLLECTOR;
} finally {
monitor.done();
}
- return result;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
index f9d38f784..16defb5e1 100644
--- a/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
+++ b/bundles/org.eclipse.equinox.p2.updatesite/src/org/eclipse/equinox/internal/p2/updatesite/SiteXMLAction.java
@@ -154,12 +154,12 @@ public class SiteXMLAction extends AbstractPublisherAction {
}
IQueryResult queryResult = results.query(query, null);
- if (queryResult.size() == 0)
- queryResult.addAll(publisherInfo.getMetadataRepository().query(query, null));
- if (queryResult.size() == 0 && publisherInfo.getContextMetadataRepository() != null)
- queryResult.addAll(publisherInfo.getContextMetadataRepository().query(query, null));
+ if (queryResult.isEmpty())
+ queryResult = publisherInfo.getMetadataRepository().query(query, null);
+ if (queryResult.isEmpty() && publisherInfo.getContextMetadataRepository() != null)
+ queryResult = publisherInfo.getContextMetadataRepository().query(query, null);
- if (queryResult.size() == 1)
+ if (!queryResult.isEmpty())
return (IInstallableUnit) queryResult.iterator().next();
return null;
}

Back to the top