// restore
restore(repositoryName, bch, backupManagerImpl);
checkConent(repositoryName);
// clean every workspace via DBCleanService
ManageableRepository repository = repositoryService.getRepository(repositoryName);
for (WorkspaceEntry wsEntry : repository.getConfiguration().getWorkspaceEntries())
{
DBCleanService.cleanWorkspaceData(wsEntry);
}
checkEmptyTables(repositoryName);
// restore
restore(repositoryName, bch, backupManagerImpl);
checkConent(repositoryName);
// clean again via DBCleaner
repository = repositoryService.getRepository(repositoryName);
WorkspaceEntry entry = repository.getConfiguration().getWorkspaceEntries().get(0);
DataSource ds =
(DataSource)new InitialContext().lookup(entry.getContainer().getParameterValue(
JDBCWorkspaceDataContainer.SOURCE_NAME));
Connection conn = ds.getConnection();
conn.setAutoCommit(false);
DBCleaner repositoryDBCleaner = DBCleanService.getRepositoryDBCleaner(conn, repository.getConfiguration());
try
{
if (repositoryName.equals("db3"))
{
// clean and rollback first
repositoryDBCleaner.executeCleanScripts();
conn.rollback();
repositoryDBCleaner.executeRollbackScripts();
conn.commit();
checkConent(repositoryName);
// clean
repositoryDBCleaner.executeCleanScripts();
repositoryDBCleaner.executeCommitScripts();
conn.commit();
}
else
{
assertNull(repositoryDBCleaner);
}
}
finally
{
conn.close();
}
if (repositoryName.equals("db3"))
{
checkEmptyTables(repositoryName);
}
// restore
restore(repositoryName, bch, backupManagerImpl);
checkConent(repositoryName);
// clean every workspace again via DBCleaner
repository = repositoryService.getRepository(repositoryName);
for (WorkspaceEntry wsEntry : repository.getConfiguration().getWorkspaceEntries())
{
ds =
(DataSource)new InitialContext().lookup(wsEntry.getContainer().getParameterValue(
JDBCWorkspaceDataContainer.SOURCE_NAME));