Added some test

This commit is contained in:
Didier Clermonté 2016-08-26 23:05:24 +02:00
parent 207e18b409
commit 1a673cc9d6
3 changed files with 50 additions and 39 deletions

View File

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

View File

@ -2,6 +2,7 @@ package org.dclermonte.siba.model;
import java.io.File;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.compress.archivers.ArchiveException;
import org.apache.commons.io.FileUtils;
@ -47,14 +48,23 @@ 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"));
System.out.println(target.getName());
// Load md5 file.
String encoding = null;
String md5LineTarget = FileUtils.readFileToString(target, encoding);
File reference = new File("test/org/dclermonte/siba/data/reference/simplestuff-2016-05-18T22h57mn57s.tgz");
String md5LineSource = FileUtils.readFileToString(reference, encoding);
File reference = new File("test/org/dclermonte/siba/data/reference/simplestuff-2016-08-26T22h17mn38s.tgz");
Boolean fileEquals = FileUtils.contentEquals(reference, target);
// Test.
Assert.assertEquals(md5LineSource, md5LineTarget);
Assert.assertTrue(fileEquals);
}
@Test
public void backupTest03() throws ArchiveException, IOException, SibaException, NoSuchAlgorithmException
{
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 md5Reference = SibaUtils.loadMD5Sum(reference);
// Test.
Assert.assertEquals(md5Calculate, md5Reference);
}
}