aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-checksum/src
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-07-02 07:36:23 +0000
committerOlivier Lamy <olamy@apache.org>2012-07-02 07:36:23 +0000
commit1484a3316addf47d88f4f05191ae4e570871eda7 (patch)
tree596b70b3f0975c00274bc3d2b2580092cc1390f5 /archiva-modules/archiva-base/archiva-checksum/src
parente3885c59da2e4748e2ba494f3901902be0470067 (diff)
downloadarchiva-1484a3316addf47d88f4f05191ae4e570871eda7.tar.gz
archiva-1484a3316addf47d88f4f05191ae4e570871eda7.zip
[MRM-1638] Improve unit test for archiva build
Based on patch provided by Eric Barboni. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1356091 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/test/java/org/apache/archiva/checksum/AbstractChecksumTestCase.java7
-rw-r--r--archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumAlgorithmTest.java9
-rw-r--r--archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumTest.java6
-rw-r--r--archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksummedFileTest.java17
4 files changed, 36 insertions, 3 deletions
diff --git a/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/AbstractChecksumTestCase.java b/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/AbstractChecksumTestCase.java
index 812cc708b..5455fcb9f 100644
--- a/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/AbstractChecksumTestCase.java
+++ b/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/AbstractChecksumTestCase.java
@@ -19,16 +19,19 @@ package org.apache.archiva.checksum;
* under the License.
*/
-import java.io.File;
-
import junit.framework.TestCase;
import org.apache.archiva.common.utils.FileUtil;
+import org.apache.archiva.test.ArchivaBlockJUnit4ClassRunner;
+import org.junit.runner.RunWith;
+
+import java.io.File;
/**
* AbstractChecksumTestCase
*
* @version $Id$
*/
+@RunWith( ArchivaBlockJUnit4ClassRunner.class )
public abstract class AbstractChecksumTestCase
extends TestCase
{
diff --git a/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumAlgorithmTest.java b/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumAlgorithmTest.java
index 7f37469b1..dabff4d62 100644
--- a/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumAlgorithmTest.java
+++ b/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumAlgorithmTest.java
@@ -22,27 +22,34 @@ package org.apache.archiva.checksum;
import java.io.File;
import junit.framework.TestCase;
+import org.apache.archiva.test.ArchivaBlockJUnit4ClassRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
/**
* ChecksumAlgorithmTest
*
* @version $Id$
*/
+@RunWith( ArchivaBlockJUnit4ClassRunner.class )
public class ChecksumAlgorithmTest
extends TestCase
{
+ @Test
public void testGetHashByExtensionSha1()
{
assertEquals( ChecksumAlgorithm.SHA1, ChecksumAlgorithm.getByExtension( new File( "something.jar.sha1" ) ) );
assertEquals( ChecksumAlgorithm.SHA1, ChecksumAlgorithm.getByExtension( new File( "OTHER.JAR.SHA1" ) ) );
}
-
+
+ @Test
public void testGetHashByExtensionMd5()
{
assertEquals( ChecksumAlgorithm.MD5, ChecksumAlgorithm.getByExtension( new File( "something.jar.md5" ) ) );
assertEquals( ChecksumAlgorithm.MD5, ChecksumAlgorithm.getByExtension( new File( "OTHER.JAR.MD5" ) ) );
}
+ @Test
public void testGetHashByExtensionInvalid()
{
try
diff --git a/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumTest.java b/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumTest.java
index 4cfcc8dd2..40f95a56b 100644
--- a/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumTest.java
+++ b/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumTest.java
@@ -23,6 +23,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import org.junit.Test;
/**
* ChecksumTest
@@ -34,6 +35,7 @@ public class ChecksumTest
{
private static final String UNSET_SHA1 = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
+ @Test
public void testConstructSha1()
{
Checksum checksum = new Checksum( ChecksumAlgorithm.SHA1 );
@@ -41,6 +43,7 @@ public class ChecksumTest
.getAlgorithm() );
}
+ @Test
public void testConstructMd5()
{
Checksum checksum = new Checksum( ChecksumAlgorithm.MD5 );
@@ -48,6 +51,7 @@ public class ChecksumTest
.getAlgorithm() );
}
+ @Test
public void testUpdate()
{
Checksum checksum = new Checksum( ChecksumAlgorithm.SHA1 );
@@ -57,6 +61,7 @@ public class ChecksumTest
assertEquals( "Checksum", "e396119ae0542e85a74759602fd2f81e5d36d762", checksum.getChecksum() );
}
+ @Test
public void testUpdateMany()
throws IOException
{
@@ -76,6 +81,7 @@ public class ChecksumTest
assertEquals( "Checksum MD5", "21c2c5ca87ec018adacb2e2fb3432219", checksumMd5.getChecksum() );
}
+ @Test
public void testUpdateWholeUpdatePartial()
{
Checksum checksum = new Checksum( ChecksumAlgorithm.SHA1 );
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 5ca089087..e4122d93a 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
@@ -24,12 +24,14 @@ import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
+import org.junit.Test;
/**
* ChecksummedFileTest
*
* @version $Id$
*/
+
public class ChecksummedFileTest
extends AbstractChecksumTestCase
{
@@ -75,6 +77,7 @@ public class ChecksummedFileTest
return jarFile;
}
+ @Test
public void testCalculateChecksumMd5()
throws IOException
{
@@ -85,6 +88,7 @@ public class ChecksummedFileTest
assertEquals( expectedChecksum, actualChecksum );
}
+ @Test
public void testCalculateChecksumSha1()
throws IOException
{
@@ -95,6 +99,7 @@ public class ChecksummedFileTest
assertEquals( expectedChecksum, actualChecksum );
}
+ @Test
public void testCreateChecksum()
throws IOException
{
@@ -108,6 +113,7 @@ public class ChecksummedFileTest
assertEquals( "2bb14b388973351b0a4dfe11d171965f59cc61a1 redback-authz-open.jar", hashContents );
}
+ @Test
public void testFixChecksum()
throws IOException
{
@@ -126,12 +132,14 @@ public class ChecksummedFileTest
assertTrue( "ChecksummedFile.isValid(SHA1) == true", checksummedFile.isValidChecksum( ChecksumAlgorithm.SHA1 ) );
}
+ @Test
public void testGetChecksumFile()
{
ChecksummedFile checksummedFile = new ChecksummedFile( new File( "test.jar" ) );
assertEquals( "test.jar.sha1", checksummedFile.getChecksumFile( ChecksumAlgorithm.SHA1 ).getName() );
}
+ @Test
public void testIsValidChecksum()
throws IOException
{
@@ -141,6 +149,7 @@ public class ChecksummedFileTest
assertTrue( "ChecksummedFile.isValid(SHA1)", checksummedFile.isValidChecksum( ChecksumAlgorithm.SHA1 ) );
}
+ @Test
public void testIsValidChecksumInvalidSha1Format()
throws IOException
{
@@ -155,6 +164,7 @@ public class ChecksummedFileTest
}
+ @Test
public void testIsValidChecksumNoChecksumFiles()
throws IOException
{
@@ -167,6 +177,7 @@ public class ChecksummedFileTest
}
+ @Test
public void testIsValidChecksumSha1AndMd5()
throws IOException
{
@@ -178,6 +189,7 @@ public class ChecksummedFileTest
ChecksumAlgorithm.MD5 } ) );
}
+ @Test
public void testIsValidChecksumSha1NoMd5()
throws IOException
{
@@ -190,6 +202,7 @@ public class ChecksummedFileTest
}
+ @Test
public void testParseChecksum()
throws IOException
{
@@ -204,6 +217,7 @@ public class ChecksummedFileTest
}
+ @Test
public void testParseChecksumAltDash1()
throws IOException
{
@@ -215,6 +229,7 @@ public class ChecksummedFileTest
assertEquals( "Checksum doesn't match", SERVLETAPI_SHA1, s );
}
+ @Test
public void testParseChecksumAltDash2()
throws IOException
{
@@ -226,6 +241,7 @@ public class ChecksummedFileTest
assertEquals( "Checksum doesn't match", SERVLETAPI_SHA1, s );
}
+ @Test
public void testRemoteMetadataChecksumFilePathSha1()
throws IOException
{
@@ -246,6 +262,7 @@ public class ChecksummedFileTest
}
}
+ @Test
public void testRemoteMetadataChecksumFilePathMd5()
throws IOException
{