1 package org.apache.maven.archiva.reporting.processor;
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.archiva.reporting.group.ReportGroup;
22 import org.apache.maven.archiva.reporting.processor.ArtifactReportProcessor;
23 import org.apache.maven.archiva.reporting.AbstractRepositoryReportsTestCase;
24 import org.apache.maven.archiva.reporting.database.ReportingDatabase;
25 import org.apache.maven.artifact.Artifact;
26 import org.codehaus.plexus.util.FileUtils;
29 import java.util.Iterator;
32 * This class tests the OldArtifactReportProcessor.
34 public class OldArtifactReportProcessorTest
35 extends AbstractRepositoryReportsTestCase
37 private ArtifactReportProcessor artifactReportProcessor;
39 private ReportingDatabase reportDatabase;
45 artifactReportProcessor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "old-artifact" );
47 ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "old-artifact" );
48 reportDatabase = new ReportingDatabase( reportGroup );
51 public void testOldArtifact()
53 Artifact artifact = createArtifact( "org.apache.maven", "maven-model", "2.0" );
55 artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
56 assertEquals( 0, reportDatabase.getNumFailures() );
57 assertEquals( 0, reportDatabase.getNumWarnings() );
58 assertEquals( "Check notices", 1, reportDatabase.getNumNotices() );
59 ArtifactResults results = (ArtifactResults) reportDatabase.getArtifactIterator().next();
60 assertEquals( artifact.getArtifactId(), results.getArtifactId() );
61 assertEquals( artifact.getGroupId(), results.getGroupId() );
62 assertEquals( artifact.getVersion(), results.getVersion() );
63 assertEquals( 1, results.getNotices().size() );
64 Iterator i = results.getNotices().iterator();
65 Result result = (Result) i.next();
66 assertEquals( "old-artifact", result.getProcessor() );
69 public void testNewArtifact()
72 File repository = getTestFile( "target/test-repository" );
74 FileUtils.copyDirectoryStructure( getTestFile( "src/test/repository/groupId" ),
75 new File( repository, "groupId" ) );
77 Artifact artifact = createArtifactFromRepository( repository, "groupId", "artifactId", "1.0-alpha-1" );
79 artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
80 assertEquals( 0, reportDatabase.getNumFailures() );
81 assertEquals( 0, reportDatabase.getNumWarnings() );
82 assertEquals( "Check no notices", 0, reportDatabase.getNumNotices() );
85 public void testMissingArtifact()
88 Artifact artifact = createArtifact( "foo", "bar", "XP" );
92 artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
93 fail( "Should not have passed" );
95 catch ( IllegalStateException e )