View Javadoc
1   package org.apache.maven.plugins.dependency.resolvers;
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  import java.io.IOException;
23  import java.util.HashSet;
24  import java.util.Set;
25  
26  import org.apache.maven.artifact.Artifact;
27  import org.apache.maven.plugins.dependency.AbstractDependencyMojoTestCase;
28  import org.apache.maven.plugins.dependency.utils.DependencyStatusSets;
29  
30  public class ResolveDependenciesMojoTest
31      extends AbstractDependencyMojoTestCase
32  {
33      protected void setUp()
34          throws Exception
35      {
36          // required for mojo lookups to work
37          super.setUp( "dss", true );
38      }
39  
40      public void testDependencyStatusLog()
41          throws IOException
42      {
43          Set<Artifact> artifacts = this.stubFactory.getMixedArtifacts();
44          doTestDependencyStatusLog( artifacts );
45      }
46  
47      public void testDependencyStatusLogNullFiles()
48          throws IOException
49      {
50          this.stubFactory.setCreateFiles( false );
51          Set<Artifact> artifacts = this.stubFactory.getMixedArtifacts();
52          doTestDependencyStatusLog( artifacts );
53      }
54  
55      public void testDependencyStatusEmptySet()
56      {
57          doTestDependencyStatusLog( new HashSet<Artifact>() );
58      }
59  
60      public void doTestDependencyStatusLog( Set<Artifact> artifacts )
61      {
62          // TODO: implement logger to check correct output
63          // this test is just looking for unexpected exceptions.
64  
65          ResolveDependenciesMojo mojo = newMojo( new DependencyStatusSets() );
66          mojo.getOutput( false, true, false );
67          mojo.getOutput( true, true, false );
68  
69          mojo = newMojo( new DependencyStatusSets( artifacts, null, null ) );
70          mojo.getOutput( false, true, false );
71          mojo.getOutput( true, true, false );
72  
73          mojo = newMojo( new DependencyStatusSets( null, artifacts, null ) );
74          mojo.getOutput( false, true, false );
75          mojo.getOutput( true, true, false );
76  
77          mojo = newMojo( new DependencyStatusSets( null, null, artifacts ) );
78          mojo.getOutput( false, true, false );
79          mojo.getOutput( true, true, false );
80  
81          mojo = newMojo( new DependencyStatusSets( artifacts, artifacts, null ) );
82          mojo.getOutput( false, true, false );
83          mojo.getOutput( true, true, false );
84  
85          mojo = newMojo( new DependencyStatusSets( null, artifacts, artifacts ) );
86          mojo.getOutput( false, true, false );
87          mojo.getOutput( true, true, false );
88  
89          mojo = newMojo( new DependencyStatusSets( artifacts, null, artifacts ) );
90          mojo.getOutput( false, true, false );
91          mojo.getOutput( true, true, false );
92  
93          mojo = newMojo( new DependencyStatusSets( artifacts, artifacts, artifacts ) );
94          mojo.getOutput( false, true, false );
95          mojo.getOutput( true, true, false );
96          mojo.getOutput( false, false, false );
97          mojo.getOutput( true, false, false );
98      }
99  
100     private ResolveDependenciesMojo newMojo( final DependencyStatusSets dss )
101     {
102         ResolveDependenciesMojo mojo = new ResolveDependenciesMojo();
103         mojo.results = dss;
104         return mojo;
105     }
106 }