From 3f2f8ec97f2b17c4dbbb314d3a85e5bc792b7c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Thu, 16 May 2024 07:55:13 +0200 Subject: [PATCH] Fix ProvisioningContextTest.testFollowHelpsResolve is violating API Currently ProvisioningContextTest.testFollowHelpsResolve() assumes it can modify the context repositories after using the context but this is not valid according to API. --- .../p2/tests/engine/ProvisioningContextTest.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningContextTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningContextTest.java index 4fe0b58794..adb8b19c44 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningContextTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/engine/ProvisioningContextTest.java @@ -22,7 +22,10 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil; import org.eclipse.equinox.p2.planner.IProfileChangeRequest; -import org.eclipse.equinox.p2.query.*; +import org.eclipse.equinox.p2.query.ExpressionMatchQuery; +import org.eclipse.equinox.p2.query.IQuery; +import org.eclipse.equinox.p2.query.IQueryable; +import org.eclipse.equinox.p2.query.QueryUtil; import org.eclipse.equinox.p2.repository.IRepository; import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; @@ -199,6 +202,12 @@ public void testFollowHelpsResolve() { context.setArtifactRepositories(new URI[0]); IProvisioningPlan plan = getPlanner(getAgent()).getProvisioningPlan(request, context, getMonitor()); assertFalse("resolve should fail with missing requirements", plan.getStatus().isOK()); + // we need to create a new context as the planner is calling + // ProvisioningContext.getMetadata(IProgressMonitor) and after that call + // repositories are fixed as per API... + context = new ProvisioningContext(getAgent()); + context.setMetadataRepositories(new URI[] { repoA.getLocation() }); + context.setArtifactRepositories(new URI[0]); context.setProperty(ProvisioningContext.FOLLOW_REPOSITORY_REFERENCES, "true"); plan = getPlanner(getAgent()).getProvisioningPlan(request, context, getMonitor()); assertTrue("resolve should pass", plan.getStatus().isOK());