Added some test
This commit is contained in:
parent
207e18b409
commit
1a673cc9d6
Binary file not shown.
@ -0,0 +1 @@
|
|||||||
|
2ca82150296f8412afd282e0d412ddea simplestuff-2016-08-26T22h17mn38s.tgz
|
@ -2,6 +2,7 @@ package org.dclermonte.siba.model;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
import org.apache.commons.compress.archivers.ArchiveException;
|
import org.apache.commons.compress.archivers.ArchiveException;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
@ -47,14 +48,23 @@ public class SibaManagerTest
|
|||||||
{
|
{
|
||||||
File source = new File("test/org/dclermonte/siba/data/simplestuff");
|
File source = new File("test/org/dclermonte/siba/data/simplestuff");
|
||||||
File target = SibaManager.backup(source, new File("test/org/dclermonte/siba/data/result"));
|
File target = SibaManager.backup(source, new File("test/org/dclermonte/siba/data/result"));
|
||||||
System.out.println(target.getName());
|
File reference = new File("test/org/dclermonte/siba/data/reference/simplestuff-2016-08-26T22h17mn38s.tgz");
|
||||||
// Load md5 file.
|
Boolean fileEquals = FileUtils.contentEquals(reference, target);
|
||||||
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);
|
|
||||||
|
|
||||||
// Test.
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user