Siba/test/org/dclermonte/siba/model/SibaManagerTest.java

71 lines
2.0 KiB
Java
Raw Normal View History

package org.dclermonte.siba.model;
2016-05-15 16:56:10 +02:00
import java.io.File;
import java.io.IOException;
2016-08-26 23:05:24 +02:00
import java.security.NoSuchAlgorithmException;
import org.apache.commons.compress.archivers.ArchiveException;
2016-05-16 23:40:07 +02:00
import org.apache.commons.io.FileUtils;
2016-05-19 18:40:00 +02:00
import org.dclermonte.siba.SibaException;
import org.testng.Assert;
import org.testng.annotations.Test;
/**
*
* @author cpm
*/
public class SibaManagerTest
{
2016-08-26 23:05:24 +02:00
/**
*
*/
@Test
public void aFooTest()
{
Assert.assertTrue(true);
}
2016-08-26 23:05:24 +02:00
/**
*
* @throws IOException
* @throws ArchiveException
* @throws SibaNullException
*/
@Test(expectedExceptions = SibaException.class)
public void backupTest01() throws ArchiveException, IOException, SibaException
{
SibaManager.backup(null, null);
}
2016-05-15 16:56:10 +02:00
2016-08-26 23:05:24 +02:00
/**
*
* @throws ArchiveException
* @throws IOException
* @throws SibaNullException
*/
@Test
public void backupTest02() throws ArchiveException, IOException, SibaException
{
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-30T22h44mn21s.tgz");
2016-08-26 23:05:24 +02:00
Boolean fileEquals = FileUtils.contentEquals(reference, target);
// Test.
Assert.assertTrue(fileEquals);
}
2016-05-15 16:56:10 +02:00
2016-08-26 23:05:24 +02:00
@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 md5Calculate = SibaUtils.md5(target);
File reference = new File("test/org/dclermonte/siba/data/reference/simplestuff-2016-08-30T22h44mn21s.tgz.md5");
2016-08-26 23:05:24 +02:00
String md5Reference = SibaUtils.loadMD5Sum(reference);
// Test.
Assert.assertEquals(md5Calculate, md5Reference);
}
}