View Javadoc

1   package org.apache.maven.plugin.dependency.utils.filters;
2   
3   /* 
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.    
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.maven.artifact.Artifact;
33  import org.apache.maven.plugin.MojoExecutionException;
34  import org.apache.maven.plugin.dependency.testUtils.DependencyArtifactStubFactory;
35  import org.apache.maven.plugin.dependency.testUtils.DependencyTestUtils;
36  import org.apache.maven.plugin.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   * @author brianf
43   * 
44   */
45  public class TestResolveMarkerFileFilter
46      extends TestCase
47  {
48      Set<Artifact> artifacts = new HashSet<Artifact>();
49  
50      Log log = new SilentLog();
51  
52      File outputFolder;
53  
54      DependencyArtifactStubFactory fact;
55  
56      protected void setUp()
57          throws Exception
58      {
59          super.setUp();
60  
61          outputFolder = new File( "target/markers/" );
62          DependencyTestUtils.removeDirectory( outputFolder );
63          assertFalse( outputFolder.exists() );
64  
65          this.fact = new DependencyArtifactStubFactory( outputFolder, false );
66          artifacts = fact.getReleaseAndSnapshotArtifacts();
67      }
68  
69      protected void tearDown()
70          throws IOException
71      {
72          DependencyTestUtils.removeDirectory( outputFolder );
73      }
74  
75      public void testResolveFile()
76          throws  IOException, ArtifactFilterException, MojoExecutionException
77      {
78          SourcesFileMarkerHandler handler = new SourcesFileMarkerHandler( outputFolder );
79  
80          Artifact artifact = fact.getReleaseArtifact();
81          handler.setArtifact( artifact );
82  
83          ResolveFileFilter filter = new ResolveFileFilter( handler );
84  
85          assertTrue( filter.isArtifactIncluded( artifact) );
86          handler.setMarker();
87          assertFalse( filter.isArtifactIncluded( artifact) );
88      }
89  
90  }