diff options
author | Olivier Lamy <olamy@apache.org> | 2015-03-23 14:57:49 +1100 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2015-03-23 14:57:49 +1100 |
commit | a6c73dcde2a11d763a576edff292f9361a2fdb16 (patch) | |
tree | e37a4a3357a6c45d288dc6d8941551c66b39a09c /archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers | |
parent | 81411e352d6dcbc2b82a762170fefc6608cd195a (diff) | |
download | archiva-a6c73dcde2a11d763a576edff292f9361a2fdb16.tar.gz archiva-a6c73dcde2a11d763a576edff292f9361a2fdb16.zip |
use more java 1.7 for file io
Diffstat (limited to 'archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers')
2 files changed, 18 insertions, 14 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java index 954ac6bf3..9b5510ca2 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumer.java @@ -155,7 +155,7 @@ public class ArtifactMissingChecksumsConsumer private void createFixChecksum( String path, ChecksumAlgorithm checksumAlgorithm ) { File artifactFile = new File( this.repositoryDir, path ); - File checksumFile = new File( this.repositoryDir, path + "." + checksumAlgorithm.getExt() ); + File checksumFile = new File( this.repositoryDir, path + checksumAlgorithm.getExt() );//+ "." if ( checksumFile.exists() ) { diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java index 8645ab01d..6c0d8a736 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java @@ -62,26 +62,32 @@ public class ArtifactMissingChecksumsConsumerTest { String path = "/no-checksums-artifact/1.0/no-checksums-artifact-1.0.jar"; - Path sha1Path = Paths.get( repoConfig.getLocation(), - path + ".sha1" );// new File( repoConfig.getLocation(), path + ".sha1" ); - Path md5FilePath = - Paths.get( repoConfig.getLocation(), path + ".md5" );// new File( repoConfig.getLocation(), path + ".md5" ); + Path sha1Path = Paths.get( repoConfig.getLocation(), path + ".sha1" ); + Path md5FilePath = Paths.get( repoConfig.getLocation(), path + ".md5" ); Files.deleteIfExists( sha1Path ); Files.deleteIfExists( md5FilePath ); - //sha1File.delete(); - //md5File.delete(); - - Assertions.assertThat( sha1Path.toFile() ).doesNotExist();// assertFalse( sha1File.exists() ); - Assertions.assertThat( md5FilePath.toFile() ).doesNotExist();// assertFalse( md5File.exists() ); + Assertions.assertThat( sha1Path.toFile() ).doesNotExist(); + Assertions.assertThat( md5FilePath.toFile() ).doesNotExist(); consumer.beginScan( repoConfig, Calendar.getInstance().getTime() ); consumer.processFile( path ); - Assertions.assertThat( sha1Path.toFile() ).exists();// assertTrue( sha1File.exists() ); - Assertions.assertThat( md5FilePath.toFile() ).exists();//assertTrue( md5File.exists() ); + Assertions.assertThat( sha1Path.toFile() ).exists(); + long sha1LastModified = sha1Path.toFile().lastModified(); + Assertions.assertThat( md5FilePath.toFile() ).exists(); + long md5LastModified = md5FilePath.toFile().lastModified(); + Thread.sleep( 1 ); + consumer.processFile( path ); + + Assertions.assertThat( sha1Path.toFile() ).exists(); + Assertions.assertThat( md5FilePath.toFile() ).exists(); + + Assertions.assertThat( sha1Path.toFile().lastModified() ).isEqualTo( sha1LastModified ); + + Assertions.assertThat( md5FilePath.toFile().lastModified() ).isEqualTo( md5LastModified ); } @Test @@ -95,10 +101,8 @@ public class ArtifactMissingChecksumsConsumerTest String path = "/incorrect-checksums/1.0/incorrect-checksums-1.0.jar"; - // new File( repoConfig.getLocation(), path + ".sha1" ); Path sha1Path = Paths.get( repoConfig.getLocation(), path + ".sha1" ); - //new File( repoConfig.getLocation(), path + ".md5" ); Path md5Path = Paths.get( repoConfig.getLocation(), path + ".md5" ); ChecksummedFile checksum = new ChecksummedFile( new File( repoConfig.getLocation(), path ) ); |