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;
|
||||||
@ -15,46 +16,55 @@ import org.testng.annotations.Test;
|
|||||||
*/
|
*/
|
||||||
public class SibaManagerTest
|
public class SibaManagerTest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void aFooTest()
|
public void aFooTest()
|
||||||
{
|
{
|
||||||
Assert.assertTrue(true);
|
Assert.assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws ArchiveException
|
* @throws ArchiveException
|
||||||
* @throws SibaNullException
|
* @throws SibaNullException
|
||||||
*/
|
*/
|
||||||
@Test(expectedExceptions = SibaException.class)
|
@Test(expectedExceptions = SibaException.class)
|
||||||
public void backupTest01() throws ArchiveException, IOException, SibaException
|
public void backupTest01() throws ArchiveException, IOException, SibaException
|
||||||
{
|
{
|
||||||
SibaManager.backup(null, null);
|
SibaManager.backup(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @throws ArchiveException
|
* @throws ArchiveException
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws SibaNullException
|
* @throws SibaNullException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void backupTest02() throws ArchiveException, IOException, SibaException
|
public void backupTest02() throws ArchiveException, IOException, SibaException
|
||||||
{
|
{
|
||||||
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;
|
// Test.
|
||||||
String md5LineTarget = FileUtils.readFileToString(target, encoding);
|
Assert.assertTrue(fileEquals);
|
||||||
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);
|
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