Search in sources :

Example 86 with DependencyNode

use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.

the class TreeDependencyVisitorTest method testDuplicateSuppression.

@Test
public void testDuplicateSuppression() throws Exception {
    DependencyNode root = parse("cycles.txt");
    RecordingVisitor rec = new RecordingVisitor();
    TreeDependencyVisitor visitor = new TreeDependencyVisitor(rec);
    root.accept(visitor);
    assertEquals(">a >b >c <c <b >d <d <a ", rec.buffer.toString());
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) Test(org.junit.Test)

Example 87 with DependencyNode

use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.

the class PatternExclusionsDependencyFilterTest method acceptTestMatches.

@Test
public void acceptTestMatches() {
    NodeBuilder builder = new NodeBuilder();
    builder.groupId("com.example.test").artifactId("testArtifact").ext("jar").version("1.0.3");
    DependencyNode node = builder.build();
    // full match
    assertEquals("com.example.test:testArtifact:jar:1.0.3", true, dontAccept(node, "com.example.test:testArtifact:jar:1.0.3"));
    // single wildcard
    assertEquals("*:testArtifact:jar:1.0.3", true, dontAccept(node, "*:testArtifact:jar:1.0.3"));
    assertEquals("com.example.test:*:jar:1.0.3", true, dontAccept(node, "com.example.test:*:jar:1.0.3"));
    assertEquals("com.example.test:testArtifact:*:1.0.3", true, dontAccept(node, "com.example.test:testArtifact:*:1.0.3"));
    assertEquals("com.example.test:testArtifact:*:1.0.3", true, dontAccept(node, "com.example.test:testArtifact:*:1.0.3"));
    // implicit wildcard
    assertEquals(":testArtifact:jar:1.0.3", true, dontAccept(node, ":testArtifact:jar:1.0.3"));
    assertEquals("com.example.test::jar:1.0.3", true, dontAccept(node, "com.example.test::jar:1.0.3"));
    assertEquals("com.example.test:testArtifact::1.0.3", true, dontAccept(node, "com.example.test:testArtifact::1.0.3"));
    assertEquals("com.example.test:testArtifact:jar:", true, dontAccept(node, "com.example.test:testArtifact:jar:"));
    // multi wildcards
    assertEquals("*:*:jar:1.0.3", true, dontAccept(node, "*:*:jar:1.0.3"));
    assertEquals("com.example.test:*:*:1.0.3", true, dontAccept(node, "com.example.test:*:*:1.0.3"));
    assertEquals("com.example.test:testArtifact:*:*", true, dontAccept(node, "com.example.test:testArtifact:*:*"));
    assertEquals("*:testArtifact:jar:*", true, dontAccept(node, "*:testArtifact:jar:*"));
    assertEquals("*:*:jar:*", true, dontAccept(node, "*:*:jar:*"));
    assertEquals(":*:jar:", true, dontAccept(node, ":*:jar:"));
    // partial wildcards
    assertEquals("*.example.test:testArtifact:jar:1.0.3", true, dontAccept(node, "*.example.test:testArtifact:jar:1.0.3"));
    assertEquals("com.example.test:testArtifact:*ar:1.0.*", true, dontAccept(node, "com.example.test:testArtifact:*ar:1.0.*"));
    assertEquals("com.example.test:testArtifact:jar:1.0.*", true, dontAccept(node, "com.example.test:testArtifact:jar:1.0.*"));
    assertEquals("*.example.*:testArtifact:jar:1.0.3", true, dontAccept(node, "*.example.*:testArtifact:jar:1.0.3"));
    // wildcard as empty string
    assertEquals("com.example.test*:testArtifact:jar:1.0.3", true, dontAccept(node, "com.example.test*:testArtifact:jar:1.0.3"));
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Example 88 with DependencyNode

use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.

the class PatternExclusionsDependencyFilterTest method acceptTestRange.

@Test
public void acceptTestRange() {
    NodeBuilder builder = new NodeBuilder();
    builder.groupId("com.example.test").artifactId("testArtifact").ext("jar").version("1.0.3");
    DependencyNode node = builder.build();
    String prefix = "com.example.test:testArtifact:jar:";
    assertTrue(prefix + "[1.0.3,1.0.4)", dontAcceptVersionRange(node, prefix + "[1.0.3,1.0.4)"));
    assertTrue(prefix + "[1.0.3,)", dontAcceptVersionRange(node, prefix + "[1.0.3,)"));
    assertTrue(prefix + "[1.0.3,]", dontAcceptVersionRange(node, prefix + "[1.0.3,]"));
    assertTrue(prefix + "(,1.0.3]", dontAcceptVersionRange(node, prefix + "(,1.0.3]"));
    assertTrue(prefix + "[1.0,]", dontAcceptVersionRange(node, prefix + "[1.0,]"));
    assertTrue(prefix + "[1,4]", dontAcceptVersionRange(node, prefix + "[1,4]"));
    assertTrue(prefix + "(1,4)", dontAcceptVersionRange(node, prefix + "(1,4)"));
    assertTrue(prefix + "(1.0.2,1.0.3]", dontAcceptVersionRange(node, prefix + "(1.0.2,1.0.3]", prefix + "(1.1,)"));
    assertFalse(prefix + "(1.0.3,2.0]", dontAcceptVersionRange(node, prefix + "(1.0.3,2.0]"));
    assertFalse(prefix + "(1,1.0.2]", dontAcceptVersionRange(node, prefix + "(1,1.0.2]"));
    assertFalse(prefix + "(1.0.2,1.0.3)", dontAcceptVersionRange(node, prefix + "(1.0.2,1.0.3)", prefix + "(1.0.3,)"));
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Example 89 with DependencyNode

use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.

the class PatternExclusionsDependencyFilterTest method acceptTestMissmatch.

@Test
public void acceptTestMissmatch() {
    NodeBuilder builder = new NodeBuilder();
    builder.groupId("com.example.test").artifactId("testArtifact").ext("jar").version("1.0.3");
    DependencyNode node = builder.build();
    assertEquals("OTHER.GROUP.ID:testArtifact:jar:1.0.3", false, dontAccept(node, "OTHER.GROUP.ID:testArtifact:jar:1.0.3"));
    assertEquals("com.example.test:OTHER_ARTIFACT:jar:1.0.3", false, dontAccept(node, "com.example.test:OTHER_ARTIFACT:jar:1.0.3"));
    assertEquals("com.example.test:OTHER_ARTIFACT:jar:1.0.3", false, dontAccept(node, "com.example.test:OTHER_ARTIFACT:jar:1.0.3"));
    assertEquals("com.example.test:testArtifact:WAR:1.0.3", false, dontAccept(node, "com.example.test:testArtifact:WAR:1.0.3"));
    assertEquals("com.example.test:testArtifact:jar:SNAPSHOT", false, dontAccept(node, "com.example.test:testArtifact:jar:SNAPSHOT"));
    assertEquals("*:*:war:*", false, dontAccept(node, "*:*:war:*"));
    assertEquals("OTHER.GROUP.ID", false, dontAccept(node, "OTHER.GROUP.ID"));
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Example 90 with DependencyNode

use of org.sonatype.aether.graph.DependencyNode in project sonatype-aether by sonatype.

the class PatternExclusionsDependencyFilterTest method acceptTestMoreToken.

@Test
public void acceptTestMoreToken() {
    NodeBuilder builder = new NodeBuilder();
    builder.groupId("com.example.test").artifactId("testArtifact").ext("jar").version("1.0.3");
    DependencyNode node = builder.build();
    assertEquals("com.example.test:testArtifact:jar:1.0.3:foo", false, dontAccept(node, "com.example.test:testArtifact:jar:1.0.3:foo"));
}
Also used : DependencyNode(org.sonatype.aether.graph.DependencyNode) NodeBuilder(org.sonatype.aether.test.util.NodeBuilder) Test(org.junit.Test)

Aggregations

DependencyNode (org.sonatype.aether.graph.DependencyNode)114 Test (org.junit.Test)82 NodeBuilder (org.sonatype.aether.test.util.NodeBuilder)20 Dependency (org.sonatype.aether.graph.Dependency)14 IdentityHashMap (java.util.IdentityHashMap)13 CollectRequest (org.sonatype.aether.collection.CollectRequest)12 CollectResult (org.sonatype.aether.collection.CollectResult)11 List (java.util.List)8 Map (java.util.Map)8 LinkedList (java.util.LinkedList)7 Artifact (org.sonatype.aether.artifact.Artifact)6 DependencyFilter (org.sonatype.aether.graph.DependencyFilter)5 ArrayList (java.util.ArrayList)4 DependencyGraphTransformationContext (org.sonatype.aether.collection.DependencyGraphTransformationContext)4 ConflictMarker (org.sonatype.aether.util.graph.transformer.ConflictMarker)4 HashMap (java.util.HashMap)3 ArtifactDescriptorException (org.sonatype.aether.resolution.ArtifactDescriptorException)3 BufferedReader (java.io.BufferedReader)2 HashSet (java.util.HashSet)2 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)2