Replication Service test which ensures that the right things get copied by the tranfer service

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21097 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2010-07-12 14:27:10 +00:00
parent d633e6416b
commit 5a3d53e5c1

View File

@@ -58,6 +58,7 @@ import org.alfresco.util.Pair;
/** /**
* @author Nick Burch * @author Nick Burch
*/ */
@SuppressWarnings("deprecation")
public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest
{ {
private ReplicationActionExecutor replicationActionExecutor; private ReplicationActionExecutor replicationActionExecutor;
@@ -469,7 +470,7 @@ public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest
* Test that when we execute a replication task, the * Test that when we execute a replication task, the
* right stuff ends up being moved for us * right stuff ends up being moved for us
*/ */
public void DISABLEDtestExecutionResult() throws Exception public void testExecutionResult() throws Exception
{ {
// Destination is empty // Destination is empty
assertEquals(0, nodeService.getChildAssocs(destinationFolder).size()); assertEquals(0, nodeService.getChildAssocs(destinationFolder).size());
@@ -478,12 +479,8 @@ public class ReplicationServiceIntegrationTest extends BaseAlfrescoSpringTest
makeTransferTarget(); makeTransferTarget();
// Put in Folder 2, so we can send Folder 2a // Put in Folder 2, so we can send Folder 2a
// TODO Finish creating it properly String folder2Name = (String)nodeService.getProperties(folder2).get(ContentModel.PROP_NAME);
NodeRef folderT2 = makeNode(destinationFolder, ContentModel.TYPE_FOLDER, folder2.getId()); NodeRef folderT2 = makeNode(destinationFolder, ContentModel.TYPE_FOLDER, folder2Name);
System.err.println("F2 = " + folder2);
System.err.println("F2 @ " + nodeService.getPath(folder2));
System.err.println("FT2 = " + folderT2);
System.err.println("FT2 @ " + nodeService.getPath(folderT2));
// Run a transfer // Run a transfer
ReplicationDefinition rd = replicationService.createReplicationDefinition(ACTION_NAME, "Test"); ReplicationDefinition rd = replicationService.createReplicationDefinition(ACTION_NAME, "Test");
@@ -500,24 +497,66 @@ System.err.println("FT2 @ " + nodeService.getPath(folderT2));
NodeRef c1 = nodeService.getChildAssocs(destinationFolder).get(0).getChildRef(); NodeRef c1 = nodeService.getChildAssocs(destinationFolder).get(0).getChildRef();
NodeRef c2 = nodeService.getChildAssocs(destinationFolder).get(1).getChildRef(); NodeRef c2 = nodeService.getChildAssocs(destinationFolder).get(1).getChildRef();
// The destination should have folder 1 (transfered)
// and folder 2 (created). folder 2 will have
// folder 2a (transfered) but not 2b
NodeRef folderT1 = null; NodeRef folderT1 = null;
NodeRef folderT2a = null; boolean foundT1 = false;
if(c1.getId().equals(folder1.getId())) { boolean foundT2 = false;
if(nodeService.getProperty(folder1, ContentModel.PROP_NAME).equals(
nodeService.getProperty(c1, ContentModel.PROP_NAME) )) {
folderT1 = c1; folderT1 = c1;
folderT2a = c2; foundT1 = true;
} else if(c2.getId().equals(folder1.getId())) { }
if(nodeService.getProperty(folder1, ContentModel.PROP_NAME).equals(
nodeService.getProperty(c2, ContentModel.PROP_NAME) )) {
folderT1 = c2; folderT1 = c2;
folderT2a = c1; foundT1 = true;
} else { }
fail("Folders 1 and 2a not found in the destination"); if(c1.equals(folderT2) || c2.equals(folderT2)) {
foundT2 = true;
}
if(!foundT1) {
fail("Folder 1 not found in the destination");
}
if(!foundT2) {
fail("Folder 2 not found in the destination");
} }
// Folder 1 has 2*content + thumbnail // Folder 1 has 2*content + thumbnail
assertEquals(3, nodeService.getChildAssocs(folderT1).size()); assertEquals(3, nodeService.getChildAssocs(folderT1).size());
// Folder 2 has // Won't have the authority, as that gets skipped
assertEquals(3, nodeService.getChildAssocs(folderT1).size()); for(ChildAssociationRef r : nodeService.getChildAssocs(folderT1)) {
if(nodeService.getType(r.getChildRef()).equals(ContentModel.TYPE_AUTHORITY)) {
fail("Found authority as " + r.getChildRef() + " but it shouldn't be transfered!");
}
}
// And the correct things were left behind // Folder 2 has 2a but not 2b, since only
// 2a was transfered
assertEquals(1, nodeService.getChildAssocs(folderT2).size());
NodeRef folderT2a = nodeService.getChildAssocs(folderT2).get(0).getChildRef();
assertEquals(
nodeService.getProperty(folder2a, ContentModel.PROP_NAME),
nodeService.getProperty(folderT2a, ContentModel.PROP_NAME)
);
// Won't have Folder 2b, as it wasn't on the payload
for(ChildAssociationRef r : nodeService.getChildAssocs(folderT2)) {
assertNotSame(
nodeService.getProperty(folder2b, ContentModel.PROP_NAME),
nodeService.getProperty(r.getChildRef(), ContentModel.PROP_NAME)
);
}
// Folder 2a has content + thumbnail
assertEquals(2, nodeService.getChildAssocs(folderT2a).size());
// Won't have the zone, as that gets skipped
for(ChildAssociationRef r : nodeService.getChildAssocs(folderT2a)) {
if(nodeService.getType(r.getChildRef()).equals(ContentModel.TYPE_ZONE)) {
fail("Found zone as " + r.getChildRef() + " but it shouldn't be transfered!");
}
}
} }
/** /**
@@ -599,16 +638,6 @@ System.err.println("FT2 @ " + nodeService.getPath(folderT2));
assertEquals(true, td.getNodes().contains(content1_1)); assertEquals(true, td.getNodes().contains(content1_1));
} }
/**
* Test that, with a mock transfer service, we
* pick the right things to replicate and call
* the transfer service correctly.
*/
public void testReplicationExecution() throws Exception
{
// TODO
}
private NodeRef makeNode(NodeRef parent, QName nodeType) private NodeRef makeNode(NodeRef parent, QName nodeType)
{ {