View Javadoc
1   package org.apache.maven.plugin.dependency.utils;
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.plugin.dependency.AbstractDependencyMojoTestCase;
28  
29  public class TestDependencyStatusSets
30      extends AbstractDependencyMojoTestCase
31  {
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 testDependencyStatusSettersGetters()
41      {
42          /*
43           * DependencyStatusSets dss = new DependencyStatusSets(); Set set = new HashSet(); dss.setResolvedDependencies(
44           * set ); assertSame( set, dss.getResolvedDependencies() ); set = new HashSet(); dss.setUnResolvedDependencies(
45           * set ); assertSame( set, dss.getUnResolvedDependencies() ); set = new HashSet(); dss.setSkippedDependencies(
46           * set ); assertSame( set, dss.getSkippedDependencies() ); assertNotSame( dss.getResolvedDependencies(),
47           * dss.getSkippedDependencies() ); assertNotSame( dss.getResolvedDependencies(), dss.getUnResolvedDependencies() );
48           * assertNotSame( dss.getSkippedDependencies(), dss.getUnResolvedDependencies() );
49           */
50      }
51  
52      public void testDependencyStatusConstructor()
53      {
54          /*
55           * Set r = new HashSet(); Set u = new HashSet(); Set s = new HashSet(); DependencyStatusSets dss = new
56           * DependencyStatusSets( r, u, s ); assertSame( r, dss.getResolvedDependencies() ); assertSame( u,
57           * dss.getUnResolvedDependencies() ); assertSame( s, dss.getSkippedDependencies() );
58           */
59      }
60  
61      public void testDependencyStatusLog()
62          throws IOException
63      {
64          Set<Artifact> artifacts = this.stubFactory.getMixedArtifacts();
65          doTestDependencyStatusLog( artifacts );
66      }
67  
68      public void testDependencyStatusLogNullFiles()
69          throws IOException
70      {
71          this.stubFactory.setCreateFiles( false );
72          Set<Artifact> artifacts = this.stubFactory.getMixedArtifacts();
73          doTestDependencyStatusLog( artifacts );
74      }
75  
76      public void testDependencyStatusEmptySet()
77      {
78          doTestDependencyStatusLog( new HashSet<Artifact>() );
79      }
80  
81      public void doTestDependencyStatusLog( Set<Artifact> artifacts )
82      {
83          // TODO: implement logger to check correct output
84          // this test is just looking for unexpected exceptions.
85  
86          DependencyStatusSets dss = new DependencyStatusSets();
87          dss.getOutput( false );
88          dss.getOutput( true );
89  
90          dss = new DependencyStatusSets( artifacts, null, null );
91          dss.getOutput( false );
92          dss.getOutput( true );
93  
94          dss = new DependencyStatusSets( null, artifacts, null );
95          dss.getOutput( false );
96          dss.getOutput( true );
97  
98          dss = new DependencyStatusSets( null, null, artifacts );
99          dss.getOutput( false );
100         dss.getOutput( true );
101 
102         dss = new DependencyStatusSets( artifacts, artifacts, null );
103         dss.getOutput( false );
104         dss.getOutput( true );
105 
106         dss = new DependencyStatusSets( null, artifacts, artifacts );
107         dss.getOutput( false );
108         dss.getOutput( true );
109 
110         dss = new DependencyStatusSets( artifacts, null, artifacts );
111         dss.getOutput( false );
112         dss.getOutput( true );
113 
114         dss = new DependencyStatusSets( artifacts, artifacts, artifacts );
115         dss.getOutput( false );
116         dss.getOutput( true );
117         dss.getOutput( false, true );
118         dss.getOutput( true, true );
119         dss.getOutput( false, false );
120         dss.getOutput( true, false );
121 
122     }
123 }