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));
conn = ds.getConnection();
conn.setAutoCommit(false);
DBCleaner workspaceDBCleaner = DBCleanService.getWorkspaceDBCleaner(conn, wsEntry);
try
{
// clean and rollback first
workspaceDBCleaner.executeCleanScripts();
conn.rollback();
workspaceDBCleaner.executeRollbackScripts();
conn.commit();
checkConent(repositoryName);
// clean
workspaceDBCleaner.executeCleanScripts();
workspaceDBCleaner.executeCommitScripts();
conn.commit();
}
finally
{
conn.close();