1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.dependency.utils.filters;
20
21
22
23
24 import java.io.File;
25 import java.io.IOException;
26 import java.util.HashSet;
27 import java.util.Set;
28
29 import junit.framework.TestCase;
30 import org.apache.commons.io.FileUtils;
31 import org.apache.maven.artifact.Artifact;
32 import org.apache.maven.plugin.MojoExecutionException;
33 import org.apache.maven.plugin.logging.Log;
34 import org.apache.maven.plugin.testing.SilentLog;
35 import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory;
36 import org.apache.maven.plugins.dependency.utils.markers.SourcesFileMarkerHandler;
37 import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
38
39
40
41
42 public class TestResolveMarkerFileFilter extends TestCase {
43 Set<Artifact> artifacts = new HashSet<>();
44
45 Log log = new SilentLog();
46
47 File outputFolder;
48
49 DependencyArtifactStubFactory fact;
50
51 protected void setUp() throws Exception {
52 super.setUp();
53
54 outputFolder = new File("target/markers/");
55 FileUtils.deleteDirectory(outputFolder);
56 assertFalse(outputFolder.exists());
57
58 this.fact = new DependencyArtifactStubFactory(outputFolder, false);
59 artifacts = fact.getReleaseAndSnapshotArtifacts();
60 }
61
62 protected void tearDown() throws IOException {
63 FileUtils.deleteDirectory(outputFolder);
64 }
65
66 public void testResolveFile() throws IOException, ArtifactFilterException, MojoExecutionException {
67 SourcesFileMarkerHandler handler = new SourcesFileMarkerHandler(outputFolder);
68
69 Artifact artifact = fact.getReleaseArtifact();
70 handler.setArtifact(artifact);
71
72 ResolveFileFilter filter = new ResolveFileFilter(handler);
73
74 assertTrue(filter.isArtifactIncluded(artifact));
75 handler.setMarker();
76 assertFalse(filter.isArtifactIncluded(artifact));
77 }
78 }