updated SibaCLI + SibaManager

This commit is contained in:
Didier Clermonté 2016-05-15 16:56:10 +02:00
parent ae921b7115
commit 79a5b78af3
2 changed files with 28 additions and 4 deletions

View File

@ -71,9 +71,16 @@ public class SibaCLI
} }
/**
*
* @param args
* @throws ArchiveException
* @throws IOException
* @throws NoSuchAlgorithmException
*/
public static void run(final String[] args) throws ArchiveException, IOException, NoSuchAlgorithmException public static void run(final String[] args) throws ArchiveException, IOException, NoSuchAlgorithmException
{ {
// This part implements an automate.
int numberParameter = args.length; int numberParameter = args.length;
if (numberParameter == 0) if (numberParameter == 0)
{ {
@ -81,14 +88,12 @@ public class SibaCLI
} }
else else
{ {
if ((args[0].equals("-h")) || (args[0].equals("-help")) || (args[0].equals("--help"))) if ((args[0].equals("-h")) || (args[0].equals("-help")) || (args[0].equals("--help")))
{ {
help(); help();
} }
else if (args[0].equals("backup")) else if (args[0].equals("backup"))
{ {
if (numberParameter == 1) if (numberParameter == 1)
{ {
System.out.println(BUNDLE.getString("missingDirectoryToSave.text")); System.out.println(BUNDLE.getString("missingDirectoryToSave.text"));

View File

@ -1,5 +1,6 @@
package org.dclermonte.siba.model; package org.dclermonte.siba.model;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.apache.commons.compress.archivers.ArchiveException; import org.apache.commons.compress.archivers.ArchiveException;
@ -22,13 +23,31 @@ public class SibaManagerTest
} }
/** /**
*
* @throws IOException * @throws IOException
* @throws ArchiveException * @throws ArchiveException
*
*/ */
@Test(expectedExceptions = IllegalArgumentException.class) @Test(expectedExceptions = IllegalArgumentException.class)
public void backupTest01() throws ArchiveException, IOException public void backupTest01() throws ArchiveException, IOException
{ {
SibaManager.backup(null, null); SibaManager.backup(null, null);
} }
/**
*
* @throws ArchiveException
* @throws IOException
*/
@Test
public void backupTest02() throws ArchiveException, IOException
{
String md5LineSource = "qslfjqmlsfjmqlsjfqmlsjfsjf mqlsfjmljdf";
File target = SibaManager.backup(new File("../data/simplestuff"), new File("/tmp/"));
// Load md5 file.
String md5LineTarget = FileUtils.load(target);
// Test.
Assert.assertEquals(md5LineSource, md5LineTarget);
}
} }