Moved dangerous helper methods out of AVMService.

Reworked handling of path lookup failures to not throw exceptions
internally, to improve performance of certain layered directory
operations.  Unfortunately there remains at least one scenario,
handling of bulk loads, and promotions of deeply nested directories in
layered contexts, in which performance is considerably less than
ideal. 

Made AVMService.createBranch() and AVMSyncService.update() perform
implicit snapshots of source tree's stores before proceeding.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3812 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-09-17 20:05:27 +00:00
parent f5e509c18b
commit 90d171b913
11 changed files with 545 additions and 181 deletions

View File

@@ -59,6 +59,61 @@ import org.alfresco.service.transaction.TransactionService;
*/
public class AVMServiceTest extends AVMServiceTestBase
{
/**
* Test that an update forces a snapshot on the source.
*/
public void testUpdateSnapshot()
{
try
{
setupBasicTree();
fService.createAVMStore("branch");
fService.createBranch(-1, "main:/", "branch:/", "branch");
// Modify some things in the branch.
fService.createFile("branch:/branch/a/b", "fing").close();
fService.getFileOutputStream("branch:/branch/a/b/c/foo").close();
fService.removeNode("branch:/branch/a/b/c", "bar");
List<AVMDifference> diffs =
fSyncService.compare(-1, "branch:/branch", -1, "main:/");
assertEquals(3, diffs.size());
// Now update.
fSyncService.update(diffs, false, false, false, false);
diffs = fSyncService.compare(-1, "branch:/branch", -1, "main:/");
assertEquals(0, diffs.size());
fService.getFileOutputStream("branch:/branch/a/b/fing").close();
assertTrue(fService.lookup(-1, "branch:/branch/a/b/fing").getId() !=
fService.lookup(-1, "main:/a/b/fing").getId());
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
/**
* Test that branching forces a snapshot on the source repository.
*/
public void testBranchSnapshot()
{
try
{
setupBasicTree();
fService.getFileOutputStream("main:/a/b/c/foo").close();
fService.createBranch(-1, "main:/a", "main:/", "abranch");
assertEquals(fService.lookup(-1, "main:/a/b/c/foo").getId(),
fService.lookup(-1, "main:/abranch/b/c/foo").getId());
fService.getFileOutputStream("main:/a/b/c/foo").close();
assertTrue(fService.lookup(-1, "main:/a/b/c/foo").getId() !=
fService.lookup(-1, "main:/abranch/b/c/foo").getId());
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
/**
* Test bulk update.
*/