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