wsQuotaManager.backup(tempDir);
DataRestoreContext context =
new DataRestoreContext(new String[]{DataRestoreContext.STORAGE_DIR}, new Object[]{tempDir});
DataRestore restorer = wsQuotaManager.getDataRestorer(context);
restorer.clean();
assertEquals(dbQuotaManager.getRepositoryDataSize(), repDataSize - wsDataSize);
try
{
wsQuotaManager.getWorkspaceQuota();
fail("Quota should be unknown after clean");
}
catch (UnknownQuotaLimitException e)
{
}
try
{
wsQuotaManager.getWorkspaceDataSize();
fail("Data size should be unknown after clean");
}
catch (UnknownDataSizeException e)
{
}
assertTrue(dataSizeShouldNotExists(wsQuotaManager, "/testRoot/test1"));
assertTrue(dataSizeShouldNotExists(wsQuotaManager, "/testRoot/test2"));
assertTrue(quotaShouldNotExists(wsQuotaManager, "/testRoot/test1"));
assertTrue(quotaShouldNotExists(wsQuotaManager, "/testRoot/test2"));
restorer.rollback();
assertEquals(dbQuotaManager.getRepositoryDataSize(), repDataSize);
assertEquals(wsDataSize, wsQuotaManager.getWorkspaceDataSize());
assertEquals(node1DataSize, wsQuotaManager.getNodeDataSize("/testRoot/test1"));
assertEquals(node2DataSize, wsQuotaManager.getNodeDataSize("/testRoot/test2"));
assertEquals(node1Quota, wsQuotaManager.getNodeQuota("/testRoot/test1"));
assertEquals(node2Quota, wsQuotaManager.getNodeQuota("/testRoot/test2"));
restorer.clean();
restorer.restore();
assertEquals(dbQuotaManager.getRepositoryDataSize(), repDataSize);
assertEquals(wsDataSize, wsQuotaManager.getWorkspaceDataSize());
assertEquals(node1DataSize, wsQuotaManager.getNodeDataSize("/testRoot/test1"));
assertEquals(node2DataSize, wsQuotaManager.getNodeDataSize("/testRoot/test2"));
assertEquals(node1Quota, wsQuotaManager.getNodeQuota("/testRoot/test1"));
assertEquals(node2Quota, wsQuotaManager.getNodeQuota("/testRoot/test2"));
restorer.commit();
restorer.close();
wsQuotaManager.resume();
assertFalse(wsQuotaManager.isSuspended());
wsQuotaManager.removeGroupOfNodesQuota("/testRoot/*");