Skip to content

Commit

Permalink
[MRESOLVER-376] UT for bug (#312)
Browse files Browse the repository at this point in the history
This UT on master makes old DF work, while BF break with SOEx.

If same UT ran on fixed branch, both pass.

Still, seems combo of range+relocation has some other issues as well,
as all this works only partially, as the range is not resolved,
only first applicant (lowest version in DF and highest version
in BF as it sort-reverse the versions).

---

https://issues.apache.org/jira/browse/MRESOLVER-376
  • Loading branch information
cstamas authored Jul 19, 2023
1 parent 6efe87a commit d9d2370
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,23 @@ public void testTransitiveDepsUseRangesDirtyTree() throws DependencyCollectionEx

protected abstract String getTransitiveDepsUseRangesDirtyTreeResource();

@Test
public void testTransitiveDepsUseRangesAndRelocationDirtyTree() throws DependencyCollectionException, IOException {
// Note: DF depends on version order (ultimately the order of versions as returned by VersionRangeResolver
// that in case of Maven, means order as in maven-metadata.xml
// BF on the other hand explicitly sorts versions from range in descending order
//
// Hence, the "dirty tree" of two will not match.
DependencyNode root = parser.parseResource(getTransitiveDepsUseRangesAndRelocationDirtyTreeResource());
Dependency dependency = root.getDependency();
CollectRequest request = new CollectRequest(dependency, singletonList(repository));

CollectResult result = collector.collectDependencies(session, request);
assertEqualSubtree(root, result.getRoot());
}

protected abstract String getTransitiveDepsUseRangesAndRelocationDirtyTreeResource();

private DependencyNode toDependencyResult(
final DependencyNode root, final String rootScope, final Boolean optional) {
// Make the root artifact resultion result a dependency resolution result for the subtree check.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ protected String getTransitiveDepsUseRangesDirtyTreeResource() {
return "transitiveDepsUseRangesDirtyTreeResult_BF.txt";
}

@Override
protected String getTransitiveDepsUseRangesAndRelocationDirtyTreeResource() {
return "transitiveDepsUseRangesAndRelocationDirtyTreeResult_BF.txt";
}

private Dependency newDep(String coords, String scope, Collection<Exclusion> exclusions) {
Dependency d = new Dependency(new DefaultArtifact(coords), scope);
return d.setExclusions(exclusions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ protected void setupCollector() {
protected String getTransitiveDepsUseRangesDirtyTreeResource() {
return "transitiveDepsUseRangesDirtyTreeResult_DF.txt";
}

@Override
protected String getTransitiveDepsUseRangesAndRelocationDirtyTreeResource() {
return "transitiveDepsUseRangesAndRelocationDirtyTreeResult_DF.txt";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
transitiveDepsUseRangesAndRelocationDirtyTree:aid:ext:1 compile
+- transitiveDepsUseRangesAndRelocationDirtyTree:relocatedcid:ext:3 compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
transitiveDepsUseRangesAndRelocationDirtyTree:aid:ext:1 compile
\- transitiveDepsUseRangesAndRelocationDirtyTree:relocatedcid:ext:1 compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[dependencies]
transitiveDepsUseRangesAndRelocationDirtyTree:cid:ext:[1,3]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[relocation]
transitiveDepsUseRangesAndRelocationDirtyTree:relocatedcid:ext:1

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[relocation]
transitiveDepsUseRangesAndRelocationDirtyTree:relocatedcid:ext:2

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[relocation]
transitiveDepsUseRangesAndRelocationDirtyTree:relocatedcid:ext:3

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[dependencies]
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public ArtifactDescriptorResult readArtifactDescriptor(
ArtifactDescription data = reader.parse(resourceName);
if (data.getRelocation() != null) {
result.addRelocation(artifact);
result.setArtifact(data.getRelocation());
artifact = data.getRelocation();
} else {
result.setArtifact(artifact);
Expand Down

0 comments on commit d9d2370

Please sign in to comment.