]> source.dussan.org Git - archiva.git/blob
afea3474a8844d9e4a634638cf1016ba6fed1ef6
[archiva.git] /
1 package org.apache.maven.archiva.reporting;
2
3 /*
4  * Copyright 2005-2006 The Apache Software Foundation.
5  *
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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  */
18
19 import org.apache.maven.artifact.Artifact;
20
21 /**
22  * This class tests the InvalidPomArtifactReportProcessor class.
23  */
24 public class InvalidPomArtifactReportProcessorTest
25     extends AbstractRepositoryReportsTestCase
26 {
27     private ArtifactReportProcessor artifactReportProcessor;
28
29     private ReportingDatabase reportDatabase;
30
31     public void setUp()
32         throws Exception
33     {
34         super.setUp();
35         artifactReportProcessor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "invalid-pom" );
36
37         ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
38         reportDatabase = new ReportingDatabase( reportGroup );
39     }
40
41     /**
42      * Test the InvalidPomArtifactReportProcessor when the artifact is an invalid pom.
43      */
44     public void testInvalidPomArtifactReportProcessorFailure()
45     {
46         Artifact artifact = createArtifact( "org.apache.maven", "artifactId", "1.0-alpha-3", "pom" );
47
48         artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
49         assertEquals( 1, reportDatabase.getNumFailures() );
50     }
51
52
53     /**
54      * Test the InvalidPomArtifactReportProcessor when the artifact is a valid pom.
55      */
56     public void testInvalidPomArtifactReportProcessorSuccess()
57     {
58         Artifact artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-2", "pom" );
59
60         artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
61         assertEquals( 0, reportDatabase.getNumFailures() );
62         assertEquals( 0, reportDatabase.getNumWarnings() );
63         assertEquals( "Check no notices", 0, reportDatabase.getNumNotices() );
64     }
65
66
67     /**
68      * Test the InvalidPomArtifactReportProcessor when the artifact is not a pom.
69      */
70     public void testNotAPomArtifactReportProcessorSuccess()
71     {
72         Artifact artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "jar" );
73
74         artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
75         assertEquals( 0, reportDatabase.getNumFailures() );
76         assertEquals( 0, reportDatabase.getNumWarnings() );
77         assertEquals( "Check no notices", 0, reportDatabase.getNumNotices() );
78     }
79 }