1 package org.apache.maven.archiva.reporting;
4 * Copyright 2005-2006 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import org.apache.maven.archiva.reporting.model.ArtifactResults;
20 import org.apache.maven.archiva.reporting.model.Result;
21 import org.apache.maven.artifact.Artifact;
22 import org.codehaus.plexus.util.FileUtils;
25 import java.util.Iterator;
28 * This class tests the OldArtifactReportProcessor.
30 public class OldArtifactReportProcessorTest
31 extends AbstractRepositoryReportsTestCase
33 private ArtifactReportProcessor artifactReportProcessor;
35 private ReportingDatabase reportDatabase;
41 artifactReportProcessor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "old-artifact" );
43 ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "old-artifact" );
44 reportDatabase = new ReportingDatabase( reportGroup );
47 public void testOldArtifact()
49 Artifact artifact = createArtifact( "org.apache.maven", "maven-model", "2.0" );
51 artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
52 assertEquals( 0, reportDatabase.getNumFailures() );
53 assertEquals( 0, reportDatabase.getNumWarnings() );
54 assertEquals( "Check notices", 1, reportDatabase.getNumNotices() );
55 ArtifactResults results = (ArtifactResults) reportDatabase.getArtifactIterator().next();
56 assertEquals( artifact.getArtifactId(), results.getArtifactId() );
57 assertEquals( artifact.getGroupId(), results.getGroupId() );
58 assertEquals( artifact.getVersion(), results.getVersion() );
59 assertEquals( 1, results.getNotices().size() );
60 Iterator i = results.getNotices().iterator();
61 Result result = (Result) i.next();
62 assertEquals( "old-artifact", result.getProcessor() );
65 public void testNewArtifact()
68 File repository = getTestFile( "target/test-repository" );
70 FileUtils.copyDirectoryStructure( getTestFile( "src/test/repository/groupId" ),
71 new File( repository, "groupId" ) );
73 Artifact artifact = createArtifactFromRepository( repository, "groupId", "artifactId", "1.0-alpha-1" );
75 artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
76 assertEquals( 0, reportDatabase.getNumFailures() );
77 assertEquals( 0, reportDatabase.getNumWarnings() );
78 assertEquals( "Check no notices", 0, reportDatabase.getNumNotices() );
81 public void testMissingArtifact()
84 Artifact artifact = createArtifact( "foo", "bar", "XP" );
88 artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
89 fail( "Should not have passed" );
91 catch ( IllegalStateException e )