Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/.externalToolBuilders/New_Builder.launch11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/.settings/org.eclipse.jdt.core.prefs4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF37
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/build.properties4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/rawData/Test Data Generator.launch5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractAntProvisioningTest.java41
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java394
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractWrappedArtifactRepository.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/FailingMetadataRepositoryFactory.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java231
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/MockQueryable.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/MirrorTaskTest.java107
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java43
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/RepoTasksTests.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java46
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java38
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug252308.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java152
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java46
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java151
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/AggregateQueryTest.java202
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CollectorTest.java51
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java240
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery1.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery2.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/QueryTest.java150
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/Bug203637.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorApplicationTest.java31
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java270
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java72
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/TestRepositoryWatcher.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ActionManagerTest.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java37
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java254
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java55
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java45
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileMetadataRepositoryTest.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java42
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java53
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java266
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java41
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointManagerTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java54
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java116
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/EclipseSDK33Test.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/FeatureToIU.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/PatchIUGeneration.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/TestGeneratorInfo.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/installer/InstallDescriptionParserTest.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java78
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java55
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java67
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java113
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/InstallableUnitTest.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LatestIUTest.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ProvidedCapabilityTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/AllTests.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/ExpressionTest.java67
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java267
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/AuthTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java79
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/HttpStatusTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/JarURLMetadataRepositoryTest.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/LocalMetadataRepositoryTest.java41
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerExceptionsTest.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/MetadataRepositoryManagerTest.java43
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/NoFailOver.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/ResumeDownloadTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/SPIMetadataRepositoryTest.java283
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/TimeoutTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactMirrorApplicationTest.java144
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/ArtifactRepositoryCleanupTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataMirrorApplicationTest.java84
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/MetadataRepositoryCleanupTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationArtifactTest.java81
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/mirror/NewMirrorApplicationMetadataTest.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/CommonPatternsTest.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatATest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatArrayTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatDTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatNTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatPTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatProcessingTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatQTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatRangeTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatSTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/FormatTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/IntersectionTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/MultiplicityTest.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/OSGiRangeTest.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/OSGiVersionTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/PerformanceTest.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawRangeTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawRangeWithOriginalTest.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawVersionTest.java614
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/RawWithOriginalTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/omniVersion/VersionTesting.java54
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/MetadataRepositoryPerformanceTest.java69
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/ProvisioningPerformanceTest.java31
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/perf/PublisherPerformanceTest.java53
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AbsolutePlanTest.java80
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ActualChangeRequestTest2.java37
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AddIUProperty.java50
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AdditionalConstraints.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstance.java151
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInExternalInstanceForCohostedMode.java150
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AgentPlanTestInRunningInstance.java153
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOptional.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOrbit.java55
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllTests.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AnotherSingleton.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug207319.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug249605.java44
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252638.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug252682.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug254481dataSet1.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug254481dataSet2.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug255984.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug262580.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug270656.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug270683.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271067.java55
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug271954.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug272251.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/Bug278668.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DependencyOnSelf.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DisabledExplanation.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/DropinsScenario.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationDeepConflict.java29
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForOptionalDependencies.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationForPartialInstallation.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationLargeConflict.java45
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ExplanationSeveralConflictingRoots.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/FindingPatchesThroughUpdates.java38
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/GreedyRequirement.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUProperties.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUPropertyRemoval.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/IUWithFilter2.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/InclusionRuleTest.java109
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/InclusionRuleTest2.java41
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MinimalInstall.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency2.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingDependency3.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingNonGreedyRequirement.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingNonGreedyRequirement2.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptional.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalNonGreedyRequirement.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies2.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MissingOptionalWithDependencies3.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleProvider.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/MultipleSingleton.java68
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NegationTesting.java127
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NoRequirements.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState.java36
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/NonMinimalState2.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ORTesting.java150
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PP2ShouldFailToInstall.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchFailingToInstall.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest10.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest11.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest12.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest13.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1b.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest1c.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest2.java53
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest3.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest4.java42
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest5.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest6.java38
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest7.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest7b.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest8.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTest9.java32
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch2.java78
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestMultiplePatch3.java78
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional2.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional3.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUninstall.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate2.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate3.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate4.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestUpdate5.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PermissiveSlicerTest.java76
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/ProvisioningPlanQueryTest.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java23
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java31
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SWTFragment.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies2.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies3.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies4.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SeveralOptionalDependencies5.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest2.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest3.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleOptionalTest4.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimpleSingleton.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java86
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TopLevelFilterTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/TwoVersionsOfWSDL.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/UninstallEverything.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/UpdateQueryTest.java49
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java65
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AbstractPublisherActionTest.java54
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AccumulateConfigDataActionTest.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ActionTest.java44
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceFileParserTest.java271
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/AdviceMatcher.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/BundlesActionTest.java82
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ConfigCUsActionTest.java33
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/DefaultCUsActionTest.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxExecutableActionTest.java51
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/EquinoxLauncherCUActionTest.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/FeaturesActionTest.java57
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/JREActionTest.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalUpdateSiteActionTest.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/LocalizationTests.java340
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/MD5GenerationTest.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTest.java81
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionTestMac.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductActionWithAdviceFileTest.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileAdviceTest.java5
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootFilesActionTest.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootIUActionTest.java37
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/VersionAdviceTest.java46
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/AllTests.java28
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java338
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java187
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/TestQueryReimplementation.java146
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/AbstractReconcilerTest.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/BasicTests.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/reconciler/dropins/ConfigurationTests.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/NTLMTest.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/repository/TimeoutTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddJVMArgumentActionTest.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddProgramArgumentActionTest.java35
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddRepositoryActionTest.java63
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AddSourceBundleActionTest.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/AllTests.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CheckTrustActionTest.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/ChmodActionTest.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/CollectActionTest.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/EclipseTouchpointTest.java60
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallBundleActionTest.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/InstallFeatureActionTest.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/JVMArgumentActionLogicTest.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/LinkActionTest.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/MarkStartedActionTest.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveJVMArgumentActionTest.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveProgramArgumentActionTest.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveRepositoryActionTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/RemoveSourceBundleActionTest.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetFrameworkDependentPropertyActionTest.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetFrameworkIndependentPropertyActionTest.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetLauncherNameActionTest.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetProgramPropertyActionTest.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/SetStartLevelActionTest.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallBundleActionTest.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UninstallFeatureActionTest.java21
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/eclipse/UtilTest.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/ChmodActionTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CleanupzipActionTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CollectActionTest.java24
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/CopyActionTest.java10
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/LinkActionTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/MkdirActionTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/NativeTouchpointTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/RemoveActionTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/RmdirActionTest.java4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/touchpoint/natives/UnzipActionTest.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatechecker/UpdateCheckerTest.java17
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/CategoryXMLActionTest.java13
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/DoesNotCacheStaleData.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/LocalUpdatesiteTest.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java22
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java93
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/ProfilePreferencesTest/with(invalid)chars/org.eclipse.equinox.p2.engine/profileRegistry/TestProfile.profile/.data/.settings/org.eclipse.equinox.p2.ui.sdk.prefs4
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/ProfilePreferencesTest/with(invalid)chars/org.eclipse.equinox.p2.engine/profileRegistry/TestProfile.profile/1345.profile.gz0
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/testData/ProfilePreferencesTest/with(invalid)chars/p2/org.eclipse.equinox.p2.engine/profileRegistry/TestProfile.profile/1345.profile.gz0
330 files changed, 7484 insertions, 6059 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/.externalToolBuilders/New_Builder.launch b/bundles/org.eclipse.equinox.p2.tests/.externalToolBuilders/New_Builder.launch
new file mode 100644
index 000000000..b4809f0a4
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/.externalToolBuilders/New_Builder.launch
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
+<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-apa"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+</launchConfiguration>
diff --git a/bundles/org.eclipse.equinox.p2.tests/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.tests/.settings/org.eclipse.jdt.core.prefs
index 5f61adc2c..47ca55680 100644
--- a/bundles/org.eclipse.equinox.p2.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.equinox.p2.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Fri Dec 12 15:45:18 EST 2008
+#Mon Dec 28 06:14:12 CET 2009
eclipse.preferences.version=1
instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
@@ -10,7 +10,7 @@ org.eclipse.jdt.core.circularClasspath=error
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=jsr14
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
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 4d9062037..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,12 +52,12 @@
<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"/>
+<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"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.equinox.p2.reconciler.tests.platform.archive=c:/builds/eclipse-platform-I20090811-0800-win32.zip&#13;&#10;-Dorg.eclipse.equinox.p2.reconciler.tests.35.platform.archive=c:/builds/eclipse-platform-3.5-win32.zip&#13;&#10;-Dorg.eclipse.equinox.p2.repository&#13;&#13;&#10;-Xmx512m"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.equinox.p2.reconciler.tests.platform.archive=c:/builds/eclipse-platform-I20090811-0800-win32.zip&#13;&#10;-Dorg.eclipse.equinox.p2.reconciler.tests.35.platform.archive=c:/builds/eclipse-platform-3.5-win32.zip&#13;&#10;-Dorg.eclipse.equinox.p2.repository&#13;&#10;-Dorg.eclipse.equinox.p2.tests.current.build.repo=http://eclipsebuildserv/3.6-I-builds/&#13;&#13;&#10;-Xmx512m"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
diff --git a/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF
index 564a94b70..438d9ea7c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.tests/META-INF/MANIFEST.MF
@@ -8,20 +8,20 @@ Bundle-Version: 1.2.0.qualifier
Import-Package: javax.xml.parsers,
org.eclipse.ant.core,
org.eclipse.ecf.filetransfer,
- org.eclipse.equinox.internal.p2.artifact.mirror,
org.eclipse.equinox.internal.p2.artifact.processors.md5,
org.eclipse.equinox.internal.p2.artifact.processors.pack200,
org.eclipse.equinox.internal.p2.artifact.repository,
org.eclipse.equinox.internal.p2.artifact.repository.simple,
+ org.eclipse.equinox.internal.p2.core,
org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.internal.p2.director,
org.eclipse.equinox.internal.p2.director.app,
- org.eclipse.equinox.internal.p2.engine,
org.eclipse.equinox.internal.p2.extensionlocation,
org.eclipse.equinox.internal.p2.jarprocessor,
org.eclipse.equinox.internal.p2.jarprocessor.verifier,
org.eclipse.equinox.internal.p2.metadata,
- org.eclipse.equinox.internal.p2.metadata.mirror,
+ org.eclipse.equinox.internal.p2.metadata.expression,
+ org.eclipse.equinox.internal.p2.metadata.query,
org.eclipse.equinox.internal.p2.metadata.repository,
org.eclipse.equinox.internal.p2.metadata.repository.io,
org.eclipse.equinox.internal.p2.persistence,
@@ -31,26 +31,24 @@ Import-Package: javax.xml.parsers,
org.eclipse.equinox.internal.p2.touchpoint.natives,
org.eclipse.equinox.internal.p2.touchpoint.natives.actions,
org.eclipse.equinox.internal.p2.update,
- org.eclipse.equinox.internal.p2.updatesite,
- org.eclipse.equinox.internal.p2.updatesite.artifact,
- org.eclipse.equinox.internal.p2.updatesite.metadata,
- org.eclipse.equinox.internal.provisional.p2.artifact.repository,
org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing,
org.eclipse.equinox.internal.provisional.p2.core,
org.eclipse.equinox.internal.provisional.p2.core.eventbus,
- org.eclipse.equinox.internal.provisional.p2.core.location,
org.eclipse.equinox.internal.provisional.p2.director,
org.eclipse.equinox.internal.provisional.p2.directorywatcher,
- org.eclipse.equinox.internal.provisional.p2.engine,
- org.eclipse.equinox.internal.provisional.p2.engine.phases,
org.eclipse.equinox.internal.provisional.p2.metadata,
- org.eclipse.equinox.internal.provisional.p2.metadata.query,
- org.eclipse.equinox.internal.provisional.p2.metadata.repository,
org.eclipse.equinox.internal.provisional.p2.repository,
- org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository,
- org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository,
- org.eclipse.equinox.internal.provisional.spi.p2.repository,
+ org.eclipse.equinox.p2.core,
+ org.eclipse.equinox.p2.internal.repository.comparator,
org.eclipse.equinox.p2.internal.repository.tools,
+ org.eclipse.equinox.p2.metadata,
+ org.eclipse.equinox.p2.metadata.expression,
+ org.eclipse.equinox.p2.metadata.query,
+ org.eclipse.equinox.p2.ql,
+ org.eclipse.equinox.p2.query,
+ org.eclipse.equinox.p2.repository.artifact.spi,
+ org.eclipse.equinox.p2.repository.metadata.spi,
+ org.eclipse.equinox.p2.repository.spi,
org.eclipse.equinox.spi.p2.publisher,
org.eclipse.internal.provisional.equinox.p2.jarprocessor,
org.eclipse.osgi.service.datalocation,
@@ -80,10 +78,15 @@ Require-Bundle: org.eclipse.equinox.p2.metadata.generator,
org.eclipse.equinox.p2.updatechecker;bundle-version="1.0.0",
org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="1.0.100",
org.eclipse.equinox.p2.repository;bundle-version="1.0.0",
- org.eclipse.equinox.p2.tests.verifier;bundle-version="1.0.0"
+ org.eclipse.equinox.p2.tests.verifier;bundle-version="1.0.0",
+ org.eclipse.equinox.security;bundle-version="1.0.0",
+ org.eclipse.equinox.p2.engine;bundle-version="2.0.0",
+ org.eclipse.equinox.p2.ql,
+ org.eclipse.equinox.p2.updatesite;bundle-version="1.0.200"
Bundle-ActivationPolicy: lazy
Eclipse-RegisterBuddy: org.eclipse.equinox.p2.artifact.repository
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,
+ J2SE-1.4
Export-Package: org.eclipse.equinox.p2.tests,
org.eclipse.equinox.p2.tests.artifact.repository,
org.eclipse.equinox.p2.tests.artifact.repository.processing,
diff --git a/bundles/org.eclipse.equinox.p2.tests/build.properties b/bundles/org.eclipse.equinox.p2.tests/build.properties
index 1518f3c93..63bbf4dba 100644
--- a/bundles/org.eclipse.equinox.p2.tests/build.properties
+++ b/bundles/org.eclipse.equinox.p2.tests/build.properties
@@ -18,5 +18,7 @@ bin.includes = META-INF/,\
plugin.properties,\
test.xml
customCallBack=foo.xml
-javacWarnings..=-raw,-unchecked,-varargsCast
src.includes = about.html
+javacWarnings..=-raw,-unchecked,-varargsCast
+javacTarget=jsr14
+javacSource=1.5
diff --git a/bundles/org.eclipse.equinox.p2.tests/rawData/Test Data Generator.launch b/bundles/org.eclipse.equinox.p2.tests/rawData/Test Data Generator.launch
index ad9a6a439..8db6aec9a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/rawData/Test Data Generator.launch
+++ b/bundles/org.eclipse.equinox.p2.tests/rawData/Test Data Generator.launch
@@ -16,10 +16,9 @@
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
<stringAttribute key="pde.version" value="3.3"/>
<booleanAttribute key="show_selected_only" value="false"/>
-<stringAttribute key="target_bundles" value="org.eclipse.core.contenttype@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.runtime@default:default,org.eclipse.core.runtime.compatibility.registry@default:default,org.eclipse.equinox.app@default:true,org.eclipse.equinox.common@default:default,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.launcher.win32.win32.x86@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.osgi@:,org.eclipse.osgi.services@default:default,org.eclipse.update.configurator@default:default"/>
+<stringAttribute key="target_bundles" value="org.eclipse.core.runtime@default:true,org.eclipse.core.contenttype@default:default,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.core.jobs@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.osgi,org.eclipse.equinox.common@2:true,org.eclipse.osgi.services@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.equinox.app@default:true,org.eclipse.update.configurator@3:true"/>
<booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useDefaultConfigArea" value="true"/>
<booleanAttribute key="useNamedJRE" value="false"/>
-<stringAttribute key="vminstall" value="ibm1.5sr1"/>
-<stringAttribute key="workspace_bundles" value="org.eclipse.ecf@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:true,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.download@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.metadata.generator@default:default,org.eclipse.equinox.p2.metadata.repository@default:default"/>
+<stringAttribute key="workspace_bundles" value="org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.p2.metadata.generator@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:true"/>
</launchConfiguration>
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractAntProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractAntProvisioningTest.java
index e72c223e8..0a82e05d9 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractAntProvisioningTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractAntProvisioningTest.java
@@ -17,12 +17,14 @@ import java.util.*;
import org.eclipse.ant.core.AntRunner;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.URIUtil;
-import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.internal.p2.persistence.XMLWriter;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.query.IQueryable;
+import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
public class AbstractAntProvisioningTest extends AbstractProvisioningTest {
protected static final String TYPE_ARTIFACT = "A";
@@ -246,11 +248,11 @@ public class AbstractAntProvisioningTest extends AbstractProvisioningTest {
assertContains(message, destination, source);
}
- protected static void assertArtifactKeyContentEquals(String message, Collector ius, URI artifactRepositoryLocation) {
+ protected void assertArtifactKeyContentEquals(String message, IQueryResult ius, URI artifactRepositoryLocation) {
try {
IArtifactRepository repo = getArtifactRepositoryManager().loadRepository(artifactRepositoryLocation, null);
List fromIUs = getArtifactKeys(ius);
- List fromRepo = Arrays.asList(repo.getArtifactKeys());
+ Iterator fromRepo = repo.query(ArtifactKeyQuery.ALL_KEYS, null).iterator();
assertContains(message, fromIUs, fromRepo);
assertContains(message, fromRepo, fromIUs);
} catch (ProvisionException e) {
@@ -259,28 +261,11 @@ public class AbstractAntProvisioningTest extends AbstractProvisioningTest {
}
- protected static void assertContains(String message, IQueryable source, IQueryable destination) {
- Collector sourceCollector = source.query(InstallableUnitQuery.ANY, new Collector(), null);
- Iterator it = sourceCollector.iterator();
+ protected static List getArtifactKeys(IQueryResult<IInstallableUnit> ius) {
+ List<IArtifactKey> keys = new ArrayList<IArtifactKey>();
- while (it.hasNext()) {
- IInstallableUnit sourceIU = (IInstallableUnit) it.next();
- Collector destinationCollector = destination.query(new InstallableUnitQuery(sourceIU), new Collector(), null);
- assertEquals(message, 1, destinationCollector.size());
- assertTrue(message, sourceIU.equals(destinationCollector.iterator().next()));
- }
- }
-
- protected static void assertContains(String message, List fromIUs, List fromRepo) {
- for (Iterator iter = fromIUs.iterator(); iter.hasNext();)
- assertTrue(message, fromRepo.contains(iter.next()));
- }
-
- protected static List getArtifactKeys(Collector ius) {
- List keys = new ArrayList(ius.size());
-
- for (Iterator iter = ius.iterator(); iter.hasNext();)
- keys.addAll(Arrays.asList(((InstallableUnit) iter.next()).getArtifacts()));
+ for (Iterator<IInstallableUnit> iter = ius.iterator(); iter.hasNext();)
+ keys.addAll(iter.next().getArtifacts());
return keys;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
index 76f090a7d..1b6ef6158 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
@@ -19,23 +19,29 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.core.helpers.URLUtil;
import org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.internal.provisional.p2.director.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.core.*;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
+import org.eclipse.equinox.p2.metadata.query.FragmentQuery;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
import org.eclipse.equinox.p2.publisher.eclipse.*;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.resolver.BundleDescription;
+import org.osgi.framework.*;
/**
* Base class for provisioning tests with convenience methods used by multiple tests.
@@ -71,6 +77,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
protected List profilesToRemove = new ArrayList();
private File testFolder = null;
+ protected Object previousSelfValue = null;
public static void assertEmptyProfile(IProfile profile) {
assertNotNull("The profile should not be null", profile);
@@ -199,7 +206,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
InstallableUnitFragmentDescription fragment = new InstallableUnitFragmentDescription();
fragment.setId(name);
fragment.setVersion(DEFAULT_VERSION);
- fragment.setProperty(IInstallableUnit.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString());
+ fragment.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString());
fragment.setTouchpointType(TOUCHPOINT_OSGI);
fragment.addTouchpointData(NO_TP_DATA);
fragment.setHost(BUNDLE_REQUIREMENT);
@@ -225,7 +232,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
public static IDirector createDirector() {
- return (IDirector) ServiceHelper.getService(TestActivator.getContext(), IDirector.class.getName());
+ return (IDirector) ServiceHelper.getService(TestActivator.getContext(), IDirector.SERVICE_NAME);
}
/**
@@ -263,8 +270,8 @@ public abstract class AbstractProvisioningTest extends TestCase {
/**
* Creates and returns a correctly formatted LDAP filter with the given key and value.
*/
- protected static String createFilter(String filterKey, String filterValue) {
- return "(" + filterKey + '=' + filterValue + ')';
+ protected static Filter createFilter(String filterKey, String filterValue) {
+ return ExpressionUtil.parseLDAP("(" + filterKey + '=' + filterValue + ')');
}
/**
@@ -304,6 +311,10 @@ public abstract class AbstractProvisioningTest extends TestCase {
* assume default values, and the default self capability is also added to the IU.
*/
public static IInstallableUnit createIU(String name, String filter, IProvidedCapability[] additionalProvides) {
+ return createIU(name, ExpressionUtil.parseLDAP(filter), additionalProvides);
+ }
+
+ public static IInstallableUnit createIU(String name, Filter filter, IProvidedCapability[] additionalProvides) {
return createIU(name, DEFAULT_VERSION, filter, NO_REQUIRES, additionalProvides, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false);
}
@@ -356,6 +367,10 @@ public abstract class AbstractProvisioningTest extends TestCase {
* assume default values, and the default self capability is also added to the IU.
*/
public static IInstallableUnit createIU(String name, Version version, String filter, IProvidedCapability[] additionalProvides) {
+ return createIU(name, version, ExpressionUtil.parseLDAP(filter), additionalProvides);
+ }
+
+ public static IInstallableUnit createIU(String name, Version version, Filter filter, IProvidedCapability[] additionalProvides) {
return createIU(name, version, filter, NO_REQUIRES, additionalProvides, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false);
}
@@ -363,7 +378,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
* Create a basic InstallableUnit with the given attributes. All other attributes
* assume default values, and the default self capability is also added to the IU.
*/
- public static IInstallableUnit createIU(String name, Version version, String filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton) {
+ public static IInstallableUnit createIU(String name, Version version, Filter filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton) {
return createIU(name, version, filter, required, additionalProvides, properties, tpType, tpData, singleton, null, null);
}
@@ -371,7 +386,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
return createIUPatch(name, version, null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, singleton, null, changes, scope, lifeCycle, NO_REQUIRES);
}
- public static IInstallableUnitPatch createIUPatch(String name, Version version, String filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton, IUpdateDescriptor update, IRequirementChange[] reqChanges, IRequiredCapability[][] scope, IRequiredCapability lifeCycle, IRequiredCapability[] metaRequirements) {
+ public static IInstallableUnitPatch createIUPatch(String name, Version version, Filter filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton, IUpdateDescriptor update, IRequirementChange[] reqChanges, IRequiredCapability[][] scope, IRequiredCapability lifeCycle, IRequiredCapability[] metaRequirements) {
InstallableUnitPatchDescription iu = new MetadataFactory.InstallableUnitPatchDescription();
iu.setId(name);
iu.setVersion(version);
@@ -400,7 +415,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
return MetadataFactory.createInstallableUnitPatch(iu);
}
- public static IInstallableUnit createIU(String name, Version version, String filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton, IUpdateDescriptor update, IRequiredCapability[] metaRequirements) {
+ public static IInstallableUnit createIU(String name, Version version, Filter filter, IRequiredCapability[] required, IProvidedCapability[] additionalProvides, Map properties, ITouchpointType tpType, ITouchpointData tpData, boolean singleton, IUpdateDescriptor update, IRequiredCapability[] metaRequirements) {
InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription();
iu.setId(name);
iu.setVersion(version);
@@ -444,47 +459,45 @@ public abstract class AbstractProvisioningTest extends TestCase {
InstallableUnitFragmentDescription fragment = new InstallableUnitFragmentDescription();
fragment.setId(name);
fragment.setVersion(version);
- fragment.setProperty(IInstallableUnit.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString());
+ fragment.setProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT, Boolean.TRUE.toString());
fragment.setRequiredCapabilities(required);
fragment.setTouchpointType(tpType);
if (tpData != null)
fragment.addTouchpointData(tpData);
if (host != null) {
VersionRange hostRange = new VersionRange(host.getVersion(), true, host.getVersion(), true);
- fragment.setHost(new IRequiredCapability[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, host.getId(), hostRange, null, false, false)});
+ fragment.setHost(new IRequirement[] {MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, host.getId(), hostRange, null, false, false)});
}
fragment.setCapabilities(new IProvidedCapability[] {getSelfCapability(name, version)});
return MetadataFactory.createInstallableUnitFragment(fragment);
}
public static void changeVersion(InstallableUnitDescription desc, Version newVersion) {
- IProvidedCapability[] capabilities = desc.getProvidedCapabilities();
- for (int i = 0; i < capabilities.length; i++) {
- if (desc.getVersion().equals(capabilities[i].getVersion()))
- capabilities[i] = MetadataFactory.createProvidedCapability(capabilities[i].getNamespace(), capabilities[i].getName(), newVersion);
+ List<IProvidedCapability> capabilities = new ArrayList(desc.getProvidedCapabilities());
+ for (int i = 0; i < capabilities.size(); i++) {
+ IProvidedCapability pc = capabilities.get(i);
+ if (desc.getVersion().equals(pc.getVersion()))
+ capabilities.set(i, MetadataFactory.createProvidedCapability(pc.getNamespace(), pc.getName(), newVersion));
}
desc.setVersion(newVersion);
+ desc.setCapabilities(capabilities.toArray(new IProvidedCapability[capabilities.size()]));
}
public static MetadataFactory.InstallableUnitDescription createIUDescriptor(IInstallableUnit prototype) {
InstallableUnitDescription desc = new MetadataFactory.InstallableUnitDescription();
- desc.setArtifacts(prototype.getArtifacts());
- IProvidedCapability originalCapabilities[] = prototype.getProvidedCapabilities();
- IProvidedCapability newCapabilities[] = new IProvidedCapability[originalCapabilities.length];
- for (int i = 0; i < originalCapabilities.length; i++) {
- newCapabilities[i] = MetadataFactory.createProvidedCapability(originalCapabilities[i].getNamespace(), originalCapabilities[i].getName(), originalCapabilities[i].getVersion());
- }
- desc.setCapabilities(newCapabilities);
+ Collection<IArtifactKey> originalArtifacts = prototype.getArtifacts();
+ desc.setArtifacts(originalArtifacts.toArray(new IArtifactKey[originalArtifacts.size()]));
+ Collection<IProvidedCapability> originalCapabilities = prototype.getProvidedCapabilities();
+ desc.setCapabilities(originalCapabilities.toArray(new IProvidedCapability[originalCapabilities.size()]));
desc.setCopyright(prototype.getCopyright());
desc.setFilter(prototype.getFilter());
desc.setId(prototype.getId());
- desc.setLicense(prototype.getLicense());
- IRequiredCapability[] originalRequirements = prototype.getRequiredCapabilities();
- IRequiredCapability[] newRequirements = new IRequiredCapability[originalRequirements.length];
- for (int i = 0; i < newRequirements.length; i++) {
- newRequirements[i] = MetadataFactory.createRequiredCapability(originalRequirements[i].getNamespace(), originalRequirements[i].getName(), originalRequirements[i].getRange(), originalRequirements[i].getFilter(), originalRequirements[i].isOptional(), originalRequirements[i].isMultiple(), originalRequirements[i].isGreedy());
- }
- desc.setRequiredCapabilities(prototype.getRequiredCapabilities());
+ Collection<ILicense> originalLicenses = prototype.getLicenses();
+ desc.setLicenses(originalLicenses.toArray(new ILicense[originalLicenses.size()]));
+ Collection<IRequirement> originalRequirements = prototype.getRequiredCapabilities();
+ desc.setRequiredCapabilities(originalRequirements.toArray(new IRequirement[originalRequirements.size()]));
+ originalRequirements = prototype.getMetaRequiredCapabilities();
+ desc.setMetaRequiredCapabilities(originalRequirements.toArray(new IRequirement[originalRequirements.size()]));
desc.setSingleton(prototype.isSingleton());
desc.setTouchpointType(MetadataFactory.createTouchpointType(prototype.getTouchpointType().getId(), prototype.getTouchpointType().getVersion()));
desc.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor(prototype.getUpdateDescriptor().getId(), prototype.getUpdateDescriptor().getRange(), prototype.getUpdateDescriptor().getSeverity(), prototype.getUpdateDescriptor().getDescription()));
@@ -499,20 +512,29 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
public static IPlanner createPlanner() {
- return (IPlanner) ServiceHelper.getService(TestActivator.getContext(), IPlanner.class.getName());
+ return (IPlanner) ServiceHelper.getService(TestActivator.getContext(), IPlanner.SERVICE_NAME);
}
/**
* Creates and returns a required capability with the provided attributes.
*/
+ protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name) {
+ return createRequiredCapabilities(namespace, name, ANY_VERSION, (Filter) null);
+ }
+
protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name, String filter) {
return createRequiredCapabilities(namespace, name, ANY_VERSION, filter);
}
- /**
- * Creates and returns a required capability with the provided attributes.
- */
+ protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name, VersionRange range) {
+ return createRequiredCapabilities(namespace, name, range, (Filter) null);
+ }
+
protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name, VersionRange range, String filter) {
+ return createRequiredCapabilities(namespace, name, range, ExpressionUtil.parseLDAP(filter));
+ }
+
+ protected static IRequiredCapability[] createRequiredCapabilities(String namespace, String name, VersionRange range, Filter filter) {
return new IRequiredCapability[] {MetadataFactory.createRequiredCapability(namespace, name, range, filter, false, false)};
}
@@ -568,7 +590,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
public static Iterator getInstallableUnits(IProfile profile2) {
- return profile2.query(InstallableUnitQuery.ANY, new Collector(), null).iterator();
+ return profile2.query(InstallableUnitQuery.ANY, null).iterator();
}
/**
@@ -581,7 +603,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
/**
* Get the 'self' capability for an installable unit with the give id and version.
*/
- private static IProvidedCapability getSelfCapability(String installableUnitId, Version installableUnitVersion) {
+ protected static IProvidedCapability getSelfCapability(String installableUnitId, Version installableUnitVersion) {
return MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, installableUnitId, installableUnitVersion);
}
@@ -618,6 +640,41 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
}
+ public static int queryResultSize(IQueryResult queryResult) {
+ if (queryResult instanceof Collector)
+ return ((Collector) queryResult).size();
+
+ int cnt = 0;
+ Iterator itor = queryResult.iterator();
+ while (itor.hasNext()) {
+ itor.next();
+ ++cnt;
+ }
+ return cnt;
+ }
+
+ public static int queryResultUniqueSize(IQueryResult queryResult) {
+ int cnt = 0;
+ Iterator itor = queryResult.iterator();
+ HashSet uniqueTracker = new HashSet();
+ while (itor.hasNext()) {
+ if (uniqueTracker.add(itor.next()))
+ ++cnt;
+ }
+ return cnt;
+ }
+
+ public static void restartBundle(final Bundle bundle) throws BundleException {
+ bundle.stop(Bundle.STOP_TRANSIENT);
+ startBundle(bundle);
+ }
+
+ public static void startBundle(final Bundle bundle) throws BundleException {
+ //see http://dev.eclipse.org/mhonarc/lists/equinox-dev/msg05917.html
+ bundle.start(Bundle.START_ACTIVATION_POLICY);
+ bundle.start(Bundle.START_TRANSIENT);
+ }
+
private static void write(IStatus status, int indent, PrintStream output) {
indent(output, indent);
output.println("Severity: " + status.getSeverity());
@@ -684,7 +741,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
* in the tearDown method.
*/
protected IProfile createProfile(String name) {
- return createProfile(name, null, null);
+ return createProfile(name, null);
}
/**
@@ -692,18 +749,14 @@ public abstract class AbstractProvisioningTest extends TestCase {
* already exists. The returned profile will be removed automatically
* in the tearDown method.
*/
- protected IProfile createProfile(String name, String parentId) {
- return createProfile(name, parentId, null);
- }
-
- protected IProfile createProfile(String name, String parentId, Map properties) {
+ protected IProfile createProfile(String name, Map properties) {
//remove any existing profile with the same name
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry profileRegistry = getProfileRegistry();
profileRegistry.removeProfile(name);
profilesToRemove.add(name);
//create and return a new profile
try {
- return profileRegistry.addProfile(name, properties, parentId);
+ return profileRegistry.addProfile(name, properties);
} catch (ProvisionException e) {
throw new IllegalArgumentException(e.getMessage());
}
@@ -714,9 +767,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
protected IProfile getProfile(String profileId) {
- //remove any existing profile with the same name
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
- return profileRegistry.getProfile(profileId);
+ return getProfileRegistry().getProfile(profileId);
}
/**
@@ -732,7 +783,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
*/
protected IMetadataRepository createTestMetdataRepository(IInstallableUnit[] units) {
IMetadataRepository repo = new TestMetadataRepository(units);
- MetadataRepositoryManager repoMan = (MetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName());
+ MetadataRepositoryManager repoMan = (MetadataRepositoryManager) getMetadataRepositoryManager();
assertNotNull(repoMan);
repoMan.addRepository(repo);
metadataRepos.add(repo);
@@ -746,8 +797,22 @@ public abstract class AbstractProvisioningTest extends TestCase {
return repo;
}
+ protected static IProvisioningAgent getAgent() {
+ //get the global agent for the currently running system
+ return (IProvisioningAgent) ServiceHelper.getService(TestActivator.getContext(), IProvisioningAgent.SERVICE_NAME);
+ }
+
+ protected static IAgentLocation getAgentLocation() {
+ //get the location of the currently running system
+ return (IAgentLocation) getAgent().getService(IAgentLocation.SERVICE_NAME);
+ }
+
protected static IArtifactRepositoryManager getArtifactRepositoryManager() {
- return (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.class.getName());
+ return (IArtifactRepositoryManager) getAgent().getService(IArtifactRepositoryManager.SERVICE_NAME);
+ }
+
+ protected IProfileRegistry getProfileRegistry() {
+ return (IProfileRegistry) getAgent().getService(IProfileRegistry.SERVICE_NAME);
}
protected IMetadataRepository createMetadataRepository(URI location, Map properties) throws ProvisionException {
@@ -765,17 +830,17 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
protected IInstallableUnit getIU(IMetadataRepository repository, String name) {
- Collector collector = repository.query(new InstallableUnitQuery(name), new Collector(), null);
+ IQueryResult queryResult = repository.query(new InstallableUnitQuery(name), null);
IInstallableUnit unit = null;
- if (collector.size() > 0)
- unit = (IInstallableUnit) collector.iterator().next();
+ if (!queryResult.isEmpty())
+ unit = (IInstallableUnit) queryResult.iterator().next();
return unit;
}
protected static IMetadataRepositoryManager getMetadataRepositoryManager() {
- return (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName());
+ return (IMetadataRepositoryManager) getAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
}
public static String getUniqueString() {
@@ -819,7 +884,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
protected void tearDown() throws Exception {
super.tearDown();
//remove all metadata repositories created by this test
- IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName());
+ IMetadataRepositoryManager repoMan = getMetadataRepositoryManager();
if (!metadataRepos.isEmpty()) {
for (Iterator it = metadataRepos.iterator(); it.hasNext();) {
IMetadataRepository repo = (IMetadataRepository) it.next();
@@ -837,7 +902,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
}
//remove all profiles created by this test
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry profileRegistry = getProfileRegistry();
for (Iterator it = profilesToRemove.iterator(); it.hasNext();) {
String toRemove = (String) it.next();
profileRegistry.removeProfile(toRemove);
@@ -867,46 +932,24 @@ public abstract class AbstractProvisioningTest extends TestCase {
return null;
}
- protected static void assertInstallOperand(ProvisioningPlan plan, IInstallableUnit iu) {
- Operand[] ops = plan.getOperands();
- for (int i = 0; i < ops.length; i++) {
- if (ops[i] instanceof InstallableUnitOperand) {
- InstallableUnitOperand iuOp = (InstallableUnitOperand) ops[i];
- if (iu.equals(iuOp.second()))
- return;
- }
- }
- fail("Can't find " + iu + " in the plan");
+ protected static void assertInstallOperand(IProvisioningPlan plan, IInstallableUnit iu) {
+ if (plan.getAdditions().query(new InstallableUnitQuery(iu), null).isEmpty())
+ fail("Can't find " + iu + " in the plan");
}
- protected static void assertUninstallOperand(ProvisioningPlan plan, IInstallableUnit iu) {
- Operand[] ops = plan.getOperands();
- for (int i = 0; i < ops.length; i++) {
- if (ops[i] instanceof InstallableUnitOperand) {
- InstallableUnitOperand iuOp = (InstallableUnitOperand) ops[i];
- if (iu.equals(iuOp.first()))
- return;
- }
- }
- fail("Can't find " + iu + " in the plan");
- }
-
- protected static void assertNoOperand(ProvisioningPlan plan, IInstallableUnit iu) {
- Operand[] ops = plan.getOperands();
- for (int i = 0; i < ops.length; i++) {
- if (ops[i] instanceof InstallableUnitOperand) {
- InstallableUnitOperand iuOp = (InstallableUnitOperand) ops[i];
- if (iuOp.second() != null && iuOp.second().equals(iu))
- fail(iu + " should not be present in this plan.");
- if (iuOp.first() != null && iuOp.first().equals(iu))
- fail(iu + " should not be present in this plan.");
- }
- }
+ protected static void assertUninstallOperand(IProvisioningPlan plan, IInstallableUnit iu) {
+ if (plan.getRemovals().query(new InstallableUnitQuery(iu), null).isEmpty())
+ fail("Can't find " + iu + " in the plan");
+ }
+
+ protected static void assertNoOperand(IProvisioningPlan plan, IInstallableUnit iu) {
+ if (!(plan.getRemovals().query(new InstallableUnitQuery(iu), null).isEmpty() && plan.getAdditions().query(new InstallableUnitQuery(iu), null).isEmpty()))
+ fail(iu + " should not be present in this plan.");
}
protected void setUp() throws Exception {
super.setUp();
- MetadataRepositoryManager repoMan = (MetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName());
+ IMetadataRepositoryManager repoMan = getMetadataRepositoryManager();
URI[] repos = repoMan.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
for (int i = 0; i < repos.length; i++) {
repoMan.removeRepository(repos[i]);
@@ -920,18 +963,18 @@ public abstract class AbstractProvisioningTest extends TestCase {
req.setInstallableUnitInclusionRules(ius[i], strict ? PlannerHelper.createStrictInclusionRule(ius[i]) : PlannerHelper.createOptionalInclusionRule(ius[i]));
}
- ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null);
+ IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null);
if (plan.getStatus().getSeverity() == IStatus.ERROR || plan.getStatus().getSeverity() == IStatus.CANCEL)
return plan.getStatus();
- return engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), null, null);
+ return engine.perform(plan, null);
}
protected IStatus uninstall(IProfile profile, IInstallableUnit[] ius, IPlanner planner, IEngine engine) {
ProfileChangeRequest req = new ProfileChangeRequest(profile);
req.removeInstallableUnits(ius);
- ProvisioningPlan plan = planner.getProvisioningPlan(req, null, null);
- return engine.perform(profile, new DefaultPhaseSet(), plan.getOperands(), null, null);
+ IProvisioningPlan plan = planner.getProvisioningPlan(req, null, null);
+ return engine.perform(plan, null);
}
protected static void assertEquals(String message, Object[] expected, Object[] actual, boolean orderImportant) {
@@ -1002,15 +1045,15 @@ public abstract class AbstractProvisioningTest extends TestCase {
if (!iu1.equals(iu2))
fail(message + " " + iu1 + " is not equal to " + iu2);
- if (iu1.isFragment()) {
- if (!iu2.isFragment())
+ if (FragmentQuery.isFragment(iu1)) {
+ if (!FragmentQuery.isFragment(iu2))
fail(message + " " + iu1 + " is not a fragment.");
try {
assertEquals(message, ((IInstallableUnitFragment) iu1).getHost(), ((IInstallableUnitFragment) iu2).getHost());
} catch (AssertionFailedError failure) {
fail(message + " Unequal hosts: " + failure.getMessage());
}
- } else if (iu2.isFragment()) {
+ } else if (FragmentQuery.isFragment(iu2)) {
fail(message + " " + iu2 + " is a fragment.");
}
@@ -1027,7 +1070,7 @@ public abstract class AbstractProvisioningTest extends TestCase {
assertEquals(message, iu1.getTouchpointType(), iu2.getTouchpointType());
assertEquals(message, iu1.getTouchpointData(), iu2.getTouchpointData());
assertEquals(message, iu1.getProperties(), iu2.getProperties());
- assertEquals(message, iu1.getLicense(), iu2.getLicense());
+ assertEquals(message, iu1.getLicenses(), iu2.getLicenses());
assertEquals(message, iu1.getCopyright(), iu2.getCopyright());
assertEquals(message, iu1.getUpdateDescriptor(), iu2.getUpdateDescriptor());
assertEquals(message, iu1.getFilter(), iu2.getFilter());
@@ -1136,15 +1179,15 @@ public abstract class AbstractProvisioningTest extends TestCase {
* Note: NOT BICONDITIONAL! assertContains(A, B) is NOT the same as assertContains(B, A)
*/
protected static void assertContains(String message, IArtifactRepository sourceRepo, IArtifactRepository destinationRepo) {
- IArtifactKey[] sourceKeys = sourceRepo.getArtifactKeys();
-
- for (int i = 0; i < sourceKeys.length; i++) {
- IArtifactDescriptor[] destinationDescriptors = destinationRepo.getArtifactDescriptors(sourceKeys[i]);
+ IQueryResult sourceKeys = sourceRepo.query(ArtifactKeyQuery.ALL_KEYS, null);
+ for (Iterator iterator = sourceKeys.iterator(); iterator.hasNext();) {
+ IArtifactKey key = (IArtifactKey) iterator.next();
+ IArtifactDescriptor[] destinationDescriptors = destinationRepo.getArtifactDescriptors(key);
if (destinationDescriptors == null || destinationDescriptors.length == 0)
- fail(message + ": unmatched key: " + sourceKeys[i].toString());
+ fail(message + ": unmatched key: " + key.toString());
//this implicitly verifies the keys are present
- IArtifactDescriptor[] sourceDescriptors = sourceRepo.getArtifactDescriptors(sourceKeys[i]);
+ IArtifactDescriptor[] sourceDescriptors = sourceRepo.getArtifactDescriptors(key);
assertEquals(message, sourceDescriptors, destinationDescriptors, false); //order doesn't matter
}
@@ -1164,13 +1207,13 @@ public abstract class AbstractProvisioningTest extends TestCase {
* Note: NOT BICONDITIONAL! assertContains(A, B) is NOT the same as assertContains(B, A)
*/
protected static void assertContains(String message, IMetadataRepository sourceRepo, IMetadataRepository destinationRepo) {
- Collector sourceCollector = sourceRepo.query(InstallableUnitQuery.ANY, new Collector(), null);
+ IQueryResult sourceCollector = sourceRepo.query(InstallableUnitQuery.ANY, null);
Iterator it = sourceCollector.iterator();
while (it.hasNext()) {
IInstallableUnit sourceIU = (IInstallableUnit) it.next();
- Collector destinationCollector = destinationRepo.query(new InstallableUnitQuery(sourceIU), new Collector(), null);
- assertEquals(message, 1, destinationCollector.size());
+ IQueryResult destinationCollector = destinationRepo.query(new InstallableUnitQuery(sourceIU), null);
+ assertEquals(message, 1, queryResultSize(destinationCollector));
assertEquals(message, sourceIU, (IInstallableUnit) destinationCollector.iterator().next());
}
}
@@ -1184,6 +1227,61 @@ public abstract class AbstractProvisioningTest extends TestCase {
assertContains(message, repo2, repo1);
}
+ public static void assertContains(String message, IQueryable source, IQueryable destination) {
+ IQueryResult sourceCollector = source.query(InstallableUnitQuery.ANY, null);
+ Iterator it = sourceCollector.iterator();
+
+ while (it.hasNext()) {
+ IInstallableUnit sourceIU = (IInstallableUnit) it.next();
+ IQueryResult destinationCollector = destination.query(new InstallableUnitQuery(sourceIU), null);
+ assertEquals(message, 1, queryResultSize(destinationCollector));
+ assertTrue(message, sourceIU.equals(destinationCollector.iterator().next()));
+ }
+ }
+
+ public static void assertContains(String message, IQueryResult result, IQueryResult mustHave) {
+ assertContains(message, result.iterator(), mustHave.iterator());
+ }
+
+ public static void assertContains(String message, Iterator result, Iterator mustHave) {
+ HashSet repoSet = new HashSet();
+ while (mustHave.hasNext())
+ repoSet.add(mustHave.next());
+ assertContains(message, result, repoSet);
+ }
+
+ public static void assertContains(String message, Iterator result, Collection mustHave) {
+ while (result.hasNext())
+ assertTrue(message, mustHave.contains(result.next()));
+ }
+
+ public static void assertContains(IQueryResult result, Object value) {
+ assertContains(null, result, value);
+ }
+
+ public static void assertNotContains(IQueryResult result, Object value) {
+ assertNotContains(null, result, value);
+ }
+
+ public static void assertContains(String message, IQueryResult result, Object value) {
+ Iterator itor = result.iterator();
+ while (itor.hasNext())
+ if (itor.next().equals(value))
+ return;
+ fail(message);
+ }
+
+ public static void assertNotContains(String message, IQueryResult result, Object value) {
+ Iterator itor = result.iterator();
+ while (itor.hasNext())
+ if (itor.next().equals(value))
+ fail(message);
+ }
+
+ public static void assertContains(String message, Collection fromIUs, Iterator fromRepo) {
+ assertContains(message, fromIUs.iterator(), fromRepo);
+ }
+
/*
* Return a boolean value indicating whether or not the given installable units
* are considered to be equal.
@@ -1327,4 +1425,76 @@ public abstract class AbstractProvisioningTest extends TestCase {
fail();
}
}
+
+ protected int getArtifactKeyCount(URI location) {
+ try {
+ return getArtifactKeyCount(getArtifactRepositoryManager().loadRepository(location, null));
+ } catch (ProvisionException e) {
+ fail("Failed to load repository " + URIUtil.toUnencodedString(location) + " for ArtifactDescriptor count");
+ return -1;
+ }
+ }
+
+ protected int getArtifactKeyCount(IArtifactRepository repo) {
+ return queryResultSize(repo.query(ArtifactKeyQuery.ALL_KEYS, null));
+ }
+
+ protected int getArtifactDescriptorCount(URI location) {
+ int count = 0;
+ try {
+ IArtifactRepository repo = getArtifactRepositoryManager().loadRepository(location, null);
+ IQueryResult descriptors = repo.descriptorQueryable().query(ArtifactDescriptorQuery.ALL_DESCRIPTORS, null);
+ return queryResultSize(descriptors);
+ } catch (ProvisionException e) {
+ fail("Failed to load repository " + URIUtil.toUnencodedString(location) + " for ArtifactDescriptor count");
+ }
+ return count;
+ }
+
+ public int countPlanElements(IProvisioningPlan plan) {
+ return queryResultSize(new CompoundQueryable(plan.getAdditions(), plan.getRemovals()).query(InstallableUnitQuery.ANY, null));
+ }
+
+ /**
+ * This method is used by tests that require access to the "self" profile. It spoofs
+ * up a fake self profile is none is already available. Tests should invoke this method
+ * from their {@link #setUp()} method, and invoke {@link #tearDownSelfProfile()}
+ * from their {@link #tearDown()} method.
+ */
+ protected void setUpSelfProfile() {
+ if (System.getProperty("eclipse.p2.profile") == null) {
+ SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) getProfileRegistry();
+ try {
+ Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$
+ selfField.setAccessible(true);
+ previousSelfValue = selfField.get(profileRegistry);
+ if (previousSelfValue == null)
+ selfField.set(profileRegistry, "agent");
+ } catch (Throwable t) {
+ fail();
+ }
+ }
+ createProfile("agent");
+ }
+
+ /**
+ * This method is used by tests that require access to the "self" profile. It cleans up
+ * a fake self profile is none is already available. Tests should invoke this method
+ * from their {@link #tearDown()} method, and invoke {@link #setUpSelfProfile()}
+ * from their {@link #setUp()} method.
+ */
+ protected void tearDownSelfProfile() {
+ if (System.getProperty("eclipse.p2.profile") == null) {
+ SimpleProfileRegistry profileRegistry = (SimpleProfileRegistry) getProfileRegistry();
+ try {
+ Field selfField = SimpleProfileRegistry.class.getDeclaredField("self"); //$NON-NLS-1$
+ selfField.setAccessible(true);
+ Object self = selfField.get(profileRegistry);
+ if (self.equals("agent"))
+ selfField.set(profileRegistry, previousSelfValue);
+ } catch (Throwable t) {
+ // ignore as we still want to continue tidying up
+ }
+ }
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractWrappedArtifactRepository.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractWrappedArtifactRepository.java
index 81beb03d8..0343fb74b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractWrappedArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractWrappedArtifactRepository.java
@@ -15,9 +15,10 @@ import java.net.URI;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.repository.artifact.*;
public class AbstractWrappedArtifactRepository implements IArtifactRepository {
@@ -51,10 +52,6 @@ public class AbstractWrappedArtifactRepository implements IArtifactRepository {
return delegate.getArtifactDescriptors(key);
}
- public IArtifactKey[] getArtifactKeys() {
- return delegate.getArtifactKeys();
- }
-
public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) {
return delegate.getArtifacts(requests, monitor);
}
@@ -130,4 +127,16 @@ public class AbstractWrappedArtifactRepository implements IArtifactRepository {
public Object getAdapter(Class adapter) {
return delegate.getAdapter(adapter);
}
+
+ public IArtifactDescriptor createArtifactDescriptor(IArtifactKey key) {
+ return delegate.createArtifactDescriptor(key);
+ }
+
+ public IQueryable<IArtifactDescriptor> descriptorQueryable() {
+ return delegate.descriptorQueryable();
+ }
+
+ public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) {
+ return delegate.query(query, monitor);
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java
index 513bbeaa1..da38e98f9 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AutomatedTests.java
@@ -35,11 +35,13 @@ public class AutomatedTests extends TestCase {
suite.addTest(org.eclipse.equinox.p2.tests.installer.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.jarprocessor.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.metadata.AllTests.suite());
+ suite.addTest(org.eclipse.equinox.p2.tests.metadata.expression.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.metadata.repository.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.mirror.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.omniVersion.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.planner.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.publisher.AllTests.suite());
+ suite.addTest(org.eclipse.equinox.p2.tests.ql.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.repository.AllTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.simpleconfigurator.SimpleConfiguratorTests.suite());
suite.addTest(org.eclipse.equinox.p2.tests.simpleconfigurator.manipulator.AllTests.suite());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/FailingMetadataRepositoryFactory.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/FailingMetadataRepositoryFactory.java
index 5126261be..6eb7adacb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/FailingMetadataRepositoryFactory.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/FailingMetadataRepositoryFactory.java
@@ -13,9 +13,9 @@ package org.eclipse.equinox.p2.tests;
import java.net.URI;
import java.util.Map;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.MetadataRepositoryFactory;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory;
/**
* A repository factory that always throws exceptions. The "fail" flag must be set to
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java
deleted file mode 100644
index f0efa0f3c..000000000
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/IUPropertyUtils.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008-2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * EclipseSource - ongoing development
- *******************************************************************************/
-package org.eclipse.equinox.p2.tests;
-
-import java.lang.ref.SoftReference;
-import java.util.*;
-import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
-
-public class IUPropertyUtils {
-
- IQueryable queryable;
-
- /**
- *
- */
- public IUPropertyUtils(IQueryable queryable) {
- this.queryable = queryable;
- }
-
- // TODO: these constants should come from API, eg. IInstallableUnit or ???
- final Locale DEFAULT_LOCALE = new Locale("df", "LT"); //$NON-NLS-1$//$NON-NLS-2$
- final String NAMESPACE_IU_LOCALIZATION = "org.eclipse.equinox.p2.localization"; //$NON-NLS-1$
-
- // Cache the IU fragments that provide localizations for a given locale.
- // map: locale => soft reference to a collector
- private Map LocaleCollectorCache = new HashMap(2);
-
- // Get the license in the default locale.
- public ILicense getLicense(IInstallableUnit iu) {
- return getLicense(iu, getCurrentLocale());
- }
-
- // Get the copyright in the default locale.
- public ICopyright getCopyright(IInstallableUnit iu) {
- return getCopyright(iu, getCurrentLocale());
- }
-
- // Get a property in the default locale
- public String getIUProperty(IInstallableUnit iu, String propertyKey) {
- return getIUProperty(iu, propertyKey, getCurrentLocale());
- }
-
- public ILicense getLicense(IInstallableUnit iu, Locale locale) {
- ILicense license = iu.getLicense();
- String body = (license != null ? license.getBody() : null);
- if (body == null || body.length() <= 1 || body.charAt(0) != '%')
- return license;
- final String actualKey = body.substring(1); // Strip off the %
- body = getLocalizedIUProperty(iu, actualKey, locale);
- return MetadataFactory.createLicense(license.getLocation(), body);
- }
-
- public ICopyright getCopyright(IInstallableUnit iu, Locale locale) {
- ICopyright copyright = iu.getCopyright();
- String body = (copyright != null ? copyright.getBody() : null);
- if (body == null || body.length() <= 1 || body.charAt(0) != '%')
- return copyright;
- final String actualKey = body.substring(1); // Strip off the %
- body = getLocalizedIUProperty(iu, actualKey, locale);
- return MetadataFactory.createCopyright(copyright.getLocation(), body);
- }
-
- public String getIUProperty(IInstallableUnit iu, String propertyKey, Locale locale) {
- String value = iu.getProperty(propertyKey);
- if (value == null || value.length() <= 1 || value.charAt(0) != '%')
- return value;
- // else have a localizable property
- final String actualKey = value.substring(1); // Strip off the %
- return getLocalizedIUProperty(iu, actualKey, locale);
- }
-
- private String getLocalizedIUProperty(IInstallableUnit iu, String actualKey, Locale locale) {
- String localizedKey = makeLocalizedKey(actualKey, locale.toString());
- String localizedValue = null;
-
- //first check for a cached localized value
- if (iu instanceof InstallableUnit)
- localizedValue = ((InstallableUnit) iu).getLocalizedProperty(localizedKey);
- //next check if the localized value is stored in the same IU (common case)
- if (localizedValue == null)
- localizedValue = iu.getProperty(localizedKey);
- if (localizedValue != null)
- return localizedValue;
-
- final List locales = buildLocaleVariants(locale);
- final IInstallableUnit theUnit = iu;
-
- Collector localizationFragments = getLocalizationFragments(locale, locales);
-
- Collector hostLocalizationCollector = new Collector() {
- public boolean accept(Object object) {
- boolean haveHost = false;
- if (object instanceof IInstallableUnitFragment) {
- IInstallableUnitFragment fragment = (IInstallableUnitFragment) object;
- IRequiredCapability[] hosts = fragment.getHost();
- for (int i = 0; i < hosts.length; i++) {
- IRequiredCapability nextHost = hosts[i];
- if (IInstallableUnit.NAMESPACE_IU_ID.equals(nextHost.getNamespace()) && //
- theUnit.getId().equals(nextHost.getName()) && //
- nextHost.getRange() != null && //
- nextHost.getRange().isIncluded(theUnit.getVersion())) {
- haveHost = true;
- break;
- }
- }
- }
- return (haveHost ? super.accept(object) : true);
- }
- };
-
- IUPropertyQuery iuQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_FRAGMENT, "true"); //$NON-NLS-1$
- Collector collected = iuQuery.perform(localizationFragments.iterator(), hostLocalizationCollector);
-
- if (!collected.isEmpty()) {
- String translation = null;
- for (Iterator iter = collected.iterator(); iter.hasNext() && translation == null;) {
- IInstallableUnit localizationIU = (IInstallableUnit) iter.next();
- for (Iterator jter = locales.iterator(); jter.hasNext();) {
- String localeKey = makeLocalizedKey(actualKey, (String) jter.next());
- translation = localizationIU.getProperty(localeKey);
- if (translation != null)
- return cacheResult(iu, localizedKey, translation);
- }
- }
- }
-
- for (Iterator iter = locales.iterator(); iter.hasNext();) {
- String nextLocale = (String) iter.next();
- String localeKey = makeLocalizedKey(actualKey, nextLocale);
- String nextValue = iu.getProperty(localeKey);
- if (nextValue != null)
- return cacheResult(iu, localizedKey, nextValue);
- }
-
- return cacheResult(iu, localizedKey, actualKey);
- }
-
- /**
- * Cache the translated property value to optimize future retrieval of the same value.
- * Currently we just cache on the installable unit object in memory. In future
- * we should push support for localized property retrieval into IInstallableUnit
- * so we aren't required to reach around the API here.
- */
- private String cacheResult(IInstallableUnit iu, String localizedKey, String localizedValue) {
- if (iu instanceof InstallableUnit)
- ((InstallableUnit) iu).setLocalizedProperty(localizedKey, localizedValue);
- return localizedValue;
- }
-
- /**
- * Collects the installable unit fragments that contain locale data for the given locales.
- */
- private synchronized Collector getLocalizationFragments(Locale locale, List localeVariants) {
- SoftReference collectorRef = (SoftReference) LocaleCollectorCache.get(locale);
- if (collectorRef != null) {
- Collector cached = (Collector) collectorRef.get();
- if (cached != null)
- return cached;
- }
-
- final List locales = localeVariants;
-
- Collector localeFragmentCollector = new Collector() {
- public boolean accept(Object object) {
- boolean haveLocale = false;
- if (object instanceof IInstallableUnitFragment) {
- IInstallableUnitFragment fragment = (IInstallableUnitFragment) object;
- IProvidedCapability[] provides = fragment.getProvidedCapabilities();
- for (int j = 0; j < provides.length && !haveLocale; j++) {
- IProvidedCapability nextProvide = provides[j];
- if (NAMESPACE_IU_LOCALIZATION.equals(nextProvide.getNamespace())) {
- String providedLocale = nextProvide.getName();
- if (providedLocale != null) {
- for (Iterator iter = locales.iterator(); iter.hasNext();) {
- if (providedLocale.equals(iter.next())) {
- haveLocale = true;
- break;
- }
- }
- }
- }
- }
- }
- return (haveLocale ? super.accept(object) : true);
- }
- };
-
- IUPropertyQuery iuQuery = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_FRAGMENT, "true"); //$NON-NLS-1$
- Collector collected = queryable.query(iuQuery, localeFragmentCollector, null);
- LocaleCollectorCache.put(locale, new SoftReference(collected));
- return collected;
- }
-
- /**
- */
- private List buildLocaleVariants(Locale locale) {
- String nl = locale.toString();
- ArrayList result = new ArrayList(4);
- int lastSeparator;
- while (true) {
- result.add(nl);
- lastSeparator = nl.lastIndexOf('_');
- if (lastSeparator == -1)
- break;
- nl = nl.substring(0, lastSeparator);
- }
- // Add the default locale (most general)
- result.add(DEFAULT_LOCALE.toString());
- return result;
- }
-
- private String makeLocalizedKey(String actualKey, String localeImage) {
- return localeImage + '.' + actualKey;
- }
-
- private Locale getCurrentLocale() {
- return Locale.getDefault();
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/MockQueryable.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/MockQueryable.java
index 1f09bab10..dfe6b5d6f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/MockQueryable.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/MockQueryable.java
@@ -13,7 +13,7 @@ package org.eclipse.equinox.p2.tests;
import java.util.ArrayList;
import java.util.Collection;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
+import org.eclipse.equinox.p2.query.*;
/**
* A test queryable that contains a simple collection of objects.
@@ -35,8 +35,8 @@ public class MockQueryable implements IQueryable {
}
- public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
- return query.perform(items.iterator(), collector);
+ public IQueryResult query(IQuery query, IProgressMonitor monitor) {
+ return query.perform(items.iterator());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java
index 7c51861c8..310fa1b57 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestActivator.java
@@ -44,9 +44,9 @@ public class TestActivator implements BundleActivator {
packageAdmin = (PackageAdmin) context.getService(packageAdminRef);
//This is a hack because the junit plugin launch config do not allow to start bundles
- getBundle("org.eclipse.equinox.p2.exemplarysetup").start();
- getBundle("org.eclipse.equinox.frameworkadmin.equinox").start();
- getBundle("org.eclipse.equinox.simpleconfigurator.manipulator").start();
+ AbstractProvisioningTest.startBundle(getBundle("org.eclipse.equinox.p2.exemplarysetup"));
+ AbstractProvisioningTest.startBundle(getBundle("org.eclipse.equinox.frameworkadmin.equinox"));
+ AbstractProvisioningTest.startBundle(getBundle("org.eclipse.equinox.simpleconfigurator.manipulator"));
}
public void stop(BundleContext context) throws Exception {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java
index 6ec898f2a..aa3d7f5a1 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestArtifactRepository.java
@@ -20,12 +20,14 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.artifact.repository.ArtifactRequest;
import org.eclipse.equinox.internal.p2.repository.Transport;
import org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryCreationException;
-import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.AbstractArtifactRepository;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest;
+import org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
/**
* A simple artifact repository implementation used for testing purposes.
@@ -107,10 +109,6 @@ public class TestArtifactRepository extends AbstractArtifactRepository {
return keysToLocations.get(key);
}
- public IArtifactKey[] getArtifactKeys() {
- return keysToLocations.keySet().toArray(new IArtifactKey[keysToLocations.keySet().size()]);
- }
-
private IStatus getArtifact(ArtifactRequest request, IProgressMonitor monitor) {
request.setSourceRepository(this);
request.perform(monitor);
@@ -130,7 +128,7 @@ public class TestArtifactRepository extends AbstractArtifactRepository {
}
}
- public void initialize(URI repoURL, InputStream descriptorFile) throws RepositoryCreationException {
+ public void initialize(URI repoURL, InputStream descriptorFile) {
location = repoURL;
}
@@ -194,4 +192,14 @@ public class TestArtifactRepository extends AbstractArtifactRepository {
public OutputStream getOutputStream(IArtifactDescriptor descriptor) {
throw new UnsupportedOperationException("Method is not implemented by this repository");
}
+
+ public IQueryable<IArtifactDescriptor> descriptorQueryable() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java
index 8cc075fbb..05130d887 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/TestMetadataRepository.java
@@ -10,19 +10,21 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import junit.framework.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.AbstractMetadataRepository;
-import org.eclipse.equinox.internal.provisional.spi.p2.metadata.repository.RepositoryReference;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.spi.AbstractMetadataRepository;
+import org.eclipse.equinox.p2.repository.spi.RepositoryReference;
/**
* A simple metadata repository used for testing purposes. All metadata
@@ -58,7 +60,7 @@ public class TestMetadataRepository extends AbstractMetadataRepository {
}
public IInstallableUnit find(String id, String versionString) {
- Iterator result = query(new InstallableUnitQuery(id, new Version(versionString)), new Collector(), null).iterator();
+ Iterator result = query(new InstallableUnitQuery(id, Version.create(versionString)), null).iterator();
return (IInstallableUnit) (result.hasNext() ? result.next() : null);
}
@@ -69,8 +71,8 @@ public class TestMetadataRepository extends AbstractMetadataRepository {
return null;
}
- public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
- return query.perform(units.iterator(), collector);
+ public IQueryResult query(IQuery query, IProgressMonitor monitor) {
+ return query.perform(units.iterator());
}
public void removeAll() {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java
index 0127f5869..759155a62 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/CompositeRepositoryTaskTest.java
@@ -18,12 +18,12 @@ import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.artifact.repository.CompositeArtifactRepository;
import org.eclipse.equinox.internal.p2.metadata.repository.CompositeMetadataRepository;
import org.eclipse.equinox.internal.p2.repository.helpers.RepositoryHelper;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.repository.ICompositeRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.repository.ICompositeRepository;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractAntProvisioningTest;
public class CompositeRepositoryTaskTest extends AbstractAntProvisioningTest {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/MirrorTaskTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/MirrorTaskTest.java
index e01bb1e31..23af9407f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/MirrorTaskTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/MirrorTaskTest.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.ant;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.*;
import java.net.URI;
@@ -21,13 +21,15 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.artifact.processors.md5.Messages;
import org.eclipse.equinox.internal.p2.director.PermissiveSlicer;
import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.internal.repository.comparator.MD5ArtifactComparator;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractAntProvisioningTest;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
@@ -301,7 +303,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
AntTaskElement mirror = createMirrorTask(TYPE_METADATA);
@@ -315,7 +317,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
p.setProperty("org.eclipse.update.install.features", String.valueOf(true));
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, true, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
try {
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
@@ -331,7 +333,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
AntTaskElement mirror = createMirrorTask(TYPE_METADATA);
@@ -344,7 +346,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
PermissiveSlicer slicer = new PermissiveSlicer(repo, new Properties(), true, false, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
try {
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
} catch (ProvisionException e) {
@@ -359,7 +361,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
AntTaskElement mirror = createMirrorTask(TYPE_METADATA);
@@ -373,7 +375,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
p.setProperty("org.eclipse.update.install.features", String.valueOf(true));
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, false, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
try {
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
} catch (ProvisionException e) {
@@ -388,7 +390,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
AntTaskElement mirror = createMirrorTask(TYPE_METADATA);
@@ -401,7 +403,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
Properties p = getSliceProperties();
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
try {
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
} catch (ProvisionException e) {
@@ -419,7 +421,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
AntTaskElement mirror = createMirrorTask(TYPE_METADATA);
@@ -433,7 +435,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
p.setProperty("org.eclipse.update.install.features", String.valueOf(true));
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
try {
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
} catch (ProvisionException e) {
@@ -451,7 +453,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
// Create task
@@ -465,7 +467,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
Properties p = getSliceProperties();
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
try {
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
} catch (ProvisionException e) {
@@ -483,7 +485,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("test.feature.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("test.feature.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
// Create task
@@ -498,10 +500,10 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of IUs", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()).size(), getIUCount(destinationRepo));
- assertEquals("Different number of ArtifactKeys", getArtifactKeyCount(result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor())), getArtifactKeyCount(destinationRepo));
+ assertEquals("Different number of IUs", queryResultSize(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getIUCount(destinationRepo));
+ assertEquals("Different number of ArtifactKeys", getArtifactKeyCount(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getArtifactKeyCount(destinationRepo));
try {
- assertArtifactKeyContentEquals("Different ArtifactKeys", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()), destinationRepo);
+ assertArtifactKeyContentEquals("Different ArtifactKeys", result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()), destinationRepo);
assertIUContentEquals("IUs differ", result, getMetadataRepositoryManager().loadRepository(destinationRepo, null));
} catch (ProvisionException e) {
fail("Failed to compare contents", e);
@@ -519,7 +521,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("test.feature.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("test.feature.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
// Create task
@@ -534,8 +536,8 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu}, new NullProgressMonitor());
- assertEquals("Different number of ArtifactKeys", getArtifactKeyCount(result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor())), getArtifactKeyCount(destinationRepo));
- assertArtifactKeyContentEquals("Different ArtifactKeys", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()), destinationRepo);
+ assertEquals("Different number of ArtifactKeys", getArtifactKeyCount(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getArtifactKeyCount(destinationRepo));
+ assertArtifactKeyContentEquals("Different ArtifactKeys", result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()), destinationRepo);
}
/*
@@ -548,10 +550,10 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("test.feature.feature.group"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("test.feature.feature.group"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
- c = repo.query(new InstallableUnitQuery("RCP_Browser_Example.feature.group"), new Collector(), new NullProgressMonitor());
+ c = repo.query(new InstallableUnitQuery("RCP_Browser_Example.feature.group"), new NullProgressMonitor());
IInstallableUnit iu2 = (IInstallableUnit) c.iterator().next();
// Create task
@@ -567,8 +569,8 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
PermissiveSlicer slicer = new PermissiveSlicer(repo, p, true, true, true, false, false);
IQueryable result = slicer.slice(new IInstallableUnit[] {iu, iu2}, new NullProgressMonitor());
- assertEquals("Different number of ArtifactKeys", getArtifactKeyCount(result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor())), getArtifactKeyCount(destinationRepo));
- assertArtifactKeyContentEquals("Different ArtifactKeys", result.query(InstallableUnitQuery.ANY, new Collector(), new NullProgressMonitor()), destinationRepo);
+ assertEquals("Different number of ArtifactKeys", getArtifactKeyCount(result.query(InstallableUnitQuery.ANY, new NullProgressMonitor())), getArtifactKeyCount(destinationRepo));
+ assertArtifactKeyContentEquals("Different ArtifactKeys", result.query(InstallableUnitQuery.ANY, new NullProgressMonitor()), destinationRepo);
}
/*
@@ -581,7 +583,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Loading repository failed", e);
}
- Collector c = repo.query(new InstallableUnitQuery("org.eclipse.ui.examples.readmetool"), new Collector(), new NullProgressMonitor());
+ IQueryResult c = repo.query(new InstallableUnitQuery("org.eclipse.ui.examples.readmetool"), new NullProgressMonitor());
IInstallableUnit iu = (IInstallableUnit) c.iterator().next();
// Create task
@@ -623,7 +625,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
*/
public void testBaselineCompareUsingMD5Comparator() {
//Setup create descriptors with different md5 values
- IArtifactKey dupKey = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3"));
+ IArtifactKey dupKey = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3"));
File artifact1 = getTestData("0.0", "/testData/mirror/mirrorSourceRepo1 with space/content.xml");
File artifact2 = getTestData("0.0", "/testData/mirror/mirrorSourceRepo2/content.xml");
@@ -677,6 +679,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
// Create a comparator element
AntTaskElement comparator = new AntTaskElement("comparator");
+ comparator.addAttribute("comparator", MD5ArtifactComparator.MD5_COMPARATOR_ID);
comparator.addElement(getRepositoryElement(baselineLocation.toURI(), null));
mirror.addElement(comparator);
@@ -750,38 +753,10 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
/*
* Get the number of ArtifactKeys in a repository
*/
- protected int getArtifactKeyCount(URI location) {
- try {
- return getArtifactRepositoryManager().loadRepository(location, null).getArtifactKeys().length;
- } catch (ProvisionException e) {
- fail("Failed to load repository " + URIUtil.toUnencodedString(location) + " for ArtifactDescriptor count");
- return -1;
- }
- }
-
- /*
- * Get the number of ArtifactKeys in a repository
- */
- protected int getArtifactKeyCount(Collector ius) {
+ protected int getArtifactKeyCount(IQueryResult ius) {
int count = 0;
for (Iterator iter = ius.iterator(); iter.hasNext();)
- count += ((InstallableUnit) iter.next()).getArtifacts().length;
- return count;
- }
-
- /*
- * Get the number of ArtifactDescriptors in a repository
- */
- protected int getArtifactDescriptorCount(URI location) {
- int count = 0;
- try {
- IArtifactRepository repo = getArtifactRepositoryManager().loadRepository(location, null);
- IArtifactKey[] keys = repo.getArtifactKeys();
- for (int i = 0; i < keys.length; i++)
- count += repo.getArtifactDescriptors(keys[i]).length;
- } catch (ProvisionException e) {
- fail("Failed to load repository " + URIUtil.toUnencodedString(location) + " for ArtifactDescriptor count");
- }
+ count += ((InstallableUnit) iter.next()).getArtifacts().size();
return count;
}
@@ -790,7 +765,7 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
*/
protected int getIUCount(URI location) {
try {
- return getMetadataRepositoryManager().loadRepository(location, null).query(InstallableUnitQuery.ANY, new Collector(), null).size();
+ return queryResultSize(getMetadataRepositoryManager().loadRepository(location, null).query(InstallableUnitQuery.ANY, null));
} catch (ProvisionException e) {
fail("Failed to load repository " + URIUtil.toUnencodedString(location) + " for ArtifactDescriptor count");
return -1;
@@ -801,9 +776,9 @@ public class MirrorTaskTest extends AbstractAntProvisioningTest {
* Add all IUs to the parent element
*/
protected void addAllIUs(AntTaskElement parent, IMetadataRepository repo) {
- Collector collector = repo.query(InstallableUnitQuery.ANY, new Collector(), null);
+ IQueryResult queryResult = repo.query(InstallableUnitQuery.ANY, null);
- for (Iterator iter = collector.iterator(); iter.hasNext();) {
+ for (Iterator iter = queryResult.iterator(); iter.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iter.next();
parent.addElement(createIUElement(iu));
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java
index 93a0a334f..1fb74ff9b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/Repo2RunnableTaskTests.java
@@ -12,16 +12,15 @@ package org.eclipse.equinox.p2.tests.ant;
import java.io.File;
import java.net.URI;
-import java.util.Collection;
+import java.util.Iterator;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.tests.AbstractAntProvisioningTest;
public class Repo2RunnableTaskTests extends AbstractAntProvisioningTest {
@@ -61,8 +60,8 @@ public class Repo2RunnableTaskTests extends AbstractAntProvisioningTest {
IInstallableUnit iu = null;
try {
IMetadataRepository repo = getMetadataRepositoryManager().loadRepository(source, new NullProgressMonitor());
- Collection ius = repo.query(new InstallableUnitQuery("helloworldfeature.feature.jar"), new Collector(), new NullProgressMonitor()).toCollection();
- assertEquals("Expected number of IUs", 1, ius.size());
+ IQueryResult ius = repo.query(new InstallableUnitQuery("helloworldfeature.feature.jar"), new NullProgressMonitor());
+ assertEquals("Expected number of IUs", 1, queryResultSize(ius));
iu = (IInstallableUnit) ius.iterator().next();
} catch (ProvisionException e) {
fail("Failed to obtain iu", e);
@@ -71,7 +70,7 @@ public class Repo2RunnableTaskTests extends AbstractAntProvisioningTest {
task.addElement(createIUElement(iu));
runAntTask();
- assertEquals("Number of artifact keys differs", iu.getArtifacts().length, getArtifactKeyCount(destination));
+ assertEquals("Number of artifact keys differs", iu.getArtifacts().size(), getArtifactKeyCount(destination));
assertTrue("Unexpected format", expectedFormat(destination));
}
@@ -117,9 +116,9 @@ public class Repo2RunnableTaskTests extends AbstractAntProvisioningTest {
} catch (ProvisionException e) {
fail("Failed to load repository", e);
}
- IArtifactKey[] keys = repo.getArtifactKeys();
- for (int i = 0; i < keys.length; i++) {
- IArtifactKey key = keys[i];
+ IQueryResult keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null);
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
+ IArtifactKey key = (IArtifactKey) iterator.next();
IArtifactDescriptor[] descriptors = repo.getArtifactDescriptors(key);
for (int n = 0; n < descriptors.length; n++) {
IArtifactDescriptor desc = descriptors[n];
@@ -130,25 +129,13 @@ public class Repo2RunnableTaskTests extends AbstractAntProvisioningTest {
else
assertFalse(desc + " is a folder", isFolder);
// Artifacts should not be packed
- assertTrue("Artifact is still packed", !"packed".equals(desc.getProperty("format")));
+ assertTrue("Artifact is still packed", !IArtifactDescriptor.FORMAT_PACKED.equals(desc.getProperty(IArtifactDescriptor.FORMAT)));
}
}
return true;
}
/*
- * Count the number of ArtifactKeys in the repository at the given location
- */
- protected int getArtifactKeyCount(URI location) {
- try {
- return getArtifactRepositoryManager().loadRepository(location, new NullProgressMonitor()).getArtifactKeys().length;
- } catch (ProvisionException e) {
- fail("Failed to count keys in repository", e);
- return -1;
- }
- }
-
- /*
* Create a simple AntTaskElement for the Repo2RunnableTask
*/
protected AntTaskElement createRepo2RunnableTaskElement() {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/RepoTasksTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/RepoTasksTests.java
index 9c274bab6..037c23683 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/RepoTasksTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ant/RepoTasksTests.java
@@ -12,10 +12,11 @@ package org.eclipse.equinox.p2.tests.ant;
import java.io.File;
import java.net.URI;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.ArtifactKeyQuery;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.tests.AbstractAntProvisioningTest;
public class RepoTasksTests extends AbstractAntProvisioningTest {
@@ -63,10 +64,8 @@ public class RepoTasksTests extends AbstractAntProvisioningTest {
assertNull(iu);
IArtifactRepository artifacts = getArtifactRepositoryManager().loadRepository(destinationRepo, null);
- IArtifactKey[] keys = artifacts.getArtifactKeys();
- for (int i = 0; i < keys.length; i++) {
- assertFalse(keys[i].getId().equals("anotherplugin"));
- }
+ IQueryResult keys = artifacts.query(new ArtifactKeyQuery(null, "anotherplugin", null), null);
+ assertTrue(keys.isEmpty());
assertFalse(new File(getTestFolder(getName()), "plugins/anotherplugin_1.0.0.jar").exists());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java
index 3a65650b1..a0ab65372 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/processors/ArtifactRepositoryMock.java
@@ -14,8 +14,8 @@ import java.io.*;
import java.lang.reflect.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.tests.TestActivator;
/**
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java
index 141681015..2c431c266 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactOutputStreamTest.java
@@ -11,7 +11,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.*;
import junit.framework.TestCase;
@@ -19,11 +19,11 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository;
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.ArtifactOutputStream;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.ArtifactDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
import org.eclipse.equinox.internal.provisional.p2.repository.IStateful;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class ArtifactOutputStreamTest extends TestCase {
@@ -44,7 +44,7 @@ public class ArtifactOutputStreamTest extends TestCase {
tempWritableLocation.mkdirs();
sar = new SimpleArtifactRepository("name", tempWritableLocation.toURI(), null);
destination = new Destination();
- ak = new ArtifactKey("classifier", "id", new Version("1.0"));
+ ak = new ArtifactKey("classifier", "id", Version.create("1.0"));
ad = new ArtifactDescriptor(ak);
temp = File.createTempFile("ArtifactOutputStreamTest", ".tmp");
temp.deleteOnExit();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java
index 2db20ca3c..5493af202 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryManagerTest.java
@@ -19,11 +19,15 @@ import junit.framework.TestSuite;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.preferences.IPreferencesService;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.repository.*;
+import org.eclipse.equinox.internal.provisional.p2.repository.RepositoryEvent;
+import org.eclipse.equinox.p2.core.IAgentLocation;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.tests.*;
+import org.eclipse.equinox.security.storage.EncodingUtils;
import org.osgi.framework.BundleException;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
@@ -60,7 +64,7 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest {
protected void setUp() throws Exception {
super.setUp();
- manager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.context, IArtifactRepositoryManager.class.getName());
+ manager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.context, IArtifactRepositoryManager.SERVICE_NAME);
}
/**
@@ -109,7 +113,9 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest {
//bash the repository preference file (don't try this at home, kids)
final String REPO_BUNDLE = "org.eclipse.equinox.p2.artifact.repository";
IPreferencesService prefService = (IPreferencesService) ServiceHelper.getService(TestActivator.getContext(), IPreferencesService.class.getName());
- Preferences prefs = prefService.getRootNode().node("/profile/_SELF_/" + REPO_BUNDLE + "/repositories"); //$NON-NLS-1$ //$NON-NLS-2$
+ IAgentLocation agentLocation = (IAgentLocation) getAgent().getService(IAgentLocation.SERVICE_NAME);
+ String locationString = EncodingUtils.encodeSlashes(agentLocation.getRootLocation().toString());
+ Preferences prefs = prefService.getRootNode().node("/profile/" + locationString + "_SELF_/" + REPO_BUNDLE + "/repositories"); //$NON-NLS-1$ //$NON-NLS-2$
try {
String[] children = prefs.childrenNames();
for (int i = 0; i < children.length; i++)
@@ -121,14 +127,13 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest {
//stop and restart the artifact repository bundle (kids, if I ever catch you doing this I'm taking PackageAdmin away)
try {
- TestActivator.getBundle(REPO_BUNDLE).stop();
- TestActivator.getBundle(REPO_BUNDLE).start();
+ restartBundle(TestActivator.getBundle(REPO_BUNDLE));
} catch (BundleException e) {
fail("1.99", e);
}
//everybody's happy again
- manager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.context, IArtifactRepositoryManager.class.getName());
+ manager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.context, IArtifactRepositoryManager.SERVICE_NAME);
assertTrue("1.0", manager.contains(location));
}
@@ -157,12 +162,7 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest {
public void testPathWithSpaces() {
File site = getTestData("Repository", "/testData/artifactRepo/simple with spaces/");
URI location = site.toURI();
- try {
- IArtifactRepository repository = manager.loadRepository(location, getMonitor());
- assertEquals("1.0", 2, repository.getArtifactKeys().length);
- } catch (ProvisionException e) {
- fail("=.99", e);
- }
+ assertEquals("1.0", 2, getArtifactKeyCount(location));
}
/**
@@ -217,12 +217,7 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest {
public void testUpdateSitePathWithSpaces() {
File site = getTestData("Repository", "/testData/updatesite/site with spaces/");
URI location = site.toURI();
- try {
- IArtifactRepository repository = manager.loadRepository(location, getMonitor());
- assertEquals("1.0", 3, repository.getArtifactKeys().length);
- } catch (ProvisionException e) {
- fail("=.99", e);
- }
+ assertEquals("1.0", 3, getArtifactKeyCount(location));
}
/**
@@ -280,13 +275,8 @@ public class ArtifactRepositoryManagerTest extends AbstractProvisioningTest {
* Tests parsing a repository with a duplicate element. See bug 255401.
*/
public void testDuplicateElement() {
- try {
- File duplicateElementXML = getTestData("testDuplicateElement", "testData/artifactRepo/duplicateElement");
- IArtifactRepository repo = getArtifactRepositoryManager().loadRepository(duplicateElementXML.toURI(), null);
- assertEquals("Ensure correct number of artifact keys exist", 2, repo.getArtifactKeys().length);
- } catch (ProvisionException e) {
- fail("Error occured while loading repository with duplicate elements", e);
- }
+ File duplicateElementXML = getTestData("testDuplicateElement", "testData/artifactRepo/duplicateElement");
+ assertEquals("Ensure correct number of artifact keys exist", 2, getArtifactKeyCount(duplicateElementXML.toURI()));
}
public void testEnablement() {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java
index 14254436a..55a3045af 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryMissingSizeData.java
@@ -10,21 +10,23 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.director.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.phases.Sizing;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.internal.p2.engine.Phase;
+import org.eclipse.equinox.internal.p2.engine.PhaseSet;
+import org.eclipse.equinox.internal.p2.engine.phases.Sizing;
+import org.eclipse.equinox.internal.provisional.p2.director.PlannerHelper;
+import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
@@ -40,8 +42,8 @@ public class ArtifactRepositoryMissingSizeData extends AbstractProvisioningTest
IMetadataRepositoryManager mmgr = getMetadataRepositoryManager();
metaRepo = mmgr.loadRepository((getTestData("MissingArtifact repo", testDataLocation).toURI()), null);
- missingArtifactIU = (IInstallableUnit) metaRepo.query(new InstallableUnitQuery("javax.wsdl", new VersionRange("[1.5, 1.6)")), new Collector(), null).iterator().next();
- missingSizeIU = (IInstallableUnit) metaRepo.query(new InstallableUnitQuery("javax.wsdl", new VersionRange("[1.4, 1.5)")), new Collector(), null).iterator().next();
+ missingArtifactIU = (IInstallableUnit) metaRepo.query(new InstallableUnitQuery("javax.wsdl", new VersionRange("[1.5, 1.6)")), null).iterator().next();
+ missingSizeIU = (IInstallableUnit) metaRepo.query(new InstallableUnitQuery("javax.wsdl", new VersionRange("[1.4, 1.5)")), null).iterator().next();
IArtifactRepositoryManager mgr = getArtifactRepositoryManager();
source = mgr.loadRepository((getTestData("MissingArtifact repo", testDataLocation).toURI()), null);
@@ -55,13 +57,13 @@ public class ArtifactRepositoryMissingSizeData extends AbstractProvisioningTest
req.addInstallableUnits(new IInstallableUnit[] {missingArtifactIU});
req.setInstallableUnitInclusionRules(missingArtifactIU, PlannerHelper.createStrictInclusionRule(missingArtifactIU));
- ProvisioningPlan plan = createPlanner().getProvisioningPlan(req, null, null);
+ IProvisioningPlan plan = createPlanner().getProvisioningPlan(req, null, null);
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
Sizing sizing = new Sizing(100, "");
PhaseSet set = new SPhaseSet(sizing);
- IStatus status = engine.perform(profile1, set, plan.getOperands(), null, new NullProgressMonitor());
+ IStatus status = engine.perform(plan, set, new NullProgressMonitor());
if (!status.matches(IStatus.ERROR)) {
fail("Incorrect status for missing artifact during Sizing.");
}
@@ -73,13 +75,13 @@ public class ArtifactRepositoryMissingSizeData extends AbstractProvisioningTest
req.addInstallableUnits(new IInstallableUnit[] {missingSizeIU});
req.setInstallableUnitInclusionRules(missingSizeIU, PlannerHelper.createStrictInclusionRule(missingSizeIU));
- ProvisioningPlan plan = createPlanner().getProvisioningPlan(req, null, null);
+ IProvisioningPlan plan = createPlanner().getProvisioningPlan(req, null, null);
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
Sizing sizing = new Sizing(100, "");
PhaseSet set = new SPhaseSet(sizing);
- IStatus status = engine.perform(profile1, set, plan.getOperands(), null, new NullProgressMonitor());
+ IStatus status = engine.perform(plan, set, new NullProgressMonitor());
if (!status.matches(IStatus.WARNING) && status.getCode() != ProvisionException.ARTIFACT_INCOMPLETE_SIZING) {
fail("Incorrect status for missing file size during Sizing");
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java
index 99bf84bb4..59be6964a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/ArtifactRepositoryWithReferenceDescriptors.java
@@ -10,22 +10,22 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.ByteArrayOutputStream;
import java.io.File;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.ArtifactDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class ArtifactRepositoryWithReferenceDescriptors extends AbstractProvisioningTest {
IArtifactRepository repo = null;
- ArtifactDescriptor descriptor1 = null;
- ArtifactDescriptor descriptor2 = null;
+ SimpleArtifactDescriptor descriptor1 = null;
+ SimpleArtifactDescriptor descriptor2 = null;
// <artifact classifier='org.eclipse.update.feature' id='org.eclipse.datatools.sqldevtools.feature' version='1.6.0.v200805301340-7F7d-E8yz-SHrDBONwUwXwIyxYSZ'>
// <repositoryProperties size='4'>
@@ -40,14 +40,14 @@ public class ArtifactRepositoryWithReferenceDescriptors extends AbstractProvisio
super.setUp();
repo = createArtifactRepository(getTempFolder().toURI(), null);
File fileLocation = getTestData("Artifacts for repositor with references", "testData/referenceArtifactRepo/test1 Reference.jar");
- descriptor1 = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "test1Reference", new Version("1.0.0")));
- descriptor1.setProcessingSteps(new ProcessingStepDescriptor[0]);
+ descriptor1 = new SimpleArtifactDescriptor(new ArtifactKey("osgi.bundle", "test1Reference", Version.create("1.0.0")));
+ descriptor1.setProcessingSteps(new IProcessingStepDescriptor[0]);
descriptor1.setRepositoryProperty("artifact.reference", fileLocation.toURL().toExternalForm());
descriptor1.setRepositoryProperty("file.name", fileLocation.getAbsolutePath());
descriptor1.setRepositoryProperty("file.lastModified", Long.toString(fileLocation.lastModified()));
- descriptor2 = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "test1Reference", new Version("1.0.0")));
- descriptor2.setProcessingSteps(new ProcessingStepDescriptor[0]);
+ descriptor2 = new SimpleArtifactDescriptor(new ArtifactKey("osgi.bundle", "test1Reference", Version.create("1.0.0")));
+ descriptor2.setProcessingSteps(new IProcessingStepDescriptor[0]);
descriptor2.setRepositoryProperty("artifact.reference", fileLocation.toURI().toString());
descriptor2.setRepositoryProperty("file.name", fileLocation.getAbsolutePath());
descriptor2.setRepositoryProperty("file.lastModified", Long.toString(fileLocation.lastModified()));
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug252308.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug252308.java
index 12e7ccef4..d93317b0b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug252308.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug252308.java
@@ -10,15 +10,17 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.*;
import java.lang.reflect.Method;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest;
+import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
@@ -119,10 +121,10 @@ public class Bug252308 extends AbstractProvisioningTest {
fail("failing setting up the tests", e);
}
- IArtifactDescriptor sourceDescriptor = getArtifactKeyFor(source, "osgi.bundle", "missingFromFileSystem", new Version(1, 0, 0))[0];
- ArtifactDescriptor targetDescriptor = new ArtifactDescriptor(sourceDescriptor);
+ IArtifactDescriptor sourceDescriptor = getArtifactKeyFor(source, "osgi.bundle", "missingFromFileSystem", Version.createOSGi(1, 0, 0))[0];
+ SimpleArtifactDescriptor targetDescriptor = new SimpleArtifactDescriptor(sourceDescriptor);
targetDescriptor.setRepositoryProperty("artifact.folder", "true");
- MirrorRequest request = new MirrorRequest(new ArtifactKey("osgi.bundle", "missingFromFileSystem", new Version(1, 0, 0)), target, null, null);
+ MirrorRequest request = new MirrorRequest(new ArtifactKey("osgi.bundle", "missingFromFileSystem", Version.createOSGi(1, 0, 0)), target, null, null);
request.setSourceRepository(source);
IStatus s = transferSingle(request, targetDescriptor, sourceDescriptor, new NullProgressMonitor());
assertTrue(s.toString(), s.getException().getClass() == FileNotFoundException.class);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java
index b00bcd5cd..20c87ce50 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug265577.java
@@ -14,15 +14,16 @@ import java.io.*;
import java.net.URI;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
@@ -37,7 +38,7 @@ public class Bug265577 extends AbstractProvisioningTest {
super.setUp();
profile = createProfile(Bug265577.class.getName());
- engine = (IEngine) ServiceHelper.getService(TestActivator.context, IEngine.class.getName());
+ engine = (IEngine) ServiceHelper.getService(TestActivator.context, IEngine.SERVICE_NAME);
// Load repositories
File repoLocation = getTestData("Repository location", "/testData/bug265577/zipRepo.zip");
if (repoLocation == null)
@@ -60,9 +61,9 @@ public class Bug265577 extends AbstractProvisioningTest {
// Tests the response to a feature folder inside a jar
public void testZippedRepoWithFolderFeature() {
- Collector collector = metadataRepo.query(new InstallableUnitQuery("Field_Assist_Example.feature.jar"), new Collector(), null);
- IInstallableUnit[] ius = (IInstallableUnit[]) collector.toArray(IInstallableUnit.class);
- IArtifactKey key = (ius[0].getArtifacts())[0];
+ IQueryResult queryResult = metadataRepo.query(new InstallableUnitQuery("Field_Assist_Example.feature.jar"), null);
+ IInstallableUnit[] ius = (IInstallableUnit[]) queryResult.toArray(IInstallableUnit.class);
+ IArtifactKey key = (ius[0].getArtifacts()).iterator().next();
IArtifactDescriptor[] descriptors = artifactRepo.getArtifactDescriptors(key);
ArtifactDescriptor desc = (ArtifactDescriptor) descriptors[0];
@@ -84,9 +85,9 @@ public class Bug265577 extends AbstractProvisioningTest {
// Test to retrieve a file from a zipped metadata & artifact repository
public void testZippedRepo() {
- Collector collector = metadataRepo.query(new InstallableUnitQuery("valid.feature.jar"), new Collector(), null);
- IInstallableUnit[] ius = (IInstallableUnit[]) collector.toArray(IInstallableUnit.class);
- IArtifactKey key = (ius[0].getArtifacts())[0];
+ IQueryResult queryResult = metadataRepo.query(new InstallableUnitQuery("valid.feature.jar"), null);
+ IInstallableUnit[] ius = (IInstallableUnit[]) queryResult.toArray(IInstallableUnit.class);
+ IArtifactKey key = (ius[0].getArtifacts()).iterator().next();
IArtifactDescriptor[] descriptors = artifactRepo.getArtifactDescriptors(key);
IArtifactDescriptor desc = descriptors[0];
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java
index bc794e3a5..762e6590a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CompositeArtifactRepositoryTest.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.*;
import java.lang.reflect.Field;
@@ -18,16 +18,19 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.artifact.processors.md5.MD5ArtifactComparator;
import org.eclipse.equinox.internal.p2.artifact.repository.*;
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
import org.eclipse.equinox.internal.p2.persistence.CompositeRepositoryState;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.internal.repository.comparator.MD5ArtifactComparator;
+import org.eclipse.equinox.p2.internal.repository.tools.ArtifactRepositoryValidator;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestArtifactRepository;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
@@ -101,7 +104,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
CompositeArtifactRepository compRepo = createRepo(false);
//Setup create a descriptor
- IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3"));
+ IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3"));
IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, null);
try {
@@ -117,7 +120,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
CompositeArtifactRepository compRepo = createRepo(false);
//Setup create a descriptor
- IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3"));
+ IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3"));
IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, null);
//Setup: create an array of descriptors
@@ -137,7 +140,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
CompositeArtifactRepository compRepo = createRepo(false);
//Setup create a descriptor
- IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3"));
+ IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3"));
IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, null);
try {
@@ -153,7 +156,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
CompositeArtifactRepository compRepo = createRepo(false);
//Setup create a key
- IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3"));
+ IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3"));
try {
compRepo.removeDescriptor(key);
@@ -307,7 +310,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
assertContains("Assert child2's content is in composite repo", repo2, compRepo);
//checks that the destination has the correct number of keys (no extras)
//FIXME will this work?
- assertEquals("Assert Correct Number of Keys", repo1.getArtifactKeys().length + repo2.getArtifactKeys().length, compRepo.getArtifactKeys().length);
+ assertEquals("Assert Correct Number of Keys", getArtifactKeyCount(repo1) + getArtifactKeyCount(repo2), getArtifactKeyCount(compRepo));
}
public void testRemoveNonexistantChild() {
@@ -361,14 +364,14 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
}
//get the keys
- IArtifactKey[] keys = repo.getArtifactKeys();
- assertTrue("Error retreaiving artifact keys", keys.length > 0);
+ IQueryResult keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null);
+ assertTrue("Error retreaiving artifact keys", !keys.isEmpty());
//test for existing key
- assertTrue("Asserting key is in composite repo", compRepo.contains(keys[0]));
+ assertTrue("Asserting key is in composite repo", compRepo.contains((IArtifactKey) keys.iterator().next()));
//Create a new key, not found in the composite repo
- IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3"));
+ IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3"));
//test for a non existing key
assertFalse("Asserting key is not in composite repo", compRepo.contains(key));
}
@@ -389,16 +392,16 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
}
//get the descriptors
- IArtifactKey[] keys = repo.getArtifactKeys();
- assertTrue("Error retreaiving artifact keys", keys.length > 0);
- IArtifactDescriptor[] descriptors = repo.getArtifactDescriptors(keys[0]);
+ IQueryResult keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null);
+ assertTrue("Error retreaiving artifact keys", !keys.isEmpty());
+ IArtifactDescriptor[] descriptors = repo.getArtifactDescriptors((IArtifactKey) keys.iterator().next());
assertTrue("Error retreaiving artifact descriptors", descriptors.length > 0);
//test for existing descriptor
assertTrue("Asserting key is in composite repo", compRepo.contains(descriptors[0]));
//Create a new descriptor, not found in the composite repo
- IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3"));
+ IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3"));
IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, null);
//test for a non existing descriptor
assertFalse("Asserting key is not in composite repo", compRepo.contains(descriptor));
@@ -420,12 +423,13 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
fail("Error creating destination", e1);
}
- IArtifactKey[] keys = compRepo.getArtifactKeys();
- assertTrue("Error retreaiving artifact keys", keys.length > 0);
- IArtifactDescriptor[] descriptors = compRepo.getArtifactDescriptors(keys[0]);
+ IQueryResult keys = compRepo.query(ArtifactKeyQuery.ALL_KEYS, null);
+ assertTrue("Error retreaiving artifact keys", !keys.isEmpty());
+ IArtifactKey key = (IArtifactKey) keys.iterator().next();
+ IArtifactDescriptor[] descriptors = compRepo.getArtifactDescriptors(key);
assertTrue("Error retreaiving artifact descriptors", descriptors.length > 0);
- IArtifactDescriptor newDescriptor = new ArtifactDescriptor(keys[0]);
+ IArtifactDescriptor newDescriptor = new ArtifactDescriptor(key);
Map properties = new OrderedProperties();
properties.putAll(descriptors[0].getProperties());
properties.remove(IArtifactDescriptor.FORMAT);
@@ -448,7 +452,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
fail("Error while downloading artifact", e);
}
//corresponding key should now be in the destination
- assertTrue("Expected Key is not in destination", destinationRepo.contains(keys[0]));
+ assertTrue("Expected Key is not in destination", destinationRepo.contains(key));
IArtifactRepository repo = null;
try {
@@ -457,7 +461,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
fail("Unable to load repository for verification", e);
}
- IArtifactDescriptor[] srcDescriptors = repo.getArtifactDescriptors(keys[0]);
+ IArtifactDescriptor[] srcDescriptors = repo.getArtifactDescriptors(key);
if (srcDescriptors == null)
fail("Error finding descriptors for validation");
@@ -503,32 +507,34 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
}
//create a request for a descriptor from repo1
- IArtifactKey[] keys1 = repo1.getArtifactKeys();
- assertTrue("Error retreaiving artifact keys", keys1.length > 0);
- IArtifactDescriptor[] descriptors1 = repo1.getArtifactDescriptors(keys1[0]);
+ IQueryResult keys1 = repo1.query(ArtifactKeyQuery.ALL_KEYS, null);
+ IArtifactKey key1 = (IArtifactKey) keys1.iterator().next();
+ assertTrue("Error retreaiving artifact keys", !keys1.isEmpty());
+ IArtifactDescriptor[] descriptors1 = repo1.getArtifactDescriptors(key1);
assertTrue("Error retreaiving artifact descriptors", descriptors1.length > 0);
assertTrue("Expected key not in composite repository", compRepo.contains(descriptors1[0]));
- IArtifactDescriptor newDescriptor1 = new ArtifactDescriptor(keys1[0]);
+ IArtifactDescriptor newDescriptor1 = new ArtifactDescriptor(key1);
Map properties1 = new OrderedProperties();
properties1.putAll(descriptors1[0].getProperties());
properties1.remove(IArtifactDescriptor.FORMAT);
((ArtifactDescriptor) newDescriptor1).addProperties(properties1);
// IArtifactRequest request1 = ((ArtifactRepositoryManager) getArtifactRepositoryManager()).createMirrorRequest(keys1[0], destinationRepo, (Properties) newDescriptor1.getProperties(), (Properties) destinationRepo.getProperties());
- IArtifactRequest request1 = ((ArtifactRepositoryManager) getArtifactRepositoryManager()).createMirrorRequest(keys1[0], destinationRepo, null, null);
+ IArtifactRequest request1 = ((ArtifactRepositoryManager) getArtifactRepositoryManager()).createMirrorRequest(key1, destinationRepo, null, null);
//create a request for a descriptor from repo2
- IArtifactKey[] keys2 = repo2.getArtifactKeys();
- assertTrue("Error retreaiving artifact keys", keys2.length > 0);
- IArtifactDescriptor[] descriptors2 = repo2.getArtifactDescriptors(keys2[0]);
+ IQueryResult keys2 = repo2.query(ArtifactKeyQuery.ALL_KEYS, null);
+ IArtifactKey key2 = (IArtifactKey) keys2.iterator().next();
+ assertTrue("Error retreaiving artifact keys", !keys2.isEmpty());
+ IArtifactDescriptor[] descriptors2 = repo2.getArtifactDescriptors(key2);
assertTrue("Error retreaiving artifact descriptors", descriptors2.length > 0);
assertTrue("Expected key not in composite repository", compRepo.contains(descriptors2[0]));
- IArtifactDescriptor newDescriptor2 = new ArtifactDescriptor(keys2[0]);
+ IArtifactDescriptor newDescriptor2 = new ArtifactDescriptor(key2);
Map properties2 = new OrderedProperties();
properties2.putAll(descriptors2[0].getProperties());
properties2.remove(IArtifactDescriptor.FORMAT);
((ArtifactDescriptor) newDescriptor2).addProperties(properties2);
// IArtifactRequest request2 = ((ArtifactRepositoryManager) getArtifactRepositoryManager()).createMirrorRequest(keys2[0], destinationRepo, (Properties) newDescriptor2.getProperties(), (Properties) destinationRepo.getProperties());
- IArtifactRequest request2 = ((ArtifactRepositoryManager) getArtifactRepositoryManager()).createMirrorRequest(keys2[0], destinationRepo, null, null);
+ IArtifactRequest request2 = ((ArtifactRepositoryManager) getArtifactRepositoryManager()).createMirrorRequest(key2, destinationRepo, null, null);
IArtifactRequest[] requests = new IArtifactRequest[2];
requests[0] = request1;
@@ -546,8 +552,8 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
fail("Error while downloading artifacts", e);
}
//corresponding keys should now be in the destination
- assertTrue("Expected Key is not in destination", destinationRepo.contains(keys1[0]));
- assertTrue("Expected Key is not in destination", destinationRepo.contains(keys2[0]));
+ assertTrue("Expected Key is not in destination", destinationRepo.contains(key1));
+ assertTrue("Expected Key is not in destination", destinationRepo.contains(key2));
//verify the file from repo1
File repo1File = ((SimpleArtifactRepository) repo1).getArtifactFile(descriptors1[0]);
@@ -664,9 +670,9 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
assertEquals("Repository should only have 1 child", 1, compRepo.getChildren().size());
}
- public void testValidate() {
+ public void testValidate() throws Exception {
//Setup create descriptors with different md5 values
- IArtifactKey dupKey = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3"));
+ IArtifactKey dupKey = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3"));
File artifact1 = getTestData("0.0", "/testData/mirror/mirrorSourceRepo1 with space/artifacts.xml");
File artifact2 = getTestData("0.0", "/testData/mirror/mirrorSourceRepo2/artifacts.xml");
IArtifactDescriptor descriptor1 = PublisherHelper.createArtifactDescriptor(dupKey, artifact1);
@@ -699,12 +705,13 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
compRepo.addChild(repo2Location.toURI());
//validate using the MD5 Comparator
- assertFalse("Running verify on invalid repository", compRepo.validate(MD5ArtifactComparator.MD5_COMPARATOR_ID));
+ ArtifactRepositoryValidator validator = new ArtifactRepositoryValidator(MD5ArtifactComparator.MD5_COMPARATOR_ID);
+ assertFalse("Running verify on invalid repository", validator.validateComposite(compRepo).isOK());
}
- public void testAddChildWithValidate() {
+ public void testAddChildWithValidate() throws ProvisionException {
//Setup create descriptors with different md5 values
- IArtifactKey dupKey = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3"));
+ IArtifactKey dupKey = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3"));
File artifact1 = getTestData("0.0", "/testData/mirror/mirrorSourceRepo1 with space/artifacts.xml");
File artifact2 = getTestData("0.0", "/testData/mirror/mirrorSourceRepo2/artifacts.xml");
IArtifactDescriptor descriptor1 = PublisherHelper.createArtifactDescriptor(dupKey, artifact1);
@@ -733,10 +740,10 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
}
//Add conflicting repositories
- assertTrue("Adding first child with validate", compRepo.addChild(repo1Location.toURI(), MD5ArtifactComparator.MD5_COMPARATOR_ID));
- assertFalse("Adding conflicting child with validate", compRepo.addChild(repo2Location.toURI(), MD5ArtifactComparator.MD5_COMPARATOR_ID));
-
- assertEquals("Asserting Composite Repository only has 1 child", 1, compRepo.getChildren().size());
+ ArtifactRepositoryValidator validator = new ArtifactRepositoryValidator(MD5ArtifactComparator.MD5_COMPARATOR_ID);
+ assertTrue(validator.validateComposite(compRepo, repo1).isOK());
+ compRepo.addChild(repo1Location.toURI());
+ assertFalse(validator.validateComposite(compRepo, repo2).isOK());
}
public void testEnabledAndSystemValues() {
@@ -759,7 +766,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
compRepo.addChild(repo2Location.toURI());
//force composite repository to load all children
- compRepo.getArtifactKeys();
+ compRepo.getArtifactDescriptors(new ArtifactKey("", "", Version.emptyVersion));
assertTrue("Ensuring previously loaded repo is enabled", getArtifactRepositoryManager().isEnabled(repo1Location.toURI()));
String repo1System = getArtifactRepositoryManager().getRepositoryProperty(repo1Location.toURI(), IRepository.PROP_SYSTEM);
@@ -811,7 +818,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
assertContains("Assert child2's content is in composite repo", repo2, compRepo);
//checks that the destination has the correct number of keys (no extras)
//FIXME will this work?
- assertEquals("Assert Correct Number of Keys", repo1.getArtifactKeys().length + repo2.getArtifactKeys().length, compRepo.getArtifactKeys().length);
+ assertEquals("Assert Correct Number of Keys", getArtifactKeyCount(repo1) + getArtifactKeyCount(repo2), getArtifactKeyCount(compRepo));
}
private CompositeArtifactRepository createRepo(boolean compressed) {
@@ -844,7 +851,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
URI childOne = new URI("memory:/in/memory/one");
URI childTwo = new URI("memory:/in/memory/two");
URI childThree = new URI("memory:/in/memory/three");
- CompositeArtifactRepository repository = new CompositeArtifactRepository(location, "in memory test", null);
+ CompositeArtifactRepository repository = createRepository(location, "in memory test");
repository.addChild(childOne);
repository.addChild(childTwo);
repository.addChild(childThree);
@@ -872,7 +879,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
// create the composite repository and add the children
URI location = new File(temp, "comp").toURI();
- CompositeArtifactRepository repository = new CompositeArtifactRepository(location, "test", null);
+ CompositeArtifactRepository repository = createRepository(location, "test");
try {
repository.addChild(new URI("../one"));
repository.addChild(new URI("../two"));
@@ -883,8 +890,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
// query the number of artifacts
List children = repository.getChildren();
assertEquals("2.0", 2, children.size());
- IArtifactKey[] keys = repository.getArtifactKeys();
- assertEquals("2.1", 2, keys.length);
+ assertEquals("2.1", 2, getArtifactKeyCount(repository));
// ensure the child URIs are stored as relative
CompositeRepositoryState state = repository.toState();
@@ -903,7 +909,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
URI location = new URI("memory:/in/memory");
URI one = new URI("one");
URI two = new URI("two");
- CompositeArtifactRepository repository = new CompositeArtifactRepository(location, "in memory test", null);
+ CompositeArtifactRepository repository = createRepository(location, "in memory test");
repository.addChild(one);
repository.addChild(two);
List children = repository.getChildren();
@@ -930,7 +936,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
destination = new File(getTempFolder(), getUniqueString());
out = new FileOutputStream(destination);
- CompositeArtifactRepository repository = new CompositeArtifactRepository(new URI("memory:/in/memory"), "in memory test", null);
+ CompositeArtifactRepository repository = createRepository(new URI("memory:/in/memory"), "in memory test");
IArtifactRepository childOne = getArtifactRepositoryManager().loadRepository(childLocation, null);
TestArtifactRepository childTwo = new TestArtifactRepository(new URI("memory:/in/memory/two"));
@@ -940,7 +946,7 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
repository.addChild(childOne.getLocation());
repository.addChild(childTwo.getLocation());
- IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "missingSize.asdf", new Version("1.5.1.v200803061910")));
+ IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "missingSize.asdf", Version.create("1.5.1.v200803061910")));
IStatus status = repository.getArtifact(descriptor, out, new NullProgressMonitor());
// We should have a failure
@@ -996,11 +1002,11 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
IArtifactRepository destination = null;
BadMirrorSite child = null;
CompositeArtifactRepository source = null;
- IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "missingSize.asdf", new Version("1.5.1.v200803061910")));
+ IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "missingSize.asdf", Version.create("1.5.1.v200803061910")));
try {
destination = super.createArtifactRepository(getTempFolder().toURI(), null);
child = new BadMirrorSite(new URI("memory:/in/memory/child"));
- source = new CompositeArtifactRepository(new URI("memory:/in/memory/source"), "in memory test", null);
+ source = createRepository(new URI("memory:/in/memory/source"), "in memory test");
source.addChild(child.getLocation());
// Create mirror request
@@ -1026,6 +1032,12 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
}
}
+ protected CompositeArtifactRepository createRepository(URI location, String name) {
+ CompositeArtifactRepositoryFactory factory = new CompositeArtifactRepositoryFactory();
+ factory.setAgent(getAgent());
+ return (CompositeArtifactRepository) factory.create(location, name, CompositeArtifactRepository.REPOSITORY_TYPE, null);
+ }
+
/*
* Test a child returning different bytes
*/
@@ -1066,8 +1078,8 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
destination = new File(getTempFolder(), getUniqueString());
out = new FileOutputStream(destination);
- source = new CompositeArtifactRepository(new URI("memory:/in/memory"), "in memory test", null);
- IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "missingSize.asdf", new Version("1.5.1.v200803061910")));
+ source = createRepository(new URI("memory:/in/memory"), "in memory test");
+ IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "missingSize.asdf", Version.create("1.5.1.v200803061910")));
// Create 'bad' child which returns an error in transfer
childOne = new BadSite(new URI("memory:/in/memory/one"));
@@ -1125,8 +1137,8 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
IArtifactRepository childOne = null;
IArtifactRepository childTwo = null;
try {
- IArtifactDescriptor desc = new ArtifactDescriptor(new ArtifactKey("osgi", "a", new Version("1.0.0")));
- source = new CompositeArtifactRepository(new URI("memory:/in/memory"), "in memory test", null);
+ IArtifactDescriptor desc = new ArtifactDescriptor(new ArtifactKey("osgi", "a", Version.create("1.0.0")));
+ source = createRepository(new URI("memory:/in/memory"), "in memory test");
childOne = createChild();
source.addChild(childOne.getLocation());
@@ -1161,8 +1173,8 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
IArtifactRepository childOne = null;
IArtifactRepository childTwo = null;
try {
- IArtifactKey desc = new ArtifactKey("osgi", "a", new Version("1.0.0"));
- source = new CompositeArtifactRepository(new URI("memory:/in/memory"), "in memory test", null);
+ IArtifactKey desc = new ArtifactKey("osgi", "a", Version.create("1.0.0"));
+ source = createRepository(new URI("memory:/in/memory"), "in memory test");
childOne = createChild();
source.addChild(childOne.getLocation());
@@ -1198,22 +1210,22 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
IArtifactRepository childTwo = null;
try {
- source = new CompositeArtifactRepository(new URI("memory:/in/memory"), "in memory test", null);
- IArtifactKey key = new ArtifactKey("classifier", "name", new Version("1.0.0"));
+ source = createRepository(new URI("memory:/in/memory"), "in memory test");
+ IArtifactKey key = new ArtifactKey("classifier", "name", Version.create("1.0.0"));
childOne = createChild();
((TestArtifactRepository) childOne).addArtifact(key, new byte[] {});
source.addChild(childOne.getLocation());
- assertTrue("Composite repo does not contain key", Arrays.asList(source.getArtifactKeys()).contains(key));
+ assertTrue("Composite repo does not contain key", source.contains(key));
markBad(source, childOne);
- assertFalse("Composite repo contains key but child is marked bad", Arrays.asList(source.getArtifactKeys()).contains(key));
+ assertFalse("Composite repo contains key but child is marked bad", source.contains(key));
childTwo = createChild();
((TestArtifactRepository) childTwo).addArtifact(key, new byte[] {});
source.addChild(childTwo.getLocation());
- assertTrue("Composite repo does not contain key, but it is available", Arrays.asList(source.getArtifactKeys()).contains(key));
+ assertTrue("Composite repo does not contain key, but it is available", source.contains(key));
} catch (Exception e) {
fail(e.getMessage(), e);
} finally {
@@ -1235,8 +1247,8 @@ public class CompositeArtifactRepositoryTest extends AbstractProvisioningTest {
IArtifactRepository childTwo = null;
try {
- source = new CompositeArtifactRepository(new URI("memory:/in/memory"), "in memory test", null);
- IArtifactKey key = new ArtifactKey("classifier", "name", new Version("1.0.0"));
+ source = createRepository(new URI("memory:/in/memory"), "in memory test");
+ IArtifactKey key = new ArtifactKey("classifier", "name", Version.create("1.0.0"));
IArtifactDescriptor desc = new ArtifactDescriptor(key);
childOne = createChild();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java
index b842f6242..cc5c9d171 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/CorruptedJar.java
@@ -15,9 +15,9 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest;
import org.eclipse.equinox.internal.p2.engine.DownloadManager;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext;
+import org.eclipse.equinox.p2.engine.ProvisioningContext;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class CorruptedJar extends AbstractProvisioningTest {
@@ -45,8 +45,9 @@ public class CorruptedJar extends AbstractProvisioningTest {
public void testDownloadCorruptedJar() {
ProvisioningContext ctx = new ProvisioningContext();
ctx.setArtifactRepositories(new URI[] {getTestData("CorruptedJar repo", testDataLocation).toURI()});
- DownloadManager mgr = new DownloadManager(ctx);
- mgr.add(new MirrorRequest(source.getArtifactKeys()[0], target, null, null));
+ DownloadManager mgr = new DownloadManager(ctx, getArtifactRepositoryManager());
+ IArtifactKey key = (IArtifactKey) source.query(ArtifactKeyQuery.ALL_KEYS, null).iterator().next();
+ mgr.add(new MirrorRequest(key, target, null, null));
IStatus s = mgr.start(new NullProgressMonitor());
assertNotOK(s);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java
index 5e822f3c3..c96ce06db 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/FoldersRepositoryTest.java
@@ -10,16 +10,19 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.File;
import java.io.FileFilter;
import java.net.URL;
+import java.util.Iterator;
import junit.framework.TestCase;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.ServiceReference;
@@ -39,7 +42,7 @@ public class FoldersRepositoryTest extends TestCase {
}
protected void setUp() throws Exception {
- managerRef = TestActivator.getContext().getServiceReference(IArtifactRepositoryManager.class.getName());
+ managerRef = TestActivator.getContext().getServiceReference(IArtifactRepositoryManager.SERVICE_NAME);
manager = (IArtifactRepositoryManager) TestActivator.getContext().getService(managerRef);
}
@@ -81,19 +84,22 @@ public class FoldersRepositoryTest extends TestCase {
String identifier = fileName.substring(0, fileName.indexOf('_'));
String version = fileName.substring(fileName.indexOf('_') + 1);
- ArtifactKey key = new ArtifactKey("osgi.bundle", identifier, new Version(version));
+ ArtifactKey key = new ArtifactKey("osgi.bundle", identifier, Version.create(version));
ArtifactDescriptor descriptor = new ArtifactDescriptor(key);
if (file.isDirectory())
descriptor.setProperty("artifact.folder", "true");
repo.addDescriptor(descriptor);
}
- IArtifactKey[] keys = repo.getArtifactKeys();
- assertEquals(2, keys.length);
- for (int i = 0; i < keys.length; i++) {
- repo.removeDescriptor(keys[i]);
+ IQueryResult keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null);
+ assertEquals(2, AbstractProvisioningTest.queryResultSize(keys));
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
+ IArtifactKey key = (IArtifactKey) iterator.next();
+ repo.removeDescriptor(key);
}
- assertEquals(0, repo.getArtifactKeys().length);
+
+ keys = repo.query(ArtifactKeyQuery.ALL_KEYS, null);
+ assertTrue(keys.isEmpty());
assertEquals(0, pluginsFolder.listFiles(filter).length);
manager.removeRepository(repo.getLocation());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java
index e180583d9..99932a704 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/JarURLArtifactRepositoryTest.java
@@ -10,15 +10,15 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.net.*;
import junit.framework.TestCase;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.ServiceReference;
@@ -36,7 +36,7 @@ public class JarURLArtifactRepositoryTest extends TestCase {
}
protected void setUp() throws Exception {
- managerRef = TestActivator.getContext().getServiceReference(IArtifactRepositoryManager.class.getName());
+ managerRef = TestActivator.getContext().getServiceReference(IArtifactRepositoryManager.SERVICE_NAME);
manager = (IArtifactRepositoryManager) TestActivator.getContext().getService(managerRef);
}
@@ -56,6 +56,6 @@ public class JarURLArtifactRepositoryTest extends TestCase {
fail(e.getMessage());
}
IArtifactRepository repo = manager.loadRepository(jarRepoLocation, null);
- assertTrue(repo.contains(new ArtifactKey("osgi.bundle", "testdata", new Version("1.0.0.1"))));
+ assertTrue(repo.contains(new ArtifactKey("osgi.bundle", "testdata", Version.create("1.0.0.1"))));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java
index 884fa123f..04e2db056 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MD5Tests.java
@@ -10,16 +10,18 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.util.Iterator;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class MD5Tests extends AbstractProvisioningTest {
@@ -34,25 +36,23 @@ public class MD5Tests extends AbstractProvisioningTest {
}
public void testCheckMD5() {
- IArtifactKey[] keys = repo.getArtifactKeys();
- for (int i = 0; i < keys.length; i++) {
- IArtifactDescriptor[] desc = repo.getArtifactDescriptors(keys[i]);
- for (int j = 0; j < desc.length; j++) {
- IStatus status = repo.getArtifact(desc[j], new ByteArrayOutputStream(500), new NullProgressMonitor());
- //All artifacts that are expected to fail MD5 check are those whose id starts with bogus
- if (desc[j].getArtifactKey().getId().startsWith("bogus")) {
- assertNotOK(status);
- continue;
- }
- assertOK("2.1 " + desc[j], status);
+ IQueryResult<IArtifactDescriptor> descriptors = repo.descriptorQueryable().query(ArtifactDescriptorQuery.ALL_DESCRIPTORS, null);
+ for (Iterator<IArtifactDescriptor> iterator = descriptors.iterator(); iterator.hasNext();) {
+ IArtifactDescriptor desc = iterator.next();
+ IStatus status = repo.getArtifact(desc, new ByteArrayOutputStream(500), new NullProgressMonitor());
+ //All artifacts that are expected to fail MD5 check are those whose id starts with bogus
+ if (desc.getArtifactKey().getId().startsWith("bogus")) {
+ assertNotOK(status);
+ continue;
}
+ assertOK("2.1 " + desc, status);
}
}
public void testBug249035_ArtifactIdentity() {
//MD5 sum should not affect the identity of the artifact
- ArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", new Version("1.0.0")));
+ ArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", Version.create("1.0.0")));
descriptor.setProperty(IArtifactDescriptor.DOWNLOAD_MD5, "42");
try {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java
index 6c6bef325..f7e7b8017 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/MirrorRequestTest.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.*;
import java.lang.reflect.Field;
@@ -24,12 +24,13 @@ import org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest;
import org.eclipse.equinox.internal.p2.artifact.repository.MirrorSelector;
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.AbstractArtifactRepository;
-import org.eclipse.equinox.internal.provisional.spi.p2.repository.AbstractRepository;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository;
+import org.eclipse.equinox.p2.repository.spi.AbstractRepository;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.AbstractWrappedArtifactRepository;
import org.w3c.dom.*;
@@ -66,7 +67,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
public void testInvalidZipFileInTheSource() {
IArtifactKey key = new ArtifactKey("org.eclipse.update.feature", "HelloWorldFeature", Version.createOSGi(1, 0, 0));
- Properties targetProperties = new Properties();
+ Map<String, String> targetProperties = new HashMap<String, String>();
targetProperties.put("artifact.folder", "true");
MirrorRequest request = new MirrorRequest(key, targetRepository, null, targetProperties);
request.setSourceRepository(sourceRepository);
@@ -79,7 +80,7 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
public void testMissingArtifact() {
IArtifactKey key = new ArtifactKey("org.eclipse.update.feature", "Missing", Version.createOSGi(1, 0, 0));
- Properties targetProperties = new Properties();
+ Map<String, String> targetProperties = new HashMap<String, String>();
targetProperties.put("artifact.folder", "true");
MirrorRequest request = new MirrorRequest(key, targetRepository, null, targetProperties);
request.setSourceRepository(sourceRepository);
@@ -134,10 +135,11 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
// Set status sequence, actual Statuses added later
source.setSequence(seq);
// Grab an ArtifactKey to mirror, doesn't matter which
- IArtifactKey[] keys = source.getArtifactKeys();
- assertTrue("Unable to obtain artifact keys", keys != null && keys.length > 0);
+ IQueryResult keys = source.query(ArtifactKeyQuery.ALL_KEYS, null);
+ assertTrue("Unable to obtain artifact keys", keys != null && !keys.isEmpty());
- MirrorRequest req = new MirrorRequest(keys[0], targetRepository, null, null);
+ IArtifactKey key = (IArtifactKey) keys.iterator().next();
+ MirrorRequest req = new MirrorRequest(key, targetRepository, null, null);
req.setSourceRepository(source);
// Set Status sequence
seq.add(new Status(IStatus.ERROR, "Activator", "Message"));
@@ -147,9 +149,9 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
assertEquals("Expected WARNING status", IStatus.WARNING, req.getResult().getSeverity());
// Remove key from repo so the same one can be used
- targetRepository.removeDescriptor(keys[0]);
+ targetRepository.removeDescriptor(key);
// Set Status sequence
- req = new MirrorRequest(keys[0], targetRepository, null, null);
+ req = new MirrorRequest(key, targetRepository, null, null);
req.setSourceRepository(source);
seq.add(new Status(IStatus.WARNING, "Activator", "Message"));
seq.add(new Status(IStatus.INFO, "Activator", "Message"));
@@ -158,9 +160,9 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
assertEquals("Expected INFO status", IStatus.INFO, req.getResult().getSeverity());
// Remove key from repo so the same one can be used
- targetRepository.removeDescriptor(keys[0]);
+ targetRepository.removeDescriptor(key);
// Set Status sequence
- req = new MirrorRequest(keys[0], targetRepository, null, null);
+ req = new MirrorRequest(key, targetRepository, null, null);
req.setSourceRepository(source);
seq.add(new Status(IStatus.INFO, "Activator", "Message"));
req.perform(new NullProgressMonitor());
@@ -289,10 +291,6 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
return delegate.getArtifactDescriptors(key);
}
- public IArtifactKey[] getArtifactKeys() {
- return delegate.getArtifactKeys();
- }
-
public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) {
return delegate.getArtifacts(requests, monitor);
}
@@ -304,6 +302,14 @@ public class MirrorRequestTest extends AbstractProvisioningTest {
public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
return delegate.getRawArtifact(descriptor, destination, monitor);
}
+
+ public IQueryable<IArtifactDescriptor> descriptorQueryable() {
+ return delegate.descriptorQueryable();
+ }
+
+ public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) {
+ return delegate.query(query, monitor);
+ }
}
/*
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
index c0173b5c9..ad1d357d1 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/SimpleArtifactRepositoryTest.java
@@ -12,23 +12,28 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.artifact.repository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository;
+import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepositoryFactory;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.*;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
-import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.SimpleArtifactRepositoryFactory;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.query.IQueryable;
+import org.eclipse.equinox.p2.repository.IRepository;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.artifact.*;
+import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.spi.p2.publisher.PublisherHelper;
@@ -80,7 +85,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
assertEquals(base, SimpleArtifactRepository.getActualLocation(base, true));
}
- public void testCompressedRepository() throws URISyntaxException, ProvisionException {
+ public void testCompressedRepository() throws ProvisionException {
IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager();
String tempDir = System.getProperty("java.io.tmpdir");
repositoryFile = new File(tempDir, "SimpleArtifactRepositoryTest");
@@ -90,7 +95,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
properties.put(IRepository.PROP_COMPRESSED, "true");
IArtifactRepository repo = artifactRepositoryManager.createRepository(repositoryURI, "artifact name", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties);
- IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3"));
+ IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3"));
IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, null);
repo.addDescriptor(descriptor);
@@ -113,7 +118,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
fail("Repository should not create artifact.xml");
}
- public void testUncompressedRepository() throws URISyntaxException, ProvisionException {
+ public void testUncompressedRepository() throws ProvisionException {
IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager();
String tempDir = System.getProperty("java.io.tmpdir");
repositoryFile = new File(tempDir, "SimpleArtifactRepositoryTest");
@@ -123,7 +128,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
properties.put(IRepository.PROP_COMPRESSED, "false");
IArtifactRepository repo = artifactRepositoryManager.createRepository(repositoryURI, "artifact name", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties);
- IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", new Version("1.2.3"));
+ IArtifactKey key = PublisherHelper.createBinaryArtifactKey("testKeyId", Version.create("1.2.3"));
IArtifactDescriptor descriptor = PublisherHelper.createArtifactDescriptor(key, null);
repo.addDescriptor(descriptor);
@@ -158,6 +163,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
public void test_248772() {
SimpleArtifactRepositoryFactory factory = new SimpleArtifactRepositoryFactory();
+ factory.setAgent(getAgent());
URI location = null;
location = new File(getTempFolder(), getUniqueString()).toURI();
factory.create(location, "test type", null, null);
@@ -193,7 +199,7 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
} catch (ProvisionException e) {
fail("Failed to create repository", e);
}
- IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", new Version("1.0.0")));
+ IArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", Version.create("1.0.0")));
OutputStream out = null;
try {
@@ -247,8 +253,8 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
// Create a descriptor for a packed repo
ArtifactDescriptor descriptor = new ArtifactDescriptor(new ArtifactKey("org.eclipse.update.feature", "test", Version.parseVersion("1.0.0")));
- descriptor.setProperty(IArtifactDescriptor.FORMAT, "packed");
- descriptor.setProcessingSteps(new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)});
+ descriptor.setProperty(IArtifactDescriptor.FORMAT, IArtifactDescriptor.FORMAT_PACKED);
+ descriptor.setProcessingSteps(new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)});
// Create repository
Map properties = new HashMap();
@@ -262,4 +268,115 @@ public class SimpleArtifactRepositoryTest extends AbstractProvisioningTest {
fail("Test failed", e);
}
}
+
+ private static class TestDescriptor implements IArtifactDescriptor {
+ private static final IProcessingStepDescriptor[] steps = new IProcessingStepDescriptor[0];
+ private IArtifactKey artifactKey;
+ private Properties properties = new Properties();
+
+ public TestDescriptor(IArtifactKey key) {
+ this.artifactKey = key;
+ }
+
+ public IArtifactKey getArtifactKey() {
+ return artifactKey;
+ }
+
+ public IProcessingStepDescriptor[] getProcessingSteps() {
+ return steps;
+ }
+
+ public Map getProperties() {
+ return properties;
+ }
+
+ public String getProperty(String key) {
+ return properties.getProperty(key);
+ }
+
+ public IArtifactRepository getRepository() {
+ return null;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (!(obj instanceof IArtifactDescriptor))
+ return false;
+
+ IArtifactDescriptor other = (IArtifactDescriptor) obj;
+ if (!artifactKey.equals(other.getArtifactKey()))
+ return false;
+
+ if (!Arrays.equals(steps, other.getProcessingSteps()))
+ return false;
+
+ String format = getProperty(FORMAT);
+ String otherFormat = other.getProperty(FORMAT);
+ if (format != null ? !format.equals(otherFormat) : otherFormat != null)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ String format = getProperty(FORMAT);
+
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((artifactKey == null) ? 0 : artifactKey.hashCode());
+ result = prime * result + Arrays.asList(steps).hashCode();
+ result = prime * result + (format != null ? format.hashCode() : 0);
+ return result;
+ }
+ }
+
+ public void testAddContains() throws Exception {
+ File folder = getTestFolder("simple_AddContains");
+ repositoryURI = folder.toURI();
+
+ Map properties = new HashMap();
+ SimpleArtifactRepository repo = (SimpleArtifactRepository) getArtifactRepositoryManager().createRepository(repositoryURI, "My Repo", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, properties);
+
+ TestDescriptor descriptor = new TestDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", Version.create("1.0.0")));
+ OutputStream stream = repo.getOutputStream(descriptor);
+ stream.write("I am an artifact\n".getBytes());
+ stream.close();
+
+ assertTrue(repo.contains(descriptor));
+
+ assertTrue(repo.contains(new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "aaPlugin", Version.create("1.0.0")))));
+
+ }
+
+ public void testQuery() throws Exception {
+ File folder = getTestFolder("ArtifactRepository_testQuery");
+ repositoryURI = folder.toURI();
+
+ IArtifactRepository repo = getArtifactRepositoryManager().createRepository(repositoryURI, "test", IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, new HashMap());
+
+ ArtifactDescriptor d1 = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "a", Version.create("1.0.0")));
+ ArtifactDescriptor d2 = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "a", Version.create("2.0.0")));
+ ArtifactDescriptor d3 = new ArtifactDescriptor(new ArtifactKey("osgi.bundle", "a", Version.create("2.0.0")));
+ d3.setProperty(IArtifactDescriptor.FORMAT, IArtifactDescriptor.FORMAT_PACKED);
+
+ repo.addDescriptor(d1);
+ repo.addDescriptor(d2);
+ repo.addDescriptor(d3);
+
+ IQueryable<IArtifactDescriptor> descQueryable = repo.descriptorQueryable();
+ IQueryResult<IArtifactDescriptor> result = descQueryable.query(new ArtifactDescriptorQuery("a", null, null), null);
+ assertEquals(3, queryResultSize(result));
+
+ result = descQueryable.query(new ArtifactDescriptorQuery(null, new VersionRange("[2.0.0, 3.0.0)"), null), null);
+ assertEquals(2, queryResultSize(result));
+ assertNotContains(result, d1);
+
+ result = descQueryable.query(new ArtifactDescriptorQuery(null, null, IArtifactDescriptor.FORMAT_PACKED), null);
+ assertEquals(1, queryResultSize(result));
+ IArtifactDescriptor resultDescriptor = result.iterator().next();
+ assertEquals(d3.getArtifactKey(), resultDescriptor.getArtifactKey());
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java
index 845d33de0..c3394503b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Adder.java
@@ -15,9 +15,9 @@ import java.io.IOException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor;
public class Adder extends ProcessingStep {
@@ -32,7 +32,7 @@ public class Adder extends ProcessingStep {
this.operand = operand;
}
- public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
+ public void initialize(IProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
super.initialize(descriptor, context);
try {
operand = Integer.valueOf(descriptor.getData()).intValue();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java
index 38c6fbeb7..507d9283a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ByteShifter.java
@@ -15,9 +15,9 @@ import java.io.IOException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor;
public class ByteShifter extends ProcessingStep {
@@ -33,7 +33,7 @@ public class ByteShifter extends ProcessingStep {
basicInitialize(null);
}
- private void basicInitialize(ProcessingStepDescriptor descriptor) {
+ private void basicInitialize(IProcessingStepDescriptor descriptor) {
// if the status is already set to something that not ok, we've already found a problem.
if (!getStatus().isOK())
return;
@@ -51,7 +51,7 @@ public class ByteShifter extends ProcessingStep {
setStatus(new Status(code, Activator.ID, "ByteShifter operand invalid: " + operand));
}
- public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
+ public void initialize(IProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
super.initialize(descriptor, context);
try {
operand = Integer.valueOf(descriptor.getData()).intValue();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java
index 008b05370..0a033464e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Counter.java
@@ -14,9 +14,9 @@ import java.io.IOException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor;
public class Counter extends ProcessingStep {
@@ -33,7 +33,7 @@ public class Counter extends ProcessingStep {
basicInitialize(null);
}
- private void basicInitialize(ProcessingStepDescriptor descriptor) {
+ private void basicInitialize(IProcessingStepDescriptor descriptor) {
// if the status is already set to something that not ok, we've already found a problem.
if (!getStatus().isOK())
return;
@@ -51,7 +51,7 @@ public class Counter extends ProcessingStep {
setStatus(new Status(code, Activator.ID, "Counter size not set"));
}
- public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
+ public void initialize(IProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
super.initialize(descriptor, context);
String data = descriptor.getData();
if (data == null)
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java
index 4b090422a..feb98171c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/Multiplier.java
@@ -15,9 +15,9 @@ import java.io.IOException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor;
public class Multiplier extends ProcessingStep {
@@ -32,7 +32,7 @@ public class Multiplier extends ProcessingStep {
this.operand = operand;
}
- public void initialize(ProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
+ public void initialize(IProcessingStepDescriptor descriptor, IArtifactDescriptor context) {
super.initialize(descriptor, context);
try {
operand = Integer.valueOf(descriptor.getData()).intValue();
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java
index c3862a5a0..d22e509fc 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/processing/ProcessingStepHandlerTest.java
@@ -18,7 +18,10 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.artifact.processors.pack200.Pack200ProcessorStep;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.internal.p2.jarprocessor.PackStep;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.*;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler;
+import org.eclipse.equinox.p2.repository.artifact.IProcessingStepDescriptor;
+import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor;
import org.eclipse.equinox.p2.tests.TestActivator;
public class ProcessingStepHandlerTest extends TestCase {
@@ -29,7 +32,7 @@ public class ProcessingStepHandlerTest extends TestCase {
IProgressMonitor monitor = new NullProgressMonitor();
public void testExecuteNoPSs() throws IOException {
- ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[0];
+ IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[0];
OutputStream result = new ByteArrayOutputStream(10);
OutputStream testStream = handler.createAndLink(descriptors, null, result, monitor);
testStream.write("Test".getBytes());
@@ -125,7 +128,7 @@ public class ProcessingStepHandlerTest extends TestCase {
//this test is only applicable if pack200 is available
if (!PackStep.canPack())
return;
- ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)};
+ IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)};
ProcessingStep[] steps = handler.create(descriptors, null);
ByteArrayOutputStream result = new ByteArrayOutputStream(100000);
OutputStream testStream = handler.link(steps, result, monitor);
@@ -137,7 +140,7 @@ public class ProcessingStepHandlerTest extends TestCase {
}
public void testCreateByteShifterPS() {
- ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.ByteShifter", "1", true)};
+ IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.ByteShifter", "1", true)};
ProcessingStep[] steps = handler.create(descriptors, null);
assertNotNull(steps);
assertEquals(1, steps.length);
@@ -153,7 +156,7 @@ public class ProcessingStepHandlerTest extends TestCase {
// }
public void testCreateAdderPS() {
- ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true)};
+ IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true)};
ProcessingStep[] steps = handler.create(descriptors, null);
assertNotNull(steps);
assertEquals(1, steps.length);
@@ -161,7 +164,7 @@ public class ProcessingStepHandlerTest extends TestCase {
}
public void testCreateMultiplierPS() {
- ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true)};
+ IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true)};
ProcessingStep[] steps = handler.create(descriptors, null);
assertNotNull(steps);
assertEquals(1, steps.length);
@@ -169,7 +172,7 @@ public class ProcessingStepHandlerTest extends TestCase {
}
public void testCreatePack200UnpackerPS() {
- ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)};
+ IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Pack200Unpacker", null, true)};
ProcessingStep[] steps = handler.create(descriptors, null);
assertNotNull(steps);
assertEquals(1, steps.length);
@@ -177,9 +180,9 @@ public class ProcessingStepHandlerTest extends TestCase {
}
public void testCreatePSsAndAssureOrderingOfPSs1() throws IOException {
- ProcessingStepDescriptor adder = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true);
- ProcessingStepDescriptor multiplier = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true);
- ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {adder, multiplier};
+ IProcessingStepDescriptor adder = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true);
+ IProcessingStepDescriptor multiplier = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true);
+ IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {adder, multiplier};
ProcessingStep[] steps = handler.create(descriptors, null);
ByteArrayOutputStream result = new ByteArrayOutputStream(10);
OutputStream testStream = handler.link(steps, result, monitor);
@@ -189,9 +192,9 @@ public class ProcessingStepHandlerTest extends TestCase {
}
public void testCreatePSsAndAssureOrderingOfPSs2() throws IOException {
- ProcessingStepDescriptor adder = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true);
- ProcessingStepDescriptor multiplier = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true);
- ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {multiplier, adder};
+ IProcessingStepDescriptor adder = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true);
+ IProcessingStepDescriptor multiplier = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true);
+ IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {multiplier, adder};
ProcessingStep[] steps = handler.create(descriptors, null);
ByteArrayOutputStream result = new ByteArrayOutputStream(10);
OutputStream testStream = handler.link(steps, result, monitor);
@@ -201,9 +204,9 @@ public class ProcessingStepHandlerTest extends TestCase {
}
public void testLinkPSs() throws IOException {
- ProcessingStepDescriptor adder = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true);
- ProcessingStepDescriptor multiplier = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true);
- ProcessingStepDescriptor[] descriptors = new ProcessingStepDescriptor[] {adder, multiplier};
+ IProcessingStepDescriptor adder = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Adder", "1", true);
+ IProcessingStepDescriptor multiplier = new ProcessingStepDescriptor("org.eclipse.equinox.p2.processing.Multiplier", "2", true);
+ IProcessingStepDescriptor[] descriptors = new IProcessingStepDescriptor[] {adder, multiplier};
ByteArrayOutputStream result = new ByteArrayOutputStream(10);
OutputStream testStream = handler.createAndLink(descriptors, null, result, monitor);
testStream.write(new byte[] {1, 2, 3, 4, 5});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/AggregateQueryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/AggregateQueryTest.java
index ddf8fca34..bea6a9cdc 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/AggregateQueryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/AggregateQueryTest.java
@@ -11,7 +11,8 @@ package org.eclipse.equinox.p2.tests.core;
import java.util.*;
import junit.framework.TestCase;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
* This tests both Compound and Composite queries
@@ -28,16 +29,17 @@ public class AggregateQueryTest extends TestCase {
}
public void testEmptyCompositeQuery() {
- CompositeQuery query = new CompositeQuery(new Query[0]);
- query.perform(getABCDE().iterator(), new Collector());
+ PipedQuery query = new PipedQuery(new IQuery[0]);
+ query.perform(getABCDE().iterator());
// We should not throw an exception. No guarantee on what perform
// will return in this case
}
public void testSymmetry() {
- Query getLatest = new ContextQuery() {
+ IQuery getLatest = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ public Collector perform(Iterator iterator) {
+ Collector result = new Collector();
List list = new ArrayList();
while (iterator.hasNext()) {
list.add(iterator.next());
@@ -48,9 +50,10 @@ public class AggregateQueryTest extends TestCase {
}
};
- Query getAllBut3 = new ContextQuery() {
+ IQuery getAllBut3 = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ public Collector perform(Iterator iterator) {
+ Collector result = new Collector();
while (iterator.hasNext()) {
Object o = iterator.next();
if (!o.equals("3"))
@@ -60,21 +63,21 @@ public class AggregateQueryTest extends TestCase {
}
};
- CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {getLatest, getAllBut3}, true);
- Collector result = compoundQuery.perform(get123().iterator(), new Collector());
- assertEquals(0, result.size());
+ CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {getLatest, getAllBut3}, true);
+ IQueryResult result = compoundQuery.perform(get123().iterator());
+ assertEquals(0, AbstractProvisioningTest.queryResultSize(result));
- compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {getAllBut3, getLatest}, true);
- result = compoundQuery.perform(get123().iterator(), new Collector());
- assertEquals(0, result.size());
+ compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {getAllBut3, getLatest}, true);
+ result = compoundQuery.perform(get123().iterator());
+ assertEquals(0, AbstractProvisioningTest.queryResultSize(result));
- compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {getLatest, getAllBut3}, false);
- result = compoundQuery.perform(get123().iterator(), new Collector());
- assertEquals(3, result.size());
+ compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {getLatest, getAllBut3}, false);
+ result = compoundQuery.perform(get123().iterator());
+ assertEquals(3, AbstractProvisioningTest.queryResultSize(result));
- compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {getAllBut3, getLatest}, false);
- result = compoundQuery.perform(get123().iterator(), new Collector());
- assertEquals(3, result.size());
+ compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {getAllBut3, getLatest}, false);
+ result = compoundQuery.perform(get123().iterator());
+ assertEquals(3, AbstractProvisioningTest.queryResultSize(result));
}
@@ -83,9 +86,10 @@ public class AggregateQueryTest extends TestCase {
* This method tests that
*/
public void testNonSymmetry() {
- Query getLatest = new ContextQuery() {
+ IQuery getLatest = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ public Collector perform(Iterator iterator) {
+ Collector result = new Collector();
List list = new ArrayList();
while (iterator.hasNext()) {
list.add(iterator.next());
@@ -96,9 +100,11 @@ public class AggregateQueryTest extends TestCase {
}
};
- Query getAllBut3 = new ContextQuery() {
+ IQuery getAllBut3 = new ContextQuery() {
+
+ public Collector perform(Iterator iterator) {
+ Collector result = new Collector();
- public Collector perform(Iterator iterator, Collector result) {
while (iterator.hasNext()) {
Object o = iterator.next();
if (!o.equals("3"))
@@ -108,95 +114,95 @@ public class AggregateQueryTest extends TestCase {
}
};
- CompositeQuery compoundQuery = new CompositeQuery(new Query[] {getLatest, getAllBut3});
- Collector result = compoundQuery.perform(get123().iterator(), new Collector());
- assertEquals(0, result.size());
+ PipedQuery compoundQuery = new PipedQuery(getLatest, getAllBut3);
+ IQueryResult result = compoundQuery.perform(get123().iterator());
+ assertEquals(0, AbstractProvisioningTest.queryResultSize(result));
- compoundQuery = new CompositeQuery(new Query[] {getAllBut3, getLatest});
- result = compoundQuery.perform(get123().iterator(), new Collector());
- assertEquals(1, result.size());
- assertEquals("2", result.toCollection().iterator().next());
+ compoundQuery = new PipedQuery(getAllBut3, getLatest);
+ result = compoundQuery.perform(get123().iterator());
+ assertEquals(1, AbstractProvisioningTest.queryResultSize(result));
+ assertEquals("2", result.iterator().next());
}
public void testCompoundAllMatchQueries() {
- Query A = new MatchQuery() {
+ IQuery A = new MatchQuery() {
public boolean isMatch(Object candidate) {
return false;
}
};
- Query B = new MatchQuery() {
+ IQuery B = new MatchQuery() {
public boolean isMatch(Object candidate) {
return false;
}
};
- Query C = new MatchQuery() {
+ IQuery C = new MatchQuery() {
public boolean isMatch(Object candidate) {
return false;
}
};
- CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {A, B, C}, true);
+ CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {A, B, C}, true);
assertTrue("1.0", compoundQuery instanceof IMatchQuery);
- assertEquals("1.1", 3, compoundQuery.getQueries().length);
- assertEquals("1.2", A, compoundQuery.getQueries()[0]);
- assertEquals("1.3", B, compoundQuery.getQueries()[1]);
- assertEquals("1.4", C, compoundQuery.getQueries()[2]);
+ assertEquals("1.1", 3, compoundQuery.getQueries().size());
+ assertEquals("1.2", A, compoundQuery.getQueries().get(0));
+ assertEquals("1.3", B, compoundQuery.getQueries().get(1));
+ assertEquals("1.4", C, compoundQuery.getQueries().get(2));
}
public void testCompoundSomeMatchQueries() {
- Query A = new MatchQuery() {
+ IQuery A = new MatchQuery() {
public boolean isMatch(Object candidate) {
return false;
}
};
- Query B = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ IQuery B = new ContextQuery() {
+ public Collector perform(Iterator iterator) {
// TODO Auto-generated method stub
return null;
}
};
- Query C = new MatchQuery() {
+ IQuery C = new MatchQuery() {
public boolean isMatch(Object candidate) {
return false;
}
};
- CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {A, B, C}, true);
+ CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {A, B, C}, true);
assertTrue("1.0", !(compoundQuery instanceof IMatchQuery));
- assertEquals("1.1", 3, compoundQuery.getQueries().length);
- assertEquals("1.2", A, compoundQuery.getQueries()[0]);
- assertEquals("1.3", B, compoundQuery.getQueries()[1]);
- assertEquals("1.4", C, compoundQuery.getQueries()[2]);
+ assertEquals("1.1", 3, compoundQuery.getQueries().size());
+ assertEquals("1.2", A, compoundQuery.getQueries().get(0));
+ assertEquals("1.3", B, compoundQuery.getQueries().get(1));
+ assertEquals("1.4", C, compoundQuery.getQueries().get(2));
}
public void testCompoundNoMatchQueries() {
- Query A = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ IQuery A = new ContextQuery() {
+ public Collector perform(Iterator iterator) {
// TODO Auto-generated method stub
return null;
}
};
- Query B = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ IQuery B = new ContextQuery() {
+ public Collector perform(Iterator iterator) {
// TODO Auto-generated method stub
return null;
}
};
- Query C = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ IQuery C = new ContextQuery() {
+ public Collector perform(Iterator iterator) {
// TODO Auto-generated method stub
return null;
}
};
- CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {A, B, C}, true);
+ CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {A, B, C}, true);
assertTrue("1.0", !(compoundQuery instanceof IMatchQuery));
- assertEquals("1.1", 3, compoundQuery.getQueries().length);
- assertEquals("1.2", A, compoundQuery.getQueries()[0]);
- assertEquals("1.3", B, compoundQuery.getQueries()[1]);
- assertEquals("1.4", C, compoundQuery.getQueries()[2]);
+ assertEquals("1.1", 3, compoundQuery.getQueries().size());
+ assertEquals("1.2", A, compoundQuery.getQueries().get(0));
+ assertEquals("1.3", B, compoundQuery.getQueries().get(1));
+ assertEquals("1.4", C, compoundQuery.getQueries().get(2));
}
public void testIntersection() {
- Query ABC = new MatchQuery() {
+ IQuery ABC = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (candidate.equals("A") || candidate.equals("B") || candidate.equals("C"))
return true;
@@ -204,7 +210,7 @@ public class AggregateQueryTest extends TestCase {
}
};
- Query BCDE = new MatchQuery() {
+ IQuery BCDE = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (candidate.equals("B") || candidate.equals("C") || candidate.equals("D") || candidate.equals("E"))
return true;
@@ -212,16 +218,17 @@ public class AggregateQueryTest extends TestCase {
}
};
- CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {ABC, BCDE}, true);
- Collector result = compoundQuery.perform(getABCDE().iterator(), new Collector());
- assertEquals("1.0", result.size(), 2);
- assertTrue("1.1", result.toCollection().contains("B"));
- assertTrue("1.2", result.toCollection().contains("C"));
+ CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {ABC, BCDE}, true);
+ IQueryResult result = compoundQuery.perform(getABCDE().iterator());
+ assertEquals("1.0", AbstractProvisioningTest.queryResultSize(result), 2);
+ AbstractProvisioningTest.assertContains("1.1", result, "B");
+ AbstractProvisioningTest.assertContains("1.2", result, "C");
}
public void testIntersection2() {
- Query ABC = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ IQuery ABC = new ContextQuery() {
+ public Collector perform(Iterator iterator) {
+ Collector result = new Collector();
while (iterator.hasNext()) {
Object o = iterator.next();
if (o.equals("A") || o.equals("B") || o.equals("C"))
@@ -231,8 +238,9 @@ public class AggregateQueryTest extends TestCase {
}
};
- Query BCDE = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ IQuery BCDE = new ContextQuery() {
+ public Collector perform(Iterator iterator) {
+ Collector result = new Collector();
while (iterator.hasNext()) {
Object o = iterator.next();
if (o.equals("B") || o.equals("C") || o.equals("D") || o.equals("E"))
@@ -242,15 +250,15 @@ public class AggregateQueryTest extends TestCase {
}
};
- CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {ABC, BCDE}, true);
- Collector result = compoundQuery.perform(getABCDE().iterator(), new Collector());
- assertEquals("1.0", result.size(), 2);
- assertTrue("1.1", result.toCollection().contains("B"));
- assertTrue("1.2", result.toCollection().contains("C"));
+ CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {ABC, BCDE}, true);
+ IQueryResult result = compoundQuery.perform(getABCDE().iterator());
+ assertEquals("1.0", AbstractProvisioningTest.queryResultSize(result), 2);
+ AbstractProvisioningTest.assertContains("1.1", result, "B");
+ AbstractProvisioningTest.assertContains("1.2", result, "C");
}
public void testUnion() {
- Query ABC = new MatchQuery() {
+ IQuery ABC = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (candidate.equals("A") || candidate.equals("B") || candidate.equals("C"))
return true;
@@ -258,7 +266,7 @@ public class AggregateQueryTest extends TestCase {
}
};
- Query BCDE = new MatchQuery() {
+ IQuery BCDE = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (candidate.equals("B") || candidate.equals("C") || candidate.equals("D") || candidate.equals("E"))
return true;
@@ -266,19 +274,20 @@ public class AggregateQueryTest extends TestCase {
}
};
- CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {ABC, BCDE}, false);
- Collector result = compoundQuery.perform(getABCDE().iterator(), new Collector());
- assertEquals("1.0", result.size(), 5);
- assertTrue("1.1", result.toCollection().contains("A"));
- assertTrue("1.2", result.toCollection().contains("B"));
- assertTrue("1.3", result.toCollection().contains("C"));
- assertTrue("1.4", result.toCollection().contains("D"));
- assertTrue("1.5", result.toCollection().contains("E"));
+ CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {ABC, BCDE}, false);
+ IQueryResult result = compoundQuery.perform(getABCDE().iterator());
+ assertEquals("1.0", AbstractProvisioningTest.queryResultSize(result), 5);
+ AbstractProvisioningTest.assertContains("1.1", result, "A");
+ AbstractProvisioningTest.assertContains("1.2", result, "B");
+ AbstractProvisioningTest.assertContains("1.3", result, "C");
+ AbstractProvisioningTest.assertContains("1.4", result, "D");
+ AbstractProvisioningTest.assertContains("1.5", result, "E");
}
public void testUnion2() {
- Query ABC = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ IQuery ABC = new ContextQuery() {
+ public Collector perform(Iterator iterator) {
+ Collector result = new Collector();
while (iterator.hasNext()) {
Object o = iterator.next();
if (o.equals("A") || o.equals("B") || o.equals("C"))
@@ -288,8 +297,9 @@ public class AggregateQueryTest extends TestCase {
}
};
- Query BCDE = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ IQuery BCDE = new ContextQuery() {
+ public Collector perform(Iterator iterator) {
+ Collector result = new Collector();
while (iterator.hasNext()) {
Object o = iterator.next();
if (o.equals("B") || o.equals("C") || o.equals("D") || o.equals("E"))
@@ -299,13 +309,13 @@ public class AggregateQueryTest extends TestCase {
}
};
- CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new Query[] {ABC, BCDE}, false);
- Collector result = compoundQuery.perform(getABCDE().iterator(), new Collector());
- assertEquals("1.0", result.size(), 5);
- assertTrue("1.1", result.toCollection().contains("A"));
- assertTrue("1.2", result.toCollection().contains("B"));
- assertTrue("1.3", result.toCollection().contains("C"));
- assertTrue("1.4", result.toCollection().contains("D"));
- assertTrue("1.5", result.toCollection().contains("E"));
+ CompoundQuery compoundQuery = CompoundQuery.createCompoundQuery(new IQuery[] {ABC, BCDE}, false);
+ IQueryResult result = compoundQuery.perform(getABCDE().iterator());
+ assertEquals("1.0", AbstractProvisioningTest.queryResultSize(result), 5);
+ AbstractProvisioningTest.assertContains("1.1", result, "A");
+ AbstractProvisioningTest.assertContains("1.2", result, "B");
+ AbstractProvisioningTest.assertContains("1.3", result, "C");
+ AbstractProvisioningTest.assertContains("1.4", result, "D");
+ AbstractProvisioningTest.assertContains("1.5", result, "E");
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CollectorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CollectorTest.java
index 7e12817bc..8b2760129 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CollectorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CollectorTest.java
@@ -12,7 +12,7 @@
package org.eclipse.equinox.p2.tests.core;
import java.util.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
+import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
@@ -47,7 +47,7 @@ public class CollectorTest extends AbstractProvisioningTest {
public void testCompositeCollectors() {
String[] s = new String[] {"A", "B", "C", "D", "E", "F", "G", "1", "2", "3", "4", "5", "6", "7"};
List list = Arrays.asList(s);
- Query numeric = new MatchQuery() {
+ IQuery numeric = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (((String) candidate).compareTo("0") > 0 && ((String) candidate).compareTo("8") < 0) {
@@ -57,7 +57,7 @@ public class CollectorTest extends AbstractProvisioningTest {
}
};
- Query fourOrFiveOrABC = new MatchQuery() {
+ IQuery fourOrFiveOrABC = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (((String) candidate).equals("4") || ((String) candidate).equals("5") || ((String) candidate).equals("A") || ((String) candidate).equals("B") || ((String) candidate).equals("C")) {
return true;
@@ -65,20 +65,19 @@ public class CollectorTest extends AbstractProvisioningTest {
return false;
}
};
- Collector collector = numeric.perform(list.iterator(), new Collector());
- assertEquals("1.0", 7, collector.toCollection().size());
-
- collector = collector.query(fourOrFiveOrABC, new Collector(), null);
- Collection collection = collector.toCollection();
- assertEquals("2.0", 2, collection.size());
- assertTrue("2.1", collection.contains("4"));
- assertTrue("2.2", collection.contains("5"));
+ IQueryResult queryResult = numeric.perform(list.iterator());
+ assertEquals("1.0", 7, queryResultSize(queryResult));
+
+ queryResult = queryResult.query(fourOrFiveOrABC, null);
+ assertEquals("2.0", 2, queryResultSize(queryResult));
+ assertContains("2.1", queryResult, "4");
+ assertContains("2.2", queryResult, "5");
}
public void testSameCollector() {
String[] s = new String[] {"A", "B", "C", "D", "E", "F", "G", "1", "2", "3", "4", "5", "6", "7"};
List list = Arrays.asList(s);
- Query numeric = new MatchQuery() {
+ IQuery numeric = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (((String) candidate).compareTo("0") > 0 && ((String) candidate).compareTo("8") < 0) {
@@ -88,7 +87,7 @@ public class CollectorTest extends AbstractProvisioningTest {
}
};
- Query fourOrFiveOrABC = new MatchQuery() {
+ IQuery fourOrFiveOrABC = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (((String) candidate).equals("4") || ((String) candidate).equals("5") || ((String) candidate).equals("A") || ((String) candidate).equals("B") || ((String) candidate).equals("C")) {
return true;
@@ -96,11 +95,12 @@ public class CollectorTest extends AbstractProvisioningTest {
return false;
}
};
- Collector collector = numeric.perform(list.iterator(), new Collector());
- assertEquals("1.0", 7, collector.toCollection().size());
+ Collector collector = new Collector();
+ collector.addAll(numeric.perform(list.iterator()));
+ assertEquals("1.0", 7, collector.unmodifiableSet().size());
- collector = collector.query(fourOrFiveOrABC, collector, null);
- Collection collection = collector.toCollection();
+ collector.addAll(collector.query(fourOrFiveOrABC, null));
+ Collection collection = collector.unmodifiableSet();
assertEquals("2.0", 7, collection.size());
}
@@ -110,7 +110,7 @@ public class CollectorTest extends AbstractProvisioningTest {
public void testEmptyCompositeCollectors() {
String[] s = new String[] {"A", "B", "C", "D", "E", "F", "G", "1", "2", "3", "4", "5", "6", "7"};
List list = Arrays.asList(s);
- Query eightOrNine = new MatchQuery() {
+ IQuery eightOrNine = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (((String) candidate).compareTo("8") > 0 && ((String) candidate).compareTo("9") < 0) {
@@ -120,7 +120,7 @@ public class CollectorTest extends AbstractProvisioningTest {
}
};
- Query fourOrFiveOrABC = new MatchQuery() {
+ IQuery fourOrFiveOrABC = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (((String) candidate).equals("4") || ((String) candidate).equals("5") || ((String) candidate).equals("A") || ((String) candidate).equals("B") || ((String) candidate).equals("C")) {
return true;
@@ -128,17 +128,16 @@ public class CollectorTest extends AbstractProvisioningTest {
return false;
}
};
- Collector collector = eightOrNine.perform(list.iterator(), new Collector());
- assertEquals("1.0", 0, collector.toCollection().size());
+ IQueryResult queryResult = eightOrNine.perform(list.iterator());
+ assertTrue("1.0", queryResult.isEmpty());
- collector = collector.query(fourOrFiveOrABC, new Collector(), null);
- Collection collection = collector.toCollection();
- assertEquals("2.0", 0, collection.size());
+ queryResult = queryResult.query(fourOrFiveOrABC, null);
+ assertTrue("2.0", queryResult.isEmpty());
}
public void testToCollection() {
Collector collector = new Collector();
- Collection result = collector.toCollection();
+ Collection result = collector.unmodifiableSet();
assertEquals("1.0", 0, result.size());
//collection should be immutable
try {
@@ -150,7 +149,7 @@ public class CollectorTest extends AbstractProvisioningTest {
String value = "value";
collector.accept(value);
- result = collector.toCollection();
+ result = collector.unmodifiableSet();
assertEquals("2.0", 1, result.size());
assertEquals("2.1", value, result.iterator().next());
//collection should be immutable
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java
index 16783c3f7..c05dd804a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/CompoundQueryableTest.java
@@ -9,11 +9,13 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.core;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Iterator;
import junit.framework.TestCase;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.tests.harness.TestProgressMonitor;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
* Tests the compound queryable
@@ -56,10 +58,11 @@ public class CompoundQueryableTest extends TestCase {
IQueryable queryable1 = new IQueryable() {
Integer[] elements = new Integer[] {1, 2, 3, 4, 5};
- public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
+ public IQueryResult query(IQuery query, IProgressMonitor monitor) {
+ IQueryResult collector;
try {
monitor.beginTask("", 10);
- collector = query.perform(createIterator(elements), collector);
+ collector = query.perform(createIterator(elements));
monitor.worked(10);
} finally {
monitor.done();
@@ -71,10 +74,11 @@ public class CompoundQueryableTest extends TestCase {
IQueryable queryable2 = new IQueryable() {
Integer[] elements = new Integer[] {4, 6, 8, 10, 12};
- public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
+ public IQueryResult query(IQuery query, IProgressMonitor monitor) {
+ IQueryResult collector;
try {
monitor.beginTask("", 10);
- collector = query.perform(createIterator(elements), collector);
+ collector = query.perform(createIterator(elements));
monitor.worked(10);
} finally {
monitor.done();
@@ -86,10 +90,11 @@ public class CompoundQueryableTest extends TestCase {
IQueryable queryable3 = new IQueryable() {
Integer[] elements = new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
- public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
+ public IQueryResult query(IQuery query, IProgressMonitor monitor) {
+ IQueryResult collector;
try {
monitor.beginTask("", 10);
- collector = query.perform(createIterator(elements), collector);
+ collector = query.perform(createIterator(elements));
monitor.worked(10);
} finally {
monitor.done();
@@ -98,7 +103,7 @@ public class CompoundQueryableTest extends TestCase {
}
};
- Query matchQuery = new MatchQuery() {
+ IQuery matchQuery = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (candidate instanceof Integer) {
@@ -110,7 +115,7 @@ public class CompoundQueryableTest extends TestCase {
}
};
- Query matchMod4query = new MatchQuery() {
+ IQuery matchMod4query = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (candidate instanceof Integer) {
int x = ((Integer) candidate).intValue();
@@ -121,9 +126,10 @@ public class CompoundQueryableTest extends TestCase {
}
};
- Query contextQuery = new ContextQuery() {
+ IQuery contextQuery = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ public Collector perform(Iterator iterator) {
+ Collector result = new Collector();
while (iterator.hasNext()) {
Object o = iterator.next();
if (o instanceof Integer && ((Integer) o).intValue() % 2 == 0) {
@@ -135,8 +141,9 @@ public class CompoundQueryableTest extends TestCase {
};
- Query greatestNumberQuery = new ContextQuery() {
- public Collector perform(Iterator iterator, Collector result) {
+ IQuery greatestNumberQuery = new ContextQuery() {
+ public Collector perform(Iterator iterator) {
+ Collector result = new Collector();
int greatest = Integer.MIN_VALUE;
while (iterator.hasNext()) {
int item = ((Integer) iterator.next()).intValue();
@@ -151,208 +158,129 @@ public class CompoundQueryableTest extends TestCase {
};
public void testMatchQuery() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
+ CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2);
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- Collector collector = cQueryable.query(matchQuery, new Collector(), monitor);
- assertEquals("1.0", 6, collector.size());
- Collection collection = collector.toCollection();
- assertTrue("1.1", collection.contains(2));
- assertTrue("1.2", collection.contains(4));
- assertTrue("1.3", collection.contains(6));
- assertTrue("1.4", collection.contains(8));
- assertTrue("1.5", collection.contains(10));
- assertTrue("1.6", collection.contains(12));
+ IQueryResult queryResult = cQueryable.query(matchQuery, monitor);
+ assertEquals("1.0", 6, AbstractProvisioningTest.queryResultSize(queryResult));
+ AbstractProvisioningTest.assertContains("1.1", queryResult, 2);
+ AbstractProvisioningTest.assertContains("1.2", queryResult, 4);
+ AbstractProvisioningTest.assertContains("1.3", queryResult, 6);
+ AbstractProvisioningTest.assertContains("1.4", queryResult, 8);
+ AbstractProvisioningTest.assertContains("1.5", queryResult, 10);
+ AbstractProvisioningTest.assertContains("1.6", queryResult, 12);
}
public void testSingleQueryable() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1});
+ CompoundQueryable cQueryable = new CompoundQueryable(queryable1);
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- Collector collector = cQueryable.query(matchQuery, new Collector(), monitor);
- assertEquals("1.0", 2, collector.size());
- Collection collection = collector.toCollection();
- assertTrue("1.1", collection.contains(2));
- assertTrue("1.2", collection.contains(4));
+ IQueryResult queryResult = cQueryable.query(matchQuery, monitor);
+ assertEquals("1.0", 2, AbstractProvisioningTest.queryResultSize(queryResult));
+ AbstractProvisioningTest.assertContains("1.1", queryResult, 2);
+ AbstractProvisioningTest.assertContains("1.2", queryResult, 4);
}
public void testSingleContextQuery() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1});
+ CompoundQueryable cQueryable = new CompoundQueryable(queryable1);
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- Collector collector = cQueryable.query(greatestNumberQuery, new Collector(), monitor);
- assertEquals("1.0", 1, collector.size());
- Collection collection = collector.toCollection();
- assertTrue("1.1", collection.contains(5));
+ IQueryResult queryResult = cQueryable.query(greatestNumberQuery, monitor);
+ assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(queryResult));
+ AbstractProvisioningTest.assertContains("1.1", queryResult, 5);
}
public void testMultipleContextQueries() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
+ CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2);
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- Collector collector = cQueryable.query(greatestNumberQuery, new Collector(), monitor);
- assertEquals("1.0", 1, collector.size());
- Collection collection = collector.toCollection();
- assertTrue("1.1", collection.contains(12));
- }
-
- public void testListCollector1() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
- CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- Collector collector = cQueryable.query(contextQuery, cQueryable.new ListCollector(), monitor);
-
- // We use a list so there should be 7 elements (4 is there twice)
- assertEquals("1.0", 7, collector.size());
- Collection collection = collector.toCollection();
- assertTrue("1.1", collection.contains(2));
- assertTrue("1.2", collection.contains(4));
- assertTrue("1.3", collection.contains(6));
- assertTrue("1.4", collection.contains(8));
- assertTrue("1.5", collection.contains(10));
- assertTrue("1.6", collection.contains(12));
- }
-
- public void testListCollector_isEmpty() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
- CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- Collector collector = cQueryable.new ListCollector();
- assertTrue("1.0", collector.isEmpty());
- collector = cQueryable.query(contextQuery, cQueryable.new ListCollector(), monitor);
- assertFalse("1.0", collector.isEmpty());
- }
-
- public void testListCollector_getCollection() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
- CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
-
- Collector collector = cQueryable.query(contextQuery, cQueryable.new ListCollector(), monitor);
-
- // We use a list so there should be 7 elements (4 is there twice)
- assertEquals("1.0", 7, collector.size());
- Integer[] array = (Integer[]) collector.toArray(Integer.class);
- Collection collection = Arrays.asList(array);
- assertTrue("1.1", collection.contains(2));
- assertTrue("1.2", collection.contains(4));
- assertTrue("1.3", collection.contains(6));
- assertTrue("1.4", collection.contains(8));
- assertTrue("1.5", collection.contains(10));
- assertTrue("1.6", collection.contains(12));
- }
-
- public void testListCollector_toArray() {
- final CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
- CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
-
- class CustomListCollector extends CompoundQueryable.ListCollector {
-
- public CustomListCollector() {
- cQueryable.super();
- }
-
- public Collection getCollection() {
- return super.getCollection();
- }
- }
-
- CustomListCollector collector = (CustomListCollector) cQueryable.query(contextQuery, new CustomListCollector(), monitor);
-
- // We use a list so there should be 7 elements (4 is there twice)
- assertEquals("1.0", 7, collector.size());
- Collection collection = collector.getCollection();
- assertTrue("1.1", collection.contains(2));
- assertTrue("1.2", collection.contains(4));
- assertTrue("1.3", collection.contains(6));
- assertTrue("1.4", collection.contains(8));
- assertTrue("1.5", collection.contains(10));
- assertTrue("1.6", collection.contains(12));
+ IQueryResult queryResult = cQueryable.query(greatestNumberQuery, monitor);
+ assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(queryResult));
+ AbstractProvisioningTest.assertContains("1.1", queryResult, 12);
}
public void testCompoundMatchAndQuery() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
+ CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2);
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- Collector collector = cQueryable.query(CompoundQuery.createCompoundQuery(new Query[] {matchQuery, matchMod4query}, true), new Collector(), monitor);
- assertEquals("1.0", 3, collector.size());
- Collection collection = collector.toCollection();
- assertTrue("1.2", collection.contains(4));
- assertTrue("1.4", collection.contains(8));
- assertTrue("1.6", collection.contains(12));
+ IQueryResult queryResult = cQueryable.query(CompoundQuery.createCompoundQuery(new IQuery[] {matchQuery, matchMod4query}, true), monitor);
+ assertEquals("1.0", 3, AbstractProvisioningTest.queryResultSize(queryResult));
+ AbstractProvisioningTest.assertContains("1.2", queryResult, 4);
+ AbstractProvisioningTest.assertContains("1.4", queryResult, 8);
+ AbstractProvisioningTest.assertContains("1.6", queryResult, 12);
}
public void testCompoundMatchOrQuery() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
+ CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2);
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- Collector collector = cQueryable.query(CompoundQuery.createCompoundQuery(new Query[] {matchQuery, matchMod4query}, false), new Collector(), monitor);
- assertEquals("1.0", 6, collector.size());
- Collection collection = collector.toCollection();
- assertTrue("1.2", collection.contains(2));
- assertTrue("1.2", collection.contains(4));
- assertTrue("1.2", collection.contains(6));
- assertTrue("1.4", collection.contains(8));
- assertTrue("1.2", collection.contains(10));
- assertTrue("1.6", collection.contains(12));
+ IQueryResult queryResult = cQueryable.query(CompoundQuery.createCompoundQuery(new IQuery[] {matchQuery, matchMod4query}, false), monitor);
+ assertEquals("1.0", 6, AbstractProvisioningTest.queryResultSize(queryResult));
+ AbstractProvisioningTest.assertContains("1.2", queryResult, 2);
+ AbstractProvisioningTest.assertContains("1.2", queryResult, 4);
+ AbstractProvisioningTest.assertContains("1.2", queryResult, 6);
+ AbstractProvisioningTest.assertContains("1.4", queryResult, 8);
+ AbstractProvisioningTest.assertContains("1.2", queryResult, 10);
+ AbstractProvisioningTest.assertContains("1.6", queryResult, 12);
}
public void testMatchQueryProgressMonitor() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
+ CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2);
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- cQueryable.query(matchQuery, new Collector(), monitor);
+ cQueryable.query(matchQuery, monitor);
assertTrue("1.0", monitor.isDone());
assertTrue("1.1", monitor.isWorkDone());
}
public void testSingleQueryableProgressMonitor() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1});
+ CompoundQueryable cQueryable = new CompoundQueryable(queryable1);
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- cQueryable.query(matchQuery, new Collector(), monitor);
+ cQueryable.query(matchQuery, monitor);
assertTrue("1.0", monitor.isDone());
assertTrue("1.1", monitor.isWorkDone());
}
public void testSingleContextQueryProgressMonitor() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1});
+ CompoundQueryable cQueryable = new CompoundQueryable(queryable1);
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- cQueryable.query(greatestNumberQuery, new Collector(), monitor);
+ cQueryable.query(greatestNumberQuery, monitor);
assertTrue("1.0", monitor.isDone());
assertTrue("1.1", monitor.isWorkDone());
}
public void testMultipleContextQueriesProgressMonitor() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
+ CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2);
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- cQueryable.query(greatestNumberQuery, new Collector(), monitor);
+ cQueryable.query(greatestNumberQuery, monitor);
assertTrue("1.0", monitor.isDone());
assertTrue("1.1", monitor.isWorkDone());
}
public void testNullProgressMonitor() {
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {queryable1, queryable2});
- cQueryable.query(greatestNumberQuery, new Collector(), null);
+ CompoundQueryable cQueryable = new CompoundQueryable(queryable1, queryable2);
+ cQueryable.query(greatestNumberQuery, null);
// this is the same as above will null passed in, this should not throw any exceptions
}
public void testDoubleCompoundContextOrQuery() {
- CompoundQueryable cQueryable1 = new CompoundQueryable(new IQueryable[] {queryable3, queryable2});
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {cQueryable1, queryable1});
+ CompoundQueryable cQueryable1 = new CompoundQueryable(queryable3, queryable2);
+ CompoundQueryable cQueryable = new CompoundQueryable(cQueryable1, queryable1);
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- Collector collector = cQueryable.query(CompoundQuery.createCompoundQuery(new Query[] {contextQuery, greatestNumberQuery}, false), new Collector(), monitor);
- assertEquals("1.0", 7, collector.size());
- Collection collection = collector.toCollection();
- assertTrue("1.2", collection.contains(2));
- assertTrue("1.2", collection.contains(4));
- assertTrue("1.2", collection.contains(6));
- assertTrue("1.4", collection.contains(8));
- assertTrue("1.2", collection.contains(10));
- assertTrue("1.6", collection.contains(12));
- assertTrue("1.6", collection.contains(13));
+ IQueryResult queryResult = cQueryable.query(CompoundQuery.createCompoundQuery(new IQuery[] {contextQuery, greatestNumberQuery}, false), monitor);
+ assertEquals("1.0", 7, AbstractProvisioningTest.queryResultSize(queryResult));
+ AbstractProvisioningTest.assertContains("1.2", queryResult, 2);
+ AbstractProvisioningTest.assertContains("1.2", queryResult, 4);
+ AbstractProvisioningTest.assertContains("1.2", queryResult, 6);
+ AbstractProvisioningTest.assertContains("1.4", queryResult, 8);
+ AbstractProvisioningTest.assertContains("1.2", queryResult, 10);
+ AbstractProvisioningTest.assertContains("1.6", queryResult, 12);
+ AbstractProvisioningTest.assertContains("1.6", queryResult, 13);
assertTrue("1.0", monitor.isDone());
assertTrue("1.1", monitor.isWorkDone());
}
public void testDoubleCompositeQuery() {
- CompoundQueryable cQueryable1 = new CompoundQueryable(new IQueryable[] {queryable3, queryable2});
- CompoundQueryable cQueryable = new CompoundQueryable(new IQueryable[] {cQueryable1, queryable1});
+ CompoundQueryable cQueryable1 = new CompoundQueryable(queryable3, queryable2);
+ CompoundQueryable cQueryable = new CompoundQueryable(cQueryable1, queryable1);
CompoundQueryTestProgressMonitor monitor = new CompoundQueryTestProgressMonitor();
- Collector collector = cQueryable.query(new CompositeQuery(new Query[] {contextQuery, greatestNumberQuery}), new Collector(), monitor);
- assertEquals("1.0", 1, collector.size());
- Collection collection = collector.toCollection();
- assertTrue("1.2", collection.contains(12));
+ IQueryResult queryResult = cQueryable.query(new PipedQuery(contextQuery, greatestNumberQuery), monitor);
+ assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(queryResult));
+ AbstractProvisioningTest.assertContains("1.2", queryResult, 12);
assertTrue("1.0", monitor.isDone());
assertTrue("1.1", monitor.isWorkDone());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery1.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery1.java
index 22d98ddbc..b212c8c28 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery1.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery1.java
@@ -9,7 +9,7 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.core;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.MatchQuery;
+import org.eclipse.equinox.p2.query.MatchQuery;
public class PropertyLookupQuery1 extends MatchQuery {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery2.java
index 7564cc633..e7e45457a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery2.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/PropertyLookupQuery2.java
@@ -10,8 +10,8 @@
package org.eclipse.equinox.p2.tests.core;
import java.util.Iterator;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.ContextQuery;
+import org.eclipse.equinox.p2.query.Collector;
+import org.eclipse.equinox.p2.query.ContextQuery;
public class PropertyLookupQuery2 extends ContextQuery {
@@ -19,7 +19,7 @@ public class PropertyLookupQuery2 extends ContextQuery {
return "bar";
}
- public Collector perform(Iterator iterator, Collector result) {
+ public Collector perform(Iterator iterator) {
return null;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/QueryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/QueryTest.java
index 81c2d9ca6..e05b16f25 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/QueryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/core/QueryTest.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.core;
-import java.util.*;
+import java.util.Arrays;
+import java.util.List;
import junit.framework.TestCase;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
* Tests for the {@link org.eclipse.equinox.internal.provisional.p2.query.Query} class.
@@ -63,29 +65,16 @@ public class QueryTest extends TestCase {
}
/**
- * A collector that only accepts the first element and then short-circuits.
- */
- static class ShortCircuitCollector extends Collector {
- @Override
- public boolean accept(Object object) {
- super.accept(object);
- return false;
- }
- }
-
- /**
- * Tests a simple perform where all items match.
- */
+ * Tests a simple perform where all items match.
+ */
public void testPerformSimple() {
List items = Arrays.asList("red", "green", "blue");
- Query query = new AnyStringQuery();
- Collector collector = new Collector();
- query.perform(items.iterator(), collector);
- Collection result = collector.toCollection();
- assertEquals("1.0", 3, result.size());
- assertTrue("1.1", result.contains("red"));
- assertTrue("1.2", result.contains("green"));
- assertTrue("1.3", result.contains("blue"));
+ IQuery query = new AnyStringQuery();
+ IQueryResult collector = query.perform(items.iterator());
+ assertEquals("1.0", 3, AbstractProvisioningTest.queryResultSize(collector));
+ AbstractProvisioningTest.assertContains("1.1", collector, "red");
+ AbstractProvisioningTest.assertContains("1.2", collector, "green");
+ AbstractProvisioningTest.assertContains("1.3", collector, "blue");
}
/**
@@ -93,53 +82,50 @@ public class QueryTest extends TestCase {
*/
public void testPerformSomeMatches() {
List items = Arrays.asList(new Object(), "green", new Object());
- Query query = new AnyStringQuery();
- Collector collector = new Collector();
- query.perform(items.iterator(), collector);
- Collection result = collector.toCollection();
- assertEquals("1.0", 1, result.size());
- assertTrue("1.1", result.contains("green"));
+ IQuery query = new AnyStringQuery();
+ IQueryResult collector = query.perform(items.iterator());
+ assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(collector));
+ AbstractProvisioningTest.assertContains("1.1", collector, "green");
}
public void testPerformHooks() {
List items = Arrays.asList("red", "green", "blue");
PerformHookQuery query = new PerformHookQuery();
- Collector collector = new Collector();
assertFalse("1.0", query.isComplete());
assertFalse("1.1", query.isPrepared());
- query.perform(items.iterator(), collector);
+ query.perform(items.iterator());
assertTrue("1.2", query.isComplete());
assertTrue("1.3", query.isPrepared());
assertTrue("1.4", query.areHooksExecutedProperly());
}
public void testPropertyLookupMatchQuery() {
- Query query1 = new PropertyLookupQuery1();
+ IQuery query1 = new PropertyLookupQuery1();
Object property = query1.getProperty("SomeProperty");
assertEquals("1.0", "foo", property);
}
public void testPropertyLookupContextQuery() {
- Query query1 = new PropertyLookupQuery2();
+ IQuery query1 = new PropertyLookupQuery2();
Object property = query1.getProperty("SomeOtherProperty");
assertEquals("1.0", "bar", property);
}
public void testPropertyLookupInvalidProperty1() {
- Query query1 = new PropertyLookupQuery1();
+ IQuery query1 = new PropertyLookupQuery1();
Object property = query1.getProperty("ThisProperty");
assertEquals("1.0", null, property);
}
public void testPropertyLookupInvalidProperty2() {
- Query query1 = new PropertyLookupQuery1();
+ IQuery query1 = new PropertyLookupQuery1();
Object property = query1.getProperty("SomeOtherProperty");
assertEquals("1.0", null, property);
}
public void testIDLookup() {
- Query query1 = new PropertyLookupQuery1();
- Query query2 = new PropertyLookupQuery2();
+ IQuery query1 = new PropertyLookupQuery1();
+ IQuery query2 = new PropertyLookupQuery2();
assertEquals("1.0", "org.eclipse.equinox.p2.tests.core.PropertyLookupQuery1", query1.getId());
assertEquals("1.0", "org.eclipse.equinox.p2.tests.core.PropertyLookupQuery2", query2.getId());
}
@@ -147,11 +133,10 @@ public class QueryTest extends TestCase {
public void testPerformHooksOnQueryFail() {
List items = Arrays.asList("red", new Object());
PerformHookQuery query = new PerformHookQuery();
- Collector collector = new Collector();
assertFalse("1.0", query.isComplete());
assertFalse("1.1", query.isPrepared());
try {
- query.perform(items.iterator(), collector);
+ query.perform(items.iterator());
} catch (RuntimeException e) {
// expected
}
@@ -162,15 +147,14 @@ public class QueryTest extends TestCase {
public void testPreAndPostCompoundANDQuery() {
List items = Arrays.asList("red", "green", "blue");
- Collector collector = new Collector();
PerformHookQuery query1 = new PerformHookQuery();
PerformHookQuery query2 = new PerformHookQuery();
- CompoundQuery cQuery = CompoundQuery.createCompoundQuery(new Query[] {query1, query2}, true);
+ CompoundQuery cQuery = CompoundQuery.createCompoundQuery(new IQuery[] {query1, query2}, true);
assertFalse("1.0", query1.isComplete());
assertFalse("1.1", query1.isPrepared());
assertFalse("1.2", query2.isComplete());
assertFalse("1.3", query2.isPrepared());
- cQuery.perform(items.iterator(), collector);
+ cQuery.perform(items.iterator());
assertTrue("1.4", query1.isComplete());
assertTrue("1.5", query1.isPrepared());
assertTrue("1.6", query2.isComplete());
@@ -181,15 +165,14 @@ public class QueryTest extends TestCase {
public void testPreAndPostCompoundOrQuery() {
List items = Arrays.asList("red", "green", "blue");
- Collector collector = new Collector();
PerformHookQuery query1 = new PerformHookQuery();
PerformHookQuery query2 = new PerformHookQuery();
- CompoundQuery cQuery = CompoundQuery.createCompoundQuery(new Query[] {query1, query2}, false);
+ CompoundQuery cQuery = CompoundQuery.createCompoundQuery(new IQuery[] {query1, query2}, false);
assertFalse("1.0", query1.isComplete());
assertFalse("1.1", query1.isPrepared());
assertFalse("1.2", query2.isComplete());
assertFalse("1.3", query2.isPrepared());
- cQuery.perform(items.iterator(), collector);
+ cQuery.perform(items.iterator());
assertTrue("1.4", query1.isComplete());
assertTrue("1.5", query1.isPrepared());
assertTrue("1.6", query2.isComplete());
@@ -200,15 +183,14 @@ public class QueryTest extends TestCase {
public void testPreAndPostCompositeQuery() {
List items = Arrays.asList("red", "green", "blue");
- Collector collector = new Collector();
PerformHookQuery query1 = new PerformHookQuery();
PerformHookQuery query2 = new PerformHookQuery();
- CompositeQuery cQuery = new CompositeQuery(new Query[] {query1, query2});
+ PipedQuery cQuery = new PipedQuery(query1, query2);
assertFalse("1.0", query1.isComplete());
assertFalse("1.1", query1.isPrepared());
assertFalse("1.2", query2.isComplete());
assertFalse("1.3", query2.isPrepared());
- cQuery.perform(items.iterator(), collector);
+ cQuery.perform(items.iterator());
assertTrue("1.4", query1.isComplete());
assertTrue("1.5", query1.isPrepared());
assertTrue("1.6", query2.isComplete());
@@ -219,16 +201,15 @@ public class QueryTest extends TestCase {
public void testPreAndPostCompoundQueryFail() {
List items = Arrays.asList("red", new Object());
- Collector collector = new Collector();
PerformHookQuery query1 = new PerformHookQuery();
PerformHookQuery query2 = new PerformHookQuery();
- CompoundQuery cQuery = CompoundQuery.createCompoundQuery(new Query[] {query1, query2}, true);
+ CompoundQuery cQuery = CompoundQuery.createCompoundQuery(new IQuery[] {query1, query2}, true);
assertFalse("1.0", query1.isComplete());
assertFalse("1.1", query1.isPrepared());
assertFalse("1.2", query2.isComplete());
assertFalse("1.3", query2.isPrepared());
try {
- cQuery.perform(items.iterator(), collector);
+ cQuery.perform(items.iterator());
fail("This query is expected to fail");
} catch (RuntimeException e) {
// expected
@@ -243,16 +224,15 @@ public class QueryTest extends TestCase {
public void testPreAndPostCompositeQueryFail() {
List items = Arrays.asList("red", new Object());
- Collector collector = new Collector();
PerformHookQuery query1 = new PerformHookQuery();
PerformHookQuery query2 = new PerformHookQuery();
- CompositeQuery cQuery = new CompositeQuery(new Query[] {query1, query2});
+ PipedQuery cQuery = new PipedQuery(query1, query2);
assertFalse("1.0", query1.isComplete());
assertFalse("1.1", query1.isPrepared());
assertFalse("1.2", query2.isComplete());
assertFalse("1.3", query2.isPrepared());
try {
- cQuery.perform(items.iterator(), collector);
+ cQuery.perform(items.iterator());
fail("This query is expected to fail");
} catch (RuntimeException e) {
// expected
@@ -265,17 +245,59 @@ public class QueryTest extends TestCase {
assertTrue("1.9", query2.areHooksExecutedProperly());
}
- /**
- * Tests a perform where the collector decides to short-circuit the query.
- */
- public void testShortCircuit() {
+ public void testLimitQuery() {
List items = Arrays.asList("red", "green", "blue");
- Query query = new AnyStringQuery();
- Collector collector = new ShortCircuitCollector();
- query.perform(items.iterator(), collector);
- Collection result = collector.toCollection();
- assertEquals("1.0", 1, result.size());
- assertTrue("1.1", result.contains("red"));
+ IQuery query = new AnyStringQuery();
+ IQuery limitQuery = new LimitQuery(query, 1);
+ IQueryResult collector = limitQuery.perform(items.iterator());
+ assertEquals("1.0", 1, AbstractProvisioningTest.queryResultSize(collector));
+ AbstractProvisioningTest.assertContains("1.1", collector, "red");
}
+ public void testLimitQuery2() {
+ List items = Arrays.asList("red", "green", "blue");
+ IQuery query = new AnyStringQuery();
+ IQuery limitQuery = new LimitQuery(query, 2);
+ IQueryResult collector = limitQuery.perform(items.iterator());
+ assertEquals("1.0", 2, AbstractProvisioningTest.queryResultSize(collector));
+ AbstractProvisioningTest.assertContains("1.1", collector, "red");
+ AbstractProvisioningTest.assertContains("1.2", collector, "green");
+ }
+
+ public void testLimitQuery3() {
+ List items = Arrays.asList("red", "green", "blue");
+ IQuery query = new AnyStringQuery();
+ IQuery limitQuery = new LimitQuery(query, 3);
+ IQueryResult collector = limitQuery.perform(items.iterator());
+ assertEquals("1.0", 3, AbstractProvisioningTest.queryResultSize(collector));
+ AbstractProvisioningTest.assertContains("1.1", collector, "red");
+ AbstractProvisioningTest.assertContains("1.2", collector, "green");
+ AbstractProvisioningTest.assertContains("1.3", collector, "blue");
+ }
+
+ public void testLimitQuery0() {
+ List items = Arrays.asList("red", "green", "blue");
+ IQuery query = new AnyStringQuery();
+ IQuery limitQuery = new LimitQuery(query, 0);
+ IQueryResult collector = limitQuery.perform(items.iterator());
+ assertEquals("1.0", 0, AbstractProvisioningTest.queryResultSize(collector));
+ }
+
+ // public void testPipedLimitQuery() {
+ // List items = Arrays.asList("pink", "red", "green", "pink");
+ // IQuery anyString = new AnyStringQuery();
+ // IQuery containsI = new MatchQuery() {
+ //
+ // public boolean isMatch(Object candidate) {
+ // return ((String) candidate).contains("e");
+ // }
+ // };
+ // IQuery pipedQuery = new PipedQuery(new IQuery[] {anyString, containsI});
+ // IQuery limitQuery = new LimitQuery(pipedQuery, 1);
+ // Collector collector = limitQuery.perform(items.iterator(), new Collector());
+ // Collection result = collector.toCollection();
+ // assertEquals("1.0", 1, result.size());
+ // assertTrue("1.1", result.contains("red"));
+ // }
+
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java
index a18084e7f..cabde3bcb 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/AutomatedDirectorTest.java
@@ -14,17 +14,21 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.osgi.framework.Filter;
/**
* Various automated tests of the {@link IDirector} API.
*/
public class AutomatedDirectorTest extends AbstractProvisioningTest {
- //private static Version version = new Version(1, 0, 0);
+ //private static Version version = Version.createOSGi(1, 0, 0);
public static Test suite() {
return new TestSuite(AutomatedDirectorTest.class);
@@ -49,8 +53,8 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
IInstallableUnit requiredIU = createIU("required." + getName());
// The IU to be installed
- String filter = createFilter("FilterKey", "true");
- IRequiredCapability capability = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), ANY_VERSION, filter, false, false);
+ Filter filter = createFilter("FilterKey", "true");
+ IRequiredCapability capability = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), ANY_VERSION, filter, false, false);
IInstallableUnit toInstallIU = createIU("toInstall." + getName(), new IRequiredCapability[] {capability});
IInstallableUnit[] allUnits = new IInstallableUnit[] {requiredIU, toInstallIU};
@@ -61,7 +65,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
//Install into a profile in which the filter is satisfied
Map properties = new HashMap();
properties.put(IProfile.PROP_ENVIRONMENTS, "FilterKey=true");
- IProfile satisfied = createProfile("Satisfied." + getName(), null, properties);
+ IProfile satisfied = createProfile("Satisfied." + getName(), properties);
ProfileChangeRequest request = new ProfileChangeRequest(satisfied);
request.addInstallableUnits(toInstallArray);
IStatus result = director.provision(request, null, null);
@@ -78,7 +82,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
IInstallableUnit requiredIU = createIU("required." + getName(), new IProvidedCapability[] {MetadataFactory.createProvidedCapability("test.capability", capabilityId, DEFAULT_VERSION)});
//The IU that optionally requires the capability
- IRequiredCapability required = MetadataFactory.createRequiredCapability("test.capability", capabilityId, ANY_VERSION, null, /* optional=> */true, /* multiple=> */false, /* greedy=>*/false);
+ IRequiredCapability required = (IRequiredCapability) MetadataFactory.createRequiredCapability("test.capability", capabilityId, ANY_VERSION, null, /* optional=> */true, /* multiple=> */false, /* greedy=>*/false);
IInstallableUnit toInstallIU = createIU("toInstall." + getName(), new IRequiredCapability[] {required});
IInstallableUnit[] allUnits = new IInstallableUnit[] {toInstallIU, requiredIU};
@@ -102,7 +106,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
public void testInstallOptionalUnavailable() {
String capabilityId = "test." + getName();
//no IU will be available that exports this capability
- IRequiredCapability required = MetadataFactory.createRequiredCapability("test.capability", capabilityId, ANY_VERSION, null, true, false);
+ IRequiredCapability required = (IRequiredCapability) MetadataFactory.createRequiredCapability("test.capability", capabilityId, ANY_VERSION, null, true, false);
IInstallableUnit toInstallIU = createIU("toInstall." + getName(), new IRequiredCapability[] {required});
IInstallableUnit[] allUnits = new IInstallableUnit[] {toInstallIU};
@@ -129,7 +133,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
IProvidedCapability[] provides = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("test.capability", capabilityId, DEFAULT_VERSION)};
IInstallableUnit requiredIU = createIU("required." + getName(), createFilter("osgi.os", "blort"), provides);
- IInstallableUnit toInstallIU = createIU("toInstall." + getName(), createRequiredCapabilities("test.capability", capabilityId, ANY_VERSION, null));
+ IInstallableUnit toInstallIU = createIU("toInstall." + getName(), createRequiredCapabilities("test.capability", capabilityId, ANY_VERSION, (Filter) null));
IInstallableUnit[] allUnits = new IInstallableUnit[] {requiredIU, toInstallIU};
IInstallableUnit[] toInstallArray = new IInstallableUnit[] {toInstallIU};
@@ -145,7 +149,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
//try again with the filter satisfied
Map properties = new HashMap();
properties.put(IProfile.PROP_ENVIRONMENTS, "osgi.os=blort");
- IProfile profile2 = createProfile("TestProfile2." + getName(), null, properties);
+ IProfile profile2 = createProfile("TestProfile2." + getName(), properties);
request = new ProfileChangeRequest(profile2);
request.addInstallableUnits(toInstallArray);
result = director.provision(request, null, null);
@@ -172,7 +176,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
//try again with the filter satisfied
Map properties = new HashMap();
properties.put(IProfile.PROP_ENVIRONMENTS, "osgi.os=blort");
- IProfile profile2 = createProfile("TestProfile2." + getName(), null, properties);
+ IProfile profile2 = createProfile("TestProfile2." + getName(), properties);
request = new ProfileChangeRequest(profile2);
request.addInstallableUnits(toInstallArray);
result = director.provision(request, null, null);
@@ -188,7 +192,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
//The IU that exports the capability
IInstallableUnit requiredIU = createIU("required." + getName(), new IProvidedCapability[] {MetadataFactory.createProvidedCapability("test.capability", capabilityId, DEFAULT_VERSION)});
- IInstallableUnit toInstallIU = createIU("toInstall." + getName(), createRequiredCapabilities("test.capability", capabilityId, ANY_VERSION, null));
+ IInstallableUnit toInstallIU = createIU("toInstall." + getName(), createRequiredCapabilities("test.capability", capabilityId, ANY_VERSION, (Filter) null));
IInstallableUnit[] allUnits = new IInstallableUnit[] {requiredIU, toInstallIU};
IInstallableUnit[] toInstallArray = new IInstallableUnit[] {toInstallIU};
@@ -214,7 +218,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
//The IU that is needed
IInstallableUnit requiredIU = createIU("required." + getName());
- IRequiredCapability capability = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), null, null, false, false);
+ IRequiredCapability capability = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), null, null, false, false);
IInstallableUnit toInstallIU = createIU("toInstall." + getName(), new IRequiredCapability[] {capability});
IInstallableUnit[] allUnits = new IInstallableUnit[] {requiredIU, toInstallIU};
@@ -242,7 +246,7 @@ public class AutomatedDirectorTest extends AbstractProvisioningTest {
//The IU that exports the capability
IInstallableUnit requiredIU = createIU("required." + getName());
- IRequiredCapability capability = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), ANY_VERSION, null, false, false);
+ IRequiredCapability capability = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, requiredIU.getId(), ANY_VERSION, null, false, false);
IInstallableUnit toInstallIU = createIU("toInstall." + getName(), new IRequiredCapability[] {capability});
IInstallableUnit[] allUnits = new IInstallableUnit[] {requiredIU, toInstallIU};
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/Bug203637.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/Bug203637.java
index c087e00b9..08e3f6fdd 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/Bug203637.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/Bug203637.java
@@ -10,19 +10,19 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.director;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class Bug203637 extends AbstractProvisioningTest {
public void test() {
IDirector d = createDirector();
IProfile profile = createProfile("TestProfile." + getName());
- IInstallableUnit a1 = createIU("A", new Version(1, 0, 0), true);
+ IInstallableUnit a1 = createIU("A", Version.createOSGi(1, 0, 0), true);
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {a1});
request.removeInstallableUnits(new IInstallableUnit[0]);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java
index 2cf543da7..d39a38c6c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorAppTest.java
@@ -22,12 +22,12 @@ import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.director.app.Activator;
import org.eclipse.equinox.internal.p2.director.app.Application;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.osgi.framework.Bundle;
@@ -473,10 +473,10 @@ public class DirectorAppTest extends AbstractProvisioningTest {
URI metadataRepo1 = getTestData("10.1", "/testData/metadataRepo/good").toURI();
URI metadataRepo2 = getTestData("10.1", "/testData/metadataRepo/multipleversions1").toURI();
Application application = new Application();
- Method method = application.getClass().getDeclaredMethod("collectRootIUs", URI[].class, Query.class, Collector.class);
+ Method method = application.getClass().getDeclaredMethod("collectRootIUs", URI[].class, IQuery.class);
method.setAccessible(true);
URI[] uris = new URI[] {metadataRepo1, metadataRepo2};
- Query query = new MatchQuery() {
+ IQuery query = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (candidate instanceof IInstallableUnit) {
IInstallableUnit iu = (IInstallableUnit) candidate;
@@ -486,8 +486,7 @@ public class DirectorAppTest extends AbstractProvisioningTest {
return false;
}
};
- Collector collector = new Collector();
- Collector result = (Collector) method.invoke(application, uris, query, collector);
+ Collector result = (Collector) method.invoke(application, uris, query);
assertEquals("1.0", 1, result.size());
}
@@ -572,8 +571,8 @@ public class DirectorAppTest extends AbstractProvisioningTest {
File artifactRepo1 = getTestData("12.0", "/testData/mirror/mirrorSourceRepo3");
File metadataRepo1 = getTestData("12.1", "/testData/mirror/mirrorSourceRepo3");
- IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
- IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
assertNotNull(artifactManager);
assertNotNull(metadataManager);
@@ -619,8 +618,8 @@ public class DirectorAppTest extends AbstractProvisioningTest {
File artifactRepo1 = getTestData("13.0", "/testData/mirror/mirrorSourceRepo4");
File metadataRepo1 = getTestData("13.1", "/testData/mirror/mirrorSourceRepo4");
- IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
- IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
assertNotNull(artifactManager);
assertNotNull(metadataManager);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorApplicationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorApplicationTest.java
index a88c991f6..336011ab3 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorApplicationTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/DirectorApplicationTest.java
@@ -22,12 +22,12 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.director.app.*;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.osgi.framework.Bundle;
@@ -526,10 +526,10 @@ public class DirectorApplicationTest extends AbstractProvisioningTest {
URI metadataRepo1 = getTestData("10.1", "/testData/metadataRepo/good").toURI();
URI metadataRepo2 = getTestData("10.1", "/testData/metadataRepo/multipleversions1").toURI();
Application application = new Application();
- Method method = application.getClass().getDeclaredMethod("collectRootIUs", URI[].class, Query.class, Collector.class);
+ Method method = application.getClass().getDeclaredMethod("collectRootIUs", URI[].class, IQuery.class);
method.setAccessible(true);
URI[] uris = new URI[] {metadataRepo1, metadataRepo2};
- Query query = new MatchQuery() {
+ IQuery query = new MatchQuery() {
public boolean isMatch(Object candidate) {
if (candidate instanceof IInstallableUnit) {
IInstallableUnit iu = (IInstallableUnit) candidate;
@@ -539,8 +539,7 @@ public class DirectorApplicationTest extends AbstractProvisioningTest {
return false;
}
};
- Collector collector = new Collector();
- Collector result = (Collector) method.invoke(application, uris, query, collector);
+ Collector result = (Collector) method.invoke(application, uris, query);
assertEquals("1.0", 1, result.size());
}
@@ -633,8 +632,8 @@ public class DirectorApplicationTest extends AbstractProvisioningTest {
File artifactRepo1 = getTestData("12.0", "/testData/mirror/mirrorSourceRepo3");
File metadataRepo1 = getTestData("12.1", "/testData/mirror/mirrorSourceRepo3");
- IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
- IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
assertNotNull(artifactManager);
assertNotNull(metadataManager);
@@ -683,8 +682,8 @@ public class DirectorApplicationTest extends AbstractProvisioningTest {
File artifactRepo1 = getTestData("13.0", "/testData/mirror/mirrorSourceRepo4");
File metadataRepo1 = getTestData("13.1", "/testData/mirror/mirrorSourceRepo4");
- IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
- IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
assertNotNull(artifactManager);
assertNotNull(metadataManager);
@@ -724,8 +723,8 @@ public class DirectorApplicationTest extends AbstractProvisioningTest {
public void testUninstallIgnoresPassedInRepos() throws Exception {
File srcRepo = getTestData("14.0", "/testData/mirror/mirrorSourceRepo4");
- IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.class.getName());
- IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.class.getName());
+ IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) ServiceHelper.getService(Activator.getContext(), IArtifactRepositoryManager.SERVICE_NAME);
+ IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) ServiceHelper.getService(Activator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
assertNotNull(artifactManager);
assertNotNull(metadataManager);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java
index 416a37a18..a1c451d32 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OperationGenerationTest.java
@@ -10,23 +10,23 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.director;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
-import java.util.ArrayList;
-import java.util.Collection;
+import java.util.*;
import org.eclipse.equinox.internal.p2.director.OperationGenerator;
import org.eclipse.equinox.internal.p2.metadata.ResolvedInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.engine.InstallableUnitOperand;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class OperationGenerationTest extends AbstractProvisioningTest {
public void testInstallUninstall() {
- IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false);
- IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false);
- IInstallableUnit a3 = createIU("a", new Version(3, 0, 0), false);
+ IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false);
+ IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false);
+ IInstallableUnit a3 = createIU("a", Version.createOSGi(3, 0, 0), false);
Collection from;
from = new ArrayList();
@@ -38,16 +38,16 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
to.add(a1);
to.add(a3);
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
// 1 x install
// 1 x uninstall
- assertEquals(2, operands.length);
+ assertEquals(2, operands.size());
}
public void test1() {
- IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false);
- IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false);
- IInstallableUnit a3 = createIU("a", new Version(3, 0, 0), false);
+ IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false);
+ IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false);
+ IInstallableUnit a3 = createIU("a", Version.createOSGi(3, 0, 0), false);
Collection from;
from = new ArrayList();
@@ -60,15 +60,15 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
to.add(a3);
to.add(a2);
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
// 1 x install
- assertEquals(1, operands.length);
+ assertEquals(1, operands.size());
}
public void test2() {
- IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false);
- IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false);
- IInstallableUnit a3 = createIU("a", new Version(3, 0, 0), false);
+ IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false);
+ IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false);
+ IInstallableUnit a3 = createIU("a", Version.createOSGi(3, 0, 0), false);
Collection from;
from = new ArrayList();
@@ -81,17 +81,17 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
to.add(a1);
to.add(a3);
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
// 1 x uninstall
- assertEquals(1, operands.length);
+ assertEquals(1, operands.size());
}
public void testUpdate1() {
- IInstallableUnit a = createIU("a", new Version(1, 0, 0), false);
+ IInstallableUnit a = createIU("a", Version.createOSGi(1, 0, 0), false);
InstallableUnitDescription b = new MetadataFactory.InstallableUnitDescription();
b.setId("b");
- b.setVersion(new Version(1, 0, 0));
+ b.setVersion(Version.createOSGi(1, 0, 0));
b.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("a", new VersionRange("[1.0.0, 2.0.0)"), IUpdateDescriptor.NORMAL, null));
Collection from;
@@ -102,18 +102,18 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
to = new ArrayList();
to.add(MetadataFactory.createInstallableUnit(b));
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
// 1 x upgrade
- assertEquals(1, operands.length);
+ assertEquals(1, operands.size());
}
public void testUpdate2() {
- IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false);
- IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false);
+ IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false);
+ IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false);
InstallableUnitDescription b = new MetadataFactory.InstallableUnitDescription();
b.setId("b");
- b.setVersion(new Version(1, 0, 0));
+ b.setVersion(Version.createOSGi(1, 0, 0));
b.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("a", new VersionRange("[1.0.0, 3.0.0)"), IUpdateDescriptor.NORMAL, null));
Collection from;
@@ -125,24 +125,24 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
to = new ArrayList();
to.add(MetadataFactory.createInstallableUnit(b));
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
// 1 x install
// 2 x uninstall
- assertEquals(3, operands.length);
+ assertEquals(3, operands.size());
}
public void testUpdate3() {
- IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false);
- IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false);
+ IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false);
+ IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false);
InstallableUnitDescription b = new MetadataFactory.InstallableUnitDescription();
b.setId("b");
- b.setVersion(new Version(1, 0, 0));
+ b.setVersion(Version.createOSGi(1, 0, 0));
b.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("a", new VersionRange("[1.0.0, 2.0.0)"), IUpdateDescriptor.NORMAL, null));
InstallableUnitDescription c = new MetadataFactory.InstallableUnitDescription();
c.setId("c");
- c.setVersion(new Version(1, 0, 0));
+ c.setVersion(Version.createOSGi(1, 0, 0));
c.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("a", new VersionRange("[2.0.0, 2.3.0)"), IUpdateDescriptor.NORMAL, null));
Collection from;
@@ -155,19 +155,19 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
to.add(MetadataFactory.createInstallableUnit(b));
to.add(MetadataFactory.createInstallableUnit(c));
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
// 2 x update
- assertEquals(2, operands.length);
+ assertEquals(2, operands.size());
}
public void testUpdate4() {
- IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false);
- IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false);
- IInstallableUnit b1 = createIU("b", new Version(1, 0, 0), false);
+ IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false);
+ IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false);
+ IInstallableUnit b1 = createIU("b", Version.createOSGi(1, 0, 0), false);
InstallableUnitDescription b2 = new MetadataFactory.InstallableUnitDescription();
b2.setId("b");
- b2.setVersion(new Version(2, 0, 0));
+ b2.setVersion(Version.createOSGi(2, 0, 0));
b2.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("b", new VersionRange("[1.0.0, 2.0.0)"), IUpdateDescriptor.NORMAL, null));
Collection from;
@@ -182,19 +182,19 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
to.add(a2);
to.add(MetadataFactory.createInstallableUnit(b2));
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
// 1 x update
- assertEquals(1, operands.length);
+ assertEquals(1, operands.size());
}
public void testUpdate5() {
- IInstallableUnit a1 = createIU("a", new Version(1, 0, 0), false);
- IInstallableUnit a2 = createIU("a", new Version(2, 0, 0), false);
- IInstallableUnit b1 = createIU("b", new Version(1, 0, 0), false);
+ IInstallableUnit a1 = createIU("a", Version.createOSGi(1, 0, 0), false);
+ IInstallableUnit a2 = createIU("a", Version.createOSGi(2, 0, 0), false);
+ IInstallableUnit b1 = createIU("b", Version.createOSGi(1, 0, 0), false);
InstallableUnitDescription b2 = new MetadataFactory.InstallableUnitDescription();
b2.setId("b");
- b2.setVersion(new Version(2, 0, 0));
+ b2.setVersion(Version.createOSGi(2, 0, 0));
b2.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("b", new VersionRange("[1.0.0, 2.0.0)"), IUpdateDescriptor.NORMAL, null));
Collection from;
@@ -208,21 +208,21 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
to.add(a1);
to.add(MetadataFactory.createInstallableUnit(b2));
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
// 1 x update
// 1 x uninstall
- assertEquals(2, operands.length);
+ assertEquals(2, operands.size());
}
public void test248468b() {
String id = "myBundle";
- IUpdateDescriptor update = createUpdateDescriptor(id, new Version("1.0.0"));
- IInstallableUnit one = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
- IUpdateDescriptor update2 = createUpdateDescriptor(id, new Version("2.0.0"));
- IInstallableUnit two = createIU(id, new Version("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update2, null);
+ IUpdateDescriptor update = createUpdateDescriptor(id, Version.create("1.0.0"));
+ IInstallableUnit one = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
+ IUpdateDescriptor update2 = createUpdateDescriptor(id, Version.create("2.0.0"));
+ IInstallableUnit two = createIU(id, Version.create("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update2, null);
- IUpdateDescriptor update3 = createUpdateDescriptor(id, new Version("3.0.0"));
- IInstallableUnit three = createIU(id, new Version("3.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update3, null);
+ IUpdateDescriptor update3 = createUpdateDescriptor(id, Version.create("3.0.0"));
+ IInstallableUnit three = createIU(id, Version.create("3.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update3, null);
Collection from = new ArrayList();
from.add(MetadataFactory.createResolvedInstallableUnit(one, new IInstallableUnitFragment[0]));
@@ -232,27 +232,27 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
Collection to = new ArrayList();
to.add(MetadataFactory.createResolvedInstallableUnit(three, new IInstallableUnitFragment[0]));
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
//We are uninstalling myBundle 1.0 and 2.0. 3.0 stays unchanged.
- for (int i = 0; i < operands.length; i++) {
- assertNotSame("3.0", three, operands[i].first());
- assertNotSame("3.0.1", three, operands[i].second());
+ for (int i = 0; i < operands.size(); i++) {
+ assertNotSame("3.0", three, operands.get(i).first());
+ assertNotSame("3.0.1", three, operands.get(i).second());
}
- assertEquals("3.1", one, operands[0].first());
- assertNull("3.2", operands[0].second());
- assertEquals("3.3", two, operands[1].first());
- assertNull("3.4", operands[1].second());
+ assertEquals("3.1", one, operands.get(0).first());
+ assertNull("3.2", operands.get(0).second());
+ assertEquals("3.3", two, operands.get(1).first());
+ assertNull("3.4", operands.get(1).second());
}
public void test248468d() {
String id = "myBundle";
- IUpdateDescriptor update = createUpdateDescriptor(id, new Version("1.0.0"));
- IInstallableUnit one = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
- update = createUpdateDescriptor(id, new Version("2.0.0"));
- IInstallableUnit two = createIU(id, new Version("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
+ IUpdateDescriptor update = createUpdateDescriptor(id, Version.create("1.0.0"));
+ IInstallableUnit one = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
+ update = createUpdateDescriptor(id, Version.create("2.0.0"));
+ IInstallableUnit two = createIU(id, Version.create("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
- IUpdateDescriptor update3 = createUpdateDescriptor(id, new Version("3.0.0"));
- IInstallableUnit three = createIU("anotherBundle", new Version("3.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update3, null);
+ IUpdateDescriptor update3 = createUpdateDescriptor(id, Version.create("3.0.0"));
+ IInstallableUnit three = createIU("anotherBundle", Version.create("3.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update3, null);
Collection from = new ArrayList();
from.add(MetadataFactory.createResolvedInstallableUnit(one, new IInstallableUnitFragment[0]));
@@ -262,28 +262,28 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
to.add(MetadataFactory.createResolvedInstallableUnit(two, new IInstallableUnitFragment[0]));
to.add(MetadataFactory.createResolvedInstallableUnit(three, new IInstallableUnitFragment[0]));
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
//Two is already in the system therefore it will not be in the operands
- for (int i = 0; i < operands.length; i++) {
- assertNotSame("2.0", two, operands[i].first());
- assertNotSame("2.1", two, operands[i].second());
+ for (int i = 0; i < operands.size(); i++) {
+ assertNotSame("2.0", two, operands.get(i).first());
+ assertNotSame("2.1", two, operands.get(i).second());
}
//three is an update of one
- assertEquals("2.2", 1, operands.length);
- assertEquals("2.4", one, operands[0].first());
- assertEquals("2.5", three, operands[0].second());
+ assertEquals("2.2", 1, operands.size());
+ assertEquals("2.4", one, operands.get(0).first());
+ assertEquals("2.5", three, operands.get(0).second());
}
public void test248468c() {
String id = "myBundle";
- IUpdateDescriptor update = createUpdateDescriptor(id, new Version("1.0.0"));
- IInstallableUnit one = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
- update = createUpdateDescriptor(id, new Version("2.0.0"));
- IInstallableUnit two = createIU(id, new Version("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
+ IUpdateDescriptor update = createUpdateDescriptor(id, Version.create("1.0.0"));
+ IInstallableUnit one = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
+ update = createUpdateDescriptor(id, Version.create("2.0.0"));
+ IInstallableUnit two = createIU(id, Version.create("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
- IUpdateDescriptor update3 = MetadataFactory.createUpdateDescriptor(id, new VersionRange(new Version(2, 0, 0), true, new Version(3, 0, 0), false), IUpdateDescriptor.HIGH, "desc");
- // IUpdateDescriptor update3 = createUpdateDescriptor(id, new Version("3.0.0"));
- IInstallableUnit three = createIU("anotherBundle", new Version("3.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update3, null);
+ IUpdateDescriptor update3 = MetadataFactory.createUpdateDescriptor(id, new VersionRange(Version.createOSGi(2, 0, 0), true, Version.createOSGi(3, 0, 0), false), IUpdateDescriptor.HIGH, "desc");
+ // IUpdateDescriptor update3 = createUpdateDescriptor(id, Version.create("3.0.0"));
+ IInstallableUnit three = createIU("anotherBundle", Version.create("3.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update3, null);
Collection from = new ArrayList();
from.add(MetadataFactory.createResolvedInstallableUnit(one, new IInstallableUnitFragment[0]));
@@ -293,26 +293,26 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
to.add(MetadataFactory.createResolvedInstallableUnit(two, new IInstallableUnitFragment[0]));
to.add(MetadataFactory.createResolvedInstallableUnit(three, new IInstallableUnitFragment[0]));
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
//Two is already in the system therefore it will not be in the operands
- for (int i = 0; i < operands.length; i++) {
- assertNotSame("2.0", two, operands[i].first());
- assertNotSame("2.1", two, operands[i].second());
+ for (int i = 0; i < operands.size(); i++) {
+ assertNotSame("2.0", two, operands.get(i).first());
+ assertNotSame("2.1", two, operands.get(i).second());
}
//We install three and uninstall one
- assertEquals("2.2", 2, operands.length);
- assertNull("2.3", operands[0].first());
- assertEquals("2.4", three, operands[0].second());
- assertEquals("2.5", one, operands[1].first());
- assertNull("2.6", operands[1].second());
+ assertEquals("2.2", 2, operands.size());
+ assertNull("2.3", operands.get(0).first());
+ assertEquals("2.4", three, operands.get(0).second());
+ assertEquals("2.5", one, operands.get(1).first());
+ assertNull("2.6", operands.get(1).second());
}
public void test248468() {
String id = "myBundle";
- IUpdateDescriptor update = createUpdateDescriptor(id, new Version("1.0.0"));
- IInstallableUnit one = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
- update = createUpdateDescriptor(id, new Version("2.0.0"));
- IInstallableUnit two = createIU(id, new Version("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
+ IUpdateDescriptor update = createUpdateDescriptor(id, Version.create("1.0.0"));
+ IInstallableUnit one = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
+ update = createUpdateDescriptor(id, Version.create("2.0.0"));
+ IInstallableUnit two = createIU(id, Version.create("2.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, update, null);
Collection from = new ArrayList();
from.add(MetadataFactory.createResolvedInstallableUnit(one, new IInstallableUnitFragment[0]));
@@ -321,20 +321,20 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
Collection to = new ArrayList();
to.add(MetadataFactory.createResolvedInstallableUnit(two, new IInstallableUnitFragment[0]));
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
- assertEquals("1.0", 1, operands.length);
- assertEquals("1.1", one, operands[0].first());
- assertNull("1.2", operands[0].second());
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
+ assertEquals("1.0", 1, operands.size());
+ assertEquals("1.1", one, operands.get(0).first());
+ assertNull("1.2", operands.get(0).second());
}
public void testConfigurationChange1() {
String id = "myBundle";
String cuId = "cu";
- IInstallableUnit anIU = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
- IInstallableUnit anotherIU = createIU("misc", new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
- IInstallableUnit anotherIU2 = createIU("misc2", new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
- IInstallableUnitFragment cu1 = createIUFragment(anIU, cuId, new Version("1.0.0"));
- IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, new Version("2.0.0"));
+ IInstallableUnit anIU = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
+ IInstallableUnit anotherIU = createIU("misc", Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
+ IInstallableUnit anotherIU2 = createIU("misc2", Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
+ IInstallableUnitFragment cu1 = createIUFragment(anIU, cuId, Version.create("1.0.0"));
+ IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, Version.create("2.0.0"));
Collection from = new ArrayList();
ResolvedInstallableUnit fromResolved = (ResolvedInstallableUnit) MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu1});
@@ -346,16 +346,17 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
to.add(toResolved);
to.add(MetadataFactory.createResolvedInstallableUnit(anotherIU2, new IInstallableUnitFragment[0]));
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
- assertEquals("1.0", 3, operands.length);
+ assertEquals("1.0", 3, operands.size());
assertContainsConfigurationChange("2.0", operands);
assertContainsInstallableUnitOperand("3.0", operands, new InstallableUnitOperand(fromResolved, toResolved));
}
- private void assertContainsInstallableUnitOperand(String message, InstallableUnitOperand[] operands, InstallableUnitOperand operand) {
- for (int i = 0; i < operands.length; i++) {
- if (operands[i].first() != null && operands[i].first().equals(operand.first()) && operands[i].second() != null && operands[i].second().equals(operand.second()))
+ private void assertContainsInstallableUnitOperand(String message, List<InstallableUnitOperand> operands, InstallableUnitOperand operand) {
+ for (int i = 0; i < operands.size(); i++) {
+ InstallableUnitOperand cmp = operands.get(i);
+ if (cmp.first() != null && cmp.first().equals(operand.first()) && cmp.second() != null && cmp.second().equals(operand.second()))
return;
}
fail(message);
@@ -364,8 +365,8 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
public void testConfigurationChange2() {
String id = "myBundle";
String cuId = "cu";
- IInstallableUnit anIU = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
- IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, new Version("2.0.0"));
+ IInstallableUnit anIU = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
+ IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, Version.create("2.0.0"));
Collection from = new ArrayList();
ResolvedInstallableUnit fromResolved = (ResolvedInstallableUnit) MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[0]);
@@ -375,17 +376,17 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
IInstallableUnit toResolved = MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu2});
to.add(toResolved);
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
- assertEquals("1.0", 1, operands.length);
+ assertEquals("1.0", 1, operands.size());
assertContainsInstallableUnitOperand("3.0", operands, new InstallableUnitOperand(fromResolved, toResolved));
}
public void testConfigurationChange3() {
String id = "myBundle";
String cuId = "cu";
- IInstallableUnit anIU = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
- IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, new Version("2.0.0"));
+ IInstallableUnit anIU = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
+ IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, Version.create("2.0.0"));
Collection from = new ArrayList();
ResolvedInstallableUnit fromResolved = (ResolvedInstallableUnit) MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu2});
@@ -395,17 +396,17 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
IInstallableUnit toResolved = MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[0]);
to.add(toResolved);
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
- assertEquals("1.0", 1, operands.length);
+ assertEquals("1.0", 1, operands.size());
assertContainsInstallableUnitOperand("3.0", operands, new InstallableUnitOperand(fromResolved, toResolved));
}
public void testConfigurationChange4() {
String id = "myBundle";
String cuId = "cu";
- IInstallableUnit anIU = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
- IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, new Version("2.0.0"));
+ IInstallableUnit anIU = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
+ IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, Version.create("2.0.0"));
Collection from = new ArrayList();
ResolvedInstallableUnit fromResolved = (ResolvedInstallableUnit) MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu2});
@@ -415,17 +416,17 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
IInstallableUnit toResolved = MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu2});
to.add(toResolved);
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
- assertEquals("1.0", 0, operands.length);
+ assertEquals("1.0", 0, operands.size());
}
public void testConfigurationChange5() {
String id = "myBundle";
String cuId = "cu";
- IInstallableUnit anIU = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
- IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, new Version("2.0.0"));
- IInstallableUnitFragment cu1 = createIUFragment(anIU, cuId, new Version("1.0.0"));
+ IInstallableUnit anIU = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
+ IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, Version.create("2.0.0"));
+ IInstallableUnitFragment cu1 = createIUFragment(anIU, cuId, Version.create("1.0.0"));
Collection from = new ArrayList();
ResolvedInstallableUnit fromResolved = (ResolvedInstallableUnit) MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu1, cu2});
@@ -435,18 +436,18 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
IInstallableUnit toResolved = MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu2, cu1});
to.add(toResolved);
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
- assertEquals("1.0", 0, operands.length);
+ assertEquals("1.0", 0, operands.size());
}
public void testConfigurationChange6() {
String id = "myBundle";
String cuId = "cu";
- IInstallableUnit anIU = createIU(id, new Version("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
- IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, new Version("2.0.0"));
- IInstallableUnitFragment cu1 = createIUFragment(anIU, cuId, new Version("1.0.0"));
- IInstallableUnitFragment cu3 = createIUFragment(anIU, cuId, new Version("3.0.0"));
+ IInstallableUnit anIU = createIU(id, Version.create("1.0.0"), null, NO_REQUIRES, NO_PROVIDES, NO_PROPERTIES, ITouchpointType.NONE, NO_TP_DATA, false, null, null);
+ IInstallableUnitFragment cu2 = createIUFragment(anIU, cuId, Version.create("2.0.0"));
+ IInstallableUnitFragment cu1 = createIUFragment(anIU, cuId, Version.create("1.0.0"));
+ IInstallableUnitFragment cu3 = createIUFragment(anIU, cuId, Version.create("3.0.0"));
Collection from = new ArrayList();
ResolvedInstallableUnit fromResolved = (ResolvedInstallableUnit) MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu1, cu2});
@@ -456,9 +457,9 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
IInstallableUnit toResolved = MetadataFactory.createResolvedInstallableUnit(anIU, new IInstallableUnitFragment[] {cu1, cu3});
to.add(toResolved);
- InstallableUnitOperand[] operands = new OperationGenerator().generateOperation(from, to);
+ List<InstallableUnitOperand> operands = new OperationGenerator().generateOperation(from, to);
- assertEquals("1.0", 1, operands.length);
+ assertEquals("1.0", 1, operands.size());
assertContainsInstallableUnitOperand("3.0", operands, new InstallableUnitOperand(fromResolved, toResolved));
}
@@ -470,9 +471,10 @@ public class OperationGenerationTest extends AbstractProvisioningTest {
fail(message + "Can't find " + expected);
}
- public void assertContainsConfigurationChange(String message, InstallableUnitOperand[] ops) {
- for (int i = 0; i < ops.length; i++) {
- if (ops[i].first() != null && ops[i].first().equals(ops[i].second())) {
+ public void assertContainsConfigurationChange(String message, List<InstallableUnitOperand> ops) {
+ for (int i = 0; i < ops.size(); i++) {
+ InstallableUnitOperand op = ops.get(i);
+ if (op.first() != null && op.first().equals(op.second())) {
return;
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java
index a947717e6..40088c1a0 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest.java
@@ -8,15 +8,15 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.director;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class OracleTest extends AbstractProvisioningTest {
@@ -31,18 +31,18 @@ public class OracleTest extends AbstractProvisioningTest {
IProfile profile;
protected void setUp() throws Exception {
- IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)"), null);
+ IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)"));
a1 = createIU("A", requires, true);
- requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.0.0, 3.0.0)"), null);
+ requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[1.0.0, 3.0.0)"));
c1 = createIU("C", requires, true);
d1 = createIU("D", DEFAULT_VERSION, true);
- requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[2.0.0, 3.0.0)"), null);
+ requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "D", new VersionRange("[2.0.0, 3.0.0)"));
b1 = createIU("B", requires, true);
- d2 = createIU("D", new Version(2, 0, 0), true);
+ d2 = createIU("D", Version.createOSGi(2, 0, 0), true);
createTestMetdataRepository(new IInstallableUnit[] {a1, c1, d1, b1});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java
index 430fadc9b..11aeff973 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/OracleTest2.java
@@ -8,15 +8,18 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.director;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class OracleTest2 extends AbstractProvisioningTest {
@@ -30,16 +33,16 @@ public class OracleTest2 extends AbstractProvisioningTest {
IProfile profile;
protected void setUp() throws Exception {
- IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)"), null);
+ IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[1.0.0, 2.0.0)"));
a1 = createIU("A", requires, true);
c1 = createIU("C", DEFAULT_VERSION, true);
- requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[2.0.0, 3.0.0)"), null);
+ requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "C", new VersionRange("[2.0.0, 3.0.0)"));
InstallableUnitDescription desc = new MetadataFactory.InstallableUnitDescription();
desc.setRequiredCapabilities(requires);
desc.setId("A");
- desc.setVersion(new Version(2, 0, 0));
+ desc.setVersion(Version.createOSGi(2, 0, 0));
desc.setSingleton(true);
desc.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("A", new VersionRange("[1.0.0, 2.3.0)"), IUpdateDescriptor.NORMAL, null));
@@ -49,7 +52,7 @@ public class OracleTest2 extends AbstractProvisioningTest {
InstallableUnitDescription desc2 = new MetadataFactory.InstallableUnitDescription();
desc2.setId("C");
- desc2.setVersion(new Version(2, 0, 0));
+ desc2.setVersion(Version.createOSGi(2, 0, 0));
desc2.setSingleton(true);
desc2.setUpdateDescriptor(MetadataFactory.createUpdateDescriptor("C", new VersionRange("[1.0.0, 2.3.0)"), IUpdateDescriptor.NORMAL, null));
c2 = MetadataFactory.createInstallableUnit(desc2);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java
index ed6f1d617..9efa4f8e3 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/ReplacePlanTest.java
@@ -10,14 +10,14 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.director;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
@@ -40,8 +40,8 @@ public class ReplacePlanTest extends AbstractProvisioningTest {
protected void setUp() throws Exception {
//base IU that others require
f1 = createIU("f1", DEFAULT_VERSION, true);
- f1_1 = createIU("f1", new Version(1, 1, 0), true);
- f1_4 = createIU("f1", new Version(1, 4, 0), true);
+ f1_1 = createIU("f1", Version.createOSGi(1, 1, 0), true);
+ f1_4 = createIU("f1", Version.createOSGi(1, 4, 0), true);
//fragments of base IU
frag1 = createIUFragment(f1, "frag1", f1.getVersion());
@@ -49,10 +49,10 @@ public class ReplacePlanTest extends AbstractProvisioningTest {
frag1_4 = createIUFragment(f1, "frag1", f1_4.getVersion());
//IUs that require base IU
- IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "f1", new VersionRange("[1.0.0, 1.3.0)"), null);
+ IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "f1", new VersionRange("[1.0.0, 1.3.0)"));
fa = createIU("fa", requires, false);
- requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "f1", new VersionRange("[1.0.0, 1.4.0)"), null);
- fap = createIU("fa", new Version(1, 1, 0), requires, NO_PROPERTIES, false);
+ requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, "f1", new VersionRange("[1.0.0, 1.4.0)"));
+ fap = createIU("fa", Version.createOSGi(1, 1, 0), requires, NO_PROPERTIES, false);
createTestMetdataRepository(new IInstallableUnit[] {f1, fa, frag1});
@@ -73,10 +73,10 @@ public class ReplacePlanTest extends AbstractProvisioningTest {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.removeInstallableUnits(oldUnits);
request.addInstallableUnits(newUnits);
- ProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), null);
+ IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), null);
assertTrue("1.0", plan.getStatus().isOK());
assertProfileContainsAll("1.1", profile, oldUnits);
- IStatus result = createEngine().perform(profile, new DefaultPhaseSet(), plan.getOperands(), null, null);
+ IStatus result = createEngine().perform(plan, null);
assertTrue("1.2", result.isOK());
assertProfileContainsAll("1.3", profile, newUnits);
}
@@ -86,7 +86,7 @@ public class ReplacePlanTest extends AbstractProvisioningTest {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.removeInstallableUnits(new IInstallableUnit[] {frag1});
request.addInstallableUnits(new IInstallableUnit[] {frag1_4});
- ProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), null);
+ IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), null);
assertTrue("1.0", plan.getStatus().isOK());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java
index 98cd52f53..5fdd4e937 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/RollbackTest.java
@@ -10,25 +10,25 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.director;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
-import java.net.*;
-import java.util.ArrayList;
-import java.util.List;
+import java.net.URI;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.director.DirectorActivator;
-import org.eclipse.equinox.internal.provisional.p2.core.*;
-import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.core.IAgentLocation;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
@@ -49,8 +49,8 @@ public class RollbackTest extends AbstractProvisioningTest {
c1 = createIU("C", DEFAULT_VERSION, true);
IRequiredCapability[] req = new IRequiredCapability[1];
- req[0] = MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true);
- d1 = createIU("D", new Version("1.0.0"), req);
+ req[0] = (IRequiredCapability) MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "A", VersionRange.emptyRange, null, false, false, true);
+ d1 = createIU("D", Version.create("1.0.0"), req);
createTestMetdataRepository(new IInstallableUnit[] {a1, b1, c1, d1});
@@ -67,21 +67,13 @@ public class RollbackTest extends AbstractProvisioningTest {
}
private IMetadataRepository getRollbackRepository() throws ProvisionException {
- try {
- IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.class.getName());
- URL location = ((AgentLocation) ServiceHelper.getService(DirectorActivator.context, AgentLocation.class.getName())).getDataArea(DirectorActivator.PI_DIRECTOR);
- return repoMan.loadRepository(URIUtil.toURI(new URL(location, "rollback")), null);
- } catch (MalformedURLException e) {
- fail("0.02", e);
- return null;
- } catch (URISyntaxException e) {
- fail("0.03", e);
- return null;
- }
+ IMetadataRepositoryManager repoMan = (IMetadataRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IMetadataRepositoryManager.SERVICE_NAME);
+ URI location = ((IAgentLocation) ServiceHelper.getService(DirectorActivator.context, IAgentLocation.class.getName())).getDataArea(DirectorActivator.PI_DIRECTOR);
+ return repoMan.loadRepository(URIUtil.append(location, "rollback"), null);
}
public void testRollbackProfileProperties() {
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry profileRegistry = getProfileRegistry();
assertEquals(1, profileRegistry.listProfileTimestamps(profile.getProfileId()).length);
ProfileChangeRequest request1 = new ProfileChangeRequest(profile);
@@ -115,7 +107,7 @@ public class RollbackTest extends AbstractProvisioningTest {
}
public void testRollbackIUs() {
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry profileRegistry = getProfileRegistry();
assertEquals(1, profileRegistry.listProfileTimestamps(profile.getProfileId()).length);
ProfileChangeRequest request1 = new ProfileChangeRequest(profile);
@@ -124,9 +116,9 @@ public class RollbackTest extends AbstractProvisioningTest {
IStatus status = director.provision(request1, null, new NullProgressMonitor());
assertEquals("1.0", IStatus.OK, status.getCode());
- List profileIUs = new ArrayList(profile.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection());
- assertTrue("2.0", profileIUs.contains(a1));
- assertTrue("3.0", profileIUs.contains(b1));
+ IQueryResult profileIUs = profile.query(InstallableUnitQuery.ANY, null);
+ assertContains("2.0", profileIUs, a1);
+ assertContains("3.0", profileIUs, b1);
assertEquals(2, profileRegistry.listProfileTimestamps(profile.getProfileId()).length);
@@ -136,10 +128,10 @@ public class RollbackTest extends AbstractProvisioningTest {
status = director.provision(request2, null, new NullProgressMonitor());
assertEquals("5.0", IStatus.OK, status.getCode());
- profileIUs = new ArrayList(profile.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection());
- assertFalse("6.0", profileIUs.contains(a1));
- assertTrue("7.0", profileIUs.contains(b1));
- assertTrue("8.0", profileIUs.contains(c1));
+ profileIUs = profile.query(InstallableUnitQuery.ANY, null);
+ assertNotContains("6.0", profileIUs, a1);
+ assertContains("7.0", profileIUs, b1);
+ assertContains("8.0", profileIUs, c1);
assertEquals(3, profileRegistry.listProfileTimestamps(profile.getProfileId()).length);
IProfile revertProfile = profileRegistry.getProfile(profile.getProfileId(), profileRegistry.listProfileTimestamps(profile.getProfileId())[1]);
@@ -147,14 +139,14 @@ public class RollbackTest extends AbstractProvisioningTest {
status = director.revert(profile, revertProfile, new ProvisioningContext(), new NullProgressMonitor());
assertEquals("10.0", IStatus.OK, status.getCode());
- profileIUs = new ArrayList(profile.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection());
- assertTrue("11.0", profileIUs.contains(a1));
- assertTrue("12.0", profileIUs.contains(b1));
- assertFalse("13.0", profileIUs.contains(c1));
+ profileIUs = profile.query(InstallableUnitQuery.ANY, null);
+ assertContains("11.0", profileIUs, a1);
+ assertContains("12.0", profileIUs, b1);
+ assertNotContains("13.0", profileIUs, c1);
}
public void testRollbackIUProfileProperties() {
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry profileRegistry = getProfileRegistry();
assertEquals(1, profileRegistry.listProfileTimestamps(profile.getProfileId()).length);
ProfileChangeRequest request1 = new ProfileChangeRequest(profile);
@@ -189,7 +181,7 @@ public class RollbackTest extends AbstractProvisioningTest {
}
public void testRollbackDependentIUProfileProperties() {
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry profileRegistry = getProfileRegistry();
assertEquals(1, profileRegistry.listProfileTimestamps(profile.getProfileId()).length);
ProfileChangeRequest request1 = new ProfileChangeRequest(profile);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java
index a21e834de..d066a3d16 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/SingletonTest.java
@@ -10,14 +10,14 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.director;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class SingletonTest extends AbstractProvisioningTest {
@@ -34,17 +34,17 @@ public class SingletonTest extends AbstractProvisioningTest {
IProfile profile;
protected void setUp() throws Exception {
- f1 = createIU("f1", new Version(1, 0, 0), true);
+ f1 = createIU("f1", Version.createOSGi(1, 0, 0), true);
- f1_1 = createIU("f1", new Version(1, 1, 0), true);
+ f1_1 = createIU("f1", Version.createOSGi(1, 1, 0), true);
- f2 = createIU("f2", new Version(1, 0, 0), true);
+ f2 = createIU("f2", Version.createOSGi(1, 0, 0), true);
- f2_1 = createIU("f2", new Version(1, 0, 1));
+ f2_1 = createIU("f2", Version.createOSGi(1, 0, 1));
- junit38 = createIU("junit", new Version(3, 8, 1));
+ junit38 = createIU("junit", Version.createOSGi(3, 8, 1));
- junit40 = createIU("junit", new Version(4, 0, 1));
+ junit40 = createIU("junit", Version.createOSGi(4, 0, 1));
createTestMetdataRepository(new IInstallableUnit[] {f1, f1_1, junit38, junit40, f2, f2_1});
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java
index 8360cd9ae..4758f3614 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UninstallTest.java
@@ -12,8 +12,8 @@ package org.eclipse.equinox.p2.tests.director;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class UninstallTest extends AbstractProvisioningTest {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java
index f2d224097..cb08ac8f5 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/director/UpdateTest.java
@@ -8,16 +8,15 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.director;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IRequiredCapability;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class UpdateTest extends AbstractProvisioningTest {
@@ -34,15 +33,15 @@ public class UpdateTest extends AbstractProvisioningTest {
protected void setUp() throws Exception {
String f1Id = getName() + "f1";
f1 = createIU(f1Id, DEFAULT_VERSION, true);
- f1_1 = createIU(f1Id, new Version(1, 1, 0), true);
- f1_4 = createIU(f1Id, new Version(1, 4, 0), true);
+ f1_1 = createIU(f1Id, Version.createOSGi(1, 1, 0), true);
+ f1_4 = createIU(f1Id, Version.createOSGi(1, 4, 0), true);
- IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, f1Id, new VersionRange("[1.0.0, 1.3.0)"), null);
+ IRequiredCapability[] requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, f1Id, new VersionRange("[1.0.0, 1.3.0)"));
String faId = getName() + ".fa";
fa = createIU(faId, requires, false);
- requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, f1Id, new VersionRange("[1.0.0, 1.4.0)"), null);
- fap = createIU(faId, new Version(1, 1, 0), requires, NO_PROPERTIES, false);
+ requires = createRequiredCapabilities(IInstallableUnit.NAMESPACE_IU_ID, f1Id, new VersionRange("[1.0.0, 1.4.0)"));
+ fap = createIU(faId, Version.createOSGi(1, 1, 0), requires, NO_PROPERTIES, false);
createTestMetdataRepository(new IInstallableUnit[] {f1, fa});
@@ -59,7 +58,7 @@ public class UpdateTest extends AbstractProvisioningTest {
public void testInstall() {
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {f1_1});
- ProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), new NullProgressMonitor());
+ IProvisioningPlan plan = planner.getProvisioningPlan(request, new ProvisioningContext(), new NullProgressMonitor());
assertOK("1.0", plan.getStatus());
assertOK("1.1", director.provision(request, null, null));
request = new ProfileChangeRequest(profile);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java
index 7df459def..a77f39e67 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/ProfileSynchronizerTest.java
@@ -10,14 +10,14 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.directorywatcher;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.File;
import java.util.*;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
/**
* @since 1.0
@@ -113,7 +113,7 @@ public class ProfileSynchronizerTest extends AbstractDirectoryWatcherTest {
IArtifactKey[] artifacts = watcher.getArtifactKeys();
assertEquals("3.0", 1, ius.length);
assertEquals("3.1", "ccc", ius[0].getId());
- assertEquals("3.2", new Version("2.0.0"), ius[0].getVersion());
+ assertEquals("3.2", Version.create("2.0.0"), ius[0].getVersion());
assertEquals("4.0", 1, artifacts.length);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java
index 1f8dd7d7b..bf2e0a86b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/RepositoryListenerTest.java
@@ -11,11 +11,12 @@
package org.eclipse.equinox.p2.tests.directorywatcher;
import java.io.File;
+import java.util.List;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.ArtifactDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactDescriptor;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
public class RepositoryListenerTest extends AbstractDirectoryWatcherTest {
@@ -33,11 +34,11 @@ public class RepositoryListenerTest extends AbstractDirectoryWatcherTest {
return new TestSuite(RepositoryListenerTest.class);
}
- public static boolean isZipped(ITouchpointData[] data) {
- if (data == null || data.length == 0)
+ public static boolean isZipped(List<ITouchpointData> data) {
+ if (data == null || data.size() == 0)
return false;
- for (int i = 0; i < data.length; i++) {
- if (data[i].getInstruction("zipped") != null) //$NON-NLS-1$
+ for (int i = 0; i < data.size(); i++) {
+ if (data.get(i).getInstruction("zipped") != null) //$NON-NLS-1$
return true;
}
return false;
@@ -135,7 +136,7 @@ public class RepositoryListenerTest extends AbstractDirectoryWatcherTest {
IArtifactKey key = keys[i];
IArtifactDescriptor[] descriptors = watcher.getArtifactDescriptors(key);
assertEquals("8.0", 1, descriptors.length);
- ArtifactDescriptor descriptor = (ArtifactDescriptor) descriptors[0];
+ SimpleArtifactDescriptor descriptor = (SimpleArtifactDescriptor) descriptors[0];
String isFolder = descriptor.getRepositoryProperty("artifact.folder");
if (Boolean.valueOf(isFolder).booleanValue()) {
assertNull("9.0", directoryDescriptor);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/TestRepositoryWatcher.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/TestRepositoryWatcher.java
index d9cfbb081..19f92dfbd 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/TestRepositoryWatcher.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/directorywatcher/TestRepositoryWatcher.java
@@ -11,16 +11,15 @@
package org.eclipse.equinox.p2.tests.directorywatcher;
import java.io.File;
-import java.util.Dictionary;
import java.util.Hashtable;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactDescriptor;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IFileArtifactRepository;
+import java.util.Map;
import org.eclipse.equinox.internal.provisional.p2.directorywatcher.DirectoryWatcher;
import org.eclipse.equinox.internal.provisional.p2.directorywatcher.RepositoryListener;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.BundleContext;
@@ -37,7 +36,7 @@ class TestRepositoryWatcher extends DirectoryWatcher {
*/
public static TestRepositoryWatcher createWatcher(File folder) {
RepositoryListener listener = new RepositoryListener(AbstractProvisioningTest.getUniqueString(), false);
- Dictionary props = new Hashtable();
+ Map<String, String> props = new Hashtable<String, String>();
props.put(DirectoryWatcher.DIR, folder.getAbsolutePath());
props.put(DirectoryWatcher.POLL, "500");
TestRepositoryWatcher result = new TestRepositoryWatcher(props, TestActivator.getContext());
@@ -48,7 +47,7 @@ class TestRepositoryWatcher extends DirectoryWatcher {
/*
* Constructor for the class.
*/
- private TestRepositoryWatcher(Dictionary props, BundleContext context) {
+ private TestRepositoryWatcher(Map<String, String> props, BundleContext context) {
super(props, context);
}
@@ -64,14 +63,15 @@ class TestRepositoryWatcher extends DirectoryWatcher {
* Return the list of all the IUs known to the metadata repository this watcher's listener.
*/
public IInstallableUnit[] getInstallableUnits() {
- return (IInstallableUnit[]) listener.getMetadataRepository().query(InstallableUnitQuery.ANY, new Collector(), null).toArray(IInstallableUnit.class);
+ return listener.getMetadataRepository().query(InstallableUnitQuery.ANY, null).toArray(IInstallableUnit.class);
}
/*
* Return the list of artifact keys known to this listener's repository.
*/
public IArtifactKey[] getArtifactKeys() {
- return listener.getArtifactRepository().getArtifactKeys();
+ IQueryResult keys = listener.getArtifactRepository().query(ArtifactKeyQuery.ALL_KEYS, null);
+ return (IArtifactKey[]) keys.toArray(IArtifactKey.class);
}
/*
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ActionManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ActionManagerTest.java
index 09a62ed29..2bdf4694d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ActionManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ActionManagerTest.java
@@ -10,13 +10,13 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.engine;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import java.io.File;
import java.net.MalformedURLException;
import org.eclipse.equinox.internal.p2.engine.ActionManager;
-import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.internal.provisional.p2.metadata.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.Bundle;
@@ -37,7 +37,7 @@ public class ActionManagerTest extends AbstractProvisioningTest {
public void testGetTouchpointQualifiedActionId() {
ActionManager manager = new ActionManager();
- assertNotNull(manager.getTouchpointQualifiedActionId("test", MetadataFactory.createTouchpointType("phaseTest", new Version("1"))));
+ assertNotNull(manager.getTouchpointQualifiedActionId("test", MetadataFactory.createTouchpointType("phaseTest", Version.create("1"))));
}
public void testGetActionWithVersion() {
@@ -50,7 +50,8 @@ public class ActionManagerTest extends AbstractProvisioningTest {
assertNotNull(manager.getAction("test1.test", null));
}
- public void testDynamicAction() throws MalformedURLException, BundleException, InterruptedException {
+ // temporarily disabling this test until API is done
+ public void DISABLED_testDynamicAction() throws MalformedURLException, BundleException, InterruptedException {
ActionManager manager = new ActionManager();
assertNull(manager.getAction("dummy.touchpointAndAction.dummy", new VersionRange("1.0.0")));
File dummy = getTestData("0.1", "/testData/engineTest/dummy.touchpointAndAction_1.0.0.jar");
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java
index 5e3d14e6f..466da3497 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/CertificateCheckerTest.java
@@ -13,14 +13,12 @@ package org.eclipse.equinox.p2.tests.engine;
import java.io.File;
import java.io.IOException;
import java.security.cert.Certificate;
-import java.util.Hashtable;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.equinox.internal.p2.core.ProvisioningAgent;
import org.eclipse.equinox.internal.p2.engine.EngineActivator;
+import org.eclipse.equinox.internal.p2.engine.phases.CertificateChecker;
import org.eclipse.equinox.internal.provisional.p2.core.IServiceUI;
-import org.eclipse.equinox.internal.provisional.p2.engine.CertificateChecker;
-import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
-import org.eclipse.equinox.p2.tests.TestData;
-import org.osgi.framework.ServiceRegistration;
+import org.eclipse.equinox.p2.tests.*;
/**
* Tests for {@link CertificateChecker}.
@@ -46,12 +44,16 @@ public class CertificateCheckerTest extends AbstractProvisioningTest {
}
CertificateChecker checker;
- ServiceRegistration serviceReg;
CertificateTestService serviceUI;
File unsigned;
+ private ProvisioningAgent testAgent;
protected void setUp() throws Exception {
- checker = new CertificateChecker();
+ serviceUI = new CertificateTestService();
+ testAgent = new ProvisioningAgent();
+ testAgent.registerService(IServiceUI.SERVICE_NAME, serviceUI);
+ testAgent.setBundleContext(TestActivator.getContext());
+ checker = new CertificateChecker(testAgent);
try {
unsigned = TestData.getFile("CertificateChecker", "unsigned.jar");
} catch (IOException e) {
@@ -59,17 +61,6 @@ public class CertificateCheckerTest extends AbstractProvisioningTest {
}
assertTrue("1.0", unsigned != null);
assertTrue("1.0", unsigned.exists());
- // We need to ensure the test service has a higher ranking than
- // anything registered by the SDK via DS.
- serviceUI = new CertificateTestService();
- Hashtable properties = new Hashtable(1);
- properties.put(org.osgi.framework.Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE));
- serviceReg = EngineActivator.getContext().registerService(IServiceUI.class.getName(), serviceUI, properties);
- }
-
- protected void tearDown() throws Exception {
- if (serviceReg != null)
- serviceReg.unregister();
}
/**
@@ -154,16 +145,10 @@ public class CertificateCheckerTest extends AbstractProvisioningTest {
*/
public void testBug291049() {
try {
-
- // Intentionally unregister our service so that we get whatever the default (or null) service is
- // in an SDK configuration.
- if (serviceReg != null) {
- serviceReg.unregister();
- serviceReg = null;
- }
+ // Intentionally replace our service with a null service
+ testAgent.registerService(IServiceUI.SERVICE_NAME, null);
checker.add(unsigned);
// TODO need to add some untrusted files here, too. To prove that we treated them as trusted temporarily
-
System.getProperties().setProperty(EngineActivator.PROP_UNSIGNED_POLICY, EngineActivator.UNSIGNED_PROMPT);
IStatus result = checker.start();
assertTrue("1.0", result.isOK());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java
index 37fde9fd3..cc89dbf17 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/DownloadManagerTest.java
@@ -17,9 +17,9 @@ import junit.framework.TestSuite;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.engine.DownloadManager;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.engine.ProvisioningContext;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
@@ -34,7 +34,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
* Tests invocation of DownloadManager when there is nothing to download.
*/
public void testEmpty() {
- DownloadManager manager = new DownloadManager(null);
+ DownloadManager manager = createDownloadManager(null);
IStatus result = manager.start(null);
assertTrue("1.0", result.isOK());
}
@@ -44,7 +44,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
*/
public void testEmptyWithContext() {
ProvisioningContext context = new ProvisioningContext();
- DownloadManager manager = new DownloadManager(context);
+ DownloadManager manager = createDownloadManager(context);
IStatus result = manager.start(null);
assertTrue("1.0", result.isOK());
}
@@ -54,7 +54,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
*/
public void testAddNullArtifactRequest() {
ProvisioningContext context = new ProvisioningContext();
- DownloadManager manager = new DownloadManager(context);
+ DownloadManager manager = createDownloadManager(context);
try {
manager.add((IArtifactRequest) null);
} catch (RuntimeException e) {
@@ -65,7 +65,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
public void testAddNullArtifactRequestArray() {
ProvisioningContext context = new ProvisioningContext();
- DownloadManager manager = new DownloadManager(context);
+ DownloadManager manager = createDownloadManager(context);
try {
manager.add((IArtifactRequest[]) null);
} catch (RuntimeException e) {
@@ -76,7 +76,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
public void testAddEmptyArtifactRequestArray() {
ProvisioningContext context = new ProvisioningContext();
- DownloadManager manager = new DownloadManager(context);
+ DownloadManager manager = createDownloadManager(context);
manager.add(new IArtifactRequest[0]);
IStatus result = manager.start(null);
assertTrue("1.0", result.isOK());
@@ -84,7 +84,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
public void testAddArtifactRequestArrayContainingNull() {
ProvisioningContext context = new ProvisioningContext();
- DownloadManager manager = new DownloadManager(context);
+ DownloadManager manager = createDownloadManager(context);
try {
IArtifactRequest[] requests = new IArtifactRequest[] {null};
manager.add(requests);
@@ -96,7 +96,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
public void testAddArtifactRequest() {
ProvisioningContext context = new ProvisioningContext();
- DownloadManager manager = new DownloadManager(context);
+ DownloadManager manager = createDownloadManager(context);
IArtifactRequest request = createArtifactRequest();
manager.add(request);
@@ -108,7 +108,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
public void testContext() {
ProvisioningContext context = new ProvisioningContext();
context.setArtifactRepositories(new URI[0]);
- DownloadManager manager = new DownloadManager(context);
+ DownloadManager manager = createDownloadManager(context);
IArtifactRequest request = createArtifactRequest();
manager.add(request);
@@ -119,7 +119,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
public void testAddArtifactRequestArray() {
ProvisioningContext context = new ProvisioningContext();
- DownloadManager manager = new DownloadManager(context);
+ DownloadManager manager = createDownloadManager(context);
IArtifactRequest[] requests = new IArtifactRequest[] {createArtifactRequest()};
manager.add(requests);
@@ -144,7 +144,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
public void testEmptyArtifactRepositoryListContext() {
ProvisioningContext context = new ProvisioningContext();
context.setArtifactRepositories(new URI[0]);
- DownloadManager manager = new DownloadManager(context);
+ DownloadManager manager = createDownloadManager(context);
IArtifactRequest[] requests = new IArtifactRequest[] {createArtifactRequest()};
manager.add(requests);
@@ -163,7 +163,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
context.setArtifactRepositories(artifactRepos);
- DownloadManager manager = new DownloadManager(context);
+ DownloadManager manager = createDownloadManager(context);
IArtifactRequest[] requests = new IArtifactRequest[] {createArtifactRequest()};
manager.add(requests);
@@ -182,7 +182,7 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
context.setArtifactRepositories(artifactRepos);
- DownloadManager manager = new DownloadManager(context);
+ DownloadManager manager = createDownloadManager(context);
IArtifactRequest[] requests = new IArtifactRequest[] {createArtifactRequest()};
manager.add(requests);
@@ -201,11 +201,15 @@ public class DownloadManagerTest extends AbstractProvisioningTest {
}
context.setArtifactRepositories(artifactRepos);
- DownloadManager manager = new DownloadManager(context);
+ DownloadManager manager = createDownloadManager(context);
IArtifactRequest[] requests = new IArtifactRequest[] {createArtifactRequest()};
manager.add(requests);
IStatus result = manager.start(null);
assertTrue("1.0", result.isOK());
}
+
+ private DownloadManager createDownloadManager(ProvisioningContext context) {
+ return new DownloadManager(context, getArtifactRepositoryManager());
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java
index b82177bb7..96349ca5e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/EngineTest.java
@@ -10,15 +10,23 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.engine;
+import org.eclipse.equinox.p2.metadata.Version;
+
import java.io.File;
import java.util.*;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.phases.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.p2.engine.*;
+import org.eclipse.equinox.internal.p2.engine.phases.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitFragment;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.Collector;
+import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.ServiceReference;
@@ -64,7 +72,7 @@ public class EngineTest extends AbstractProvisioningTest {
return super.initializePhase(monitor, profile, parameters);
}
- protected ProvisioningAction[] getActions(Operand operand) {
+ protected List<ProvisioningAction> getActions(Operand operand) {
return null;
}
@@ -83,7 +91,7 @@ public class EngineTest extends AbstractProvisioningTest {
throw new NullPointerException();
}
- protected ProvisioningAction[] getActions(Operand operand) {
+ protected List<ProvisioningAction> getActions(Operand operand) {
return null;
}
}
@@ -97,7 +105,7 @@ public class EngineTest extends AbstractProvisioningTest {
this(false);
}
- protected ProvisioningAction[] getActions(Operand operand) {
+ protected List<ProvisioningAction> getActions(Operand operand) {
ProvisioningAction action = new ProvisioningAction() {
public IStatus undo(Map parameters) {
@@ -108,7 +116,7 @@ public class EngineTest extends AbstractProvisioningTest {
throw new NullPointerException();
}
};
- return new ProvisioningAction[] {action};
+ return Collections.singletonList(action);
}
}
@@ -165,10 +173,9 @@ public class EngineTest extends AbstractProvisioningTest {
public void testNullProfile() {
IProfile profile = null;
- PhaseSet phaseSet = new DefaultPhaseSet();
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {};
try {
- engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
} catch (IllegalArgumentException expected) {
return;
}
@@ -181,32 +188,89 @@ public class EngineTest extends AbstractProvisioningTest {
PhaseSet phaseSet = null;
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {};
try {
- engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
} catch (IllegalArgumentException expected) {
return;
}
fail();
}
- public void testNullOperands() {
+ public void testNullPlan() {
- IProfile profile = createProfile("test");
- PhaseSet phaseSet = new DefaultPhaseSet();
- InstallableUnitOperand[] operands = null;
try {
- engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ engine.perform(null, new NullProgressMonitor());
fail();
- } catch (IllegalArgumentException expected) {
+ } catch (RuntimeException expected) {
+ //expected
+ }
+ }
+
+ /*
+ * Tests for {@link IEngine#createPhaseSetExcluding}.
+ */
+ public void testCreatePhaseSetExcluding() {
+ //null argument
+ IPhaseSet set = engine.createPhaseSetExcluding(null);
+ assertEquals("1.0", 7, set.getPhaseIds().length);
+
+ //empty argument
+ set = engine.createPhaseSetExcluding(new String[0]);
+ assertEquals("2.0", 7, set.getPhaseIds().length);
+
+ //bogus argument
+ set = engine.createPhaseSetExcluding(new String[] {"blort"});
+ assertEquals("3.0", 7, set.getPhaseIds().length);
+
+ //valid argument
+ set = engine.createPhaseSetExcluding(new String[] {IPhaseSet.PHASE_CHECK_TRUST});
+ final String[] phases = set.getPhaseIds();
+ assertEquals("4.0", 6, phases.length);
+ for (int i = 0; i < phases.length; i++)
+ if (phases[i].equals(IPhaseSet.PHASE_CHECK_TRUST))
+ fail("4.1." + i);
+
+ }
+
+ /*
+ * Tests for {@link IEngine#createPhaseSetIncluding}.
+ */
+ public void testCreatePhaseSetIncluding() {
+ //null argument
+ try {
+ engine.createPhaseSetIncluding(null);
+ fail("1.0");
+ } catch (RuntimeException e) {
//expected
}
+ //empty argument
+ IPhaseSet set = engine.createPhaseSetIncluding(new String[0]);
+ assertNotNull("2.0", set);
+ assertEquals("2.1", 0, set.getPhaseIds().length);
+
+ //unknown argument
+ set = engine.createPhaseSetIncluding(new String[] {"blort", "not a phase", "bad input"});
+ assertNotNull("3.0", set);
+ assertEquals("3.1", 0, set.getPhaseIds().length);
+
+ //one valid phase
+ set = engine.createPhaseSetIncluding(new String[] {IPhaseSet.PHASE_COLLECT});
+ assertNotNull("4.0", set);
+ assertEquals("4.1", 1, set.getPhaseIds().length);
+ assertEquals("4.2", IPhaseSet.PHASE_COLLECT, set.getPhaseIds()[0]);
+
+ //one valid phase and one bogus
+ set = engine.createPhaseSetIncluding(new String[] {IPhaseSet.PHASE_COLLECT, "bogus"});
+ assertNotNull("4.0", set);
+ assertEquals("4.1", 1, set.getPhaseIds().length);
+ assertEquals("4.2", IPhaseSet.PHASE_COLLECT, set.getPhaseIds()[0]);
+
}
public void testEmptyOperands() {
IProfile profile = createProfile("test");
- PhaseSet phaseSet = new DefaultPhaseSet();
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertTrue(result.isOK());
}
@@ -219,7 +283,7 @@ public class EngineTest extends AbstractProvisioningTest {
InstallableUnitOperand op = new InstallableUnitOperand(createResolvedIU(createIU("name")), null);
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {op};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
assertTrue(result.isOK());
}
@@ -235,7 +299,6 @@ public class EngineTest extends AbstractProvisioningTest {
public void testPerformPropertyInstallUninstall() {
IProfile profile = createProfile("testPerformPropertyInstallUninstall");
- PhaseSet phaseSet = new DefaultPhaseSet();
PropertyOperand propOp = new PropertyOperand("test", null, "test");
IInstallableUnit testIU = createResolvedIU(createIU("test"));
@@ -243,7 +306,7 @@ public class EngineTest extends AbstractProvisioningTest {
InstallableUnitPropertyOperand iuPropOp = new InstallableUnitPropertyOperand(testIU, "test", null, "test");
Operand[] operands = new Operand[] {propOp, iuOp, iuPropOp};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertTrue(result.isOK());
assertEquals("test", profile.getProperty("test"));
assertEquals("test", profile.getInstallableUnitProperty(testIU, "test"));
@@ -251,7 +314,7 @@ public class EngineTest extends AbstractProvisioningTest {
PropertyOperand uninstallPropOp = new PropertyOperand("test", "test", null);
InstallableUnitPropertyOperand uninstallIuPropOp = new InstallableUnitPropertyOperand(testIU, "test", "test", null);
operands = new Operand[] {uninstallPropOp, uninstallIuPropOp};
- result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertTrue(result.isOK());
assertNull("test", profile.getProperty("test"));
assertNull("test", profile.getInstallableUnitProperty(testIU, "test"));
@@ -262,18 +325,17 @@ public class EngineTest extends AbstractProvisioningTest {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformSizing", null, properties);
+ IProfile profile = createProfile("testPerformSizing", properties);
for (Iterator it = getInstallableUnits(profile); it.hasNext();) {
- PhaseSet phaseSet = new DefaultPhaseSet();
IInstallableUnit doomed = (IInstallableUnit) it.next();
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(createResolvedIU(doomed), null)};
- engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
}
final Sizing sizingPhase = new Sizing(100, "sizing");
PhaseSet phaseSet = new PhaseSet(new Phase[] {sizingPhase}) {};
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU())};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
assertTrue(result.isOK());
assertTrue(sizingPhase.getDiskSize() == 0);
assertTrue(sizingPhase.getDlSize() == 0);
@@ -283,17 +345,15 @@ public class EngineTest extends AbstractProvisioningTest {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformInstallOSGiFramework", null, properties);
+ IProfile profile = createProfile("testPerformInstallOSGiFramework", properties);
for (Iterator it = getInstallableUnits(profile); it.hasNext();) {
- PhaseSet phaseSet = new DefaultPhaseSet();
IInstallableUnit doomed = (IInstallableUnit) it.next();
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(createResolvedIU(doomed), null)};
- engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
}
PhaseSet phaseSet = new DefaultPhaseSet();
-
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU())};
- IStatus result = engine.validate(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = ((Engine) engine).validate(profile, phaseSet, operands, null, new NullProgressMonitor());
assertTrue(result.isOK());
}
@@ -301,17 +361,14 @@ public class EngineTest extends AbstractProvisioningTest {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformInstallOSGiFramework", null, properties);
+ IProfile profile = createProfile("testPerformInstallOSGiFramework", properties);
for (Iterator it = getInstallableUnits(profile); it.hasNext();) {
- PhaseSet phaseSet = new DefaultPhaseSet();
IInstallableUnit doomed = (IInstallableUnit) it.next();
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(createResolvedIU(doomed), null)};
- engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
}
- PhaseSet phaseSet = new DefaultPhaseSet();
-
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU())};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertTrue(result.isOK());
Iterator ius = getInstallableUnits(profile);
assertTrue(ius.hasNext());
@@ -320,22 +377,21 @@ public class EngineTest extends AbstractProvisioningTest {
public void testPerformUpdateOSGiFramework() {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformUpdateOSGiFramework", null, properties);
- PhaseSet phaseSet = new DefaultPhaseSet();
+ IProfile profile = createProfile("testPerformUpdateOSGiFramework", properties);
IInstallableUnit iu33 = createOSGiIU("3.3");
IInstallableUnit iu34 = createOSGiIU("3.4");
InstallableUnitOperand[] installOperands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, iu33)};
- IStatus result = engine.perform(profile, phaseSet, installOperands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, installOperands, null), new NullProgressMonitor());
assertTrue(result.isOK());
- Iterator ius = profile.query(new InstallableUnitQuery(iu33), new Collector(), null).iterator();
+ Iterator ius = profile.query(new InstallableUnitQuery(iu33), null).iterator();
assertTrue(ius.hasNext());
InstallableUnitOperand[] updateOperands = new InstallableUnitOperand[] {new InstallableUnitOperand(iu33, iu34)};
- result = engine.perform(profile, phaseSet, updateOperands, null, new NullProgressMonitor());
+ result = engine.perform(engine.createCustomPlan(profile, updateOperands, null), new NullProgressMonitor());
assertTrue(result.isOK());
- ius = profile.query(new InstallableUnitQuery(iu34), new Collector(), null).iterator();
+ ius = profile.query(new InstallableUnitQuery(iu34), null).iterator();
assertTrue(ius.hasNext());
}
@@ -344,10 +400,9 @@ public class EngineTest extends AbstractProvisioningTest {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformUninstallOSGiFramework", null, properties);
- PhaseSet phaseSet = new DefaultPhaseSet();
+ IProfile profile = createProfile("testPerformUninstallOSGiFramework", properties);
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(createOSGiIU(), null)};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertTrue(result.isOK());
assertEmptyProfile(profile);
}
@@ -356,14 +411,13 @@ public class EngineTest extends AbstractProvisioningTest {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformRollback", null, properties);
- PhaseSet phaseSet = new DefaultPhaseSet();
+ IProfile profile = createProfile("testPerformRollback", properties);
Iterator ius = getInstallableUnits(profile);
assertFalse(ius.hasNext());
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU()), new InstallableUnitOperand(null, createBadIU())};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertFalse(result.isOK());
ius = getInstallableUnits(profile);
@@ -374,14 +428,14 @@ public class EngineTest extends AbstractProvisioningTest {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformRollback", null, properties);
+ IProfile profile = createProfile("testPerformRollback", properties);
PhaseSet phaseSet = new DefaultPhaseSet();
Iterator ius = getInstallableUnits(profile);
assertFalse(ius.hasNext());
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU()), new InstallableUnitOperand(null, createMissingActionIU())};
- IStatus result = engine.validate(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = ((Engine) engine).validate(profile, phaseSet, operands, null, new NullProgressMonitor());
assertFalse(result.isOK());
Throwable t = result.getException();
@@ -394,14 +448,13 @@ public class EngineTest extends AbstractProvisioningTest {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformMissingAction", null, properties);
- PhaseSet phaseSet = new DefaultPhaseSet();
+ IProfile profile = createProfile("testPerformMissingAction", properties);
Iterator ius = getInstallableUnits(profile);
assertFalse(ius.hasNext());
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU()), new InstallableUnitOperand(null, createMissingActionIU())};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertFalse(result.isOK());
ius = getInstallableUnits(profile);
assertFalse(ius.hasNext());
@@ -411,7 +464,7 @@ public class EngineTest extends AbstractProvisioningTest {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformRollbackOnError", null, properties);
+ IProfile profile = createProfile("testPerformRollbackOnError", properties);
NPEPhase phase = new NPEPhase();
PhaseSet phaseSet = new TestPhaseSet(phase);
@@ -419,7 +472,7 @@ public class EngineTest extends AbstractProvisioningTest {
assertFalse(ius.hasNext());
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU())};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
assertFalse(result.isOK());
ius = getInstallableUnits(profile);
assertFalse(ius.hasNext());
@@ -430,7 +483,7 @@ public class EngineTest extends AbstractProvisioningTest {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformRollbackOnError", null, properties);
+ IProfile profile = createProfile("testPerformRollbackOnError", properties);
ActionNPEPhase phase = new ActionNPEPhase();
PhaseSet phaseSet = new TestPhaseSet(phase);
@@ -438,7 +491,7 @@ public class EngineTest extends AbstractProvisioningTest {
assertFalse(ius.hasNext());
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU())};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
assertFalse(result.isOK());
ius = getInstallableUnits(profile);
assertFalse(ius.hasNext());
@@ -448,7 +501,7 @@ public class EngineTest extends AbstractProvisioningTest {
public void testPerformForcedPhaseWithActionError() {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformForceWithActionError", null, properties);
+ IProfile profile = createProfile("testPerformForceWithActionError", properties);
ActionNPEPhase phase = new ActionNPEPhase(true);
PhaseSet phaseSet = new TestPhaseSet(phase);
@@ -456,7 +509,7 @@ public class EngineTest extends AbstractProvisioningTest {
assertFalse(ius.hasNext());
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createOSGiIU())};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
assertTrue(result.isOK());
ius = getInstallableUnits(profile);
assertTrue(ius.hasNext());
@@ -466,7 +519,7 @@ public class EngineTest extends AbstractProvisioningTest {
public void testPerformForcedUninstallWithBadUninstallIUActionThrowsException() {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformForcedUninstallWithBadUninstallIUActionThrowsException", null, properties);
+ IProfile profile = createProfile("testPerformForcedUninstallWithBadUninstallIUActionThrowsException", properties);
// forcedUninstall is false by default
PhaseSet phaseSet = new DefaultPhaseSet();
@@ -476,20 +529,20 @@ public class EngineTest extends AbstractProvisioningTest {
IInstallableUnit badUninstallIU = createBadUninstallIUThrowsException();
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, badUninstallIU)};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertTrue(result.isOK());
ius = getInstallableUnits(profile);
assertTrue(ius.hasNext());
operands = new InstallableUnitOperand[] {new InstallableUnitOperand(badUninstallIU, null)};
- result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertFalse(result.isOK());
ius = getInstallableUnits(profile);
assertTrue(ius.hasNext());
// this simulates a DefaultPhaseSet with forcedUninstall set
phaseSet = new TestPhaseSet(true);
- result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
assertTrue(result.isOK());
ius = getInstallableUnits(profile);
assertFalse(ius.hasNext());
@@ -498,30 +551,29 @@ public class EngineTest extends AbstractProvisioningTest {
public void testPerformForcedUninstallWithBadUninstallIUActionReturnsError() {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, testProvisioning.getAbsolutePath());
- IProfile profile = createProfile("testPerformForcedUninstallWithBadUninstallIUActionReturnsError", null, properties);
+ IProfile profile = createProfile("testPerformForcedUninstallWithBadUninstallIUActionReturnsError", properties);
// forcedUninstall is false by default
- PhaseSet phaseSet = new DefaultPhaseSet();
Iterator ius = getInstallableUnits(profile);
assertFalse(ius.hasNext());
IInstallableUnit badUninstallIU = createBadUninstallIUReturnsError();
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, badUninstallIU)};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertTrue(result.isOK());
ius = getInstallableUnits(profile);
assertTrue(ius.hasNext());
operands = new InstallableUnitOperand[] {new InstallableUnitOperand(badUninstallIU, null)};
- result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertFalse(result.isOK());
ius = getInstallableUnits(profile);
assertTrue(ius.hasNext());
// this simulates a DefaultPhaseSet with forcedUninstall set
- phaseSet = new TestPhaseSet(true);
- result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IPhaseSet phaseSet = new TestPhaseSet(true);
+ result = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
assertTrue(result.isOK());
ius = getInstallableUnits(profile);
assertFalse(ius.hasNext());
@@ -529,15 +581,14 @@ public class EngineTest extends AbstractProvisioningTest {
public void testOrphanedIUProperty() {
IProfile profile = createProfile("testOrphanedIUProperty");
- PhaseSet phaseSet = new DefaultPhaseSet();
IInstallableUnit iu = createIU("someIU");
Operand[] operands = new InstallableUnitPropertyOperand[] {new InstallableUnitPropertyOperand(iu, "key", null, "value")};
- IStatus result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ IStatus result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertTrue(result.isOK());
assertFalse(profile.getInstallableUnitProperties(iu).containsKey("key"));
operands = new Operand[] {new InstallableUnitOperand(null, iu), new InstallableUnitPropertyOperand(iu, "adifferentkey", null, "value")};
- result = engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ result = engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
assertTrue(result.isOK());
assertTrue(profile.getInstallableUnitProperties(iu).containsKey("adifferentkey"));
assertFalse(profile.getInstallableUnitProperties(iu).containsKey("key"));
@@ -550,7 +601,7 @@ public class EngineTest extends AbstractProvisioningTest {
private IInstallableUnit createOSGiIU(String version) {
InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription();
description.setId("org.eclipse.osgi");
- description.setVersion(new Version(version));
+ description.setVersion(Version.create(version));
description.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI);
Map touchpointData = new HashMap();
String manifest = "Manifest-Version: 1.0\r\n" + "Bundle-Activator: org.eclipse.osgi.framework.internal.core.SystemBundl\r\n" + " eActivator\r\n" + "Bundle-RequiredExecutionEnvironment: J2SE-1.4,OSGi/Minimum-1.0\r\n" + "Export-Package: org.eclipse.osgi.event;version=\"1.0\",org.eclipse.osgi.\r\n" + " framework.console;version=\"1.0\",org.eclipse.osgi.framework.eventmgr;v\r\n" + " ersion=\"1.0\",org.eclipse.osgi.framework.log;version=\"1.0\",org.eclipse\r\n" + " .osgi.service.datalocation;version=\"1.0\",org.eclipse.osgi.service.deb\r\n" + " ug;version=\"1.0\",org.eclipse.osgi.service.environment;version=\"1.0\",o\r\n" + " rg.eclipse.osgi.service.localization;version=\"1.0\",org.eclipse.osgi.s\r\n" + " ervice.pluginconversion;version=\"1.0\",org.eclipse.osgi.service.resolv\r\n"
@@ -568,7 +619,7 @@ public class EngineTest extends AbstractProvisioningTest {
IInstallableUnitFragment fragment = MetadataFactory.createInstallableUnitFragment(desc);
cus[0] = fragment;
- //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", new Version("3.3.1.R33x_v20070828"));
+ //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", Version.create("3.3.1.R33x_v20070828"));
//iu.setArtifacts(new IArtifactKey[] {key});
IInstallableUnit iu = MetadataFactory.createInstallableUnit(description);
@@ -578,7 +629,7 @@ public class EngineTest extends AbstractProvisioningTest {
private IInstallableUnit createBadIU() {
InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription();
description.setId("org.eclipse.osgi.bad");
- description.setVersion(new Version("3.3.1.R33x_v20070828"));
+ description.setVersion(Version.create("3.3.1.R33x_v20070828"));
description.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI);
Map touchpointData = new HashMap();
String manifest = "Manifest-Version: 1.0\r\n" + "Bundle-Activator: org.eclipse.osgi.framework.internal.core.SystemBundl\r\n" + " eActivator\r\n" + "Bundle-RequiredExecutionEnvironment: J2SE-1.4,OSGi/Minimum-1.0\r\n" + "Export-Package: org.eclipse.osgi.event;version=\"1.0\",org.eclipse.osgi.\r\n" + " framework.console;version=\"1.0\",org.eclipse.osgi.framework.eventmgr;v\r\n" + " ersion=\"1.0\",org.eclipse.osgi.framework.log;version=\"1.0\",org.eclipse\r\n" + " .osgi.service.datalocation;version=\"1.0\",org.eclipse.osgi.service.deb\r\n" + " ug;version=\"1.0\",org.eclipse.osgi.service.environment;version=\"1.0\",o\r\n" + " rg.eclipse.osgi.service.localization;version=\"1.0\",org.eclipse.osgi.s\r\n" + " ervice.pluginconversion;version=\"1.0\",org.eclipse.osgi.service.resolv\r\n"
@@ -594,7 +645,7 @@ public class EngineTest extends AbstractProvisioningTest {
desc.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
cus[0] = MetadataFactory.createInstallableUnitFragment(desc);
- //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", new Version("3.3.1.R33x_v20070828"));
+ //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", Version.create("3.3.1.R33x_v20070828"));
//iu.setArtifacts(new IArtifactKey[] {key});
IInstallableUnit iu = MetadataFactory.createInstallableUnit(description);
@@ -604,7 +655,7 @@ public class EngineTest extends AbstractProvisioningTest {
private IInstallableUnit createBadUninstallIUReturnsError() {
InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription();
description.setId("org.eclipse.osgi.bad");
- description.setVersion(new Version("3.3.1.R33x_v20070828"));
+ description.setVersion(Version.create("3.3.1.R33x_v20070828"));
description.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI);
Map touchpointData = new HashMap();
String manifest = "Manifest-Version: 1.0\r\n" + "Bundle-Activator: org.eclipse.osgi.framework.internal.core.SystemBundl\r\n" + " eActivator\r\n" + "Bundle-RequiredExecutionEnvironment: J2SE-1.4,OSGi/Minimum-1.0\r\n" + "Export-Package: org.eclipse.osgi.event;version=\"1.0\",org.eclipse.osgi.\r\n" + " framework.console;version=\"1.0\",org.eclipse.osgi.framework.eventmgr;v\r\n" + " ersion=\"1.0\",org.eclipse.osgi.framework.log;version=\"1.0\",org.eclipse\r\n" + " .osgi.service.datalocation;version=\"1.0\",org.eclipse.osgi.service.deb\r\n" + " ug;version=\"1.0\",org.eclipse.osgi.service.environment;version=\"1.0\",o\r\n" + " rg.eclipse.osgi.service.localization;version=\"1.0\",org.eclipse.osgi.s\r\n" + " ervice.pluginconversion;version=\"1.0\",org.eclipse.osgi.service.resolv\r\n"
@@ -620,7 +671,7 @@ public class EngineTest extends AbstractProvisioningTest {
desc.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
cus[0] = MetadataFactory.createInstallableUnitFragment(desc);
- //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", new Version("3.3.1.R33x_v20070828"));
+ //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", Version.create("3.3.1.R33x_v20070828"));
//iu.setArtifacts(new IArtifactKey[] {key});
IInstallableUnit iu = MetadataFactory.createInstallableUnit(description);
@@ -630,7 +681,7 @@ public class EngineTest extends AbstractProvisioningTest {
private IInstallableUnit createBadUninstallIUThrowsException() {
InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription();
description.setId("org.eclipse.osgi.bad");
- description.setVersion(new Version("3.3.1.R33x_v20070828"));
+ description.setVersion(Version.create("3.3.1.R33x_v20070828"));
description.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI);
Map touchpointData = new HashMap();
String manifest = "Manifest-Version: 1.0\r\n" + "Bundle-Activator: org.eclipse.osgi.framework.internal.core.SystemBundl\r\n" + " eActivator\r\n" + "Bundle-RequiredExecutionEnvironment: J2SE-1.4,OSGi/Minimum-1.0\r\n" + "Export-Package: org.eclipse.osgi.event;version=\"1.0\",org.eclipse.osgi.\r\n" + " framework.console;version=\"1.0\",org.eclipse.osgi.framework.eventmgr;v\r\n" + " ersion=\"1.0\",org.eclipse.osgi.framework.log;version=\"1.0\",org.eclipse\r\n" + " .osgi.service.datalocation;version=\"1.0\",org.eclipse.osgi.service.deb\r\n" + " ug;version=\"1.0\",org.eclipse.osgi.service.environment;version=\"1.0\",o\r\n" + " rg.eclipse.osgi.service.localization;version=\"1.0\",org.eclipse.osgi.s\r\n" + " ervice.pluginconversion;version=\"1.0\",org.eclipse.osgi.service.resolv\r\n"
@@ -646,7 +697,7 @@ public class EngineTest extends AbstractProvisioningTest {
desc.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
cus[0] = MetadataFactory.createInstallableUnitFragment(desc);
- //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", new Version("3.3.1.R33x_v20070828"));
+ //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", Version.create("3.3.1.R33x_v20070828"));
//iu.setArtifacts(new IArtifactKey[] {key});
IInstallableUnit iu = MetadataFactory.createInstallableUnit(description);
@@ -656,7 +707,7 @@ public class EngineTest extends AbstractProvisioningTest {
private IInstallableUnit createMissingActionIU() {
InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription();
description.setId("org.eclipse.osgi.bad");
- description.setVersion(new Version("3.3.1.R33x_v20070828"));
+ description.setVersion(Version.create("3.3.1.R33x_v20070828"));
description.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI);
Map touchpointData = new HashMap();
String manifest = "Manifest-Version: 1.0\r\n" + "Bundle-Activator: org.eclipse.osgi.framework.internal.core.SystemBundl\r\n" + " eActivator\r\n" + "Bundle-RequiredExecutionEnvironment: J2SE-1.4,OSGi/Minimum-1.0\r\n" + "Export-Package: org.eclipse.osgi.event;version=\"1.0\",org.eclipse.osgi.\r\n" + " framework.console;version=\"1.0\",org.eclipse.osgi.framework.eventmgr;v\r\n" + " ersion=\"1.0\",org.eclipse.osgi.framework.log;version=\"1.0\",org.eclipse\r\n" + " .osgi.service.datalocation;version=\"1.0\",org.eclipse.osgi.service.deb\r\n" + " ug;version=\"1.0\",org.eclipse.osgi.service.environment;version=\"1.0\",o\r\n" + " rg.eclipse.osgi.service.localization;version=\"1.0\",org.eclipse.osgi.s\r\n" + " ervice.pluginconversion;version=\"1.0\",org.eclipse.osgi.service.resolv\r\n"
@@ -672,7 +723,7 @@ public class EngineTest extends AbstractProvisioningTest {
desc.addTouchpointData(MetadataFactory.createTouchpointData(touchpointData));
cus[0] = MetadataFactory.createInstallableUnitFragment(desc);
- //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", new Version("3.3.1.R33x_v20070828"));
+ //IArtifactKey key = new ArtifactKey("eclipse", "plugin", "org.eclipse.osgi", Version.create("3.3.1.R33x_v20070828"));
//iu.setArtifacts(new IArtifactKey[] {key});
IInstallableUnit iu = MetadataFactory.createInstallableUnit(description);
@@ -682,8 +733,8 @@ public class EngineTest extends AbstractProvisioningTest {
public void testIncompatibleProfile() {
IProfile profile = new IProfile() {
- public Collector available(Query query, Collector collector, IProgressMonitor monitor) {
- return null;
+ public Collector available(IQuery query, IProgressMonitor monitor) {
+ return new Collector();
}
public Map getInstallableUnitProperties(IInstallableUnit iu) {
@@ -694,18 +745,6 @@ public class EngineTest extends AbstractProvisioningTest {
return null;
}
- public Map getLocalProperties() {
- return null;
- }
-
- public String getLocalProperty(String key) {
- return null;
- }
-
- public IProfile getParentProfile() {
- return null;
- }
-
public String getProfileId() {
return null;
}
@@ -718,30 +757,17 @@ public class EngineTest extends AbstractProvisioningTest {
return null;
}
- public String[] getSubProfileIds() {
- return null;
- }
-
public long getTimestamp() {
return 0;
}
- public boolean hasSubProfiles() {
- return false;
- }
-
- public boolean isRootProfile() {
- return false;
- }
-
- public Collector query(Query query, Collector collector, IProgressMonitor monitor) {
- return null;
+ public Collector query(IQuery query, IProgressMonitor monitor) {
+ return new Collector();
}
};
- PhaseSet phaseSet = new DefaultPhaseSet();
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {};
try {
- engine.perform(profile, phaseSet, operands, null, new NullProgressMonitor());
+ engine.perform(engine.createCustomPlan(profile, operands, null), new NullProgressMonitor());
} catch (IllegalArgumentException expected) {
return;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java
index ec2f10ea2..c37eabce8 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/InstructionParserTest.java
@@ -10,23 +10,24 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.engine;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
+import java.util.List;
import java.util.Map;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.engine.ActionManager;
import org.eclipse.equinox.internal.p2.engine.InstructionParser;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
-import org.eclipse.equinox.internal.provisional.p2.engine.Touchpoint;
-import org.eclipse.equinox.internal.provisional.p2.metadata.ITouchpointType;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.Touchpoint;
+import org.eclipse.equinox.p2.metadata.ITouchpointType;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class InstructionParserTest extends AbstractProvisioningTest {
- public static final ITouchpointType TOUCHPOINT_TYPE = MetadataFactory.createTouchpointType("InstructionParserTestTouchpoint", new Version("1.0")); //$NON-NLS-1$ //$NON-NLS-2$
+ public static final ITouchpointType TOUCHPOINT_TYPE = MetadataFactory.createTouchpointType("InstructionParserTestTouchpoint", Version.create("1.0")); //$NON-NLS-1$ //$NON-NLS-2$
public static class InstructionParserTestTouchpoint extends Touchpoint {
@@ -65,21 +66,21 @@ public class InstructionParserTest extends AbstractProvisioningTest {
public void testGoodAction() {
InstructionParser parser = new InstructionParser(new ActionManager());
- ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction()", null), TOUCHPOINT_TYPE);
- assertEquals(1, actions.length);
+ List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction()", null), TOUCHPOINT_TYPE);
+ assertEquals(1, actions.size());
}
public void testGoodActionFullyQualified() {
InstructionParser parser = new InstructionParser(new ActionManager());
- ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("instructionparsertest.goodAction()", null), null);
- assertEquals(1, actions.length);
+ List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("instructionparsertest.goodAction()", null), null);
+ assertEquals(1, actions.size());
}
public void testBadActionFullyQualified() {
InstructionParser parser = new InstructionParser(new ActionManager());
try {
- ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("instructionparsertest.badAction()", null), null);
- actions[0].execute(null);
+ List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("instructionparsertest.badAction()", null), null);
+ actions.get(0).execute(null);
} catch (IllegalArgumentException e) {
return;
}
@@ -88,21 +89,21 @@ public class InstructionParserTest extends AbstractProvisioningTest {
public void testGoodActionFromImport() {
InstructionParser parser = new InstructionParser(new ActionManager());
- ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction()", "instructionparsertest.goodAction"), null);
- assertEquals(1, actions.length);
+ List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction()", "instructionparsertest.goodAction"), null);
+ assertEquals(1, actions.size());
}
public void testGoodActionFromImportWithVersionRange() {
InstructionParser parser = new InstructionParser(new ActionManager());
- ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction()", "instructionparsertest.goodAction;version=[1.0,2.0)"), null);
- assertEquals(1, actions.length);
+ List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction()", "instructionparsertest.goodAction;version=[1.0,2.0)"), null);
+ assertEquals(1, actions.size());
}
public void testBadActionFromImport() {
InstructionParser parser = new InstructionParser(new ActionManager());
try {
- ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("badAction()", "instructionparsertest.badAction"), null);
- actions[0].execute(null);
+ List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("badAction()", "instructionparsertest.badAction"), null);
+ actions.get(0).execute(null);
} catch (IllegalArgumentException e) {
return;
}
@@ -111,20 +112,20 @@ public class InstructionParserTest extends AbstractProvisioningTest {
public void testGoodActions() {
InstructionParser parser = new InstructionParser(new ActionManager());
- ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(); goodAction()", null), TOUCHPOINT_TYPE);
- assertEquals(2, actions.length);
+ List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(); goodAction()", null), TOUCHPOINT_TYPE);
+ assertEquals(2, actions.size());
}
public void testGoodParameter() {
InstructionParser parser = new InstructionParser(new ActionManager());
- ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(a:1)", null), TOUCHPOINT_TYPE);
- assertEquals(1, actions.length);
+ List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(a:1)", null), TOUCHPOINT_TYPE);
+ assertEquals(1, actions.size());
}
public void testGoodParameters() {
InstructionParser parser = new InstructionParser(new ActionManager());
- ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(a:1, b:2)", null), TOUCHPOINT_TYPE);
- assertEquals(1, actions.length);
+ List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(a:1, b:2)", null), TOUCHPOINT_TYPE);
+ assertEquals(1, actions.size());
}
public void testBadParameter() {
@@ -160,8 +161,8 @@ public class InstructionParserTest extends AbstractProvisioningTest {
public void testGoodActionBadAction() {
InstructionParser parser = new InstructionParser(new ActionManager());
try {
- ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(); badAction()", null), TOUCHPOINT_TYPE);
- actions[1].execute(null);
+ List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("goodAction(); badAction()", null), TOUCHPOINT_TYPE);
+ actions.get(1).execute(null);
} catch (IllegalArgumentException e) {
return;
}
@@ -171,8 +172,8 @@ public class InstructionParserTest extends AbstractProvisioningTest {
public void testNoActionFound() {
InstructionParser parser = new InstructionParser(new ActionManager());
try {
- ProvisioningAction[] actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("notfoundaction()", null), TOUCHPOINT_TYPE);
- actions[0].execute(null);
+ List<ProvisioningAction> actions = parser.parseActions(MetadataFactory.createTouchpointInstruction("notfoundaction()", null), TOUCHPOINT_TYPE);
+ actions.get(0).execute(null);
} catch (IllegalArgumentException e) {
return;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java
index 10ad1b8a7..e0069225f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ParameterizedProvisioningActionTest.java
@@ -14,7 +14,7 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.internal.p2.engine.ParameterizedProvisioningAction;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class ParameterizedProvisioningActionTest extends AbstractProvisioningTest {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java
index c8da12b6e..a717ac609 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseApplicabilityTest.java
@@ -10,11 +10,11 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.engine;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.engine.InstallableUnitOperand;
-import org.eclipse.equinox.internal.provisional.p2.engine.phases.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.internal.p2.engine.phases.*;
+import org.eclipse.equinox.p2.engine.InstallableUnitOperand;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
@@ -32,8 +32,8 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest {
public void testCollectPhase() {
- IInstallableUnit iuXv1 = createIU("iuX", new Version("1.0.0"));
- IInstallableUnit iuXv2 = createIU("iuX", new Version("2.0.0"));
+ IInstallableUnit iuXv1 = createIU("iuX", Version.create("1.0.0"));
+ IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0"));
Collect collectPhase = new Collect(1) {
protected boolean isApplicable(InstallableUnitOperand op) {
@@ -48,8 +48,8 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest {
public void testSizingPhase() {
- IInstallableUnit iuXv1 = createIU("iuX", new Version("1.0.0"));
- IInstallableUnit iuXv2 = createIU("iuX", new Version("2.0.0"));
+ IInstallableUnit iuXv1 = createIU("iuX", Version.create("1.0.0"));
+ IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0"));
Sizing sizingPhase = new Sizing(1, "collect") {
protected boolean isApplicable(InstallableUnitOperand op) {
@@ -64,8 +64,8 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest {
public void testUnconfigurePhase() {
- IInstallableUnit iuXv1 = createIU("iuX", new Version("1.0.0"));
- IInstallableUnit iuXv2 = createIU("iuX", new Version("2.0.0"));
+ IInstallableUnit iuXv1 = createIU("iuX", Version.create("1.0.0"));
+ IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0"));
Unconfigure unconfigurePhase = new Unconfigure(1) {
protected boolean isApplicable(InstallableUnitOperand op) {
@@ -80,8 +80,8 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest {
public void testUninstallPhase() {
- IInstallableUnit iuXv1 = createIU("iuX", new Version("1.0.0"));
- IInstallableUnit iuXv2 = createIU("iuX", new Version("2.0.0"));
+ IInstallableUnit iuXv1 = createIU("iuX", Version.create("1.0.0"));
+ IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0"));
Uninstall uninstallPhase = new Uninstall(1) {
protected boolean isApplicable(InstallableUnitOperand op) {
@@ -96,8 +96,8 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest {
public void testInstallPhase() {
- IInstallableUnit iuXv1 = createIU("iuX", new Version("1.0.0"));
- IInstallableUnit iuXv2 = createIU("iuX", new Version("2.0.0"));
+ IInstallableUnit iuXv1 = createIU("iuX", Version.create("1.0.0"));
+ IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0"));
Install installPhase = new Install(1) {
protected boolean isApplicable(InstallableUnitOperand op) {
@@ -112,8 +112,8 @@ public class PhaseApplicabilityTest extends AbstractProvisioningTest {
public void testConfigurePhase() {
- IInstallableUnit iuXv1 = createIU("iuX", new Version("1.0.0"));
- IInstallableUnit iuXv2 = createIU("iuX", new Version("2.0.0"));
+ IInstallableUnit iuXv1 = createIU("iuX", Version.create("1.0.0"));
+ IInstallableUnit iuXv2 = createIU("iuX", Version.create("2.0.0"));
Configure configurePhase = new Configure(1) {
protected boolean isApplicable(InstallableUnitOperand op) {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java
index 7f714321b..2faad7acf 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseSetTest.java
@@ -12,7 +12,8 @@ package org.eclipse.equinox.p2.tests.engine;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
+import org.eclipse.equinox.internal.p2.engine.*;
+import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
@@ -53,7 +54,7 @@ public class PhaseSetTest extends AbstractProvisioningTest {
InstallableUnitOperand[] operands = new InstallableUnitOperand[] {op};
ProvisioningContext context = new ProvisioningContext();
- IStatus result = phaseSet.perform(null, new EngineSession(profile, null, context), profile, operands, context, new NullProgressMonitor());
+ IStatus result = phaseSet.perform(new EngineSession(null, profile, context), operands, new NullProgressMonitor());
assertTrue(result.isOK());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java
index 5f26f5e68..30b6b1d8c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/PhaseTest.java
@@ -10,15 +10,17 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.engine;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.File;
import java.io.IOException;
import java.util.*;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.p2.engine.ParameterizedProvisioningAction;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.p2.engine.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.ServiceReference;
@@ -79,9 +81,9 @@ public class PhaseTest extends AbstractProvisioningTest {
return super.initializePhase(monitor, profile, parameters);
}
- protected ProvisioningAction[] getActions(InstallableUnitOperand operand) {
+ protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) {
IInstallableUnit unit = operand.second();
- ProvisioningAction[] parsedActions = getActions(unit, phaseId);
+ List<ProvisioningAction> parsedActions = getActions(unit, phaseId);
if (parsedActions != null)
return parsedActions;
@@ -94,7 +96,7 @@ public class PhaseTest extends AbstractProvisioningTest {
if (action == null) {
throw new IllegalArgumentException("action not found: " + phaseId);
}
- return new ProvisioningAction[] {action};
+ return Collections.singletonList(action);
}
}
@@ -160,7 +162,8 @@ public class PhaseTest extends AbstractProvisioningTest {
PhaseSet phaseSet = new TestPhaseSet(new TestPhase());
IProfile profile = createProfile("PhaseTest");
- engine.perform(profile, phaseSet, new InstallableUnitOperand[0], null, new NullProgressMonitor());
+ final InstallableUnitOperand[] operands = new InstallableUnitOperand[0];
+ engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
}
public void testInitCompletePhase() {
@@ -186,7 +189,8 @@ public class PhaseTest extends AbstractProvisioningTest {
PhaseSet phaseSet = new TestPhaseSet(phase);
IProfile profile = createProfile("PhaseTest");
IInstallableUnit unit = createIU("unit");
- engine.perform(profile, phaseSet, new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)}, null, new NullProgressMonitor());
+ final InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)};
+ engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
assertTrue(phase.initializePhase);
assertTrue(phase.completePhase);
}
@@ -215,7 +219,8 @@ public class PhaseTest extends AbstractProvisioningTest {
IProfile profile = createProfile("PhaseTest");
IInstallableUnit unit = createIU("testInitCompleteOperand");
- engine.perform(profile, phaseSet, new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)}, null, new NullProgressMonitor());
+ final InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)};
+ engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
assertTrue(phase.initializeOperand);
assertTrue(phase.completeOperand);
}
@@ -250,7 +255,8 @@ public class PhaseTest extends AbstractProvisioningTest {
IProfile profile = createProfile("PhaseTest");
IInstallableUnit unit = createIU("testGetProfileDataArea");
- engine.perform(profile, phaseSet, new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)}, null, new NullProgressMonitor());
+ final InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)};
+ engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
assertTrue(phase.initializePhase);
assertTrue(phase.completePhase);
}
@@ -269,17 +275,17 @@ public class PhaseTest extends AbstractProvisioningTest {
public void testGetAction() {
final ArrayList actionsList1 = new ArrayList();
InstallableUnitPhase phase1 = new InstallableUnitPhase("test", 1) {
- protected ProvisioningAction[] getActions(InstallableUnitOperand operand) {
- ProvisioningAction[] actions = getActions(operand.second(), "test1");
- actionsList1.addAll(Arrays.asList(actions));
+ protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) {
+ List<ProvisioningAction> actions = getActions(operand.second(), "test1");
+ actionsList1.addAll(actions);
return actions;
}
};
final ArrayList actionsList2 = new ArrayList();
InstallableUnitPhase phase2 = new InstallableUnitPhase("test", 1) {
- protected ProvisioningAction[] getActions(InstallableUnitOperand operand) {
- ProvisioningAction[] actions = getActions(operand.second(), "test2");
- actionsList2.addAll(Arrays.asList(actions));
+ protected List<ProvisioningAction> getActions(InstallableUnitOperand operand) {
+ List<ProvisioningAction> actions = getActions(operand.second(), "test2");
+ actionsList2.addAll(actions);
return actions;
}
};
@@ -291,8 +297,9 @@ public class PhaseTest extends AbstractProvisioningTest {
instructions.put("test1", MetadataFactory.createTouchpointInstruction("test1.test()", null));
instructions.put("test2", MetadataFactory.createTouchpointInstruction("test2.test()", null));
ITouchpointData touchpointData = MetadataFactory.createTouchpointData(instructions);
- IInstallableUnit unit = createIU("test", new Version("1.0.0"), null, NO_REQUIRES, new IProvidedCapability[0], NO_PROPERTIES, ITouchpointType.NONE, touchpointData, false);
- IStatus status = engine.perform(profile, phaseSet, new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)}, null, new NullProgressMonitor());
+ IInstallableUnit unit = createIU("test", Version.create("1.0.0"), null, NO_REQUIRES, new IProvidedCapability[0], NO_PROPERTIES, ITouchpointType.NONE, touchpointData, false);
+ final InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, unit)};
+ IStatus status = engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
if (!status.isOK()) {
fail(status.toString());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileMetadataRepositoryTest.java
index 6b5bcc5b8..40b612f58 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileMetadataRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileMetadataRepositoryTest.java
@@ -12,16 +12,14 @@ package org.eclipse.equinox.p2.tests.engine;
import java.io.File;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
+import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepositoryFactory;
import org.eclipse.equinox.internal.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.spi.p2.artifact.repository.SimpleArtifactRepositoryFactory;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
-import org.eclipse.equinox.p2.tests.TestActivator;
/**
* Simple test of the engine API.
@@ -73,7 +71,7 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest {
IProfile profile = registry.getProfile("SDKPatchingTest");
assertNotNull("0.3", profile);
- Collector profileCollector = profile.query(InstallableUnitQuery.ANY, new Collector(), getMonitor());
+ IQueryResult profileCollector = profile.query(InstallableUnitQuery.ANY, getMonitor());
assertFalse("0.4", profileCollector.isEmpty());
File simpleProfileFolder = new File(tempFolder, "SDKPatchingTest.profile");
@@ -87,9 +85,9 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest {
fail("0.99", e1);
}
- Collector repoCollector = repo.query(InstallableUnitQuery.ANY, new Collector(), getMonitor());
+ IQueryResult repoCollector = repo.query(InstallableUnitQuery.ANY, getMonitor());
assertFalse("1.0", repoCollector.isEmpty());
- assertTrue("1.1", repoCollector.toCollection().containsAll(profileCollector.toCollection()));
+ assertContains("1.1", repoCollector, profileCollector);
}
public void testLoadTimestampedProfile() {
@@ -101,7 +99,7 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest {
IProfile profile = registry.getProfile("SDKPatchingTest");
assertNotNull("0.3", profile);
- Collector profileCollector = profile.query(InstallableUnitQuery.ANY, new Collector(), getMonitor());
+ IQueryResult profileCollector = profile.query(InstallableUnitQuery.ANY, getMonitor());
assertFalse("0.4", profileCollector.isEmpty());
File simpleProfileFolder = new File(tempFolder, "SDKPatchingTest.profile");
@@ -118,9 +116,9 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest {
fail("0.99", e1);
}
- Collector repoCollector = repo.query(InstallableUnitQuery.ANY, new Collector(), getMonitor());
+ IQueryResult repoCollector = repo.query(InstallableUnitQuery.ANY, getMonitor());
assertFalse("1.0", repoCollector.isEmpty());
- assertTrue("1.1", repoCollector.toCollection().containsAll(profileCollector.toCollection()));
+ assertContains("1.1", repoCollector, profileCollector);
}
public void DISABLED_testDefaultAgentRepoAndBundlePoolFromProfileRepo() throws InterruptedException {
@@ -128,17 +126,19 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest {
// /p2/org.eclipse.equinox.p2.engine/profileRegistry");
File tempFolder = getTempFolder();
copy("0.2", testData, tempFolder);
- new SimpleArtifactRepositoryFactory().create(tempFolder.toURI(), "", "", null);
+ final SimpleArtifactRepositoryFactory simpleFactory = new SimpleArtifactRepositoryFactory();
+ simpleFactory.setAgent(getAgent());
+ simpleFactory.create(tempFolder.toURI(), "", "", null);
File defaultAgenRepositoryDirectory = new File(tempFolder, "p2/org.eclipse.equinox.p2.core/cache");
- new SimpleArtifactRepositoryFactory().create(defaultAgenRepositoryDirectory.toURI(), "", "", null);
+ simpleFactory.create(defaultAgenRepositoryDirectory.toURI(), "", "", null);
File profileRegistryFolder = new File(tempFolder, "p2/org.eclipse.equinox.p2.engine/profileRegistry");
SimpleProfileRegistry registry = new SimpleProfileRegistry(profileRegistryFolder, null, false);
IProfile profile = registry.getProfile("SDKPatchingTest");
assertNotNull("1.0", profile);
- Collector profileCollector = profile.query(InstallableUnitQuery.ANY, new Collector(), getMonitor());
+ IQueryResult profileCollector = profile.query(InstallableUnitQuery.ANY, getMonitor());
assertFalse("1.1", profileCollector.isEmpty());
File simpleProfileFolder = new File(profileRegistryFolder, "SDKPatchingTest.profile");
@@ -147,7 +147,7 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest {
File timeStampedProfile = new File(simpleProfileFolder, "" + profile.getTimestamp() + ".profile");
assertTrue("1.3", timeStampedProfile.exists());
- IArtifactRepositoryManager manager = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.context, IArtifactRepositoryManager.class.getName());
+ IArtifactRepositoryManager manager = getArtifactRepositoryManager();
assertNotNull("2.0", manager);
assertFalse("2.1", manager.contains(tempFolder.toURI()));
@@ -159,9 +159,9 @@ public class ProfileMetadataRepositoryTest extends AbstractProvisioningTest {
fail("2.99", e1);
}
- Collector repoCollector = repo.query(InstallableUnitQuery.ANY, new Collector(), getMonitor());
+ IQueryResult repoCollector = repo.query(InstallableUnitQuery.ANY, getMonitor());
assertFalse("3.0", repoCollector.isEmpty());
- assertTrue("3.1", repoCollector.toCollection().containsAll(profileCollector.toCollection()));
+ assertContains("3.1", repoCollector, profileCollector);
int maxTries = 20;
int current = 0;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java
index 6f9c50874..81b4a6be3 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfilePreferencesTest.java
@@ -10,12 +10,21 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.engine;
+import java.io.File;
+import java.net.URI;
+import java.util.Hashtable;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IPreferencesService;
+import org.eclipse.equinox.internal.p2.core.ProvisioningAgent;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.engine.ProfilePreferences;
+import org.eclipse.equinox.p2.core.IAgentLocation;
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.engine.ProfileScope;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
+import org.eclipse.equinox.security.storage.EncodingUtils;
+import org.osgi.framework.ServiceRegistration;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
@@ -34,20 +43,47 @@ public class ProfilePreferencesTest extends AbstractProvisioningTest {
public void testInvalidProfile() {
try {
//reading and storing for a non-existent profile shouldn't cause any errors
- Preferences node = prefServ.getRootNode().node("/profile/NonExistantProfile/testing");
+ IAgentLocation agentLocation = (IAgentLocation) getAgent().getService(IAgentLocation.SERVICE_NAME);
+ String locationString = EncodingUtils.encodeSlashes(agentLocation.getRootLocation().toString());
+ Preferences node = prefServ.getRootNode().node("/profile/" + locationString + "/NonExistantProfile/testing");
node.sync();
} catch (BackingStoreException e) {
fail("1.0", e);
}
}
+ /**
+ * Profile preferences looks up the agent location using an LDAP filter. Make
+ * sure it can handle an agent location that contains characters that are not valid in an LDAP filter
+ */
+ public void testInvalidFilterChars() {
+ File folder = getTestData("Prefs", "/testData/ProfilePreferencesTest/with(invalid)chars/");
+ URI location = folder.toURI();
+ ProvisioningAgent agent = new ProvisioningAgent();
+ agent.setLocation(location);
+ agent.setBundleContext(TestActivator.getContext());
+ IAgentLocation agentLocation = (IAgentLocation) agent.getService(IAgentLocation.SERVICE_NAME);
+ Hashtable props = new Hashtable();
+ props.put("locationURI", location.toString());
+ ServiceRegistration reg = TestActivator.getContext().registerService(IProvisioningAgent.SERVICE_NAME, agent, props);
+ try {
+ Preferences prefs = new ProfileScope(agentLocation, "TestProfile").getNode("org.eclipse.equinox.p2.ui.sdk");
+ assertEquals("1.0", "always", prefs.get("allowNonOKPlan", ""));
+ } finally {
+ reg.unregister();
+ }
+
+ }
+
public void testProfilePreference() {
Preferences pref = null;
String key = "Test";
String value = "Value";
+ IAgentLocation agentLocation = (IAgentLocation) getAgent().getService(IAgentLocation.SERVICE_NAME);
+ String locationString = EncodingUtils.encodeSlashes(agentLocation.getRootLocation().toString());
try {
- pref = prefServ.getRootNode().node("/profile/_SELF_/testing");
+ pref = prefServ.getRootNode().node("/profile/" + locationString + "/_SELF_/testing");
} catch (IllegalArgumentException e) {
fail("IllegalArgumentException when accessing preferences for self profile");
}
@@ -68,7 +104,7 @@ public class ProfilePreferencesTest extends AbstractProvisioningTest {
//
}
waitForSave();
- pref = prefServ.getRootNode().node("/profile/_SELF_/testing");
+ pref = prefServ.getRootNode().node("/profile/" + locationString + "/_SELF_/testing");
assertEquals("Value not present after load", value, pref.get(key, null));
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java
index 7d4af1791..70014395b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileRegistryTest.java
@@ -10,25 +10,21 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.engine;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.Properties;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
-import org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener;
-import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.core.IAgentLocation;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.ServiceReference;
@@ -50,7 +46,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest {
}
protected void getServices() {
- registryRef = TestActivator.getContext().getServiceReference(IProfileRegistry.class.getName());
+ registryRef = TestActivator.getContext().getServiceReference(IProfileRegistry.SERVICE_NAME);
registry = (IProfileRegistry) TestActivator.getContext().getService(registryRef);
}
@@ -75,12 +71,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest {
private void restart() {
try {
ungetServices();
- TestActivator.getBundle("org.eclipse.equinox.p2.exemplarysetup").stop();
- TestActivator.getBundle("org.eclipse.equinox.p2.exemplarysetup").start();
- //ensure artifact repository manager is registered with event bus. See bug 247584
- IProvisioningEventBus bus = (IProvisioningEventBus) ServiceHelper.getService(TestActivator.getContext(), IProvisioningEventBus.SERVICE_NAME);
- IArtifactRepositoryManager repoMan = (IArtifactRepositoryManager) ServiceHelper.getService(TestActivator.getContext(), IArtifactRepositoryManager.class.getName());
- bus.addListener((ProvisioningListener) repoMan);
+ restartBundle(TestActivator.getBundle("org.eclipse.equinox.p2.exemplarysetup"));
getServices();
} catch (Exception e) {
fail();
@@ -123,7 +114,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest {
public void testPropertyPeristence() throws ProvisionException {
assertNull(registry.getProfile(PROFILE_NAME));
- Properties properties = new Properties();
+ Map<String, String> properties = new HashMap<String, String>();
properties.put("test", "test");
Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties);
assertTrue(profile.getProperties().containsKey("test"));
@@ -148,28 +139,28 @@ public class ProfileRegistryTest extends AbstractProvisioningTest {
public void testIUPeristence() throws ProvisionException {
assertNull(registry.getProfile(PROFILE_NAME));
Profile profile = (Profile) registry.addProfile(PROFILE_NAME);
- assertEquals(0, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty());
profile.addInstallableUnit(createIU("test"));
- assertEquals(1, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null)));
saveProfile(registry, profile);
restart();
profile = (Profile) registry.getProfile(PROFILE_NAME);
- assertEquals(1, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null)));
profile.removeInstallableUnit(createIU("test"));
- assertEquals(0, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty());
saveProfile(registry, profile);
restart();
profile = (Profile) registry.getProfile(PROFILE_NAME);
- assertEquals(0, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty());
registry.removeProfile(PROFILE_NAME);
restart();
assertNull(registry.getProfile(PROFILE_NAME));
}
public void testIUPropertyPeristence() throws ProvisionException {
- Properties properties = new Properties();
+ Map<String, String> properties = new HashMap<String, String>();
properties.put("test", "test");
assertNull(registry.getProfile(PROFILE_NAME));
Profile profile = (Profile) registry.addProfile(PROFILE_NAME);
@@ -202,7 +193,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest {
public void testTimestampedProfiles() throws ProvisionException {
assertNull(registry.getProfile(PROFILE_NAME));
- Properties properties = new Properties();
+ Map<String, String> properties = new HashMap<String, String>();
properties.put("test", "test");
Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties);
long oldtimestamp = profile.getTimestamp();
@@ -229,7 +220,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest {
public void testIsCurrent() throws Exception {
assertNull(registry.getProfile(PROFILE_NAME));
- Properties properties = new Properties();
+ Map<String, String> properties = new HashMap<String, String>();
properties.put("test", "test");
Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties);
@@ -255,7 +246,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest {
profile = (Profile) registry.getProfile(PROFILE_NAME);
assertTrue(registry.isCurrent(profile));
- AgentLocation agentLocation = (AgentLocation) ServiceHelper.getService(TestActivator.getContext(), AgentLocation.SERVICE_NAME);
+ IAgentLocation agentLocation = getAgentLocation();
SimpleProfileRegistry simpleRegistry2 = new SimpleProfileRegistry(SimpleProfileRegistry.getDefaultRegistryDirectory(agentLocation));
profile2 = (Profile) simpleRegistry2.getProfile(PROFILE_NAME);
simpleRegistry2.lockProfile(profile2);
@@ -672,7 +663,7 @@ public class ProfileRegistryTest extends AbstractProvisioningTest {
public void testRemoveProfileTimestamps() throws ProvisionException {
assertNull(registry.getProfile(PROFILE_NAME));
- Properties properties = new Properties();
+ Map<String, String> properties = new HashMap<String, String>();
properties.put("test", "test");
Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties);
assertTrue(profile.getProperties().containsKey("test"));
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java
index 914d5c89b..e6a70f064 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProfileTest.java
@@ -10,21 +10,20 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.engine;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
-import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.BundleContext;
import org.xml.sax.*;
@@ -62,9 +61,9 @@ public class ProfileTest extends AbstractProvisioningTest {
}
public void testAddRemoveProperty() throws ProvisionException {
- IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry registry = getProfileRegistry();
assertNull(registry.getProfile(PROFILE_NAME));
- Properties properties = new Properties();
+ Map<String, String> properties = new HashMap<String, String>();
properties.put("test", "test");
Profile profile = (Profile) registry.addProfile(PROFILE_NAME, properties);
assertTrue(profile.getProperties().containsKey("test"));
@@ -80,57 +79,57 @@ public class ProfileTest extends AbstractProvisioningTest {
}
public void testAddRemoveIU() throws ProvisionException {
- IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry registry = getProfileRegistry();
assertNull(registry.getProfile(PROFILE_NAME));
Profile profile = (Profile) registry.addProfile(PROFILE_NAME);
- assertTrue(profile.query(InstallableUnitQuery.ANY, new Collector(), null).isEmpty());
+ assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty());
profile.addInstallableUnit(createIU("test"));
- assertEquals(1, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null)));
profile.removeInstallableUnit(createIU("test"));
- assertTrue(profile.query(InstallableUnitQuery.ANY, new Collector(), null).isEmpty());
+ assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty());
registry.removeProfile(PROFILE_NAME);
assertNull(registry.getProfile(PROFILE_NAME));
}
public void testAddIUTwice() throws ProvisionException {
- IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry registry = getProfileRegistry();
assertNull(registry.getProfile(PROFILE_NAME));
Profile profile = (Profile) registry.addProfile(PROFILE_NAME);
- assertTrue(profile.query(InstallableUnitQuery.ANY, new Collector(), null).isEmpty());
+ assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty());
profile.addInstallableUnit(createIU("test"));
- assertEquals(1, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null)));
profile.addInstallableUnit(createIU("test"));
- assertEquals(1, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null)));
registry.removeProfile(PROFILE_NAME);
assertNull(registry.getProfile(PROFILE_NAME));
}
public void testAddRemoveIUProperty() throws ProvisionException {
- IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry registry = getProfileRegistry();
assertNull(registry.getProfile(PROFILE_NAME));
Profile profile = (Profile) registry.addProfile(PROFILE_NAME);
- assertTrue(profile.query(InstallableUnitQuery.ANY, new Collector(), null).isEmpty());
+ assertTrue(profile.query(InstallableUnitQuery.ANY, null).isEmpty());
profile.addInstallableUnit(createIU("test"));
assertNull(profile.getInstallableUnitProperty(createIU("test"), "test"));
assertNull(profile.removeInstallableUnitProperty(createIU("test"), "test"));
- Properties iuProperties = new Properties();
+ Map<String, String> iuProperties = new HashMap<String, String>();
iuProperties.put("test", "test");
profile.addInstallableUnitProperties(createIU("test"), iuProperties);
assertEquals("test", profile.getInstallableUnitProperty(createIU("test"), "test"));
profile.removeInstallableUnitProperty(createIU("test"), "test");
assertNull(profile.getInstallableUnitProperty(createIU("test"), "test"));
- assertEquals(1, profile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(1, queryResultSize(profile.query(InstallableUnitQuery.ANY, null)));
registry.removeProfile(PROFILE_NAME);
assertNull(registry.getProfile(PROFILE_NAME));
}
public void testAvailable() throws ProvisionException {
- IProfileRegistry registry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry registry = getProfileRegistry();
assertNull(registry.getProfile(PROFILE_NAME));
Profile profile = (Profile) registry.addProfile(PROFILE_NAME);
- assertTrue(profile.available(InstallableUnitQuery.ANY, new Collector(), null).isEmpty());
+ assertTrue(profile.available(InstallableUnitQuery.ANY, null).isEmpty());
profile.addInstallableUnit(createIU("test"));
- assertEquals(1, profile.available(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(1, queryResultSize(profile.available(InstallableUnitQuery.ANY, null)));
profile.setSurrogateProfileHandler(new ISurrogateProfileHandler() {
public IProfile createProfile(String id) {
return null;
@@ -140,200 +139,22 @@ public class ProfileTest extends AbstractProvisioningTest {
return false;
}
- public Collector queryProfile(IProfile profile, Query query, Collector collector, IProgressMonitor monitor) {
- return collector;
+ public IQueryResult queryProfile(IProfile profile, IQuery query, IProgressMonitor monitor) {
+ return new Collector();
}
public boolean updateProfile(IProfile selfProfile) {
return false;
}
});
- assertTrue(profile.available(InstallableUnitQuery.ANY, new Collector(), null).isEmpty());
- assertTrue(profile.snapshot().available(InstallableUnitQuery.ANY, new Collector(), null).isEmpty());
+ assertTrue(profile.available(InstallableUnitQuery.ANY, null).isEmpty());
+ assertTrue(profile.snapshot().available(InstallableUnitQuery.ANY, null).isEmpty());
registry.removeProfile(PROFILE_NAME);
assertNull(registry.getProfile(PROFILE_NAME));
}
- public void testNestedProfileStructure() {
- Properties properties = new Properties();
- properties.put("test", "test");
- IProfile parent = createProfile("parent", null, properties);
- IProfile child = createProfile("child", "parent");
- parent = getProfile("parent");
- assertTrue(parent.hasSubProfiles());
- assertFalse(child.hasSubProfiles());
- assertNotNull(parent.getLocalProperty("test"));
- assertNotNull(child.getProperty("test"));
- assertNotNull(child.getProperties().get("test"));
- assertNull(child.getLocalProperty("test"));
- assertNull(child.getLocalProperties().get("test"));
-
- assertTrue("Parentless profile should be a root.", parent.isRootProfile());
- assertFalse("Child profile should not be a root.", child.isRootProfile());
- assertTrue("Parent should be parent of child", child.getParentProfile().getProfileId().equals(parent.getProfileId()));
- assertTrue("Parent should have one child.", parent.getSubProfileIds().length == 1);
- assertTrue("Child should have no children.", child.getSubProfileIds().length == 0);
-
- IProfile grandchild = createProfile("grand", "child");
- child = getProfile("child");
- assertFalse("Grandchild profile should not be a root.", grandchild.isRootProfile());
- assertTrue("Parent should have one child.", parent.getSubProfileIds().length == 1);
- assertTrue("Child should have one child.", child.getSubProfileIds().length == 1);
- assertTrue("Grandparent of grandchild should be parent of child.", grandchild.getParentProfile().getParentProfile().getProfileId().equals(parent.getProfileId()));
- }
-
- /* The test profile has the following structure and properties where
- * id{x,y} indicates a profile with id "id" and properties defined
- * with keys "x" and "y"
- *
- * grandchild00{foo}
- * /
- * /
- * child0{foo} | --- grandchild01{}
- * / \
- * / \
- * / grandchild01{bar}
- * parent{foo,bar} |
- * \ grandchild10{foo}
- * \ /
- * child1{} |
- * \
- * grandchild11{}
- *
- */
- private static String parentId = "parent";
- private static String child0Id = "child0";
- private static String grandchild00Id = "grand00";
- private static String grandchild01Id = "grand01";
- private static String grandchild02Id = "grand02";
- private static String child1Id = "child1";
- private static String grandchild10Id = "grand10";
- private static String grandchild11Id = "grand11";
-
- private static String key = "org.eclipse.p2.foo";
- private static String parentValue = "parent";
- private static String child0Value = "child0";
- private static String grandchild00Value = "grandchild00";
- private static String grandchild02Value = "grandchild02";
- private static String grandchild10Value = "grandchild10";
- private static String otherKey = "org.eclipse.p2.bar";
- private static String otherValue = "other";
-
- // Create the profiles and test get after set
- // for associated properties.
- private IProfile[] createTestProfiles() {
-
- Map properties = new HashMap();
-
- properties.put(key, parentValue);
- properties.put(otherKey, otherValue);
- IProfile parent = createProfile(parentId, null, properties);
- properties.clear();
- assertTrue(parentValue.equals(parent.getProperty(key)));
- assertTrue(otherValue.equals(parent.getProperty(otherKey)));
-
- properties.put(key, child0Value);
- IProfile child0 = createProfile(child0Id, parentId, properties);
- properties.clear();
- assertTrue(child0Value.equals(child0.getProperty(key)));
-
- IProfile child1 = createProfile(child1Id, parentId, properties);
- // no value in child1
-
- properties.put(key, grandchild00Value);
- IProfile grandchild00 = createProfile(grandchild00Id, child0Id, properties);
- properties.clear();
- assertTrue(grandchild00Value.equals(grandchild00.getProperty(key)));
-
- IProfile grandchild01 = createProfile(grandchild01Id, child0Id);
- // no value in grandchild01
-
- properties.put(otherKey, grandchild02Value);
- IProfile grandchild02 = createProfile(grandchild02Id, child0Id, properties);
- properties.clear();
- assertTrue(grandchild02Value.equals(grandchild02.getProperty(otherKey)));
-
- properties.put(key, grandchild10Value);
- IProfile grandchild10 = createProfile(grandchild10Id, child1Id, properties);
- properties.clear();
- assertTrue(grandchild10Value.equals(grandchild10.getProperty(key)));
-
- IProfile grandchild11 = createProfile(grandchild11Id, child1Id);
- // no value in grandchild11
-
- parent = getProfile(parentId);
- child0 = getProfile(child0Id);
- child1 = getProfile(child1Id);
- grandchild00 = getProfile(grandchild00Id);
- grandchild01 = getProfile(grandchild01Id);
- grandchild02 = getProfile(grandchild02Id);
- grandchild10 = getProfile(grandchild10Id);
- grandchild11 = getProfile(grandchild11Id);
-
- IProfile[] profiles = {parent, child0, child1, grandchild00, grandchild01, grandchild02, grandchild10, grandchild11};
- return profiles;
- }
-
- public void testNestedProfileProperties() {
- validateProfiles(createTestProfiles());
- }
-
- public void validateProfiles(IProfile[] profiles) {
- IProfile parent = profiles[0];
- IProfile child0 = profiles[1];
- IProfile child1 = profiles[2];
- IProfile grandchild00 = profiles[3];
- IProfile grandchild01 = profiles[4];
- IProfile grandchild02 = profiles[5];
- IProfile grandchild10 = profiles[6];
- IProfile grandchild11 = profiles[7];
-
- assertTrue(parentId.equals(parent.getProfileId()));
- assertTrue("Profile should have 3 local properties", parent.getLocalProperties().size() == 2);
- assertTrue(parentValue.equals(parent.getProperty(key)));
- assertTrue(otherValue.equals(parent.getProperty(otherKey)));
- assertTrue("Parent should have 2 children.", parent.getSubProfileIds().length == 2);
-
- assertTrue(child0Id.equals(child0.getProfileId()));
- assertTrue("First Child should have 1 local properties.", child0.getLocalProperties().size() == 1);
- assertTrue(child0Value.equals(child0.getProperty(key)));
- assertTrue(otherValue.equals(child0.getProperty(otherKey)));
- assertTrue("First Child should have 3 children.", child0.getSubProfileIds().length == 3);
-
- assertTrue(child1Id.equals(child1.getProfileId()));
- assertTrue("Second Child should have 0 local properties.", child1.getLocalProperties().size() == 0);
- assertTrue(parentValue.equals(child1.getProperty(key)));
- assertTrue(otherValue.equals(child1.getProperty(otherKey)));
- assertTrue("Second Child should have 2 children.", child1.getSubProfileIds().length == 2);
-
- assertTrue(grandchild00Id.equals(grandchild00.getProfileId()));
- assertTrue("First Grandchild of first Child should have 1 property.", grandchild00.getLocalProperties().size() == 1);
- assertTrue(grandchild00Value.equals(grandchild00.getProperty(key)));
- assertTrue(otherValue.equals(grandchild00.getProperty(otherKey)));
-
- assertTrue(grandchild01Id.equals(grandchild01.getProfileId()));
- assertTrue("Second Grandchild of first Child should have 0 properties.", grandchild01.getLocalProperties().size() == 0);
- assertTrue(child0Value.equals(grandchild01.getProperty(key)));
- assertTrue(otherValue.equals(grandchild01.getProperty(otherKey)));
-
- assertTrue(grandchild02Id.equals(grandchild02.getProfileId()));
- assertTrue("Third Grandchild of first Child should have 1 property.", grandchild02.getLocalProperties().size() == 1);
- assertTrue(child0Value.equals(grandchild02.getProperty(key)));
- assertTrue(grandchild02Value.equals(grandchild02.getProperty(otherKey)));
-
- assertTrue(grandchild10Id.equals(grandchild10.getProfileId()));
- assertTrue("First Grandchild of second Child should have 1 property.", grandchild10.getLocalProperties().size() == 1);
- assertTrue(grandchild10Value.equals(grandchild10.getProperty(key)));
- assertTrue(otherValue.equals(grandchild10.getProperty(otherKey)));
-
- assertTrue(grandchild11Id.equals(grandchild11.getProfileId()));
- assertTrue("Second Grandchild of second Child should have 0 properties.", grandchild11.getLocalProperties().size() == 0);
- assertTrue(parentValue.equals(grandchild11.getProperty(key)));
- assertTrue(otherValue.equals(grandchild11.getProperty(otherKey)));
- }
-
private static String PROFILE_TEST_TARGET = "profileTest";
- private static Version PROFILE_TEST_VERSION = new Version("0.0.1");
+ private static Version PROFILE_TEST_VERSION = Version.create("0.0.1");
private static String PROFILE_TEST_ELEMENT = "test";
public static final String PROFILES_ELEMENT = "profiles"; //$NON-NLS-1$
@@ -529,35 +350,4 @@ public class ProfileTest extends AbstractProvisioningTest {
return result;
}
}
-
- public void testProfilePersistence() throws IOException {
- IProfile[] testProfiles = createTestProfiles();
- ByteArrayOutputStream output0 = new ByteArrayOutputStream(1492);
- ProfileStringWriter writer0 = new ProfileStringWriter(output0);
- writer0.writeTest(testProfiles);
- String profileText0 = output0.toString();
- output0.close();
-
- ProfileStringParser parser = new ProfileStringParser(TestActivator.context, TestActivator.PI_PROV_TESTS);
- parser.parse(profileText0);
- assertTrue("Error parsing test profile: " + parser.getStatus().getMessage(), parser.getStatus().isOK());
- Map profileMap = (Map) parser.getRootObject();
- IProfile parent = (IProfile) profileMap.get(parentId);
- IProfile child0 = (IProfile) profileMap.get(child0Id);
- IProfile child1 = (IProfile) profileMap.get(child1Id);
- IProfile grandchild00 = (IProfile) profileMap.get(grandchild00Id);
- IProfile grandchild01 = (IProfile) profileMap.get(grandchild01Id);
- IProfile grandchild02 = (IProfile) profileMap.get(grandchild02Id);
- IProfile grandchild10 = (IProfile) profileMap.get(grandchild10Id);
- IProfile grandchild11 = (IProfile) profileMap.get(grandchild11Id);
- IProfile[] profiles = {parent, child0, child1, grandchild00, grandchild01, grandchild02, grandchild10, grandchild11};
- validateProfiles(profiles);
- ByteArrayOutputStream output1 = new ByteArrayOutputStream(1492);
- ProfileStringWriter writer = new ProfileStringWriter(output1);
-
- writer.writeTest(profiles);
- String profileText1 = output1.toString();
- output1.close();
- assertTrue("Profile write after read after write produced different XML", profileText1.equals(profileText0));
- }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java
index bb172d214..26784f4a6 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/SurrogateProfileHandlerTest.java
@@ -11,18 +11,14 @@
package org.eclipse.equinox.p2.tests.engine;
import java.lang.reflect.Field;
-import java.util.HashSet;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.equinox.internal.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
-import org.eclipse.equinox.p2.tests.TestActivator;
-import org.osgi.framework.ServiceReference;
public class SurrogateProfileHandlerTest extends AbstractProvisioningTest {
private static final String PROFILE_NAME = "profile.SurrogateProfileHandlerTest";
@@ -33,7 +29,6 @@ public class SurrogateProfileHandlerTest extends AbstractProvisioningTest {
return new TestSuite(SurrogateProfileHandlerTest.class);
}
- private ServiceReference registryRef;
private IProfileRegistry registry;
private SurrogateProfileHandler handler;
@@ -51,13 +46,11 @@ public class SurrogateProfileHandlerTest extends AbstractProvisioningTest {
}
protected void getServices() {
- registryRef = TestActivator.getContext().getServiceReference(IProfileRegistry.class.getName());
- registry = (IProfileRegistry) TestActivator.getContext().getService(registryRef);
+ registry = getProfileRegistry();
}
private void ungetServices() {
registry = null;
- TestActivator.getContext().ungetService(registryRef);
}
protected void setUp() throws Exception {
@@ -89,8 +82,8 @@ public class SurrogateProfileHandlerTest extends AbstractProvisioningTest {
saveProfile(registry, profile);
IProfile surrogateProfile = handler.createProfile(PROFILE_NAME);
assertTrue(handler.isSurrogate(surrogateProfile));
- assertEquals(0, surrogateProfile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
- assertEquals(1, surrogateProfile.available(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(0, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null)));
+ assertEquals(1, queryResultSize(surrogateProfile.available(InstallableUnitQuery.ANY, null)));
}
public void testUpdateProfile() throws ProvisionException {
@@ -99,34 +92,34 @@ public class SurrogateProfileHandlerTest extends AbstractProvisioningTest {
profile.setInstallableUnitProperty(createIU("test"), PROP_TYPE_ROOT, Boolean.TRUE.toString());
saveProfile(registry, profile);
IProfile surrogateProfile = handler.createProfile(PROFILE_NAME);
- assertEquals(1, surrogateProfile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(1, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null)));
// HashSet used here to eliminate duplicates
- assertEquals(1, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, new Collector(), null).toCollection()).size());
+ assertEquals(1, queryResultUniqueSize(surrogateProfile.available(InstallableUnitQuery.ANY, null)));
handler.updateProfile(surrogateProfile);
- assertEquals(1, surrogateProfile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(1, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null)));
// HashSet used here to eliminate duplicates
- assertEquals(1, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, new Collector(), null).toCollection()).size());
+ assertEquals(1, queryResultUniqueSize(surrogateProfile.available(InstallableUnitQuery.ANY, null)));
Profile writeableSurrogateProfile = (Profile) surrogateProfile;
writeableSurrogateProfile.addInstallableUnit(createIU("surrogate.test"));
writeableSurrogateProfile.setInstallableUnitProperty(createIU("surrogate.test"), PROP_TYPE_ROOT, Boolean.TRUE.toString());
- assertEquals(2, surrogateProfile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(2, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null)));
// HashSet used here to eliminate duplicates
- assertEquals(2, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, new Collector(), null).toCollection()).size());
+ assertEquals(2, queryResultUniqueSize(surrogateProfile.available(InstallableUnitQuery.ANY, null)));
profile.addInstallableUnit(createIU("test2"));
profile.setInstallableUnitProperty(createIU("test2"), PROP_TYPE_ROOT, Boolean.TRUE.toString());
saveProfile(registry, profile);
- assertEquals(2, surrogateProfile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(2, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null)));
// HashSet used here to eliminate duplicates
- assertEquals(3, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, new Collector(), null).toCollection()).size());
+ assertEquals(3, queryResultUniqueSize(surrogateProfile.available(InstallableUnitQuery.ANY, null)));
//Strictly speaking this should not be necessary however without resetting the timestamp this test will sometimes fail
writeableSurrogateProfile.setProperty(PROP_SHARED_TIMESTAMP, null);
handler.updateProfile(surrogateProfile);
- assertEquals(3, surrogateProfile.query(InstallableUnitQuery.ANY, new Collector(), null).size());
+ assertEquals(3, queryResultSize(surrogateProfile.query(InstallableUnitQuery.ANY, null)));
// HashSet used here to eliminate duplicates
- assertEquals(3, new HashSet(surrogateProfile.available(InstallableUnitQuery.ANY, new Collector(), null).toCollection()).size());
+ assertEquals(3, queryResultUniqueSize(surrogateProfile.available(InstallableUnitQuery.ANY, null)));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointManagerTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointManagerTest.java
index c296e822c..762e0912e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointManagerTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointManagerTest.java
@@ -46,7 +46,8 @@ public class TouchpointManagerTest extends AbstractProvisioningTest {
assertNotNull(manager.getTouchpoint("phaseTest", null));
}
- public void testDynamicTouchpoint() throws MalformedURLException, BundleException, InterruptedException {
+ // temporarily disabling this test until API is done
+ public void DISABLED_testDynamicTouchpoint() throws MalformedURLException, BundleException, InterruptedException {
TouchpointManager manager = new TouchpointManager();
assertNull(manager.getTouchpoint("dummy", "1.0.0"));
File dummy = getTestData("0.1", "/testData/engineTest/dummy.touchpointAndAction_1.0.0.jar");
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java
index b386d6953..8bee0b3ce 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/TouchpointTest.java
@@ -10,14 +10,16 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.engine;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.util.Map;
import org.eclipse.core.runtime.*;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.internal.p2.engine.PhaseSet;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.engine.spi.Touchpoint;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.eclipse.equinox.p2.tests.engine.PhaseTest.TestPhaseSet;
@@ -144,7 +146,8 @@ public class TouchpointTest extends AbstractProvisioningTest {
testTouchpoint.resetCounters();
PhaseSet phaseSet = new TestPhaseSet();
IProfile profile = createProfile("testProfile");
- engine.perform(profile, phaseSet, new InstallableUnitOperand[] {new InstallableUnitOperand(null, createTestIU("operandTest"))}, null, new NullProgressMonitor());
+ final InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createTestIU("operandTest"))};
+ engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
assertEquals(1, testTouchpoint.initializeOperand);
assertEquals(1, testTouchpoint.completeOperand);
}
@@ -154,7 +157,8 @@ public class TouchpointTest extends AbstractProvisioningTest {
testTouchpoint.resetCounters();
PhaseSet phaseSet = new TestPhaseSet();
IProfile profile = createProfile("testProfile");
- engine.perform(profile, phaseSet, new InstallableUnitOperand[] {new InstallableUnitOperand(null, createTestIU("phaseTest"))}, null, new NullProgressMonitor());
+ final InstallableUnitOperand[] operands = new InstallableUnitOperand[] {new InstallableUnitOperand(null, createTestIU("phaseTest"))};
+ engine.perform(engine.createCustomPlan(profile, operands, null), phaseSet, new NullProgressMonitor());
assertEquals(1, testTouchpoint.initializePhase);
assertEquals(1, testTouchpoint.completePhase);
}
@@ -162,8 +166,8 @@ public class TouchpointTest extends AbstractProvisioningTest {
private IInstallableUnit createTestIU(String touchpointName) {
InstallableUnitDescription description = new MetadataFactory.InstallableUnitDescription();
description.setId("org.eclipse.test");
- description.setVersion(new Version("1.0.0"));
- description.setTouchpointType(MetadataFactory.createTouchpointType(touchpointName, new Version("1.0.0")));
+ description.setVersion(Version.create("1.0.0"));
+ description.setTouchpointType(MetadataFactory.createTouchpointType(touchpointName, Version.create("1.0.0")));
IInstallableUnit unit = MetadataFactory.createInstallableUnit(description);
return createResolvedIU(unit);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java
index b304bdca0..7df721d5c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationArtifactRepositoryFactoryTest.java
@@ -16,9 +16,9 @@ import java.net.*;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.equinox.internal.p2.extensionlocation.Constants;
import org.eclipse.equinox.internal.p2.extensionlocation.ExtensionLocationArtifactRepositoryFactory;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
@@ -172,7 +172,7 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv
URI location = directory.toURI();
try {
IArtifactRepository repo = factory.load(location, 0, getMonitor());
- if (repo.getArtifactKeys().length != 2)
+ if (getArtifactKeyCount(repo) != 2)
fail("2.1");
} catch (ProvisionException ex) {
fail("2.0");
@@ -188,7 +188,7 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv
URI location = directory.toURI();
try {
IArtifactRepository repo = factory.load(location, 0, getMonitor());
- if (repo.getArtifactKeys().length != 1)
+ if (getArtifactKeyCount(repo) != 1)
fail("2.1");
} catch (ProvisionException ex) {
fail("2.0");
@@ -204,7 +204,7 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv
URI location = directory.toURI();
try {
IArtifactRepository repo = factory.load(location, 0, getMonitor());
- if (repo.getArtifactKeys().length != 1)
+ if (getArtifactKeyCount(repo) != 1)
fail("2.1");
} catch (ProvisionException ex) {
fail("2.0");
@@ -218,7 +218,7 @@ public class ExtensionLocationArtifactRepositoryFactoryTest extends AbstractProv
copy("1.1", getTestData("1.1", "/testData/extensionlocation"), eclipseDirectory);
try {
IArtifactRepository repo = factory.load(directory.toURI(), 0, getMonitor());
- if (repo.getArtifactKeys().length != 2)
+ if (getArtifactKeyCount(repo) != 2)
fail("1.0");
} catch (ProvisionException e) {
fail("0.5", e);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java
index 82af17cd1..0049f8def 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/extensionlocation/ExtensionLocationMetadataRepositoryFactoryTest.java
@@ -15,11 +15,10 @@ import java.io.IOException;
import java.net.*;
import org.eclipse.equinox.internal.p2.extensionlocation.Constants;
import org.eclipse.equinox.internal.p2.extensionlocation.ExtensionLocationMetadataRepositoryFactory;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.repository.IRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProvisioningTest {
@@ -164,7 +163,7 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv
URI location = directory.toURI();
try {
IMetadataRepository repo = factory.load(location, 0, getMonitor());
- if (repo.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().size() != 3)
+ if (queryResultSize(repo.query(InstallableUnitQuery.ANY, null)) != 3)
fail("2.99");
} catch (ProvisionException ex) {
fail("2.0");
@@ -180,7 +179,7 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv
URI location = directory.toURI();
try {
IMetadataRepository repo = factory.load(location, 0, getMonitor());
- if (repo.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().size() != 2)
+ if (queryResultSize(repo.query(InstallableUnitQuery.ANY, null)) != 2)
fail("3.0");
} catch (ProvisionException ex) {
fail("2.0");
@@ -196,7 +195,7 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv
URI location = directory.toURI();
try {
IMetadataRepository repo = factory.load(location, 0, getMonitor());
- if (repo.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().size() != 1)
+ if (queryResultSize(repo.query(InstallableUnitQuery.ANY, null)) != 1)
fail("3.0");
} catch (ProvisionException ex) {
fail("2.0");
@@ -210,7 +209,7 @@ public class ExtensionLocationMetadataRepositoryFactoryTest extends AbstractProv
copy("1.0", getTestData("1.1", "/testData/extensionlocation"), eclipseDirectory);
try {
IMetadataRepository repo = factory.load(directory.toURI(), 0, getMonitor());
- if (repo.query(InstallableUnitQuery.ANY, new Collector(), null).toCollection().size() != 3)
+ if (queryResultSize(repo.query(InstallableUnitQuery.ANY, null)) != 3)
fail("3.0");
} catch (ProvisionException e) {
fail("2.0");
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java
index 7add26707..00f1b472e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/AllTests.java
@@ -20,8 +20,8 @@ public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(AllTests.class.getName());
suite.addTestSuite(End2EndTest.class);
- // suite.addTest(From35to36.suite());
- // suite.addTest(Install36from35.suite());
+ suite.addTest(From35to36.suite());
+ suite.addTest(Install36from35.suite());
return suite;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java
index b5413b610..7dc4ddb89 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/DirectorTest.java
@@ -10,23 +10,22 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.full;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.VersionRange;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
-import org.eclipse.equinox.internal.provisional.p2.core.location.AgentLocation;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.IProfileRegistry;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
@@ -39,7 +38,7 @@ import org.osgi.framework.ServiceReference;
public class DirectorTest extends AbstractProvisioningTest {
public void testInstallIU() throws ProvisionException {
- ServiceReference sr = TestActivator.context.getServiceReference(IDirector.class.getName());
+ ServiceReference sr = TestActivator.context.getServiceReference(IDirector.SERVICE_NAME);
if (sr == null) {
throw new RuntimeException("Director service not available");
}
@@ -48,23 +47,21 @@ public class DirectorTest extends AbstractProvisioningTest {
throw new RuntimeException("Director could not be loaded");
}
- ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.class.getName());
+ ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.SERVICE_NAME);
IMetadataRepositoryManager mgr = (IMetadataRepositoryManager) TestActivator.context.getService(sr2);
if (mgr == null) {
throw new RuntimeException("Repository manager could not be loaded");
}
String autoInstall = System.getProperty("eclipse.p2.autoInstall");
- Collector allJobs = mgr.query(new InstallableUnitQuery(autoInstall, VersionRange.emptyRange), new Collector(), null);
+ IQueryResult allJobs = mgr.query(new InstallableUnitQuery(autoInstall, VersionRange.emptyRange), null);
String installFolder = System.getProperty(IProfile.PROP_INSTALL_FOLDER);
- ServiceReference profileRegSr = TestActivator.context.getServiceReference(IProfileRegistry.class.getName());
- IProfileRegistry profileRegistry = (IProfileRegistry) TestActivator.context.getService(profileRegSr);
+ IProfileRegistry profileRegistry = getProfileRegistry();
if (profileRegistry == null) {
throw new RuntimeException("Profile registry service not available");
}
- String newFlavor = System.getProperty("eclipse.p2.configurationFlavor");
boolean doUninstall = (Boolean.TRUE.equals(Boolean.valueOf(System.getProperty("eclipse.p2.doUninstall"))));
IProfile p = null;
@@ -75,12 +72,11 @@ public class DirectorTest extends AbstractProvisioningTest {
} else {
Map properties = new HashMap();
properties.put(IProfile.PROP_INSTALL_FOLDER, installFolder);
- properties.put(IProfile.PROP_FLAVOR, newFlavor);
EnvironmentInfo info = (EnvironmentInfo) ServiceHelper.getService(TestActivator.getContext(), EnvironmentInfo.class.getName());
if (info != null)
properties.put(IProfile.PROP_ENVIRONMENTS, "osgi.os=" + info.getOS() + ",osgi.ws=" + info.getWS() + ",osgi.arch=" + info.getOSArch());
- p = createProfile(installFolder, null, properties);
+ p = createProfile(installFolder, properties);
}
IInstallableUnit[] allRoots = new IInstallableUnit[1];
@@ -100,24 +96,8 @@ public class DirectorTest extends AbstractProvisioningTest {
if (!operationStatus.isOK())
fail("The installation has failed");
- IInstallableUnit[] result = (IInstallableUnit[]) p.query(new InstallableUnitQuery(allRoots[0].getId(), VersionRange.emptyRange), new Collector(), null).toArray(IInstallableUnit.class);
+ IInstallableUnit[] result = (IInstallableUnit[]) p.query(new InstallableUnitQuery(allRoots[0].getId(), VersionRange.emptyRange), null).toArray(IInstallableUnit.class);
assertEquals(result.length, (!doUninstall ? 1 : 0));
- result = (IInstallableUnit[]) p.query(new InstallableUnitQuery("toolingdefault", VersionRange.emptyRange), new Collector(), null).toArray(IInstallableUnit.class);
-
- ensureFragmentAssociationIsNotPersisted(mgr);
- }
-
- private void ensureFragmentAssociationIsNotPersisted(IMetadataRepositoryManager mgr) throws ProvisionException {
- //Test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=177661
- AgentLocation location = (AgentLocation) ServiceHelper.getService(TestActivator.getContext(), AgentLocation.class.getName());
- mgr.removeRepository(location.getMetadataRepositoryURI());
- IMetadataRepository repo = null;
- repo = mgr.loadRepository(location.getMetadataRepositoryURI(), null);
- Iterator it = repo.query(new InstallableUnitQuery("org.eclipse.equinox.simpleconfigurator", VersionRange.emptyRange), new Collector(), null).iterator();
- if (!it.hasNext())
- return;
- IInstallableUnit sc = (IInstallableUnit) it.next();
- if (sc.isResolved())
- fail("The repository should not store resolved installable units");
+ result = (IInstallableUnit[]) p.query(new InstallableUnitQuery("toolingdefault", VersionRange.emptyRange), null).toArray(IInstallableUnit.class);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
index 4cb0f640f..6508f93cf 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/End2EndTest.java
@@ -10,27 +10,29 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.full;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.File;
import java.io.IOException;
import java.net.URI;
-import java.net.URISyntaxException;
import java.util.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.provisional.frameworkadmin.*;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.director.IDirector;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.core.*;
+import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
@@ -46,26 +48,21 @@ public class End2EndTest extends AbstractProvisioningTest {
private ServiceTracker fwAdminTracker;
+ private static URI repositoryLocation = URI.create("http://download.eclipse.org/eclipse/updates/3.5");
+
+ private IProvisioningAgent end2endAgent = null;
+
protected void setUp() throws Exception {
- ServiceReference sr = TestActivator.context.getServiceReference(IDirector.class.getName());
- if (sr == null)
- throw new RuntimeException("Director service not available");
- director = createDirector();
- // planner = createPlanner();
- ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.class.getName());
- metadataRepoManager = (IMetadataRepositoryManager) TestActivator.context.getService(sr2);
- if (metadataRepoManager == null)
- throw new RuntimeException("Metadata repository manager could not be loaded");
-
- ServiceReference sr3 = TestActivator.context.getServiceReference(IArtifactRepositoryManager.class.getName());
- artifactRepoManager = (IArtifactRepositoryManager) TestActivator.context.getService(sr3);
- if (artifactRepoManager == null)
- throw new RuntimeException("Artifact repo manager could not be loaded");
+ ServiceReference sr = TestActivator.context.getServiceReference(IProvisioningAgentProvider.SERVICE_NAME);
+ IProvisioningAgentProvider agentFactory = (IProvisioningAgentProvider) TestActivator.context.getService(sr);
+ end2endAgent = agentFactory.createAgent(getTempFolder().toURI());
+ metadataRepoManager = (IMetadataRepositoryManager) end2endAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
+ artifactRepoManager = (IArtifactRepositoryManager) end2endAgent.getService(IArtifactRepositoryManager.SERVICE_NAME);
+ director = (IDirector) end2endAgent.getService(IDirector.SERVICE_NAME);
}
protected IProfile createProfile(String profileId, String installFolder) {
- ServiceReference profileRegSr = TestActivator.context.getServiceReference(IProfileRegistry.class.getName());
- IProfileRegistry profileRegistry = (IProfileRegistry) TestActivator.context.getService(profileRegSr);
+ IProfileRegistry profileRegistry = (IProfileRegistry) end2endAgent.getService(IProfileRegistry.SERVICE_NAME);
if (profileRegistry == null) {
throw new RuntimeException("Profile registry service not available");
}
@@ -77,7 +74,11 @@ public class End2EndTest extends AbstractProvisioningTest {
properties.put(IProfile.PROP_ENVIRONMENTS, "osgi.os=" + info.getOS() + ",osgi.ws=" + info.getWS() + ",osgi.arch=" + info.getOSArch());
properties.put("org.eclipse.update.install.features", "true");
properties.put(IProfile.PROP_CACHE, installFolder);
- return createProfile(profileId, null, properties);
+ try {
+ return profileRegistry.addProfile(profileId, properties);
+ } catch (ProvisionException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
}
public void testInstallSDK35() {
@@ -86,16 +87,13 @@ public class End2EndTest extends AbstractProvisioningTest {
//Add repository of the release
try {
- URI location = new URI("http://download.eclipse.org/eclipse/updates/3.5");
- metadataRepoManager.addRepository(location);
- metadataRepoManager.setEnabled(location, true);
- metadataRepoManager.loadRepository(location, new NullProgressMonitor());
- artifactRepoManager.addRepository(location);
- artifactRepoManager.setEnabled(location, true);
+ metadataRepoManager.addRepository(repositoryLocation);
+ metadataRepoManager.setEnabled(repositoryLocation, true);
+ metadataRepoManager.loadRepository(repositoryLocation, new NullProgressMonitor());
+ artifactRepoManager.addRepository(repositoryLocation);
+ artifactRepoManager.setEnabled(repositoryLocation, true);
} catch (ProvisionException e) {
fail("Exception loading the repository.", e);
- } catch (URISyntaxException e) {
- fail("Invalid repository location", e);
}
installPlatform35(profile2, installFolder);
@@ -113,19 +111,19 @@ public class End2EndTest extends AbstractProvisioningTest {
}
private void attemptToUninstallRCP35(IProfile profile2, File installFolder) {
- Collector collect = profile2.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor());
- assertEquals(1, collect.size());
+ IQueryResult collect = profile2.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor());
+ assertEquals(1, queryResultSize(collect));
ProfileChangeRequest request = new ProfileChangeRequest(profile2);
request.removeInstallableUnits(new IInstallableUnit[] {(IInstallableUnit) collect.iterator().next()});
IStatus s = director.provision(request, null, new NullProgressMonitor());
assertOK("Can not uninstall RCP", s);
- assertEquals(1, profile2.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new Collector(), new NullProgressMonitor()).size());
+ assertEquals(1, queryResultSize(profile2.query(new InstallableUnitQuery("org.eclipse.rcp.feature.group"), new NullProgressMonitor())));
}
protected void uninstallPlatform(IProfile profile2, File installFolder) {
System.out.println("Uninstall the platform");
- Collector collect = profile2.query(new InstallableUnitQuery("org.eclipse.platform.ide"), new Collector(), new NullProgressMonitor());
- assertEquals(1, collect.size());
+ IQueryResult collect = profile2.query(new InstallableUnitQuery("org.eclipse.platform.ide"), new NullProgressMonitor());
+ assertEquals(1, queryResultSize(collect));
// Collector collect2 = profile2.query(new InstallableUnitQuery("org.eclipse.platform.source.feature.group"), new Collector(), new NullProgressMonitor());
ProfileChangeRequest request = new ProfileChangeRequest(profile2);
request.removeInstallableUnits(new IInstallableUnit[] {(IInstallableUnit) collect.iterator().next()});//, (IInstallableUnit) collect2.iterator().next()});
@@ -134,7 +132,7 @@ public class End2EndTest extends AbstractProvisioningTest {
}
private void rollbackPlatformSource35(IProfile profile2, File installFolder) {
- IProfileRegistry profileRegistry = (IProfileRegistry) ServiceHelper.getService(TestActivator.getContext(), IProfileRegistry.class.getName());
+ IProfileRegistry profileRegistry = (IProfileRegistry) end2endAgent.getService(IProfileRegistry.SERVICE_NAME);
long[] timestamps = profileRegistry.listProfileTimestamps(profile2.getProfileId());
assertEquals(3, timestamps.length);
@@ -149,11 +147,9 @@ public class End2EndTest extends AbstractProvisioningTest {
private void installPlatformSource35(IProfile profile2, File installFolder) {
final String id = "org.eclipse.platform.source.feature.group";
- final Version version = new Version("3.5.0.v20090611a-9gEeG1HFtQcmRThO4O3aR_fqSMvJR2sJ");
+ final Version version = Version.create("3.5.0.v20090611a-9gEeG1HFtQcmRThO4O3aR_fqSMvJR2sJ");
IInstallableUnit toInstall = getIU(id, version);
- if (toInstall == null)
- assertNotNull(toInstall);
ProfileChangeRequest request = new ProfileChangeRequest(profile2);
request.addInstallableUnits(new IInstallableUnit[] {toInstall});
@@ -168,13 +164,13 @@ public class End2EndTest extends AbstractProvisioningTest {
private void installBogusIU(IProfile profile, File installFolder) {
InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
iud.setId("org.eclipse.equinox.p2.tests.bogusIU.end2end");
- iud.setVersion(new Version("1.0.0"));
- iud.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.equinox.p2.tests.bogusIU.end2end", new Version("1.0.0"))});
+ iud.setVersion(Version.create("1.0.0"));
+ iud.setCapabilities(new IProvidedCapability[] {MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, "org.eclipse.equinox.p2.tests.bogusIU.end2end", Version.create("1.0.0"))});
Map data = new HashMap();
data.put("install", "org.eclipse.equinox.p2.osgi.removeJvmArg(programArg:-XX:+UnlockDiagnosticVMOptions);");
iud.addTouchpointData(MetadataFactory.createTouchpointData(data));
IInstallableUnit bogusIU = MetadataFactory.createInstallableUnit(iud);
- iud.setTouchpointType(MetadataFactory.createTouchpointType("org.eclipse.equinox.p2.osgi", new Version("1.0.0")));
+ iud.setTouchpointType(MetadataFactory.createTouchpointType("org.eclipse.equinox.p2.osgi", Version.create("1.0.0")));
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(new IInstallableUnit[] {bogusIU});
IStatus s = director.provision(request, null, new NullProgressMonitor());
@@ -183,13 +179,11 @@ public class End2EndTest extends AbstractProvisioningTest {
private void installPlatform35(IProfile profile2, File installFolder) {
final String id = "org.eclipse.platform.ide";
- final Version version = new Version("3.5.0.I20090611-1540");
+ final Version version = Version.create("3.5.0.I20090611-1540");
//First we install the platform
ProfileChangeRequest request = new ProfileChangeRequest(profile2);
IInstallableUnit platformIU = getIU(id, version);
- if (platformIU == null)
- assertNotNull(platformIU);
request.addInstallableUnits(new IInstallableUnit[] {platformIU});
IStatus s = director.provision(request, null, new NullProgressMonitor());
@@ -203,11 +197,31 @@ public class End2EndTest extends AbstractProvisioningTest {
assertFalse(new File(installFolder, "configuration/org.eclipse.equinox.source").exists());
}
+ /**
+ * Returns the IU corresponding to the given id and version. Fails if the IU could
+ * not be found. Never returns null.
+ */
public IInstallableUnit getIU(String id, Version v) {
- Iterator it = metadataRepoManager.query(new InstallableUnitQuery(id, v), new Collector(), null).iterator();
+ final InstallableUnitQuery query = new InstallableUnitQuery(id, v);
+ Iterator it = metadataRepoManager.query(query, null).iterator();
if (it.hasNext())
return (IInstallableUnit) it.next();
- return null;
+ //try the repository location directly - retry because eclipse.org can be flaky
+ Exception failure = null;
+ for (int i = 0; i < 3; i++) {
+ try {
+ IMetadataRepository repo = metadataRepoManager.loadRepository(repositoryLocation, null);
+ it = repo.query(query, null).iterator();
+ if (it.hasNext())
+ return (IInstallableUnit) it.next();
+ } catch (ProvisionException e) {
+ failure = e;
+ }
+ }
+ if (failure == null)
+ failure = new RuntimeException("IU not found");
+ fail("Failed to obtain " + id + " version: " + v + " from: " + repositoryLocation, failure);
+ return null;//will never get here
}
private void validateInstallContentFor35(File installFolder) {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java
index d59876f3f..3f4ffac2a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/full/RepoValidator.java
@@ -14,15 +14,17 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.director.IPlanner;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
-import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningContext;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.p2.core.ProvisionException;
+import org.eclipse.equinox.p2.engine.IProfile;
+import org.eclipse.equinox.p2.engine.ProvisioningContext;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.query.IQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.ServiceReference;
@@ -30,7 +32,7 @@ import org.osgi.framework.ServiceReference;
public class RepoValidator extends AbstractProvisioningTest {
public void testValidate() throws ProvisionException, URISyntaxException {
URI repoLoc = new URI("http://fullmoon.ottawa.ibm.com/eclipse/updates/3.5-I-builds/");
- ServiceReference sr = TestActivator.context.getServiceReference(IPlanner.class.getName());
+ ServiceReference sr = TestActivator.context.getServiceReference(IPlanner.SERVICE_NAME);
if (sr == null) {
throw new RuntimeException("Planner service not available");
}
@@ -39,7 +41,7 @@ public class RepoValidator extends AbstractProvisioningTest {
throw new RuntimeException("Planner could not be loaded");
}
- ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.class.getName());
+ ServiceReference sr2 = TestActivator.context.getServiceReference(IMetadataRepositoryManager.SERVICE_NAME);
IMetadataRepositoryManager mgr = (IMetadataRepositoryManager) TestActivator.context.getService(sr2);
if (mgr == null) {
throw new RuntimeException("Repository manager could not be loaded");
@@ -47,18 +49,17 @@ public class RepoValidator extends AbstractProvisioningTest {
IMetadataRepository validatedRepo = mgr.loadRepository(repoLoc, null);
Map properties = new HashMap();
- properties.put(IInstallableUnit.NAMESPACE_FLAVOR, "tooling");
properties.put("osgi.os", "win32");
properties.put("osgi.ws", "win32");
properties.put("osgi.arch", "x86");
- IProfile p = createProfile("repoValidator", null, properties);
+ IProfile p = createProfile("repoValidator", properties);
- Query q;
+ IQuery q;
q = new InstallableUnitQuery("org.eclipse.rcp.feature.group");
// q = InstallableUnitQuery.ANY;
- Collector iusToTest = validatedRepo.query(q, new Collector(), null);
+ IQueryResult iusToTest = validatedRepo.query(q, null);
ProvisioningContext pc = new ProvisioningContext(new URI[] {repoLoc});
for (Iterator iterator = iusToTest.iterator(); iterator.hasNext();) {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/EclipseSDK33Test.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/EclipseSDK33Test.java
index 292f19f5e..78ccc09a8 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/EclipseSDK33Test.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/EclipseSDK33Test.java
@@ -17,11 +17,11 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.generator.Generator;
import org.eclipse.equinox.internal.provisional.p2.metadata.generator.IGeneratorInfo;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.GroupQuery;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.tests.*;
import org.osgi.framework.Bundle;
@@ -88,15 +88,14 @@ public class EclipseSDK33Test extends AbstractProvisioningTest {
assertGroup(unit);
IArtifactRepository artifactRepo = generatorInfo.getArtifactRepository();
- IArtifactKey[] keys = artifactRepo.getArtifactKeys();
- assertTrue(keys.length == 11);
+ assertTrue(getArtifactKeyCount(artifactRepo) == 11);
}
/**
* Asserts that the given IU represents a group.
*/
private void assertGroup(IInstallableUnit unit) {
- assertEquals("IU is not a group", Boolean.TRUE.toString(), unit.getProperty(IInstallableUnit.PROP_TYPE_GROUP));
+ assertEquals("IU is not a group", Boolean.TRUE.toString(), GroupQuery.isGroup(unit));
}
private IGeneratorInfo createGeneratorInfo() {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/FeatureToIU.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/FeatureToIU.java
index 5f677588a..4593802dd 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/FeatureToIU.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/FeatureToIU.java
@@ -9,9 +9,9 @@
package org.eclipse.equinox.p2.tests.generator;
import org.eclipse.equinox.internal.p2.metadata.generator.features.FeatureParser;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.generator.Feature;
import org.eclipse.equinox.internal.provisional.p2.metadata.generator.MetadataGeneratorHelper;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class FeatureToIU extends AbstractProvisioningTest {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/PatchIUGeneration.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/PatchIUGeneration.java
index 5d015fcb9..5e11a2f35 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/PatchIUGeneration.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/PatchIUGeneration.java
@@ -8,13 +8,16 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.generator;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.VersionRange;
+import junit.framework.TestCase;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.p2.metadata.generator.features.FeatureParser;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnitPatch;
import org.eclipse.equinox.internal.provisional.p2.metadata.generator.Feature;
import org.eclipse.equinox.internal.provisional.p2.metadata.generator.MetadataGeneratorHelper;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IInstallableUnitPatch;
+import org.eclipse.equinox.p2.metadata.query.PatchQuery;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class PatchIUGeneration extends AbstractProvisioningTest {
@@ -31,19 +34,19 @@ public class PatchIUGeneration extends AbstractProvisioningTest {
assertEquals(patchIU.getId(), "org.eclipse.jdt.3.2.1.patch.feature.group");
//Check applicability scope
- assertEquals(IInstallableUnit.NAMESPACE_IU_ID, patchIU.getApplicabilityScope()[0][0].getNamespace());
- assertEquals("org.eclipse.jdt.feature.group", patchIU.getApplicabilityScope()[0][0].getName());
- assertEquals(new VersionRange("[3.2.1.r321_v20060905-R4CM1Znkvre9wC-,3.2.1.r321_v20060905-R4CM1Znkvre9wC-]"), patchIU.getApplicabilityScope()[0][0].getRange());
+ assertEquals(IInstallableUnit.NAMESPACE_IU_ID, ((IRequiredCapability) patchIU.getApplicabilityScope()[0][0]).getNamespace());
+ assertEquals("org.eclipse.jdt.feature.group", ((TestCase) patchIU.getApplicabilityScope()[0][0]).getName());
+ assertEquals(new VersionRange("[3.2.1.r321_v20060905-R4CM1Znkvre9wC-,3.2.1.r321_v20060905-R4CM1Znkvre9wC-]"), ((IRequiredCapability) patchIU.getApplicabilityScope()[0][0]).getRange());
- assertEquals("org.eclipse.jdt.core", patchIU.getRequirementsChange()[0].applyOn().getName());
- assertEquals(VersionRange.emptyRange, patchIU.getRequirementsChange()[0].applyOn().getRange());
- assertEquals("org.eclipse.jdt.core", patchIU.getRequirementsChange()[0].newValue().getName());
- assertEquals(new VersionRange("[3.2.2,3.2.2]"), patchIU.getRequirementsChange()[0].newValue().getRange());
- assertEquals(Boolean.TRUE.toString(), patchIU.getProperty(IInstallableUnit.PROP_TYPE_PATCH));
- assertEquals(1, patchIU.getRequiredCapabilities().length);
- assertEquals(featureIU.getId(), patchIU.getRequiredCapabilities()[0].getName());
- assertEquals("org.eclipse.jdt.feature.group", patchIU.getLifeCycle().getName());
+ assertEquals("org.eclipse.jdt.core", patchIU.getRequirementsChange().get(0).applyOn().getName());
+ assertEquals(VersionRange.emptyRange, patchIU.getRequirementsChange().get(0).applyOn().getRange());
+ assertEquals("org.eclipse.jdt.core", patchIU.getRequirementsChange().get(0).newValue().getName());
+ assertEquals(new VersionRange("[3.2.2,3.2.2]"), patchIU.getRequirementsChange().get(0).newValue().getRange());
+ assertTrue(PatchQuery.isPatch(patchIU));
+ assertEquals(1, patchIU.getRequiredCapabilities().size());
+ assertEquals(featureIU.getId(), ((IRequiredCapability) patchIU.getRequiredCapabilities().iterator().next()).getName());
+ assertEquals("org.eclipse.jdt.feature.group", ((IRequiredCapability) patchIU.getLifeCycle()).getName());
assertFalse(patchIU.getLifeCycle().isGreedy());
- assertFalse(patchIU.getLifeCycle().isOptional());
+ assertFalse(patchIU.getLifeCycle().getMin() == 0);
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/TestGeneratorInfo.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/TestGeneratorInfo.java
index ea46ad3c3..ef6dc5013 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/TestGeneratorInfo.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/generator/TestGeneratorInfo.java
@@ -15,10 +15,10 @@ import java.net.URI;
import java.util.*;
import org.eclipse.equinox.internal.provisional.frameworkadmin.ConfigData;
import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData;
-import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.metadata.generator.IGeneratorInfo;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.tests.TestArtifactRepository;
import org.eclipse.equinox.p2.tests.TestMetadataRepository;
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/installer/InstallDescriptionParserTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/installer/InstallDescriptionParserTest.java
index ceb2ec938..5d6e11047 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/installer/InstallDescriptionParserTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/installer/InstallDescriptionParserTest.java
@@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.installer;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IVersionedId;
-
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.io.File;
import java.io.IOException;
@@ -20,6 +18,7 @@ import java.net.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.installer.InstallDescriptionParser;
import org.eclipse.equinox.internal.provisional.p2.installer.InstallDescription;
+import org.eclipse.equinox.p2.metadata.IVersionedId;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestData;
@@ -117,9 +116,9 @@ public class InstallDescriptionParserTest extends AbstractProvisioningTest {
IVersionedId[] roots = description.getRoots();
assertEquals("1.7", 2, roots.length);
assertEquals("1.8", "testRoot", roots[0].getId());
- assertEquals("1.9", new Version("2.0"), roots[0].getVersion());
+ assertEquals("1.9", Version.create("2.0"), roots[0].getVersion());
assertEquals("1.8", "anotherRoot", roots[1].getId());
- assertEquals("1.9", new Version("1.0.1"), roots[1].getVersion());
+ assertEquals("1.9", Version.create("1.0.1"), roots[1].getVersion());
assertTrue("1.10", !description.isAutoStart());
assertEquals("1.11", new Path("/tmp/agent/"), description.getAgentLocation());
assertEquals("1.12", new Path("/tmp/bundles/"), description.getBundleLocation());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java
index c1b43a84a..0b7e19c85 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ArtifactKeyParsingTest.java
@@ -10,11 +10,11 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import junit.framework.TestCase;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.p2.metadata.IArtifactKey;
/**
* Test <code>ArtifactkeyDeSerializer</code>
@@ -22,12 +22,12 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
public class ArtifactKeyParsingTest extends TestCase {
public void testSerialize() {
- IArtifactKey key = new ArtifactKey("classifier", "identifier", new Version("1.0"));
+ IArtifactKey key = new ArtifactKey("classifier", "identifier", Version.create("1.0"));
assertEquals("classifier,identifier,1.0.0", key.toExternalForm());
}
public void testSerializeEmptyClassifier() {
- IArtifactKey key = new ArtifactKey("", "identifier", new Version("1.0"));
+ IArtifactKey key = new ArtifactKey("", "identifier", Version.create("1.0"));
assertEquals(",identifier,1.0.0", key.toExternalForm());
}
@@ -36,7 +36,7 @@ public class ArtifactKeyParsingTest extends TestCase {
assertNotNull(key);
assertEquals("classifier", key.getClassifier());
assertEquals("identifier", key.getId());
- assertEquals(new Version("1.0"), key.getVersion());
+ assertEquals(Version.create("1.0"), key.getVersion());
}
public void testDeserializeEmptyClassifier() {
@@ -44,7 +44,7 @@ public class ArtifactKeyParsingTest extends TestCase {
assertNotNull(key);
assertEquals("", key.getClassifier());
assertEquals("identifier", key.getId());
- assertEquals(new Version("1.0"), key.getVersion());
+ assertEquals(Version.create("1.0"), key.getVersion());
}
public void testDeserializeEmptyIdentifier() {
@@ -52,7 +52,7 @@ public class ArtifactKeyParsingTest extends TestCase {
assertNotNull(key);
assertEquals("classifier", key.getClassifier());
assertEquals("", key.getId());
- assertEquals(new Version("1.0"), key.getVersion());
+ assertEquals(Version.create("1.0"), key.getVersion());
}
public void testDeserializeEmptyVersion() {
@@ -60,7 +60,7 @@ public class ArtifactKeyParsingTest extends TestCase {
assertNotNull(key);
assertEquals("classifier", key.getClassifier());
assertEquals("identifier", key.getId());
- assertEquals(new Version("0.0"), key.getVersion());
+ assertEquals(Version.create("0.0"), key.getVersion());
}
public void testDeserializeEmptyEverything() {
@@ -68,7 +68,7 @@ public class ArtifactKeyParsingTest extends TestCase {
assertNotNull(key);
assertEquals("", key.getClassifier());
assertEquals("", key.getId());
- assertEquals(new Version("0.0"), key.getVersion());
+ assertEquals(Version.create("0.0"), key.getVersion());
}
public void testDeserializeTooFewPartsI() {
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java
index e41a590f2..e6ad021f2 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentMethodTest.java
@@ -10,16 +10,18 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
-import java.util.HashSet;
-import java.util.Iterator;
+import java.util.*;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitFragmentDescription;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class FragmentMethodTest extends TestCase {
@@ -28,10 +30,8 @@ public class FragmentMethodTest extends TestCase {
private static final String TEST_REQUIRED = "testRequired";
IInstallableUnit iu1;
IInstallableUnit iu3;
- IRequiredCapability[] iu1Deps;
- IRequiredCapability[] iu3Deps;
- IProvidedCapability[] iu1Caps;
- IProvidedCapability[] iu3Caps;
+ Collection<IProvidedCapability> iu1Caps;
+ Collection<IProvidedCapability> iu3Caps;
protected void setUp() throws Exception {
super.setUp();
@@ -39,8 +39,6 @@ public class FragmentMethodTest extends TestCase {
iu3 = createIUFragment("iu.fragment");
iu1Caps = iu1.getProvidedCapabilities();
iu3Caps = iu3.getProvidedCapabilities();
- iu1Deps = iu1.getRequiredCapabilities();
- iu3Deps = iu3.getRequiredCapabilities();
HashSet hash = new HashSet();
hash.add(iu1);
hash.add(iu3);
@@ -57,34 +55,30 @@ public class FragmentMethodTest extends TestCase {
protected void tearDown() throws Exception {
iu1 = null;
iu3 = null;
- iu1Deps = null;
- iu3Deps = null;
iu1Caps = null;
iu3Caps = null;
super.tearDown();
}
public void testCapabilities() {
- IProvidedCapability[] iuCapabilities = iu1Caps;
- IProvidedCapability[] initialFragmentCapabilities = iu3Caps;
-
- IProvidedCapability[] mergedCapabilities = iu1.getProvidedCapabilities();
- for (int i = 0; i < iuCapabilities.length; i++) {
- FragmentTest.assertContainsWithEquals(mergedCapabilities, iuCapabilities[i]);
+ Collection<IProvidedCapability> mergedCapabilities = iu1.getProvidedCapabilities();
+ for (IProvidedCapability capability : mergedCapabilities) {
+ FragmentTest.assertContainsWithEquals(mergedCapabilities, capability);
}
//The fragment property is not set
- assertNull(iu1.getProperty(IInstallableUnit.PROP_TYPE_FRAGMENT));
+ assertNull(iu1.getProperty(InstallableUnitDescription.PROP_TYPE_FRAGMENT));
//The fragment does not contain iu namespace
- for (int i = 0; i < initialFragmentCapabilities.length; i++) {
- if (initialFragmentCapabilities[i].getNamespace().equals(IInstallableUnit.NAMESPACE_IU_ID)) {
- assertDoesNotContain(mergedCapabilities, initialFragmentCapabilities[i]);
+ Collection<IProvidedCapability> initialFragmentCapabilities = iu3Caps;
+ for (IProvidedCapability capability : initialFragmentCapabilities) {
+ if (capability.getNamespace().equals(IInstallableUnit.NAMESPACE_IU_ID)) {
+ assertDoesNotContain(mergedCapabilities, capability);
break;
}
}
- assertEquals("The fragment capabilities should not change", initialFragmentCapabilities, iu3.getProvidedCapabilities(), false);
+ assertEquals("The fragment capabilities should not change", initialFragmentCapabilities, iu3.getProvidedCapabilities());
}
protected void assertEquals(String message, Object[] expected, Object[] actual) {
@@ -98,38 +92,22 @@ public class FragmentMethodTest extends TestCase {
assertEquals(message, expected[i], actual[i]);
}
- protected void assertEquals(String message, Object[] expected, Object[] actual, boolean orderImportant) {
- // if the order in the array must match exactly, then call the other method
- if (orderImportant) {
- assertEquals(message, expected, actual);
- return;
- }
- // otherwise use this method and check that the arrays are equal in any order
+ protected void assertEquals(String message, Collection<? extends Object> expected, Collection<? extends Object> actual) {
if (expected == null && actual == null)
return;
if (expected == actual)
return;
if (expected == null || actual == null)
assertTrue(message + ".1", false);
- if (expected.length != actual.length)
+ if (expected.size() != actual.size())
assertTrue(message + ".2", false);
- boolean[] found = new boolean[expected.length];
- for (int i = 0; i < expected.length; i++) {
- for (int j = 0; j < expected.length; j++) {
- if (!found[j] && expected[i].equals(actual[j]))
- found[j] = true;
- }
- }
- for (int i = 0; i < found.length; i++)
- if (!found[i])
- assertTrue(message + ".3." + i, false);
+ if (!expected.containsAll(actual))
+ fail(message + ".3");
}
- public static void assertDoesNotContain(Object[] objects, Object searched) {
- for (int i = 0; i < objects.length; i++) {
- if (objects[i].equals(searched))
- throw new AssertionFailedError("The array should not contain the searched element");
- }
+ public static void assertDoesNotContain(Collection<? extends Object> objects, Object searched) {
+ if (objects.contains(searched))
+ throw new AssertionFailedError("The array should not contain the searched element");
}
public void testProperties() {
@@ -141,12 +119,12 @@ public class FragmentMethodTest extends TestCase {
public IInstallableUnit createIUFragment(String name) {
InstallableUnitFragmentDescription iu = new InstallableUnitFragmentDescription();
iu.setId(name);
- iu.setVersion(new Version(1, 0, 0));
+ iu.setVersion(Version.createOSGi(1, 0, 0));
iu.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI);
iu.setProperty(PROP_FRAG, "value");
IRequiredCapability[] reqs = new IRequiredCapability[] {MetadataFactory.createRequiredCapability("eclipse.touchpoint", "bundle", VersionRange.emptyRange, null, false, true), MetadataFactory.createRequiredCapability(TEST_REQUIRED, TEST_REQUIRED, VersionRange.emptyRange, null, true, false)};
iu.setHost(reqs);
- IProvidedCapability[] cap = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("testCapabilityInFragment", "testCapabilityInFragment", new Version(1, 0, 0))};
+ IProvidedCapability[] cap = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("testCapabilityInFragment", "testCapabilityInFragment", Version.createOSGi(1, 0, 0))};
iu.setCapabilities(cap);
return MetadataFactory.createInstallableUnitFragment(iu);
}
@@ -154,10 +132,10 @@ public class FragmentMethodTest extends TestCase {
public IInstallableUnit createIU(String name) {
InstallableUnitDescription iu = new MetadataFactory.InstallableUnitDescription();
iu.setId(name);
- iu.setVersion(new Version(1, 0, 0));
+ iu.setVersion(Version.createOSGi(1, 0, 0));
iu.setTouchpointType(AbstractProvisioningTest.TOUCHPOINT_OSGI);
iu.setProperty(PROP_IU, "valueIU");
- IProvidedCapability[] cap = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("eclipse.touchpoint", "bundle", new Version(1, 0, 0)), MetadataFactory.createProvidedCapability("testCapability", "testCapability", new Version(1, 0, 0))};
+ IProvidedCapability[] cap = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("eclipse.touchpoint", "bundle", Version.createOSGi(1, 0, 0)), MetadataFactory.createProvidedCapability("testCapability", "testCapability", Version.createOSGi(1, 0, 0))};
iu.setCapabilities(cap);
return MetadataFactory.createInstallableUnit(iu);
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java
index 2e8e460ce..e51f887e5 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/FragmentTest.java
@@ -10,13 +10,13 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import java.util.HashMap;
-import java.util.Iterator;
+import java.util.*;
import junit.framework.AssertionFailedError;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.query.FragmentQuery;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class FragmentTest extends AbstractProvisioningTest {
@@ -27,7 +27,7 @@ public class FragmentTest extends AbstractProvisioningTest {
IInstallableUnit iu2 = createBundleFragment("iuFragment.test1");
ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName()));
createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2});
- Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, new Collector(), null).iterator();
+ Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, null).iterator();
// ResolutionHelper rh = new ResolutionHelper(new Hashtable(), null);
// HashSet set = new HashSet();
// set.add(iu1);
@@ -36,8 +36,8 @@ public class FragmentTest extends AbstractProvisioningTest {
for (; iterator.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iterator.next();
if (iu.getId().equals(ID)) {
- assertEquals(iu.getFragments().length, 1);
- assertEquals(iu.getFragments()[0].getId(), "iuFragment.test1");
+ assertEquals(iu.getFragments().size(), 1);
+ assertEquals(iu.getFragments().get(0).getId(), "iuFragment.test1");
}
}
}
@@ -50,48 +50,48 @@ public class FragmentTest extends AbstractProvisioningTest {
IInstallableUnit iu2 = createBundleFragment("iuFragment.test1");
ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName()));
createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2, iu3});
- Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, new Collector(), null).iterator();
+ Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, null).iterator();
for (; iterator.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iterator.next();
if (iu.getId().equals(ID1)) {
- assertEquals(iu.getFragments().length, 1);
- assertEquals(iu.getFragments()[0].getId(), "iuFragment.test1");
+ assertEquals(iu.getFragments().size(), 1);
+ assertEquals(iu.getFragments().get(0).getId(), "iuFragment.test1");
}
if (iu.getId().equals(ID3)) {
- assertEquals(iu.getFragments().length, 1);
- assertEquals(iu.getFragments()[0].getId(), "iuFragment.test1");
+ assertEquals(iu.getFragments().size(), 1);
+ assertEquals(iu.getFragments().get(0).getId(), "iuFragment.test1");
}
}
}
public void testTouchpointData() {
- assertEquals(createIUWithTouchpointData().getTouchpointData().length, 1);
- assertEquals(createBundleFragment("iuFragment.test1").getTouchpointData().length, 1);
+ assertEquals(createIUWithTouchpointData().getTouchpointData().size(), 1);
+ assertEquals(createBundleFragment("iuFragment.test1").getTouchpointData().size(), 1);
IInstallableUnit iu1 = createIUWithTouchpointData();
IInstallableUnit iu2 = createBundleFragment("iuFragment.test1");
ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName()));
createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2});
- Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, new Collector(), null).iterator();
+ Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, null).iterator();
for (; iterator.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iterator.next();
if (iu.getId().equals(iu1.getId()))
- assertEquals(2, iu.getTouchpointData().length);
+ assertEquals(2, iu.getTouchpointData().size());
}
}
public void testFragmentCapability() {
IInstallableUnit iu = createBundleFragment("iuFragment.test1");
- assertEquals(Boolean.TRUE.toString(), iu.getProperty(IInstallableUnit.PROP_TYPE_FRAGMENT));
+ assertTrue(FragmentQuery.isFragment(iu));
}
public void testDefaultIUCapability() {
IInstallableUnit iu = createEclipseIU("ui.test1");
- IProvidedCapability[] cap = iu.getProvidedCapabilities();
- for (int i = 0; i < cap.length; i++) {
- if (cap[i].getNamespace().equals(IInstallableUnit.NAMESPACE_IU_ID)) {
- assertEquals(cap[i].getNamespace(), IInstallableUnit.NAMESPACE_IU_ID);
- assertEquals(cap[i].getName(), iu.getId());
+ Collection<IProvidedCapability> capabilities = iu.getProvidedCapabilities();
+ for (IProvidedCapability c : capabilities) {
+ if (c.getNamespace().equals(IInstallableUnit.NAMESPACE_IU_ID)) {
+ assertEquals(c.getNamespace(), IInstallableUnit.NAMESPACE_IU_ID);
+ assertEquals(c.getName(), iu.getId());
return;
}
}
@@ -106,11 +106,10 @@ public class FragmentTest extends AbstractProvisioningTest {
throw new AssertionFailedError("The array does not contain the searched element");
}
- public static void assertContainsWithEquals(Object[] objects, Object searched) {
- for (int i = 0; i < objects.length; i++) {
- if (objects[i].equals(searched))
- return;
- }
+ public static void assertContainsWithEquals(Collection<? extends Object> objects, Object searched) {
+ if (objects.contains(searched))
+ return;
+
throw new AssertionFailedError("The array does not contain the searched element");
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java
index cb384633f..fb301060c 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPatchPersistenceTest.java
@@ -10,21 +10,20 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
-
import java.io.*;
import java.util.*;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
-import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
-import org.eclipse.equinox.internal.p2.metadata.InstallableUnitPatch;
+import org.eclipse.equinox.internal.p2.metadata.*;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataParser;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataWriter;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
import org.xml.sax.*;
public class IUPatchPersistenceTest extends AbstractProvisioningTest {
@@ -34,8 +33,8 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
private static String PackagesNS = "osgi.packages";
private static String id = "org.eclipse.osgi.services";
- private static Version version = new Version("3.1.200.v20070605");
- private static String filter = "(& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))"; // not really
+ private static Version version = Version.create("3.1.200.v20070605");
+ private static Filter filter = ExpressionUtil.parseLDAP("(& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))"); // not really
private static String[][] properties = new String[][] {new String[] {"equinox.p2.name", "OSGi Release 4.0.1 Services"}, //
new String[] {"equinox.p2.description", "OSGi Service Platform Release 4.0.1 Service Interfaces and Classes"}, //
@@ -95,7 +94,7 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
IProvidedCapability[] provided = new IProvidedCapability[provideTuples.length];
for (int i = 0; i < provideTuples.length; i++) {
String[] nextTuple = provideTuples[i];
- provided[i] = MetadataFactory.createProvidedCapability(nextTuple[0], nextTuple[1], new Version(nextTuple[2]));
+ provided[i] = MetadataFactory.createProvidedCapability(nextTuple[0], nextTuple[1], Version.create(nextTuple[2]));
}
// provided[provideTuples.length] = BUNDLE_CAPABILITY;
return provided;
@@ -105,7 +104,7 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
IRequiredCapability[] required = new IRequiredCapability[requireTuples.length];
for (int i = 0; i < requireTuples.length; i++) {
String[] nextTuple = requireTuples[i];
- required[i] = MetadataFactory.createRequiredCapability(nextTuple[0], nextTuple[1], new VersionRange(nextTuple[2]), null, Boolean.valueOf(nextTuple[3]).booleanValue(), false);
+ required[i] = (IRequiredCapability) MetadataFactory.createRequiredCapability(nextTuple[0], nextTuple[1], new VersionRange(nextTuple[2]), null, Boolean.valueOf(nextTuple[3]).booleanValue(), false);
}
return required;
}
@@ -120,7 +119,7 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
}
private static String IU_TEST_TARGET = "installableUnitTest";
- private static Version IU_TEST_VERSION = new Version("0.0.1");
+ private static Version IU_TEST_VERSION = Version.create("0.0.1");
private static String IU_TEST_ELEMENT = "test";
@@ -286,8 +285,8 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
IRequirementChange change1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true));
IRequirementChange change2 = MetadataFactory.createRequirementChange(null, MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true));
IRequirementChange change3 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), null);
- IRequiredCapability[][] scope = new IRequiredCapability[][] { {MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true), MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true)}, {MetadataFactory.createRequiredCapability("zoo", "far", null, null, true, true)}};
- IRequiredCapability lifeCycle = MetadataFactory.createRequiredCapability("zoo", "x", null, null, false, false, false);
+ IRequiredCapability[][] scope = new IRequiredCapability[][] { {(IRequiredCapability) MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true), (IRequiredCapability) MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true)}, {(IRequiredCapability) MetadataFactory.createRequiredCapability("zoo", "far", null, null, true, true)}};
+ IRequiredCapability lifeCycle = (IRequiredCapability) MetadataFactory.createRequiredCapability("zoo", "x", null, null, false, false, false);
IInstallableUnitPatch iu = createIUPatch(id, version, filter, requirements, additionalProvides, propertyMap, TOUCHPOINT_OSGI, tpData, singleton, update, new IRequirementChange[] {change1, change2, change3}, scope, lifeCycle, metaRequirements);
return iu;
}
@@ -296,11 +295,11 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
validateIU(iu);
assertTrue(iu.getApplicabilityScope() != null);
assertTrue(iu.getRequiredCapabilities() != null);
- assertEquals(3, iu.getRequirementsChange().length);
- assertEquals(null, iu.getRequirementsChange()[1].applyOn());
- assertNotNull(iu.getRequirementsChange()[1].newValue());
- assertEquals(null, iu.getRequirementsChange()[2].newValue());
- assertNotNull(iu.getRequirementsChange()[2].applyOn());
+ assertEquals(3, iu.getRequirementsChange().size());
+ assertEquals(null, iu.getRequirementsChange().get(1).applyOn());
+ assertNotNull(iu.getRequirementsChange().get(1).newValue());
+ assertEquals(null, iu.getRequirementsChange().get(2).newValue());
+ assertNotNull(iu.getRequirementsChange().get(2).applyOn());
assertEquals(2, iu.getApplicabilityScope().length);
assertEquals(2, iu.getApplicabilityScope()[0].length);
assertEquals(1, iu.getApplicabilityScope()[1].length);
@@ -346,31 +345,33 @@ public class IUPatchPersistenceTest extends AbstractProvisioningTest {
}
private static String[][] extractProvides(IInstallableUnit iu) {
- IProvidedCapability[] provydes = iu.getProvidedCapabilities();
- String[][] tuples = new String[provydes.length][3];
- for (int i = 0; i < provydes.length; i++) {
- IProvidedCapability next = provydes[i];
- tuples[i] = new String[] {next.getNamespace(), next.getName(), next.getVersion().toString()};
+ Collection<IProvidedCapability> provydes = iu.getProvidedCapabilities();
+ String[][] tuples = new String[provydes.size()][3];
+ int i = 0;
+ for (IProvidedCapability capability : provydes) {
+ tuples[i++] = new String[] {capability.getNamespace(), capability.getName(), capability.getVersion().toString()};
}
return tuples;
}
private static String[][] extractRequires(IInstallableUnit iu) {
- IRequiredCapability[] requyres = iu.getRequiredCapabilities();
- String[][] tuples = new String[requyres.length][4];
- for (int i = 0; i < requyres.length; i++) {
- IRequiredCapability next = requyres[i];
- tuples[i] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.isOptional()).toString()};
+ Collection<IRequirement> reqs = iu.getRequiredCapabilities();
+ String[][] tuples = new String[reqs.size()][4];
+ int i = 0;
+ for (Iterator iterator = reqs.iterator(); iterator.hasNext();) {
+ IRequiredCapability next = (IRequiredCapability) iterator.next();
+ tuples[i++] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.getMin() == 0).toString()};
}
return tuples;
}
private static String[][] extractMetaRequires(IInstallableUnit iu) {
- IRequiredCapability[] requyres = iu.getMetaRequiredCapabilities();
- String[][] tuples = new String[requyres.length][4];
- for (int i = 0; i < requyres.length; i++) {
- IRequiredCapability next = requyres[i];
- tuples[i] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.isOptional()).toString()};
+ Collection<IRequirement> requyres = iu.getMetaRequiredCapabilities();
+ String[][] tuples = new String[requyres.size()][4];
+ int i = 0;
+ for (Iterator iterator = requyres.iterator(); iterator.hasNext();) {
+ IRequiredCapability next = (IRequiredCapability) iterator.next();
+ tuples[i++] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.getMin() == 0).toString()};
}
return tuples;
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java
index b4f5feba1..3f7989298 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/IUPersistenceTest.java
@@ -10,21 +10,22 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
-
import java.io.*;
+import java.net.URI;
import java.util.*;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.equinox.internal.p2.core.helpers.OrderedProperties;
-import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
-import org.eclipse.equinox.internal.p2.metadata.InstallableUnitPatch;
+import org.eclipse.equinox.internal.p2.metadata.*;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataParser;
import org.eclipse.equinox.internal.p2.metadata.repository.io.MetadataWriter;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
import org.xml.sax.*;
public class IUPersistenceTest extends AbstractProvisioningTest {
@@ -134,7 +135,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
}
}
- private static String filter = "(& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))"; // not really
+ private static Filter filter = ExpressionUtil.parseLDAP("(& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))"); // not really
private static String id = "org.eclipse.osgi.services";
private static String[][] instructions = new String[][] {new String[] {"manifest", "Manifest-Version: 1.0\\Bundle-Vendor: Eclipse.org\\Bundle-ContactAddress: www.eclipse.org\\...a whole bunch of other manifest content..."}, new String[] {"zipped", "true"}, //
@@ -144,7 +145,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
private static String IU_TEST_TARGET = "installableUnitTest";
- private static Version IU_TEST_VERSION = new Version("0.0.1");
+ private static Version IU_TEST_VERSION = Version.create("0.0.1");
// Randomly chose org.eclipse.osgi.services as the IU for testing persistence
// but 'enhanced' it for better coverage.
@@ -176,7 +177,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
private static String[][] metaRequires = new String[][] {new String[] {PackagesNS, "some.actions1", "0.0.0", "true"}, //
new String[] {PackagesNS, "some.actions2", "1.2.0", "false"}}; //
- private static Version version = new Version("3.1.200.v20070605");
+ private static Version version = Version.create("3.1.200.v20070605");
private Map propertyMap;
@@ -203,7 +204,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
IProvidedCapability[] provided = new IProvidedCapability[provideTuples.length];
for (int i = 0; i < provideTuples.length; i++) {
String[] nextTuple = provideTuples[i];
- provided[i] = MetadataFactory.createProvidedCapability(nextTuple[0], nextTuple[1], new Version(nextTuple[2]));
+ provided[i] = MetadataFactory.createProvidedCapability(nextTuple[0], nextTuple[1], Version.create(nextTuple[2]));
}
// provided[provideTuples.length] = BUNDLE_CAPABILITY;
return provided;
@@ -213,7 +214,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
IRequiredCapability[] required = new IRequiredCapability[requireTuples.length];
for (int i = 0; i < requireTuples.length; i++) {
String[] nextTuple = requireTuples[i];
- required[i] = MetadataFactory.createRequiredCapability(nextTuple[0], nextTuple[1], new VersionRange(nextTuple[2]), null, Boolean.valueOf(nextTuple[3]).booleanValue(), false);
+ required[i] = (IRequiredCapability) MetadataFactory.createRequiredCapability(nextTuple[0], nextTuple[1], new VersionRange(nextTuple[2]), null, Boolean.valueOf(nextTuple[3]).booleanValue(), false);
}
return required;
}
@@ -232,38 +233,40 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
}
private static String[][] extractProvides(IInstallableUnit iu) {
- IProvidedCapability[] provydes = iu.getProvidedCapabilities();
- String[][] tuples = new String[provydes.length][3];
- for (int i = 0; i < provydes.length; i++) {
- IProvidedCapability next = provydes[i];
- tuples[i] = new String[] {next.getNamespace(), next.getName(), next.getVersion().toString()};
+ Collection<IProvidedCapability> provydes = iu.getProvidedCapabilities();
+ String[][] tuples = new String[provydes.size()][3];
+ int i = 0;
+ for (IProvidedCapability capability : provydes) {
+ tuples[i++] = new String[] {capability.getNamespace(), capability.getName(), capability.getVersion().toString()};
}
return tuples;
}
private static String[][] extractRequires(IInstallableUnit iu) {
- IRequiredCapability[] requyres = iu.getRequiredCapabilities();
- String[][] tuples = new String[requyres.length][4];
- for (int i = 0; i < requyres.length; i++) {
- IRequiredCapability next = requyres[i];
- tuples[i] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.isOptional()).toString()};
+ Collection<IRequirement> requyres = iu.getRequiredCapabilities();
+ String[][] tuples = new String[requyres.size()][4];
+ int i = 0;
+ for (Iterator iterator = requyres.iterator(); iterator.hasNext();) {
+ IRequiredCapability next = (IRequiredCapability) iterator.next();
+ tuples[i++] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.getMin() == 0).toString()};
}
return tuples;
}
private static String[][] extractMetaRequires(IInstallableUnit iu) {
- IRequiredCapability[] requyres = iu.getMetaRequiredCapabilities();
- String[][] tuples = new String[requyres.length][4];
- for (int i = 0; i < requyres.length; i++) {
- IRequiredCapability next = requyres[i];
- tuples[i] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.isOptional()).toString()};
+ Collection<IRequirement> requyres = iu.getMetaRequiredCapabilities();
+ String[][] tuples = new String[requyres.size()][4];
+ int i = 0;
+ for (Iterator iterator = requyres.iterator(); iterator.hasNext();) {
+ IRequiredCapability next = (IRequiredCapability) iterator.next();
+ tuples[i++] = new String[] {next.getNamespace(), next.getName(), next.getRange().toString(), Boolean.valueOf(next.getMin() == 0).toString()};
}
return tuples;
}
private IInstallableUnitPatch createPatchIU() {
propertyMap = createProperties(properties);
- propertyMap.put(IInstallableUnit.PROP_TYPE_PATCH, "true");
+ propertyMap.put(InstallableUnitDescription.PROP_TYPE_PATCH, "true");
IProvidedCapability[] additionalProvides = createProvided(provides);
IRequiredCapability[] requirements = createRequired(requires);
IRequiredCapability[] metaRequirements = createRequired(metaRequires);
@@ -273,14 +276,14 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
IRequirementChange change1 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true));
IRequirementChange change2 = MetadataFactory.createRequirementChange(null, MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", new VersionRange("[1.1.0, 1.3.0)"), null, false, false, true));
IRequirementChange change3 = MetadataFactory.createRequirementChange(MetadataFactory.createRequiredCapability(IInstallableUnit.NAMESPACE_IU_ID, "B", VersionRange.emptyRange, null, false, false, false), null);
- IRequiredCapability[][] scope = new IRequiredCapability[][] { {MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true), MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true)}, {MetadataFactory.createRequiredCapability("zoo", "far", null, null, true, true)}};
+ IRequiredCapability[][] scope = new IRequiredCapability[][] { {(IRequiredCapability) MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true), (IRequiredCapability) MetadataFactory.createRequiredCapability("foo", "bar", null, null, true, true)}, {(IRequiredCapability) MetadataFactory.createRequiredCapability("zoo", "far", null, null, true, true)}};
IInstallableUnitPatch iu = createIUPatch(id, version, filter, requirements, additionalProvides, propertyMap, TOUCHPOINT_OSGI, tpData, singleton, update, new IRequirementChange[] {change1, change2, change3}, scope, null, metaRequirements);
return iu;
}
private IInstallableUnitPatch createPatchWithEmptyScope() {
propertyMap = createProperties(properties);
- propertyMap.put(IInstallableUnit.PROP_TYPE_PATCH, "true");
+ propertyMap.put(InstallableUnitDescription.PROP_TYPE_PATCH, "true");
IProvidedCapability[] additionalProvides = createProvided(provides);
IRequiredCapability[] requirements = createRequired(requires);
IRequiredCapability[] metaRequirements = createRequired(metaRequires);
@@ -300,10 +303,35 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
IProvidedCapability[] additionalProvides = createProvided(provides);
IRequiredCapability[] requirements = createRequired(requires);
IRequiredCapability[] metaRequirements = createRequired(metaRequires);
+ ILicense[] licenses = new ILicense[] {MetadataFactory.createLicense(URI.create("http://eclipse.org"), "license text"), MetadataFactory.createLicense(URI.create("http://apache.org"), "license text2")};
ITouchpointData tpData = createTouchpointData(instructions);
IUpdateDescriptor update = createUpdateDescriptor();
- boolean singleton = false;
- IInstallableUnit iu = createIU(id, version, filter, requirements, additionalProvides, propertyMap, TOUCHPOINT_OSGI, tpData, singleton, update, metaRequirements);
+ InstallableUnitDescription iu1 = new MetadataFactory.InstallableUnitDescription();
+ iu1.setId(id);
+ iu1.setVersion(version);
+ iu1.setFilter(filter);
+ iu1.setLicenses(licenses);
+ IProvidedCapability[] provides1 = new IProvidedCapability[additionalProvides.length + 1];
+ provides1[0] = getSelfCapability(id, version);
+ for (int i = 0; i < additionalProvides.length; i++) {
+ provides1[i + 1] = additionalProvides[i];
+ }
+ for (Iterator iter = propertyMap.keySet().iterator(); iter.hasNext();) {
+ String nextKey = (String) iter.next();
+ String nextValue = (String) propertyMap.get(nextKey);
+ iu1.setProperty(nextKey, nextValue);
+ }
+ iu1.setCapabilities(provides1);
+ iu1.setRequiredCapabilities(requirements);
+ iu1.setTouchpointType(TOUCHPOINT_OSGI);
+ if (tpData != null)
+ iu1.addTouchpointData(tpData);
+ iu1.setSingleton(false);
+ iu1.setUpdateDescriptor(update);
+ if (metaRequirements == null)
+ metaRequirements = NO_REQUIRES;
+ iu1.setMetaRequiredCapabilities(metaRequirements);
+ IInstallableUnit iu = MetadataFactory.createInstallableUnit(iu1);
return iu;
}
@@ -370,6 +398,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
assertTrue("Error parsing test iu: " + parser.getStatus().getMessage(), parser.getStatus().isOK());
InstallableUnit iu1 = (InstallableUnit) parser.getRootObject();
validateIU(iu1);
+ assertEquals(2, iu1.getLicenses().size());
ByteArrayOutputStream output1 = new ByteArrayOutputStream(1492);
IUStringWriter writer = new IUStringWriter(output1);
writer.writeTest(iu1);
@@ -381,7 +410,7 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
private void validateIU(IInstallableUnit iu) {
assertTrue("Installable unit id is not correct", id.equals(iu.getId()));
assertTrue("Installable unit version is not correct", version.equals(iu.getVersion()));
- assertTrue("Installable unit filter is not correct", filter.equals(iu.getFilter()));
+ assertTrue("Installable unit filter is not correct", filter.equals(iu.getFilter() == null ? null : iu.getFilter()));
assertEquals("Installable unit properties are not correct", propertyMap, iu.getProperties());
assertTrue("Installable unit provided capabilities are not correct", equal(addSelfCapability(iu, provides), extractProvides(iu)));
assertTrue("Installable unit required capabilities are not correct", equal(requires, extractRequires(iu)));
@@ -396,11 +425,11 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
validateIU(iu);
assertTrue(iu.getApplicabilityScope() != null);
assertTrue(iu.getRequiredCapabilities() != null);
- assertEquals(3, iu.getRequirementsChange().length);
- assertEquals(null, iu.getRequirementsChange()[1].applyOn());
- assertNotNull(iu.getRequirementsChange()[1].newValue());
- assertEquals(null, iu.getRequirementsChange()[2].newValue());
- assertNotNull(iu.getRequirementsChange()[2].applyOn());
+ assertEquals(3, iu.getRequirementsChange().size());
+ assertEquals(null, iu.getRequirementsChange().get(1).applyOn());
+ assertNotNull(iu.getRequirementsChange().get(1).newValue());
+ assertEquals(null, iu.getRequirementsChange().get(2).newValue());
+ assertNotNull(iu.getRequirementsChange().get(2).applyOn());
assertEquals(2, iu.getApplicabilityScope().length);
assertEquals(2, iu.getApplicabilityScope()[0].length);
assertEquals(1, iu.getApplicabilityScope()[1].length);
@@ -411,11 +440,11 @@ public class IUPersistenceTest extends AbstractProvisioningTest {
validateIU(iu);
assertTrue(iu.getApplicabilityScope() != null);
assertTrue(iu.getRequiredCapabilities() != null);
- assertEquals(3, iu.getRequirementsChange().length);
- assertEquals(null, iu.getRequirementsChange()[1].applyOn());
- assertNotNull(iu.getRequirementsChange()[1].newValue());
- assertEquals(null, iu.getRequirementsChange()[2].newValue());
- assertNotNull(iu.getRequirementsChange()[2].applyOn());
+ assertEquals(3, iu.getRequirementsChange().size());
+ assertEquals(null, iu.getRequirementsChange().get(1).applyOn());
+ assertNotNull(iu.getRequirementsChange().get(1).newValue());
+ assertEquals(null, iu.getRequirementsChange().get(2).newValue());
+ assertNotNull(iu.getRequirementsChange().get(2).applyOn());
assertEquals(0, iu.getApplicabilityScope().length);
assertNull(iu.getLifeCycle());
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/InstallableUnitTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/InstallableUnitTest.java
index c51bf173b..68d6dd67f 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/InstallableUnitTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/InstallableUnitTest.java
@@ -10,10 +10,13 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.VersionRange;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
@@ -24,7 +27,7 @@ public class InstallableUnitTest extends AbstractProvisioningTest {
* Tests for {@link org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit#satisfies(org.eclipse.equinox.internal.provisional.p2.metadata.RequiredCapability)}.
*/
public void testSatisfies() {
- IProvidedCapability[] provides = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("testNamespace", "name", new Version(1, 0, 0))};
+ IProvidedCapability[] provides = new IProvidedCapability[] {MetadataFactory.createProvidedCapability("testNamespace", "name", Version.createOSGi(1, 0, 0))};
IInstallableUnit iu = createIU("iu", provides);
IRequiredCapability wrongNamespace = MetadataFactory.createRequiredCapability("wrongNamespace", "name", VersionRange.emptyRange, null, false, false);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LatestIUTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LatestIUTest.java
index 525e15c7c..8814ae826 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LatestIUTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LatestIUTest.java
@@ -9,14 +9,13 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
import java.net.URI;
-import java.util.Collection;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.LatestIUVersionQuery;
-import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.equinox.internal.p2.metadata.query.LatestIUVersionQuery;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.query.IQueryResult;
+import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
import org.eclipse.equinox.p2.tests.TestData;
@@ -36,10 +35,9 @@ public class LatestIUTest extends AbstractProvisioningTest {
IMetadataRepositoryManager metadataRepositoryManager = getMetadataRepositoryManager();
metadataRepositoryManager.addRepository(location);
- Collector query = metadataRepositoryManager.query(new LatestIUVersionQuery(), new Collector(), null);
- Collection collection = query.toCollection();
- assertEquals("1.0", 1, collection.size());
- assertEquals("1.1", new Version(2, 1, 0), ((IInstallableUnit) collection.iterator().next()).getVersion());
+ IQueryResult query = metadataRepositoryManager.query(new LatestIUVersionQuery(), null);
+ assertEquals("1.0", 1, queryResultSize(query));
+ assertEquals("1.1", Version.createOSGi(2, 1, 0), ((IInstallableUnit) query.iterator().next()).getVersion());
}
public void testLatestIUSingleRepo2() throws Exception {
@@ -53,10 +51,9 @@ public class LatestIUTest extends AbstractProvisioningTest {
IMetadataRepositoryManager metadataRepositoryManager = getMetadataRepositoryManager();
metadataRepositoryManager.addRepository(location);
- Collector query = metadataRepositoryManager.query(new LatestIUVersionQuery(), new Collector(), null);
- Collection collection = query.toCollection();
- assertEquals("1.0", 1, collection.size());
- assertEquals("1.1", new Version(3, 0, 0), ((IInstallableUnit) collection.iterator().next()).getVersion());
+ IQueryResult query = metadataRepositoryManager.query(new LatestIUVersionQuery(), null);
+ assertEquals("1.0", 1, queryResultSize(query));
+ assertEquals("1.1", Version.createOSGi(3, 0, 0), ((IInstallableUnit) query.iterator().next()).getVersion());
}
public void testLatestIUMultiRepo() throws Exception {
@@ -73,9 +70,8 @@ public class LatestIUTest extends AbstractProvisioningTest {
metadataRepositoryManager.addRepository(location1);
metadataRepositoryManager.addRepository(location2);
- Collector collector = metadataRepositoryManager.query(new LatestIUVersionQuery(), new Collector(), null);
- Collection collection = collector.toCollection();
- assertEquals("1.0", 1, collection.size());
- assertEquals("1.1", new Version(3, 0, 0), ((IInstallableUnit) collection.iterator().next()).getVersion());
+ IQueryResult queryResult = metadataRepositoryManager.query(new LatestIUVersionQuery(), null);
+ assertEquals("1.0", 1, queryResultSize(queryResult));
+ assertEquals("1.1", Version.createOSGi(3, 0, 0), ((IInstallableUnit) queryResult.iterator().next()).getVersion());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java
index c51d3097c..c62b1d75d 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/LicenseTest.java
@@ -12,8 +12,8 @@
package org.eclipse.equinox.p2.tests.metadata;
import junit.framework.TestCase;
-import org.eclipse.equinox.internal.provisional.p2.metadata.ILicense;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.metadata.ILicense;
/**
* Tests for License class
@@ -22,10 +22,10 @@ public class LicenseTest extends TestCase {
public void testNormalize() {
ILicense licenseOne = MetadataFactory.createLicense(null, "a b");
ILicense licenseTwo = MetadataFactory.createLicense(null, "a\t\n\r \t\n\r b");
- assertEquals("1.0", licenseOne.getDigest(), licenseTwo.getDigest());
+ assertEquals("1.0", licenseOne.getUUID(), licenseTwo.getUUID());
licenseOne = MetadataFactory.createLicense(null, " a b c ");
licenseTwo = MetadataFactory.createLicense(null, "a\t\nb\r \t\n\r c");
- assertEquals("1.1", licenseOne.getDigest(), licenseTwo.getDigest());
+ assertEquals("1.1", licenseOne.getUUID(), licenseTwo.getUUID());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java
index 44c186449..e917893f3 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/MultipleIUAndFragmentTest.java
@@ -10,14 +10,15 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import org.eclipse.equinox.internal.provisional.p2.metadata.VersionRange;
+import org.eclipse.equinox.p2.metadata.VersionRange;
import java.util.Collection;
import java.util.Iterator;
+import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.director.ProfileChangeRequest;
-import org.eclipse.equinox.internal.provisional.p2.metadata.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.Collector;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class MultipleIUAndFragmentTest extends AbstractProvisioningTest {
@@ -40,16 +41,16 @@ public class MultipleIUAndFragmentTest extends AbstractProvisioningTest {
iu3 = createBundleFragment("fragment");
ProfileChangeRequest req = new ProfileChangeRequest(createProfile(getName()));
createTestMetdataRepository(new IInstallableUnit[] {iu1, iu2, iu3});
- Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, new Collector(), null).iterator();
+ Iterator iterator = createPlanner().getProvisioningPlan(req, null, null).getAdditions().query(InstallableUnitQuery.ANY, null).iterator();
for (; iterator.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) iterator.next();
if (iu.getId().equals(iu1.getId())) {
- assertEquals(1, iu.getFragments().length);
- assertEquals(iu.getFragments()[0].getId(), iu3.getId());
+ assertEquals(1, iu.getFragments().size());
+ assertEquals(iu.getFragments().get(0).getId(), iu3.getId());
}
if (iu.getId().equals(iu2.getId())) {
- assertEquals(1, iu.getFragments().length);
- assertEquals(iu.getFragments()[0].getId(), iu3.getId());
+ assertEquals(1, iu.getFragments().size());
+ assertEquals(iu.getFragments().get(0).getId(), iu3.getId());
}
if (iu.getId().equals(iu3.getId())) {
//fragments don't have fragments
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ProvidedCapabilityTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ProvidedCapabilityTest.java
index d78a65e24..316d64c50 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ProvidedCapabilityTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/ProvidedCapabilityTest.java
@@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata;
-import org.eclipse.equinox.internal.provisional.p2.metadata.Version;
+import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.internal.provisional.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
/**
@@ -23,7 +23,7 @@ public class ProvidedCapabilityTest extends AbstractProvisioningTest {
public void testEquals() {
IProvidedCapability cap = MetadataFactory.createProvidedCapability("namespace", "name", DEFAULT_VERSION);
IProvidedCapability equal = MetadataFactory.createProvidedCapability("namespace", "name", DEFAULT_VERSION);
- IProvidedCapability notEqual = MetadataFactory.createProvidedCapability("namespace", "name", new Version(2, 0, 0));
+ IProvidedCapability notEqual = MetadataFactory.createProvidedCapability("namespace", "name", Version.createOSGi(2, 0, 0));
assertEquals("1.0", cap, equal);
assertFalse("1.1", cap.equals(notEqual));
assertFalse("1.1", notEqual.equals(cap));
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/AllTests.java
new file mode 100644
index 000000000..39fed0b38
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/AllTests.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.metadata.expression;
+
+import junit.framework.*;
+
+/**
+ * Performs all automated director tests.
+ */
+public class AllTests extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AllTests.class.getName());
+ suite.addTestSuite(ExpressionTest.class);
+ suite.addTestSuite(FilterTest.class);
+ return suite;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/ExpressionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/ExpressionTest.java
new file mode 100644
index 000000000..9c7407c63
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/ExpressionTest.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Cloudsmith Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cloudsmith Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.p2.tests.metadata.expression;
+
+import org.eclipse.equinox.p2.metadata.expression.*;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+
+public class ExpressionTest extends AbstractProvisioningTest {
+ private static final IExpressionFactory factory = ExpressionUtil.getFactory();
+
+ protected void testExpression(String exprStr, Object expectedOutcome) throws Exception {
+ IExpression expr = ExpressionUtil.parse(exprStr);
+ assertEquals(expr.evaluate(factory.createContext()), expectedOutcome);
+ }
+
+ protected void testMatch(String expr, boolean expectedOutcome) throws Exception {
+ testExpression(expr, Boolean.valueOf(expectedOutcome));
+ }
+
+ public void testCompare() throws Exception {
+ testMatch("'foo' == 'foo'", true);
+ testMatch("'foo' == 'fooo'", false);
+ testMatch("'foo' != 'foo'", false);
+ testMatch("'foo' != 'fooo'", true);
+ testMatch("2 < 1", false);
+ testMatch("2 <= 1", false);
+ testMatch("2 < 2", false);
+ testMatch("2 <= 2", true);
+ testMatch("2 < 3", true);
+ testMatch("2 <= 3", true);
+ testMatch("1 > 2", false);
+ testMatch("1 >= 2", false);
+ testMatch("2 > 2", false);
+ testMatch("2 >= 2", true);
+ testMatch("3 > 2", true);
+ testMatch("3 >= 2", true);
+ }
+
+ public void testAutoCoerce() throws Exception {
+ testMatch("'12' == 12", true);
+ testMatch("'012' == 12", true);
+ testMatch("'2' > '10'", true);
+ testMatch("'2' > 10", false);
+ testMatch("true == 'true'", true);
+ testMatch("true == 'True'", true);
+ testMatch("false == 'false'", true);
+ testMatch("false == 'False'", true);
+ }
+
+ public void testLeftToRigthAssociativity() throws Exception {
+ testMatch("2 < 10 == true", true);
+ try {
+ testMatch("true == 2 < 10", false);
+ fail("Auto coercion from boolean to integer succeded");
+ } catch (IllegalArgumentException e) {
+ // OK
+ }
+ }
+}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java
new file mode 100644
index 000000000..cf3cba552
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/expression/FilterTest.java
@@ -0,0 +1,267 @@
+package org.eclipse.equinox.p2.tests.metadata.expression;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.*;
+import junit.framework.*;
+import org.eclipse.equinox.p2.metadata.expression.*;
+import org.osgi.framework.*;
+
+public class FilterTest extends TestCase {
+ private static class DictionaryServiceReference implements ServiceReference {
+ private final Map<String, ? extends Object> dictionary;
+
+ private final String[] keys;
+
+ DictionaryServiceReference(Map<String, ? extends Object> dictionary) {
+ if (dictionary == null) {
+ this.dictionary = null;
+ this.keys = new String[] {};
+ return;
+ }
+ this.dictionary = dictionary;
+ List<String> keyList = new ArrayList<String>(dictionary.size());
+ for (Iterator<String> e = dictionary.keySet().iterator(); e.hasNext();) {
+ String key = e.next();
+ for (Iterator i = keyList.iterator(); i.hasNext();) {
+ if (key.equalsIgnoreCase((String) i.next())) {
+ throw new IllegalArgumentException();
+ }
+ }
+ keyList.add(key);
+ }
+ this.keys = keyList.toArray(new String[keyList.size()]);
+ }
+
+ public int compareTo(Object reference) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Bundle getBundle() {
+ return null;
+ }
+
+ public Object getProperty(String k) {
+ for (int i = 0, length = keys.length; i < length; i++) {
+ String key = keys[i];
+ if (key.equalsIgnoreCase(k)) {
+ return dictionary.get(key);
+ }
+ }
+ return null;
+ }
+
+ public String[] getPropertyKeys() {
+ return keys.clone();
+ }
+
+ public Bundle[] getUsingBundles() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isAssignableTo(Bundle bundle, String className) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private static class SampleComparable implements Comparable {
+ private int value = -1;
+
+ public SampleComparable(String value) {
+ this.value = Integer.parseInt(value);
+ }
+
+ public boolean equals(Object o) {
+ return o instanceof SampleComparable && value == ((SampleComparable) o).value;
+ }
+
+ public int compareTo(Object o) {
+ return value - ((SampleComparable) o).value;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(value);
+ }
+ }
+
+ static final int ISTRUE = 1;
+
+ static final int ISFALSE = 2;
+
+ static final int ISILLEGAL = 3;
+
+ public static Test suite() {
+ return new TestSuite(FilterTest.class);
+ }
+
+ public void testComparable() throws Exception {
+ IFilterExpression f1 = ExpressionUtil.parseLDAP("(comparable=42)"); //$NON-NLS-1$
+ Object comp;
+ Map<String, Object> hash = new HashMap<String, Object>();
+
+ comp = new SampleComparable("42"); //$NON-NLS-1$
+ hash.put("comparable", comp); //$NON-NLS-1$
+ assertTrue("does not match filter", f1.match(hash)); //$NON-NLS-1$
+ assertTrue("does not match filter", f1.match(new DictionaryServiceReference(hash))); //$NON-NLS-1$
+
+ comp = new Long(42);
+ hash.put("comparable", comp); //$NON-NLS-1$
+ assertTrue("does not match filter", f1.match(hash)); //$NON-NLS-1$
+ assertTrue("does not match filter", f1.match(new DictionaryServiceReference(hash))); //$NON-NLS-1$
+
+ IFilterExpression f2 = ExpressionUtil.parseLDAP("(comparable=42)"); //$NON-NLS-1$
+ hash = new Hashtable<String, Object>();
+
+ comp = new SampleComparable("42"); //$NON-NLS-1$
+ hash.put("comparable", comp); //$NON-NLS-1$
+ assertTrue("does not match filter", f2.match(hash)); //$NON-NLS-1$
+ assertTrue("does not match filter", f2.match(new DictionaryServiceReference(hash))); //$NON-NLS-1$
+
+ comp = new Long(42);
+ hash.put("comparable", comp); //$NON-NLS-1$
+ assertTrue("does not match filter", f2.match(hash)); //$NON-NLS-1$
+ assertTrue("does not match filter", f2.match(new DictionaryServiceReference(hash))); //$NON-NLS-1$
+
+ assertEquals("not equal", f1, f2); //$NON-NLS-1$
+ }
+
+ public void testFilter() {
+ Properties props = new Properties();
+ props.put("room", "bedroom"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.put("channel", new Integer(34)); //$NON-NLS-1$
+ props.put("status", "(on\\)*"); //$NON-NLS-1$//$NON-NLS-2$
+ props.put("max record time", new Long(150)); //$NON-NLS-1$
+ props.put("canrecord", "true(x)"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.put("shortvalue", new Short((short) 1000)); //$NON-NLS-1$
+ props.put("bytevalue", new Byte((byte) 10)); //$NON-NLS-1$
+ props.put("floatvalue", new Float(1.01)); //$NON-NLS-1$
+ props.put("doublevalue", new Double(2.01)); //$NON-NLS-1$
+ props.put("charvalue", new Character('A')); //$NON-NLS-1$
+ props.put("booleanvalue", new Boolean(false)); //$NON-NLS-1$
+ props.put("weirdvalue", new Hashtable()); //$NON-NLS-1$
+ try {
+ props.pu