Skip to content

Commit

Permalink
0001440: Implement simple conflict resolution for file sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanes committed Oct 18, 2013
1 parent a51276b commit ee4384c
Showing 1 changed file with 50 additions and 1 deletion.
Expand Up @@ -85,7 +85,8 @@ protected void test(ISymmetricEngine rootServer, ISymmetricEngine clientServer)
testTargetWins(rootServer, clientServer);

testManual(rootServer, clientServer);


testUpdateManual(rootServer,clientServer);
}

protected void testInitialLoadFromServerToClient(ISymmetricEngine rootServer,
Expand Down Expand Up @@ -286,6 +287,54 @@ protected void testManual(ISymmetricEngine rootServer,
List<OutgoingBatch> batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
assertEquals(1, batches.size());

allFile1Target.delete();

pullFiles();

assertEquals("server value", FileUtils.readFileToString(allFile1Target));

batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
assertEquals(0, batches.size());

}

protected void testUpdateManual(ISymmetricEngine rootServer,
ISymmetricEngine clientServer) throws Exception {
OutgoingBatches batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
List<OutgoingBatch> batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
assertEquals(0, batches.size());

IFileSyncService fileSyncService = rootServer.getFileSyncService();
FileTriggerRouter fileTriggerRouter = fileSyncService.getFileTriggerRouter("all","server_2_client");
fileTriggerRouter.setConflictStrategy(FileConflictStrategy.MANUAL);
fileSyncService.saveFileTriggerRouter(fileTriggerRouter);

pull("client");

File allFile1 = new File(allSvrSourceDir, "manual/test2.txt");
allFile1.getParentFile().mkdirs();
FileUtils.write(allFile1, "base value");

File allFile1Target = new File(allClntTargetDir, allFile1.getParentFile().getName() + "/" + allFile1.getName());
allFile1Target.getParentFile().mkdirs();

pullFiles();

assertEquals("base value", FileUtils.readFileToString(allFile1Target));
batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
assertEquals(0, batches.size());

FileUtils.write(allFile1, "new value",true);

pullFiles();

assertEquals("base valuenew value", FileUtils.readFileToString(allFile1Target));
batchesInError = rootServer.getOutgoingBatchService().getOutgoingBatchErrors(10);
batches = batchesInError.getBatchesForChannel(Constants.CHANNEL_FILESYNC);
assertEquals(0, batches.size());

}

protected boolean pullFiles() {
Expand Down

0 comments on commit ee4384c

Please sign in to comment.