Search in sources :

Example 61 with LocalTransferSettings

use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.

the class CleanupOperationTest method testCleanupManyUpsAfterCleanup.

@Test
public void testCleanupManyUpsAfterCleanup() throws Exception {
    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    CleanupOperationOptions options = new CleanupOperationOptions();
    options.setRemoveOldVersions(true);
    options.setMinKeepSeconds(0);
    // Run
    // A: Create some file versions
    clientA.createNewFile("file.jpg");
    for (int i = 1; i <= 4; i++) {
        clientA.changeFile("file.jpg");
        clientA.upWithForceChecksum();
    }
    // B: Sync down
    clientB.down();
    // A: Cleanup
    CleanupOperationResult cleanupOperationResult = clientA.cleanup(options);
    assertEquals(CleanupResultCode.OK, cleanupOperationResult.getResultCode());
    assertEquals(4, cleanupOperationResult.getMergedDatabaseFilesCount());
    assertEquals(3, cleanupOperationResult.getRemovedMultiChunksCount());
    assertEquals(1, cleanupOperationResult.getRemovedOldVersionsCount());
    // A: Continue to upload stuff ! <<<<<<<<<<<<<<<<<<<<<
    for (int i = 1; i <= 4; i++) {
        clientA.changeFile("file.jpg");
        clientA.upWithForceChecksum();
    }
    clientA.createNewFile("file2.jpg");
    for (int i = 1; i <= 4; i++) {
        clientA.changeFile("file2.jpg");
        clientA.upWithForceChecksum();
    }
    // B: Sync down
    clientB.down();
    TestAssertUtil.assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : CleanupOperationResult(org.syncany.operations.cleanup.CleanupOperationResult) LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) UnreliableLocalTransferSettings(org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) CleanupOperationOptions(org.syncany.operations.cleanup.CleanupOperationOptions) Test(org.junit.Test)

Aggregations

LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)61 Test (org.junit.Test)50 TestClient (org.syncany.tests.util.TestClient)46 File (java.io.File)33 CleanupOperationOptions (org.syncany.operations.cleanup.CleanupOperationOptions)21 UnreliableLocalTransferSettings (org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings)17 UpOperationOptions (org.syncany.operations.up.UpOperationOptions)13 CleanupOperationResult (org.syncany.operations.cleanup.CleanupOperationResult)8 FilenameFilter (java.io.FilenameFilter)7 InitOperationOptions (org.syncany.operations.init.InitOperationOptions)7 UpOperationResult (org.syncany.operations.up.UpOperationResult)7 Random (java.util.Random)6 ConfigTO (org.syncany.config.to.ConfigTO)6 StatusOperationOptions (org.syncany.operations.status.StatusOperationOptions)6 SqlDatabase (org.syncany.database.SqlDatabase)5 PluginOperationOptions (org.syncany.operations.plugin.PluginOperationOptions)5 PluginOperationResult (org.syncany.operations.plugin.PluginOperationResult)5 TimeUnit (org.syncany.operations.cleanup.CleanupOperationOptions.TimeUnit)4 DownOperationResult (org.syncany.operations.down.DownOperationResult)4 InitOperation (org.syncany.operations.init.InitOperation)4