1 package org.apache.archiva.consumers.dependencytree;
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
23 import java.io.IOException;
25 import org.apache.commons.io.FileUtils;
26 import org.apache.commons.io.IOUtils;
27 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
28 import org.apache.maven.archiva.consumers.ConsumerException;
29 import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
30 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
32 public class DependencyTreeGeneratorConsumerTest
33 extends PlexusInSpringTestCase
35 private DependencyTreeGeneratorConsumer consumer;
37 private ManagedRepositoryConfiguration repository;
39 private File repositoryLocation;
41 private File generatedRepositoryLocation;
49 (DependencyTreeGeneratorConsumer) lookup( KnownRepositoryContentConsumer.class, "dependency-tree-generator" );
51 repositoryLocation = getTestFile( "target/test-" + getName() + "/test-repo" );
52 FileUtils.deleteDirectory( repositoryLocation );
53 FileUtils.copyDirectory( getTestFile( "target/test-classes/test-repo" ), repositoryLocation );
55 generatedRepositoryLocation = getTestFile( "target/test-" + getName() + "/generated-test-repo" );
56 FileUtils.deleteDirectory( generatedRepositoryLocation );
58 consumer.setGeneratedRepositoryLocation( generatedRepositoryLocation );
60 repository = new ManagedRepositoryConfiguration();
61 repository.setId( "dependency-tree" );
62 repository.setLocation( repositoryLocation.getAbsolutePath() );
65 public void testGenerateBasicTree()
66 throws IOException, ConsumerException
68 consumer.beginScan( repository );
70 String path = "org/apache/maven/maven-core/2.0/maven-core-2.0.pom";
71 consumer.processFile( path );
73 File generatedFile = new File( generatedRepositoryLocation, path + ".xml" );
74 assertEquals( IOUtils.toString( getClass().getResourceAsStream( "/test-data/maven-core-2.0-tree.xml" ) ),
75 FileUtils.readFileToString( generatedFile ) );
77 consumer.completeScan();