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   * ArchivaCommonDependencyGraphTest
31   * 
32   * DependencyGraphTest for testing <code>org.apache.maven.archiva:archiva-common:1.0-alpha-2-SNAPSHOT</code>
33   *
34   * Generated by <code>archivadev:generate-dependency-tests</code> plugin
35   * @version $Id: ArchivaCommonDependencyGraphTest.java 755277 2009-03-17 15:18:35Z brett $
36   */
37  public class ArchivaCommonDependencyGraphTest
38     extends AbstractDependencyGraphFactoryTestCase
39  {
40     public void testResolvedDepsToNodes()
41          throws GraphTaskException
42     {
43        MemoryRepositoryDependencyGraphBuilder graphBuilder = 
44                       new MemoryRepositoryDependencyGraphBuilder();
45        MemoryRepository repository = new ArchivaCommonMemoryRepository();
46        graphBuilder.setMemoryRepository( repository );
47  
48        // Create the factory, and add the test resolver.
49        DependencyGraphFactory factory = new DependencyGraphFactory();
50        factory.setGraphBuilder( graphBuilder );
51        factory.setDesiredScope( DependencyScope.TEST );
52  
53        // Get the model to resolve from
54        VersionedReference rootRef = toVersionedReference( "org.apache.maven.archiva:archiva-common:1.0-alpha-2-SNAPSHOT"); 
55  
56        // Perform the resolution.
57        DependencyGraph graph = factory.getGraph( rootRef );
58  
59        // Test the results.
60        assertNotNull( "Graph shouldn't be null.", graph );
61  
62        String expectedRootRef = "org.apache.maven.archiva:archiva-common:1.0-alpha-2-SNAPSHOT";
63        List<String> expectedNodes = new ArrayList<String>();
64  
65        // Check for all nodes, regardless of scope.
66        expectedNodes.clear();
67        expectedNodes.add( "commons-lang:commons-lang:2.2::jar" );
68        expectedNodes.add( "junit:junit:3.8.1::jar" );
69        expectedNodes.add( "org.codehaus.plexus:plexus-classworlds:1.2-alpha-7::jar" );
70        expectedNodes.add( "org.codehaus.plexus:plexus-component-api:1.0-alpha-22::jar" );
71        expectedNodes.add( "org.codehaus.plexus:plexus-container-default:1.0-alpha-22::jar" );
72        expectedNodes.add( "org.codehaus.plexus:plexus-utils:1.4::jar" );
73  
74        assertGraph( graph, expectedRootRef, expectedNodes );
75     }
76  
77  }