1 package org.apache.maven.archiva.dependency.graph;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import org.apache.maven.archiva.dependency.DependencyGraphFactory;
23 import org.apache.maven.archiva.model.DependencyScope;
24 import org.apache.maven.archiva.model.VersionedReference;
26 import java.util.ArrayList;
27 import java.util.List;
30 * SimpleDependencyGraphTest
34 public class SimpleDependencyGraphTest
35 extends AbstractDependencyGraphFactoryTestCase
37 public void testResolveDependenciesBasic() throws GraphTaskException
39 MemoryRepositoryDependencyGraphBuilder graphBuilder = new MemoryRepositoryDependencyGraphBuilder();
40 MemoryRepository repository = new SimpleMemoryRepository();
41 graphBuilder.setMemoryRepository( repository );
43 // Create the factory, and add the test resolver.
44 DependencyGraphFactory factory = new DependencyGraphFactory();
45 factory.setGraphBuilder( graphBuilder );
46 factory.setDesiredScope( DependencyScope.TEST );
48 // Get the model to resolve from
49 VersionedReference rootRef = toVersionedReference( "org.apache.maven.archiva:archiva-commons:1.0" );
51 // Perform the resolution.
52 DependencyGraph graph = factory.getGraph( rootRef );
55 assertNotNull( "Graph shouldn't be null.", graph );
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 );
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" ) );
68 assertEdges( graph, expectedEdges );