SibaManager updated path to absolutePath and test

This commit is contained in:
Didier Clermonté 2016-08-30 23:00:49 +02:00
parent ac1e2d1c48
commit 86584648cc
10 changed files with 10 additions and 10 deletions

View File

@ -111,8 +111,7 @@ public final class SibaManager
out = new TarArchiveOutputStream(gzipOutputStream);
SibaUtils.tarDirectoryTree(fileToSave, out);
out.close();
String fileSeparator = System.getProperty("file.separator");
SibaUtils.createMD5File(result, target + fileSeparator + outputFileNameWithoutExtension + ".tgz.md5");
SibaUtils.createMD5File(result, target + File.separator + outputFileNameWithoutExtension + ".tgz.md5");
}
}
catch (IOException exception)

View File

@ -311,7 +311,7 @@ public final class SibaUtils
if (file.listFiles().length == 0)
{
TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(file);
String pathPartiel = file.getPath().substring(pathLength);
String pathPartiel = file.getAbsolutePath().substring(pathLength);
tarArchiveEntry.setName(pathPartiel);
outputStream.putArchiveEntry(tarArchiveEntry);
outputStream.closeArchiveEntry();
@ -324,7 +324,7 @@ public final class SibaUtils
else
{
TarArchiveEntry tarArchiveEntry = new TarArchiveEntry(file);
String pathPartiel = file.getPath().substring(pathLength);
String pathPartiel = file.getAbsolutePath().substring(pathLength);
tarArchiveEntry.setName(pathPartiel);
outputStream.putArchiveEntry(tarArchiveEntry);
IOUtils.copy(new FileInputStream(file), outputStream);

View File

@ -1 +0,0 @@
2ca82150296f8412afd282e0d412ddea simplestuff-2016-08-26T22h17mn38s.tgz

View File

@ -0,0 +1 @@
0cdb449c8a62adc04d7ac0a095b2a247 simplestuff-2016-08-30T22h44mn21s.tgz

View File

@ -0,0 +1 @@
toto est là

View File

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View File

@ -48,7 +48,8 @@ public class SibaManagerTest
{
File source = new File("test/org/dclermonte/siba/data/simplestuff");
File target = SibaManager.backup(source, new File("test/org/dclermonte/siba/data/result"));
File reference = new File("test/org/dclermonte/siba/data/reference/simplestuff-2016-08-26T22h17mn38s.tgz");
File reference = new File("test/org/dclermonte/siba/data/reference/simplestuff-2016-08-30T22h44mn21s.tgz");
Boolean fileEquals = FileUtils.contentEquals(reference, target);
// Test.
Assert.assertTrue(fileEquals);
@ -59,10 +60,9 @@ public class SibaManagerTest
{
File source = new File("test/org/dclermonte/siba/data/simplestuff");
File target = SibaManager.backup(source, new File("test/org/dclermonte/siba/data/result"));
String fileNameMD5 = "test/org/dclermonte/siba/data/result/fileMD5";
File fileMD5 = SibaUtils.createMD5File(target, fileNameMD5);
String md5Calculate = SibaUtils.loadMD5Sum(fileMD5);
File reference = new File("test/org/dclermonte/siba/data/reference/simplestuff-2016-08-26T22h17mn38s.tgz.md5");
String md5Calculate = SibaUtils.md5(target);
File reference = new File("test/org/dclermonte/siba/data/reference/simplestuff-2016-08-30T22h44mn21s.tgz.md5");
String md5Reference = SibaUtils.loadMD5Sum(reference);
// Test.
Assert.assertEquals(md5Calculate, md5Reference);