summaryrefslogtreecommitdiffstats
path: root/archiva-reports-standard/src
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2006-09-09 07:05:03 +0000
committerBrett Porter <brett@apache.org>2006-09-09 07:05:03 +0000
commit9c557abae7052e10688f415600a723d19267e063 (patch)
treeb9248d3220091be83f76a0b26771fe71b2ca6d6f /archiva-reports-standard/src
parent47e2bcd3684600c678b04c31c828d41d80352581 (diff)
downloadarchiva-9c557abae7052e10688f415600a723d19267e063.tar.gz
archiva-9c557abae7052e10688f415600a723d19267e063.zip
[MRM-77] hadle some edge cases in reports
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@441751 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-reports-standard/src')
-rw-r--r--archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java22
-rw-r--r--archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessor.java19
-rw-r--r--archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessorTest.java20
-rw-r--r--archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessorTest.java31
4 files changed, 81 insertions, 11 deletions
diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java
index 354b67b76..e1e7b8d91 100644
--- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java
+++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessor.java
@@ -197,17 +197,21 @@ public class BadMetadataReportProcessor
RepositoryQueryLayer repositoryQueryLayer =
repositoryQueryLayerFactory.createRepositoryQueryLayer( repository );
- Snapshot snapshot = metadata.getMetadata().getVersioning().getSnapshot();
+ Versioning versioning = metadata.getMetadata().getVersioning();
+ if ( versioning != null )
+ {
+ Snapshot snapshot = versioning.getSnapshot();
- String version = StringUtils.replace( metadata.getBaseVersion(), Artifact.SNAPSHOT_VERSION,
- snapshot.getTimestamp() + "-" + snapshot.getBuildNumber() );
- Artifact artifact =
- artifactFactory.createProjectArtifact( metadata.getGroupId(), metadata.getArtifactId(), version );
- artifact.isSnapshot(); // trigger baseVersion correction
+ String version = StringUtils.replace( metadata.getBaseVersion(), Artifact.SNAPSHOT_VERSION,
+ snapshot.getTimestamp() + "-" + snapshot.getBuildNumber() );
+ Artifact artifact =
+ artifactFactory.createProjectArtifact( metadata.getGroupId(), metadata.getArtifactId(), version );
+ artifact.isSnapshot(); // trigger baseVersion correction
- if ( !repositoryQueryLayer.containsArtifact( artifact ) )
- {
- reporter.addFailure( metadata, "Snapshot artifact " + version + " does not exist." );
+ if ( !repositoryQueryLayer.containsArtifact( artifact ) )
+ {
+ reporter.addFailure( metadata, "Snapshot artifact " + version + " does not exist." );
+ }
}
}
diff --git a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessor.java b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessor.java
index 0226b9131..f9960bfc2 100644
--- a/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessor.java
+++ b/archiva-reports-standard/src/main/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessor.java
@@ -82,6 +82,15 @@ public class DependencyArtifactReportProcessor
{
Artifact artifact = createArtifact( dependency );
+ // TODO: handle ranges properly. We should instead be mapping out all the artifacts in the
+ // repository and mapping out the graph
+
+ if ( artifact.getVersion() == null )
+ {
+ // it was a range, for now presume it exists
+ continue;
+ }
+
if ( !repositoryQueryLayer.containsArtifact( artifact ) )
{
String reason = MessageFormat.format(
@@ -118,8 +127,14 @@ public class DependencyArtifactReportProcessor
private Artifact createArtifact( Dependency dependency )
throws InvalidVersionSpecificationException
{
- return artifactFactory.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(),
- VersionRange.createFromVersionSpec( dependency.getVersion() ),
+ VersionRange spec = VersionRange.createFromVersionSpec( dependency.getVersion() );
+
+ if ( spec == null )
+ {
+ throw new InvalidVersionSpecificationException( "Dependency version was null" );
+ }
+
+ return artifactFactory.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), spec,
dependency.getType(), dependency.getClassifier(),
dependency.getScope() );
}
diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessorTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessorTest.java
index 4acec2982..67e36fd7b 100644
--- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessorTest.java
+++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/BadMetadataReportProcessorTest.java
@@ -99,6 +99,26 @@ public class BadMetadataReportProcessorTest
assertFalse( "check no more failures", failures.hasNext() );
}
+ public void testSnapshotMetadataMissingVersioning()
+ {
+ Artifact artifact =
+ artifactFactory.createBuildArtifact( "groupId", "snapshot-artifact", "1.0-alpha-1-SNAPSHOT", "type" );
+
+ RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact );
+
+ badMetadataReportProcessor.processMetadata( metadata, repository, reporter );
+
+ Iterator failures = reporter.getMetadataIterator();
+ assertTrue( "check there is a failure", failures.hasNext() );
+ MetadataResults results = (MetadataResults) failures.next();
+ failures = results.getFailures().iterator();
+ assertTrue( "check there is a failure", failures.hasNext() );
+ assertMetadata( metadata, results );
+ Result result = (Result) failures.next();
+ assertEquals( "check reason", "Missing lastUpdated element inside the metadata.", result.getReason() );
+ assertFalse( "check no more failures", failures.hasNext() );
+ }
+
public void testMetadataValidVersions()
{
Artifact artifact = artifactFactory.createBuildArtifact( "groupId", "artifactId", "1.0-alpha-1", "type" );
diff --git a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessorTest.java b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessorTest.java
index ae7edc2d1..3894e614f 100644
--- a/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessorTest.java
+++ b/archiva-reports-standard/src/test/java/org/apache/maven/archiva/reporting/DependencyArtifactReportProcessorTest.java
@@ -241,6 +241,37 @@ public class DependencyArtifactReportProcessorTest
assertEquals( getDependencyVersionInvalidMessage( dependency, "[" ), result.getReason() );
}
+ public void testValidArtifactWithInvalidDependencyVersionRange()
+ {
+ Artifact artifact = createValidArtifact();
+
+ Dependency dependency = createDependency( VALID_GROUP_ID, VALID_ARTIFACT_ID, "[1.0,)" );
+ model.addDependency( dependency );
+
+ processor.processArtifact( artifact, model, reporter );
+ assertEquals( 0, reporter.getNumFailures() );
+ assertEquals( 0, reporter.getNumWarnings() );
+ }
+
+ public void testValidArtifactWithMissingDependencyVersion()
+ {
+ Artifact artifact = createValidArtifact();
+
+ Dependency dependency = createDependency( VALID_GROUP_ID, VALID_ARTIFACT_ID, null );
+ model.addDependency( dependency );
+
+ processor.processArtifact( artifact, model, reporter );
+ assertEquals( 1, reporter.getNumFailures() );
+ assertEquals( 0, reporter.getNumWarnings() );
+
+ Iterator failures = reporter.getArtifactIterator();
+ ArtifactResults results = (ArtifactResults) failures.next();
+ assertFalse( failures.hasNext() );
+ failures = results.getFailures().iterator();
+ Result result = (Result) failures.next();
+ assertEquals( getDependencyVersionInvalidMessage( dependency, null ), result.getReason() );
+ }
+
private String getDependencyVersionInvalidMessage( Dependency dependency, String version )
{
return "Artifact's dependency " + getDependencyString( dependency ) + " contains an invalid version " + version;