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 org.apache.maven.archiva.dependency.DependencyGraphFactory;
23  import org.apache.maven.archiva.model.DependencyScope;
24  import org.apache.maven.archiva.model.VersionedReference;
25  
26  import java.util.ArrayList;
27  import java.util.List;
28  
29  /**
30   * DepManDeepVersionDependencyGraphTest
31   * 
32   * DependencyGraphTest for testing <code>net.example.depman.deepversion:A:1.0</code>
33   *
34   * @version $Id: DepManDeepVersionDependencyGraphTest.java 755277 2009-03-17 15:18:35Z brett $
35   */
36  public class DepManDeepVersionDependencyGraphTest
37      extends AbstractDependencyGraphFactoryTestCase
38  {
39      public void testResolvedDepsToNodes()
40          throws GraphTaskException
41      {
42          MemoryRepositoryDependencyGraphBuilder graphBuilder = new MemoryRepositoryDependencyGraphBuilder();
43          MemoryRepository repository = new DepManDeepVersionMemoryRepository();
44          graphBuilder.setMemoryRepository( repository );
45  
46          // Create the factory, and add the test resolver.
47          DependencyGraphFactory factory = new DependencyGraphFactory();
48          factory.setGraphBuilder( graphBuilder );
49          factory.setDesiredScope( DependencyScope.TEST );
50  
51          // Get the model to resolve from
52          VersionedReference rootRef = toVersionedReference( "net.example.depman.deepversion:A:1.0" );
53  
54          // Perform the resolution.
55          DependencyGraph graph = factory.getGraph( rootRef );
56  
57          // Test the results.
58          assertNotNull( "Graph shouldn't be null.", graph );
59  
60          String expectedRootRef = "net.example.depman.deepversion:A:1.0";
61          List<String> expectedNodes = new ArrayList<String>();
62  
63          // Check for all nodes, regardless of scope.
64          expectedNodes.clear();
65          expectedNodes.add( "net.example.depman.deepversion:B:1.0::jar" );
66          expectedNodes.add( "net.example.depman.deepversion:C:1.0::jar" );
67          expectedNodes.add( "net.example.depman.deepversion:D:2.0::jar" );
68          expectedNodes.add( "net.example.depman.deepversion:E:3.0::jar" );
69          expectedNodes.add( "net.example.depman.deepversion:F:1.0::jar" );
70  
71          assertGraph( graph, expectedRootRef, expectedNodes );
72      }
73  
74  }