BackupManagerTestCase.java revision 75fceea66e311b3de58d76a4c993af0fec13dd3d
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2015 ForgeRock AS
*/
@SuppressWarnings("javadoc")
public class BackupManagerTestCase extends DirectoryServerTestCase
{
{
// Need the schema to be available, so make sure the server is started.
// startFakeServer() is insufficient because we also need the CryptoManager to be initialized
}
// For each case is provided
// - a label identifying the case (not used in method but allow to identify easily the case in IDE)
// - a mock of a backupable (building the mock also involves creating directory and files to backup)
// - a backup config
// - a restore config
backupConfig1.setHashData(true);
backupConfig2.setHashData(true);
backupConfig2.setSignHash(true);
backupConfig3.setEncryptData(true);
backupConfig3.setCompressData(true);
// should perform a normal backup in absence of incremental base ID
backupConfig4.setHashData(true);
Backupable backupable6 = buildBackupableForMultipleDirectoriesCase(createSourceDirectory(label6), 3);
return new Object[][] {
};
}
/**
* This test encompasses creation, restore and remove of a backup.
*
* It allows to ensure that a backup can actually be restored.
*/
public void testCreateBackupThenRestoreThenRemove(String label, Backupable backupable, BackupConfig backupConfig,
{
// create and check archive files
// change content of directory to later check that backup is recovering everything
// restore and check list of files
// remove the backup archive and check
//cleanDirectories(sourceDirectory, backupPath);
}
/**
* This test encompasses creation, restore and remove of an incremental backup.
*
* It allows to ensure that a backup can actually be restored.
*/
@Test()
public void testCreateIncrementalBackupThenRestoreThenRemove() throws Exception
{
// perform first backup with 2 files
// check archive and info file
// perform second backup with 4 files (2 initial files plus 2 new files)
// now backup with id "backupID" should depend on backup with id "backupID_0"
// change content of directory to later check that backup is recovering everything
// restore and check list of files
// remove the backup archive and check
}
@Test
public void testCreateDirectoryWithNumericSuffix() throws Exception
{
// delete the directory to ensure creation works fine when there is no directory
}
@Test
public void testSaveFilesToDirectory() throws Exception
{
Backupable backupable = buildBackupableForMultipleDirectoriesCase(createSourceDirectory("saveFiles-root"), 2);
File actualTargetDir = BackupManager.saveFilesToDirectory(rootDir.toPath(), backupable.getFilesToBackup(),
// all files should have been saved in the target directory, with correct sub-path
}
{
}
{
}
{
{
}
}
{
{
}
}
{
BackupDirectory backupDir = new BackupDirectory(backupDirectory.getAbsolutePath(), DN.valueOf(ENTRY_DN));
return backupDir;
}
{
return backupable;
}
/**
* Create files in source directory + additional files under a subdirectory of source directory
*/
private Backupable buildBackupableForMultipleDirectoriesCase(Path sourceDirectory, int numberOfFiles)
throws Exception
{
// create an additional subdirectory with files
return backupable;
}
{
return sourceDirectory.toPath();
}
throws Exception
{
for (int i = 0; i < numberOfFiles; i++)
{
}
return files;
}
try
{
}
finally {
}
}
}