diff --git a/src/org/dclermonte/siba/model/SibaManager.java b/src/org/dclermonte/siba/model/SibaManager.java index 331a54d..db98834 100644 --- a/src/org/dclermonte/siba/model/SibaManager.java +++ b/src/org/dclermonte/siba/model/SibaManager.java @@ -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) diff --git a/src/org/dclermonte/siba/model/SibaUtils.java b/src/org/dclermonte/siba/model/SibaUtils.java index 123a12e..ec2f661 100644 --- a/src/org/dclermonte/siba/model/SibaUtils.java +++ b/src/org/dclermonte/siba/model/SibaUtils.java @@ -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); diff --git a/test/org/dclermonte/siba/data/reference/simplestuff-2016-08-26T22h17mn38s.tgz b/test/org/dclermonte/siba/data/reference/simplestuff-2016-08-26T22h17mn38s.tgz deleted file mode 100644 index 20b56e8..0000000 Binary files a/test/org/dclermonte/siba/data/reference/simplestuff-2016-08-26T22h17mn38s.tgz and /dev/null differ diff --git a/test/org/dclermonte/siba/data/reference/simplestuff-2016-08-26T22h17mn38s.tgz.md5 b/test/org/dclermonte/siba/data/reference/simplestuff-2016-08-26T22h17mn38s.tgz.md5 deleted file mode 100644 index f191b27..0000000 --- a/test/org/dclermonte/siba/data/reference/simplestuff-2016-08-26T22h17mn38s.tgz.md5 +++ /dev/null @@ -1 +0,0 @@ -2ca82150296f8412afd282e0d412ddea simplestuff-2016-08-26T22h17mn38s.tgz diff --git a/test/org/dclermonte/siba/data/reference/simplestuff-2016-08-30T22h44mn21s.tgz b/test/org/dclermonte/siba/data/reference/simplestuff-2016-08-30T22h44mn21s.tgz new file mode 100644 index 0000000..1aec916 Binary files /dev/null and b/test/org/dclermonte/siba/data/reference/simplestuff-2016-08-30T22h44mn21s.tgz differ diff --git a/test/org/dclermonte/siba/data/reference/simplestuff-2016-08-30T22h44mn21s.tgz.md5 b/test/org/dclermonte/siba/data/reference/simplestuff-2016-08-30T22h44mn21s.tgz.md5 new file mode 100644 index 0000000..bc608cf --- /dev/null +++ b/test/org/dclermonte/siba/data/reference/simplestuff-2016-08-30T22h44mn21s.tgz.md5 @@ -0,0 +1 @@ +0cdb449c8a62adc04d7ac0a095b2a247 simplestuff-2016-08-30T22h44mn21s.tgz diff --git a/test/org/dclermonte/siba/data/simplestuff/DIRECTORY1/toto b/test/org/dclermonte/siba/data/simplestuff/DIRECTORY1/toto deleted file mode 100644 index e69de29..0000000 diff --git a/test/org/dclermonte/siba/data/simplestuff/DIRECTORY1_essai/toto b/test/org/dclermonte/siba/data/simplestuff/DIRECTORY1_essai/toto new file mode 100644 index 0000000..2f681fd --- /dev/null +++ b/test/org/dclermonte/siba/data/simplestuff/DIRECTORY1_essai/toto @@ -0,0 +1 @@ +toto est là diff --git a/test/org/dclermonte/siba/data/simplestuff/bbb-splash.jpg b/test/org/dclermonte/siba/data/simplestuff/bbb-essai-splash.jpg similarity index 100% rename from test/org/dclermonte/siba/data/simplestuff/bbb-splash.jpg rename to test/org/dclermonte/siba/data/simplestuff/bbb-essai-splash.jpg diff --git a/test/org/dclermonte/siba/model/SibaManagerTest.java b/test/org/dclermonte/siba/model/SibaManagerTest.java index 953dab6..6f459c2 100644 --- a/test/org/dclermonte/siba/model/SibaManagerTest.java +++ b/test/org/dclermonte/siba/model/SibaManagerTest.java @@ -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);