Checkpoint for AVMSyncService. Update (that's promote to use

preferred parlance or submit if you have a certain background) is
substantially working, passing a handful of basic tests. Compare
harmlessly returns no differences always, so Kev can program against
it if he's so inclined.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3785 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-09-14 00:28:16 +00:00
parent 7fd363c599
commit bf1fdd9cd6
5 changed files with 382 additions and 42 deletions

View File

@@ -42,6 +42,8 @@ import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncException;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AccessPermission;
@@ -56,6 +58,79 @@ import org.alfresco.service.transaction.TransactionService;
*/
public class AVMServiceTest extends AVMServiceTestBase
{
/**
* Test AVMSyncService update.
*/
public void testUpdate()
{
try
{
setupBasicTree();
// Try branch to branch update.
fService.createBranch(-1, "main:/a", "main:/", "abranch");
fService.createFile("main:/abranch", "monkey").close();
fService.getFileOutputStream("main:/abranch/b/c/foo").close();
System.out.println(recursiveList("main", -1, true));
List<AVMDifference> diffs = new ArrayList<AVMDifference>();
diffs.add(new AVMDifference(-1, "main:/abranch/monkey",
-1, "main:/a/monkey",
AVMDifference.NEWER));
diffs.add(new AVMDifference(-1, "main:/abranch/b/c/foo",
-1, "main:/a/b/c/foo",
AVMDifference.NEWER));
fSyncService.update(diffs, false, false, false, false);
fService.createSnapshot("main");
System.out.println(recursiveList("main", -1, true));
assertEquals(fService.lookup(-1, "main:/abranch/monkey").getId(),
fService.lookup(-1, "main:/a/monkey").getId());
assertEquals(fService.lookup(-1, "main:/abranch/b/c/foo").getId(),
fService.lookup(-1, "main:/a/b/c/foo").getId());
// Try updating a deletion.
fService.removeNode("main:/abranch", "monkey");
System.out.println(recursiveList("main", -1, true));
diffs.clear();
diffs.add(new AVMDifference(-1, "main:/abranch/monkey",
-1, "main:/a/monkey",
AVMDifference.NEWER));
fSyncService.update(diffs, false, false, false, false);
fService.createSnapshot("main");
System.out.println(recursiveList("main", -1, true));
assertEquals(fService.lookup(-1, "main:/abranch/monkey", true).getId(),
fService.lookup(-1, "main:/a/monkey", true).getId());
// Try one that should fail.
fService.createFile("main:/abranch", "monkey").close();
diffs.clear();
diffs.add(new AVMDifference(-1, "main:/a/monkey",
-1, "main:/abranch/monkey",
AVMDifference.NEWER));
try
{
fSyncService.update(diffs, false, false, false, false);
fail();
}
catch (AVMSyncException se)
{
// Do nothing.
}
// Get synced again by doing an override conflict.
System.out.println(recursiveList("main", -1, true));
diffs.clear();
diffs.add(new AVMDifference(-1, "main:/a/monkey",
-1, "main:/abranch/monkey",
AVMDifference.NEWER));
fSyncService.update(diffs, false, false, true, false);
fService.createSnapshot("main");
System.out.println(recursiveList("main", -1, true));
assertEquals(fService.lookup(-1, "main:/a/monkey", true).getId(),
fService.lookup(-1, "main:/abranch/monkey", true).getId());
}
catch (Exception e)
{
e.printStackTrace(System.err);
fail();
}
}
/**
* Test link AVMService call.
*/