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