Search in sources :

Example 76 with TestClient

use of org.syncany.tests.util.TestClient in project syncany by syncany.

the class ManyRenamesScenarioTest method testManyRenames.

@Test
public void testManyRenames() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // A new/up
    clientA.createNewFile("A-original");
    clientA.up();
    // B down/move/up
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    clientB.moveFile("A-original", "B-moved");
    clientB.up();
    // A down/move/up
    clientA.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    clientA.moveFile("B-moved", "A-moved");
    clientA.up();
    // B down only
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // A down/move/up
    clientA.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    clientA.moveFile("A-moved", "A-moved-again");
    clientA.up();
    // B down/move/up
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // same filename as above!
    clientB.moveFile("A-moved-again", "B-moved");
    clientB.up();
    // A down/move/up
    clientA.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // same filename as above!
    clientA.moveFile("B-moved", "A-moved");
    clientA.up();
    // B down only
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Test(org.junit.Test)

Example 77 with TestClient

use of org.syncany.tests.util.TestClient in project syncany by syncany.

the class ManySyncUpsAndOtherClientSyncDownScenarioTest method testManySyncUpsAndOtherClientSyncDownSameFileAddRemove.

@Test
public void testManySyncUpsAndOtherClientSyncDownSameFileAddRemove() throws Exception {
    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // TODO Test not finished
    // ROUND 1: many sync up (cleanups expected)
    String[] names = new String[] { "one", "two", "three", "four", "five" };
    int nameIndex = 0;
    for (int i = 1; i <= 20; i++) {
        String filename = names[nameIndex++ % names.length];
        if (clientA.getLocalFile(filename).exists()) {
            clientA.deleteFile(filename);
        } else {
            clientA.createNewFile(filename);
        }
        clientA.up();
    }
    // ROUND 2: sync down by B
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) Test(org.junit.Test)

Example 78 with TestClient

use of org.syncany.tests.util.TestClient in project syncany by syncany.

the class LongRunningLargeFileScenarioTest method testLargeFile.

private void testLargeFile(long size) throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    Logging.disableLogging();
    logln("NOTE: This test can take several minutes!");
    logln("Disabling console logging for this test; Too much output/overhead.");
    logln("");
    // A
    logln("Creating large file for scenario (" + (size / 1024L / 1024L) + " MB) ...");
    clientA.createNewFile("A-large-file.zip", size);
    logln("Done creating large file. Now creating checksum ...");
    String checksumFileA = StringUtil.toHex(TestFileUtil.createChecksum(clientA.getLocalFile("A-large-file.zip")));
    logln("Done. Checksum is: " + checksumFileA);
    logln("clientA.up() started.");
    clientA.up();
    logln("clientA.up() completed.");
    logln("Freeing up space, deleting file at client A ...");
    clientA.deleteFile("A-large-file.zip");
    logln("Deleting done.");
    // B
    logln("clientB.down(); started.");
    clientB.down();
    logln("clientB.down(); completed.");
    String checksumFileB = StringUtil.toHex(TestFileUtil.createChecksum(clientB.getLocalFile("A-large-file.zip")));
    logln("Done. Checksum is: " + checksumFileB);
    logln("Freeing up space, deleting file at client B ...");
    clientB.deleteFile("A-large-file.zip");
    logln("Deleting done.");
    try {
        assertEquals("File checksum should be equal. ", checksumFileA, checksumFileB);
        assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    } finally {
        // Tear down
        clientA.deleteTestData();
        clientB.deleteTestData();
    }
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings)

Example 79 with TestClient

use of org.syncany.tests.util.TestClient in project syncany by syncany.

the class LongRunningNewAndDeleteScenarioTest method testLongRunningNewAndDeleteFilesNoConflicts.

@Test
public void testLongRunningNewAndDeleteFilesNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Disable logging
    logger.log(Level.INFO, "NOTE: This test can take several minutes!");
    logger.log(Level.INFO, "Disabling console logging for this test; Too much output/overhead.");
    Logging.disableLogging();
    // Run
    for (int round = 1; round < 30; round++) {
        // A
        for (int i = 1; i < 100; i++) {
            clientA.createNewFile("A-file-with-size-" + i + ".jpg", i);
        }
        clientA.up();
        // B
        clientB.down();
        assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
        assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
        for (int i = 1; i < 100; i++) {
            clientB.changeFile("A-file-with-size-" + i + ".jpg");
        }
        clientB.up();
        // A
        clientA.down();
        assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
        assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
        for (int i = 1; i < 100; i++) {
            clientA.deleteFile("A-file-with-size-" + i + ".jpg");
        }
        clientA.up();
        // B
        clientB.down();
        assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
        assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    }
    fail("No asserts yet.");
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Test(org.junit.Test)

Example 80 with TestClient

use of org.syncany.tests.util.TestClient in project syncany by syncany.

the class SingleFileNoConflictsScenarioTest method testSingleFileDeleteNoConflicts.

@Test
public void testSingleFileDeleteNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Create files and upload
    clientA.createNewFile("file");
    clientA.up();
    clientB.down();
    assertFileEquals(clientA.getLocalFile("file"), clientB.getLocalFile("file"));
    clientB.deleteFile("file");
    clientB.up();
    clientA.down();
    assertFalse("Deleted file should not exist.", clientA.getLocalFile("file").exists());
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    // Cleanup
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Test(org.junit.Test)

Aggregations

TestClient (org.syncany.tests.util.TestClient)126 Test (org.junit.Test)122 TransferSettings (org.syncany.plugins.transfer.TransferSettings)65 LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)53 File (java.io.File)50 CleanupOperationOptions (org.syncany.operations.cleanup.CleanupOperationOptions)31 UnreliableLocalTransferSettings (org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings)28 UpOperationOptions (org.syncany.operations.up.UpOperationOptions)23 CleanupOperationResult (org.syncany.operations.cleanup.CleanupOperationResult)14 FilenameFilter (java.io.FilenameFilter)11 StorageException (org.syncany.plugins.transfer.StorageException)11 StatusOperationOptions (org.syncany.operations.status.StatusOperationOptions)10 MultichunkRemoteFile (org.syncany.plugins.transfer.files.MultichunkRemoteFile)10 DownOperationResult (org.syncany.operations.down.DownOperationResult)9 UpOperationResult (org.syncany.operations.up.UpOperationResult)8 DatabaseRemoteFile (org.syncany.plugins.transfer.files.DatabaseRemoteFile)6 SqlDatabase (org.syncany.database.SqlDatabase)5 TimeUnit (org.syncany.operations.cleanup.CleanupOperationOptions.TimeUnit)5 PluginOperationOptions (org.syncany.operations.plugin.PluginOperationOptions)5 PluginOperationResult (org.syncany.operations.plugin.PluginOperationResult)5