use of org.sonatype.aether.test.util.NodeBuilder in project sonatype-aether by sonatype.
the class DependencyFilterUtilsTest method testClasspathFilterTest.
@Test
public void testClasspathFilterTest() {
NodeBuilder builder = new NodeBuilder().artifactId("aid");
DependencyFilter filter = DependencyFilterUtils.classpathFilter("test");
assertTrue(filter.accept(builder.scope("compile").build(), PARENTS));
assertTrue(filter.accept(builder.scope("system").build(), PARENTS));
assertTrue(filter.accept(builder.scope("provided").build(), PARENTS));
assertTrue(filter.accept(builder.scope("runtime").build(), PARENTS));
assertTrue(filter.accept(builder.scope("test").build(), PARENTS));
}
use of org.sonatype.aether.test.util.NodeBuilder in project sonatype-aether by sonatype.
the class DependencyFilterUtilsTest method testClasspathFilterNull.
@Test
public void testClasspathFilterNull() {
NodeBuilder builder = new NodeBuilder().artifactId("aid");
DependencyFilter filter = DependencyFilterUtils.classpathFilter((String[]) null);
assertFalse(filter.accept(builder.scope("compile").build(), PARENTS));
assertFalse(filter.accept(builder.scope("system").build(), PARENTS));
assertFalse(filter.accept(builder.scope("provided").build(), PARENTS));
assertFalse(filter.accept(builder.scope("runtime").build(), PARENTS));
assertFalse(filter.accept(builder.scope("test").build(), PARENTS));
}
use of org.sonatype.aether.test.util.NodeBuilder in project sonatype-aether by sonatype.
the class ScopeDependencyFilterTest method acceptTest.
@Test
public void acceptTest() {
NodeBuilder builder = new NodeBuilder();
builder.scope("compile").artifactId("test");
List<DependencyNode> parents = new LinkedList<DependencyNode>();
// null or empty
assertTrue(new ScopeDependencyFilter(null, null).accept(builder.build(), parents));
assertTrue(new ScopeDependencyFilter(new LinkedList<String>(), new LinkedList<String>()).accept(builder.build(), parents));
assertTrue(new ScopeDependencyFilter((String[]) null).accept(builder.build(), parents));
//only excludes
assertTrue(new ScopeDependencyFilter("test").accept(builder.build(), parents));
assertFalse(new ScopeDependencyFilter("compile").accept(builder.build(), parents));
assertFalse(new ScopeDependencyFilter("compile", "test").accept(builder.build(), parents));
//Both
String[] excludes1 = { "provided" };
String[] includes1 = { "compile", "test" };
assertTrue(new ScopeDependencyFilter(Arrays.asList(includes1), Arrays.asList(excludes1)).accept(builder.build(), parents));
assertTrue(new ScopeDependencyFilter(Arrays.asList(includes1), null).accept(builder.build(), parents));
//exclude wins
String[] excludes2 = { "compile" };
String[] includes2 = { "compile" };
assertFalse(new ScopeDependencyFilter(Arrays.asList(includes2), Arrays.asList(excludes2)).accept(builder.build(), parents));
}
use of org.sonatype.aether.test.util.NodeBuilder in project sonatype-aether by sonatype.
the class DependencyFilterUtilsTest method testClasspathFilterCompilePlusRuntime.
@Test
public void testClasspathFilterCompilePlusRuntime() {
NodeBuilder builder = new NodeBuilder().artifactId("aid");
DependencyFilter filter = DependencyFilterUtils.classpathFilter("compile+runtime");
assertTrue(filter.accept(builder.scope("compile").build(), PARENTS));
assertTrue(filter.accept(builder.scope("system").build(), PARENTS));
assertTrue(filter.accept(builder.scope("provided").build(), PARENTS));
assertTrue(filter.accept(builder.scope("runtime").build(), PARENTS));
assertFalse(filter.accept(builder.scope("test").build(), PARENTS));
}
use of org.sonatype.aether.test.util.NodeBuilder 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"));
}
Aggregations