Search in sources :

Example 6 with TimeUnit

use of org.syncany.operations.cleanup.CleanupOperationOptions.TimeUnit in project syncany by syncany.

the class CleanupOperationTest method testFullyDeletingDeletedFiles.

@Test
public void testFullyDeletingDeletedFiles() throws Exception {
    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    java.sql.Connection databaseConnectionA = clientA.getConfig().createDatabaseConnection();
    CleanupOperationOptions options = new CleanupOperationOptions();
    options.setRemoveOldVersions(true);
    options.setMinSecondsBetweenCleanups(0);
    options.setPurgeFileVersionSettings(new TreeMap<Long, TimeUnit>());
    options.setMinKeepSeconds(2);
    clientA.createNewFile("file.jpg");
    clientA.up();
    clientA.deleteFile("file.jpg");
    clientA.up();
    clientA.cleanup(options);
    assertEquals("2", TestSqlUtil.runSqlSelect("select count(*) from fileversion", databaseConnectionA));
    Thread.sleep(3000);
    clientA.cleanup(options);
    assertEquals("0", TestSqlUtil.runSqlSelect("select count(*) from fileversion", databaseConnectionA));
    // Tear down
    clientA.deleteTestData();
}
Also used : 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) TimeUnit(org.syncany.operations.cleanup.CleanupOperationOptions.TimeUnit) Test(org.junit.Test)

Aggregations

TimeUnit (org.syncany.operations.cleanup.CleanupOperationOptions.TimeUnit)6 Test (org.junit.Test)5 CleanupOperationOptions (org.syncany.operations.cleanup.CleanupOperationOptions)5 UnreliableLocalTransferSettings (org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings)5 TestClient (org.syncany.tests.util.TestClient)5 LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)4 CleanupOperationResult (org.syncany.operations.cleanup.CleanupOperationResult)3 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 FileVersion (org.syncany.database.FileVersion)1 FileHistoryId (org.syncany.database.PartialFileHistory.FileHistoryId)1 StorageException (org.syncany.plugins.transfer.StorageException)1 TransferManager (org.syncany.plugins.transfer.TransferManager)1 TransactionAware (org.syncany.plugins.transfer.features.TransactionAware)1