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.project.artifact;
20  
21  import org.codehaus.plexus.PlexusTestCase;
22  import org.junit.Ignore;
23  
24  @Ignore
25  public class MavenMetadataSourceTest extends PlexusTestCase {
26  
27      protected void setUp() throws Exception {
28          super.setUp();
29      }
30  
31      @Override
32      protected void tearDown() throws Exception {
33          super.tearDown();
34      }
35  
36      public void testShouldNotCarryExclusionsOverFromDependencyToDependency() throws Exception {
37          /*
38          Dependency dep1 = new Dependency();
39          dep1.setGroupId( "test" );
40          dep1.setArtifactId( "test-artifact" );
41          dep1.setVersion( "1" );
42          dep1.setType( "jar" );
43  
44          Exclusion exc = new Exclusion();
45          exc.setGroupId( "test" );
46          exc.setArtifactId( "test-artifact3" );
47  
48          dep1.addExclusion( exc );
49  
50          Dependency dep2 = new Dependency();
51          dep2.setGroupId( "test" );
52          dep2.setArtifactId( "test-artifact2" );
53          dep2.setVersion( "1" );
54          dep2.setType( "jar" );
55  
56          List deps = new ArrayList();
57          deps.add( dep1 );
58          deps.add( dep2 );
59  
60          ArtifactFactory factory = lookup( ArtifactFactory.class );
61  
62          ArtifactFilter dependencyFilter = new ScopeArtifactFilter( Artifact.SCOPE_COMPILE );
63  
64          MavenProject project = new MavenProject( new Model() );
65  
66          Set result = project.createArtifacts( dependencyFilter );
67  
68          for ( Iterator it = result.iterator(); it.hasNext(); )
69          {
70              Artifact artifact = ( Artifact ) it.next();
71  
72              if ( "test-artifact2".equals( artifact.getArtifactId() ) )
73              {
74                  ArtifactFilter filter = artifact.getDependencyFilter();
75  
76                  assertSame( dependencyFilter, filter );
77              }
78          }
79          */
80      }
81  
82      // TODO restore these if it makes sense
83      /*
84      public void testShouldUseCompileScopeIfDependencyScopeEmpty()
85          throws Exception
86      {
87          String groupId = "org.apache.maven";
88          String artifactId = "maven-model";
89  
90          Dependency dep = new Dependency();
91  
92          dep.setGroupId( groupId );
93          dep.setArtifactId( artifactId );
94          dep.setVersion( "2.0-alpha-3" );
95  
96          Model model = new Model();
97  
98          model.addDependency( dep );
99  
100         MavenProject project = new MavenProject( model, repositorySystem );
101 
102         project.setArtifacts( project.createArtifacts( null ) );
103 
104         String key = ArtifactUtils.versionlessKey( groupId, artifactId );
105 
106         Map artifactMap = project.getArtifactMap();
107 
108         assertNotNull( "artifact-map should not be null.", artifactMap );
109         assertEquals( "artifact-map should contain 1 element.", 1, artifactMap.size() );
110 
111         Artifact artifact = (Artifact) artifactMap.get( key );
112 
113         assertNotNull( "dependency artifact not found in map.", artifact );
114         assertEquals( "dependency artifact has wrong scope.", Artifact.SCOPE_COMPILE, artifact.getScope() );
115 
116         //check for back-propagation of default scope.
117         assertEquals( "default scope NOT back-propagated to dependency.", Artifact.SCOPE_COMPILE, dep.getScope() );
118     }
119 
120     public void testShouldUseInjectedTestScopeFromDependencyManagement()
121         throws Exception
122     {
123         String groupId = "org.apache.maven";
124         String artifactId = "maven-model";
125 
126         Dependency dep = new Dependency();
127 
128         dep.setGroupId( groupId );
129         dep.setArtifactId( artifactId );
130         dep.setVersion( "2.0-alpha-3" );
131 
132         Model model = new Model();
133 
134         model.addDependency( dep );
135 
136         Dependency mgd = new Dependency();
137         mgd.setGroupId( groupId );
138         mgd.setArtifactId( artifactId );
139         mgd.setScope( Artifact.SCOPE_TEST );
140 
141         DependencyManagement depMgmt = new DependencyManagement();
142 
143         depMgmt.addDependency( mgd );
144 
145         model.setDependencyManagement( depMgmt );
146 
147         MavenProject project = new MavenProject( model, repositorySystem );
148 
149         TestModelDefaultsInjector injector = new TestModelDefaultsInjector();
150 
151         injector.injectDefaults( model );
152 
153         project.setArtifacts( project.createArtifacts( null ) );
154 
155         String key = ArtifactUtils.versionlessKey( groupId, artifactId );
156 
157         Map artifactMap = project.getArtifactMap();
158 
159         assertNotNull( "artifact-map should not be null.", artifactMap );
160         assertEquals( "artifact-map should contain 1 element.", 1, artifactMap.size() );
161 
162         Artifact artifact = (Artifact) artifactMap.get( key );
163 
164         assertNotNull( "dependency artifact not found in map.", artifact );
165         assertEquals( "dependency artifact has wrong scope.", Artifact.SCOPE_TEST, artifact.getScope() );
166 
167         //check for back-propagation of default scope.
168         assertEquals( "default scope NOT back-propagated to dependency.", Artifact.SCOPE_TEST, dep.getScope() );
169     }
170     */
171 
172 }