2016-05-10 18:59:52 +02:00
|
|
|
package org.dclermonte.siba.model;
|
|
|
|
|
2016-05-15 16:56:10 +02:00
|
|
|
import java.io.File;
|
2016-05-10 18:59:52 +02:00
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
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;
|
2016-05-10 18:59:52 +02:00
|
|
|
import org.testng.Assert;
|
|
|
|
import org.testng.annotations.Test;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author cpm
|
|
|
|
*/
|
|
|
|
public class SibaManagerTest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void aFooTest()
|
|
|
|
{
|
|
|
|
Assert.assertTrue(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-15 16:56:10 +02:00
|
|
|
*
|
2016-05-10 18:59:52 +02:00
|
|
|
* @throws IOException
|
|
|
|
* @throws ArchiveException
|
2016-05-16 23:40:07 +02:00
|
|
|
* @throws SibaNullException
|
2016-05-10 18:59:52 +02:00
|
|
|
*/
|
2016-05-19 18:40:00 +02:00
|
|
|
@Test(expectedExceptions = SibaException.class)
|
|
|
|
public void backupTest01() throws ArchiveException, IOException, SibaException
|
2016-05-10 18:59:52 +02:00
|
|
|
{
|
|
|
|
SibaManager.backup(null, null);
|
|
|
|
}
|
2016-05-15 16:56:10 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @throws ArchiveException
|
|
|
|
* @throws IOException
|
2016-05-16 23:40:07 +02:00
|
|
|
* @throws SibaNullException
|
2016-05-15 16:56:10 +02:00
|
|
|
*/
|
|
|
|
@Test
|
2016-05-19 18:40:00 +02:00
|
|
|
public void backupTest02() throws ArchiveException, IOException, SibaException
|
2016-05-15 16:56:10 +02:00
|
|
|
{
|
2016-05-18 23:20:29 +02:00
|
|
|
File source = new File("test/org/dclermonte/siba/data/simplestuff");
|
|
|
|
File target = SibaManager.backup(source, new File("test/org/dclermonte/siba/data/result"));
|
2016-05-17 23:59:42 +02:00
|
|
|
System.out.println(target.getName());
|
2016-05-15 16:56:10 +02:00
|
|
|
// Load md5 file.
|
2016-05-16 23:40:07 +02:00
|
|
|
String encoding = null;
|
|
|
|
String md5LineTarget = FileUtils.readFileToString(target, encoding);
|
2016-05-18 23:20:29 +02:00
|
|
|
File reference = new File("test/org/dclermonte/siba/data/reference/simplestuff-2016-05-18T22h57mn57s.tgz");
|
|
|
|
String md5LineSource = FileUtils.readFileToString(reference, encoding);
|
2016-05-15 16:56:10 +02:00
|
|
|
|
|
|
|
// Test.
|
|
|
|
Assert.assertEquals(md5LineSource, md5LineTarget);
|
|
|
|
}
|
2016-05-10 18:59:52 +02:00
|
|
|
}
|