View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugins.dependency.utils.filters;
20  
21  import java.io.File;
22  import java.io.IOException;
23  
24  import org.apache.maven.artifact.Artifact;
25  import org.apache.maven.plugin.MojoExecutionException;
26  import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory;
27  import org.apache.maven.plugins.dependency.utils.markers.SourcesFileMarkerHandler;
28  import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
29  import org.junit.jupiter.api.BeforeEach;
30  import org.junit.jupiter.api.Test;
31  import org.junit.jupiter.api.io.TempDir;
32  
33  import static org.junit.jupiter.api.Assertions.assertFalse;
34  import static org.junit.jupiter.api.Assertions.assertTrue;
35  
36  /**
37   * @author brianf
38   */
39  public class TestResolveMarkerFileFilter {
40  
41      @TempDir
42      File outputFolder;
43  
44      DependencyArtifactStubFactory fact;
45  
46      @BeforeEach
47      protected void setUp() throws IOException {
48          fact = new DependencyArtifactStubFactory(outputFolder, false);
49          fact.getReleaseAndSnapshotArtifacts();
50      }
51  
52      @Test
53      public void testResolveFile() throws IOException, ArtifactFilterException, MojoExecutionException {
54          SourcesFileMarkerHandler handler = new SourcesFileMarkerHandler(outputFolder);
55  
56          Artifact artifact = fact.getReleaseArtifact();
57          handler.setArtifact(artifact);
58  
59          ResolveFileFilter filter = new ResolveFileFilter(handler);
60  
61          assertTrue(filter.isArtifactIncluded(artifact));
62          handler.setMarker();
63          assertFalse(filter.isArtifactIncluded(artifact));
64      }
65  }