]> source.dussan.org Git - archiva.git/blob
b11c78c40e872987f323e8c11624fcd77b576cea
[archiva.git] /
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  * SimpleDependencyGraphTest 
31  *
32  * @version $Id$
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 expectedNodes = new ArrayList();
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 expectedEdges = new ArrayList();
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 }