summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-checksum/src
diff options
context:
space:
mode:
authorMaria Odea B. Ching <oching@apache.org>2008-05-29 09:48:50 +0000
committerMaria Odea B. Ching <oching@apache.org>2008-05-29 09:48:50 +0000
commit06b0d06fde442119b9928f6b54c3ef86373074c2 (patch)
tree731fe03516982b93819c51736af51c86fd9fc613 /archiva-modules/archiva-base/archiva-checksum/src
parent130711f5b21e068d9a6152693ee338a4b1b25cee (diff)
downloadarchiva-06b0d06fde442119b9928f6b54c3ef86373074c2.tar.gz
archiva-06b0d06fde442119b9928f6b54c3ef86373074c2.zip
[MRM-790]
-added check specifically for remote metadata checksum files -added test case git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@661273 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-checksum/src')
-rw-r--r--archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksummedFile.java9
-rw-r--r--archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksummedFileTest.java45
-rw-r--r--archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/metadata/maven-metadata-remote.xml0
-rw-r--r--archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/metadata/maven-metadata-remote.xml.md51
-rw-r--r--archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/metadata/maven-metadata-remote.xml.sha11
5 files changed, 55 insertions, 1 deletions
diff --git a/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksummedFile.java b/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksummedFile.java
index d93ec53a3..6b5657121 100644
--- a/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksummedFile.java
+++ b/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksummedFile.java
@@ -292,6 +292,15 @@ public class ChecksummedFile
private boolean isValidChecksumPattern( String filename, String path )
{
+ // check if it is a remote metadata file
+ Pattern pattern = Pattern.compile( "maven-metadata-\\S*.xml" );
+ Matcher m = pattern.matcher( path );
+ if( m.matches() )
+ {
+ return filename.endsWith( path ) || ( "-".equals( filename ) )
+ || filename.endsWith( "maven-metadata.xml" );
+ }
+
return filename.endsWith( path ) || ( "-".equals( filename ) );
}
diff --git a/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksummedFileTest.java b/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksummedFileTest.java
index 733ffb7d3..16377079b 100644
--- a/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksummedFileTest.java
+++ b/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksummedFileTest.java
@@ -36,9 +36,13 @@ public class ChecksummedFileTest
{
/** SHA1 checksum from www.ibiblio.org/maven2, incuding file path */
private static final String SERVLETAPI_SHA1 = "bcc82975c0f9c681fcb01cc38504c992553e93ba";
+
+ private static final String REMOTE_METADATA_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
+
+ private static final String REMOTE_METADATA_MD5 = "d41d8cd98f00b204e9800998ecf8427e";
private File createTestableJar( String filename )
- throws IOException
+ throws IOException
{
File srcFile = getTestResource( filename );
File destFile = new File( getTestOutputDir(), srcFile.getName() );
@@ -223,4 +227,43 @@ public class ChecksummedFileTest
assertEquals( "Checksum doesn't match", SERVLETAPI_SHA1, s );
}
+ public void testRemoteMetadataChecksumFilePathSha1()
+ throws IOException
+ {
+ String expected = REMOTE_METADATA_SHA1 + " /home/test/repository/examples/metadata/maven-metadata.xml";
+ File testfile = getTestResource( "examples/metadata/maven-metadata-remote.xml" );
+ ChecksummedFile checksummedFile = new ChecksummedFile( testfile );
+
+ try
+ {
+ String s = checksummedFile.parseChecksum( expected, ChecksumAlgorithm.SHA1,
+ "maven-metadata-remote.xml" );
+ assertEquals( "Checksum doesn't match", REMOTE_METADATA_SHA1, s );
+ }
+ catch ( IOException e )
+ {
+ e.printStackTrace();
+ fail( "IOException should not occur." );
+ }
+ }
+
+ public void testRemoteMetadataChecksumFilePathMd5()
+ throws IOException
+ {
+ String expected = REMOTE_METADATA_MD5 + " ./examples/metadata/maven-metadata.xml";
+ File testfile = getTestResource( "examples/metadata/maven-metadata-remote.xml" );
+ ChecksummedFile checksummedFile = new ChecksummedFile( testfile );
+
+ try
+ {
+ String s = checksummedFile.parseChecksum( expected, ChecksumAlgorithm.MD5,
+ "maven-metadata-remote.xml" );
+ assertEquals( "Checksum doesn't match", REMOTE_METADATA_MD5, s );
+ }
+ catch ( IOException e )
+ {
+ e.printStackTrace();
+ fail( "IOException should not occur." );
+ }
+ }
}
diff --git a/archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/metadata/maven-metadata-remote.xml b/archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/metadata/maven-metadata-remote.xml
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/metadata/maven-metadata-remote.xml
diff --git a/archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/metadata/maven-metadata-remote.xml.md5 b/archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/metadata/maven-metadata-remote.xml.md5
new file mode 100644
index 000000000..8f9a626ff
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/metadata/maven-metadata-remote.xml.md5
@@ -0,0 +1 @@
+d41d8cd98f00b204e9800998ecf8427e ./examples/metadata/maven-metadata.xml \ No newline at end of file
diff --git a/archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/metadata/maven-metadata-remote.xml.sha1 b/archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/metadata/maven-metadata-remote.xml.sha1
new file mode 100644
index 000000000..e87d16529
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-checksum/src/test/resources/examples/metadata/maven-metadata-remote.xml.sha1
@@ -0,0 +1 @@
+da39a3ee5e6b4b0d3255bfef95601890afd80709 /home/test/repository/examples/metadata/maven-metadata.xml \ No newline at end of file