Skip to content

Commit

Permalink
Fix ProvisioningContextTest.testFollowHelpsResolve is violating API
Browse files Browse the repository at this point in the history
Currently ProvisioningContextTest.testFollowHelpsResolve() assumes it
can modify the context repositories after using the context but this is
not valid according to API.
  • Loading branch information
laeubi authored and HannesWell committed Sep 26, 2024
1 parent dab6dd0 commit 5bc1d2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ private Set<IMetadataRepository> getLoadedMetadataRepositories(IProgressMonitor

// Clear out the list of remembered artifact repositories
referencedArtifactRepositories = new HashMap<>();
for (URI repositorie : repositories) {
loadMetadataRepository(repoManager, repositorie, loadedRepos, shouldFollowReferences(), sub.split(1));
for (URI repository : repositories) {
loadMetadataRepository(repoManager, repository, loadedRepos, shouldFollowReferences(), sub.split(1));
}
}
return new HashSet<>(loadedRepos.values());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 5bc1d2d

Please sign in to comment.