]> source.dussan.org Git - archiva.git/blob
049ae48d54576fb692da74e4cff9ae8e1718824c
[archiva.git] /
1 package org.apache.maven.archiva.reporting.processor;
2
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements.  See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership.  The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License.  You may obtain a copy of the License at
11  *
12  *   http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied.  See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  */
21
22 import org.apache.maven.archiva.reporting.AbstractRepositoryReportsTestCase;
23 import org.apache.maven.archiva.reporting.database.ReportingDatabase;
24 import org.apache.maven.archiva.reporting.group.ReportGroup;
25 import org.apache.maven.artifact.Artifact;
26
27 /**
28  * This class tests the InvalidPomArtifactReportProcessor class.
29  */
30 public class InvalidPomArtifactReportProcessorTest
31     extends AbstractRepositoryReportsTestCase
32 {
33     private ArtifactReportProcessor artifactReportProcessor;
34
35     private ReportingDatabase reportDatabase;
36
37     public void setUp()
38         throws Exception
39     {
40         super.setUp();
41         artifactReportProcessor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "invalid-pom" );
42
43         ReportGroup reportGroup = (ReportGroup) lookup( ReportGroup.ROLE, "health" );
44         reportDatabase = new ReportingDatabase( reportGroup );
45     }
46
47     /**
48      * Test the InvalidPomArtifactReportProcessor when the artifact is an invalid pom.
49      */
50     public void testInvalidPomArtifactReportProcessorFailure()
51     {
52         Artifact artifact = createArtifact( "org.apache.maven", "artifactId", "1.0-alpha-3", "pom" );
53
54         artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
55         assertEquals( 1, reportDatabase.getNumFailures() );
56     }
57
58
59     /**
60      * Test the InvalidPomArtifactReportProcessor when the artifact is a valid pom.
61      */
62     public void testInvalidPomArtifactReportProcessorSuccess()
63     {
64         Artifact artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-2", "pom" );
65
66         artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
67         assertEquals( 0, reportDatabase.getNumFailures() );
68         assertEquals( 0, reportDatabase.getNumWarnings() );
69         assertEquals( "Check no notices", 0, reportDatabase.getNumNotices() );
70     }
71
72
73     /**
74      * Test the InvalidPomArtifactReportProcessor when the artifact is not a pom.
75      */
76     public void testNotAPomArtifactReportProcessorSuccess()
77     {
78         Artifact artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "jar" );
79
80         artifactReportProcessor.processArtifact( artifact, null, reportDatabase );
81         assertEquals( 0, reportDatabase.getNumFailures() );
82         assertEquals( 0, reportDatabase.getNumWarnings() );
83         assertEquals( "Check no notices", 0, reportDatabase.getNumNotices() );
84     }
85 }