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.artifact.Artifact;
20 import org.apache.maven.artifact.DefaultArtifact;
21 import org.apache.maven.artifact.handler.ArtifactHandler;
22 import org.apache.maven.artifact.handler.DefaultArtifactHandler;
23 import org.apache.maven.artifact.versioning.VersionRange;
26 * This class tests the InvalidPomArtifactReportProcessor class.
28 public class InvalidPomArtifactReportProcessorTest
29 extends AbstractRepositoryReportsTestCase
31 private ArtifactReportProcessor artifactReportProcessor;
33 private ArtifactReporter reporter = new DefaultArtifactReporter();
39 artifactReportProcessor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "invalid-pom" );
43 * Test the InvalidPomArtifactReportProcessor when the artifact is an invalid pom.
45 public void testInvalidPomArtifactReportProcessorFailure()
46 throws ReportProcessorException
48 ArtifactHandler handler = new DefaultArtifactHandler( "pom" );
49 VersionRange version = VersionRange.createFromVersion( "1.0-alpha-3" );
51 new DefaultArtifact( "org.apache.maven", "artifactId", version, "compile", "pom", "", handler );
53 artifactReportProcessor.processArtifact( null, artifact, reporter, repository );
54 assertEquals( 1, reporter.getNumFailures() );
59 * Test the InvalidPomArtifactReportProcessor when the artifact is a valid pom.
61 public void testInvalidPomArtifactReportProcessorSuccess()
62 throws ReportProcessorException
64 ArtifactHandler handler = new DefaultArtifactHandler( "pom" );
65 VersionRange version = VersionRange.createFromVersion( "1.0-alpha-2" );
66 Artifact artifact = new DefaultArtifact( "groupId", "artifactId", version, "compile", "pom", "", handler );
68 artifactReportProcessor.processArtifact( null, artifact, reporter, repository );
69 assertEquals( 1, reporter.getNumSuccesses() );
74 * Test the InvalidPomArtifactReportProcessor when the artifact is not a pom.
76 public void testNotAPomArtifactReportProcessorSuccess()
77 throws ReportProcessorException
79 ArtifactHandler handler = new DefaultArtifactHandler( "jar" );
80 VersionRange version = VersionRange.createFromVersion( "1.0-alpha-1" );
81 Artifact artifact = new DefaultArtifact( "groupId", "artifactId", version, "compile", "jar", "", handler );
83 artifactReportProcessor.processArtifact( null, artifact, reporter, repository );
84 assertEquals( 1, reporter.getNumWarnings() );