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