import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
+import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
throws IOException
{
File checksumFile = new File( referenceFile.getAbsolutePath() + "." + checksumAlgorithm.getExt() );
+ Files.deleteIfExists( checksumFile.toPath() );
String checksum = calculateChecksum( checksumAlgorithm );
- FileUtils.writeStringToFile( checksumFile, checksum + " " + referenceFile.getName() );
+ Files.write( checksumFile.toPath(), (checksum + " " + referenceFile.getName()).getBytes(), StandardOpenOption.CREATE_NEW );
+ //FileUtils.writeStringToFile( checksumFile, checksum + " " + referenceFile.getName() );
return checksumFile;
}
{
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
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 ) );