archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marti...@apache.org
Subject [1/3] archiva git commit: Moved checksum module to java.nio
Date Sat, 02 Sep 2017 20:05:36 GMT
Repository: archiva
Updated Branches:
  refs/heads/master 90250dc30 -> cd1f4a9e7


Moved checksum module to java.nio


Project: http://git-wip-us.apache.org/repos/asf/archiva/repo
Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/faceef26
Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/faceef26
Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/faceef26

Branch: refs/heads/master
Commit: faceef262c3521c1f27bfc49c7ab74c1b41a57ec
Parents: 90250dc
Author: Martin Stockhammer <martin_s@apache.org>
Authored: Sat Sep 2 20:37:52 2017 +0200
Committer: Martin Stockhammer <martin_s@apache.org>
Committed: Sat Sep 2 20:37:52 2017 +0200

----------------------------------------------------------------------
 .../org/apache/archiva/checksum/ChecksumAlgorithm.java   |  9 +++++----
 .../apache/archiva/checksum/ChecksumAlgorithmTest.java   | 11 ++++++-----
 2 files changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/archiva/blob/faceef26/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksumAlgorithm.java
----------------------------------------------------------------------
diff --git a/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksumAlgorithm.java
b/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksumAlgorithm.java
index 71f051f..8d20239 100644
--- a/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksumAlgorithm.java
+++ b/archiva-modules/archiva-base/archiva-checksum/src/main/java/org/apache/archiva/checksum/ChecksumAlgorithm.java
@@ -19,10 +19,11 @@ package org.apache.archiva.checksum;
  * under the License.
  */
 
-import java.io.File;
 
 import org.apache.commons.io.FilenameUtils;
 
+import java.nio.file.Path;
+
 /**
  * Enumeration of available ChecksumAlgorithm techniques.
  *
@@ -32,9 +33,9 @@ public enum ChecksumAlgorithm {
     SHA1("SHA-1", "sha1", "SHA1"),
     MD5("MD5", "md5", "MD5");
 
-    public static ChecksumAlgorithm getByExtension( File file )
+    public static ChecksumAlgorithm getByExtension( Path file )
     {
-        String ext = FilenameUtils.getExtension( file.getName() ).toLowerCase();
+        String ext = FilenameUtils.getExtension( file.getFileName().toString() ).toLowerCase();
         if ( ChecksumAlgorithm.SHA1.getExt().equals( ext ) )
         {
             return ChecksumAlgorithm.SHA1;
@@ -44,7 +45,7 @@ public enum ChecksumAlgorithm {
             return ChecksumAlgorithm.MD5;
         }
 
-        throw new IllegalArgumentException( "Filename " + file.getName() + " has no associated
extension." );
+        throw new IllegalArgumentException( "Filename " + file.getFileName() + " has no associated
extension." );
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/archiva/blob/faceef26/archiva-modules/archiva-base/archiva-checksum/src/test/java/org/apache/archiva/checksum/ChecksumAlgorithmTest.java
----------------------------------------------------------------------
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 bfaa06b..39719cc 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
@@ -20,6 +20,7 @@ package org.apache.archiva.checksum;
  */
 
 import java.io.File;
+import java.nio.file.Paths;
 
 import junit.framework.TestCase;
 import org.apache.archiva.test.utils.ArchivaBlockJUnit4ClassRunner;
@@ -38,15 +39,15 @@ public class ChecksumAlgorithmTest
     @Test
     public void testGetHashByExtensionSha1()
     {
-        assertEquals( ChecksumAlgorithm.SHA1, ChecksumAlgorithm.getByExtension( new File(
"something.jar.sha1" ) ) );
-        assertEquals( ChecksumAlgorithm.SHA1, ChecksumAlgorithm.getByExtension( new File(
"OTHER.JAR.SHA1" ) ) );
+        assertEquals( ChecksumAlgorithm.SHA1, ChecksumAlgorithm.getByExtension( Paths.get(
"something.jar.sha1" ) ) );
+        assertEquals( ChecksumAlgorithm.SHA1, ChecksumAlgorithm.getByExtension( Paths.get(
"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" ) ) );
+        assertEquals( ChecksumAlgorithm.MD5, ChecksumAlgorithm.getByExtension( Paths.get(
"something.jar.md5" ) ) );
+        assertEquals( ChecksumAlgorithm.MD5, ChecksumAlgorithm.getByExtension( Paths.get(
"OTHER.JAR.MD5" ) ) );
     }
 
     @Test
@@ -54,7 +55,7 @@ public class ChecksumAlgorithmTest
     {
         try
         {
-            ChecksumAlgorithm.getByExtension( new File( "something.jar" ) );
+            ChecksumAlgorithm.getByExtension( Paths.get( "something.jar" ) );
             fail( "Expected " + IllegalArgumentException.class.getName() );
         }
         catch ( IllegalArgumentException e )


Mime
View raw message