View Javadoc

1   package org.apache.maven.archiva.dependency.graph;
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.util.ArrayList;
23  import java.util.List;
24  
25  import org.apache.maven.archiva.dependency.DependencyGraphFactory;
26  import org.apache.maven.archiva.model.DependencyScope;
27  import org.apache.maven.archiva.model.VersionedReference;
28  
29  /**
30   * SimpleDependencyGraphTest 
31   *
32   * @version $Id: SimpleDependencyGraphTest.java 755277 2009-03-17 15:18:35Z brett $
33   */
34  public class SimpleDependencyGraphTest
35      extends AbstractDependencyGraphFactoryTestCase
36  {
37      public void testResolveDependenciesBasic() throws GraphTaskException
38      {
39          MemoryRepositoryDependencyGraphBuilder graphBuilder = new MemoryRepositoryDependencyGraphBuilder();
40          MemoryRepository repository = new SimpleMemoryRepository();
41          graphBuilder.setMemoryRepository( repository );
42  
43          // Create the factory, and add the test resolver.
44          DependencyGraphFactory factory = new DependencyGraphFactory();
45          factory.setGraphBuilder( graphBuilder );
46          factory.setDesiredScope( DependencyScope.TEST );
47  
48          // Get the model to resolve from
49          VersionedReference rootRef = toVersionedReference( "org.apache.maven.archiva:archiva-commons:1.0" );
50  
51          // Perform the resolution.
52          DependencyGraph graph = factory.getGraph( rootRef );
53  
54          // Test the results.
55          assertNotNull( "Graph shouldn't be null.", graph );
56  
57          List<String> expectedNodes = new ArrayList<String>();
58          expectedNodes.add( "org.apache.maven.archiva:archiva-commons:1.0::pom" );
59          expectedNodes.add( "org.codehaus.plexus:plexus-digest:1.0::jar" );
60          expectedNodes.add( "junit:junit:3.8.1::jar" );
61          assertNodes( graph, expectedNodes );
62  
63          List<ExpectedEdge> expectedEdges = new ArrayList<ExpectedEdge>();
64          expectedEdges.add( new ExpectedEdge( "org.apache.maven.archiva:archiva-commons:1.0::pom",
65                                               "org.codehaus.plexus:plexus-digest:1.0::jar" ) );
66          expectedEdges.add( new ExpectedEdge( "org.codehaus.plexus:plexus-digest:1.0::jar", "junit:junit:3.8.1::jar" ) );
67  
68          assertEdges( graph, expectedEdges );
69      }
70  }