Search in sources :

Example 11 with TestClient

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

the class Issue429ScenarioTest method testSpecificQueue.

@Ignore
public void testSpecificQueue() throws Exception {
    String[] commands = new String[] { "A5", "B5", "B0", "B0", "A7", "A3", "B6", "B1", "A7", "A6", "A7", "B5", "A1", "A0", "B6", "A5", "B0", "B6", "A7", "A0", "B7", "A5", "B1", "B7", "A6", "B7", "A0", "A3", "B4", "B7", "A2", "A7", "A4", "B1", "B4", "A3", "B0", "A0", "A4", "A6", "B3", "B3", "B2", "A1", "B1", "B3", "A1", "A7", "B7", "B7", "A1", "B4", "A4", "A4", "A1", "B4", "A6", "B2", "B5", "B7", "A5", "B2", "B2", "B3", "B1", "B5", "B3", "B1", "B3", "B2", "B4" };
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    for (String command : commands) {
        int choice = Integer.parseInt(command.substring(1));
        if (command.contains("A")) {
            performAction(clientA, choice);
        } else {
            performAction(clientB, choice);
        }
    }
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) Ignore(org.junit.Ignore)

Example 12 with TestClient

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

the class ManySyncUpsAndDatabaseFileCleanupScenarioTest method testManySyncUpsAndDatabaseFileCleanup.

@Test
public void testManySyncUpsAndDatabaseFileCleanup() throws Exception {
    // Setup 
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    // ROUND 1: many sync up (no cleanup expected here)		
    for (int i = 1; i <= 15; i++) {
        clientA.createNewFile("file" + i, 1);
        clientA.up();
    }
    for (int i = 1; i <= 15; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file SHOULD exist: " + expectedDatabaseFile, expectedDatabaseFile.exists());
    }
    // ROUND 2: 1x sync up (cleanup expected!)
    clientA.createNewFile("file16", 1);
    clientA.up();
    // Force cleanup
    clientA.cleanup();
    for (int i = 1; i <= 15; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file should NOT exist: " + expectedDatabaseFile, !expectedDatabaseFile.exists());
    }
    for (int i = 17; i <= 17; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file SHOULD exist: " + expectedDatabaseFile, expectedDatabaseFile.exists());
    }
    // ROUND 3: many sync up (no cleanup expected here)		
    for (int i = 17; i <= 30; i++) {
        clientA.createNewFile("file" + i, 1);
        clientA.up();
    }
    for (int i = 1; i <= 16; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file should NOT exist: " + expectedDatabaseFile, !expectedDatabaseFile.exists());
    }
    for (int i = 17; i <= 31; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file SHOULD exist: " + expectedDatabaseFile, expectedDatabaseFile.exists());
    }
    // ROUND 4: 1x sync up (cleanup expected!)
    clientA.createNewFile("file31", 1);
    clientA.up();
    CleanupOperationOptions options = new CleanupOperationOptions();
    options.setForce(true);
    // Force cleanup 
    clientA.cleanup(options);
    for (int i = 1; i <= 32; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file should NOT exist: " + expectedDatabaseFile, !expectedDatabaseFile.exists());
    }
    for (int i = 33; i <= 33; i++) {
        DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
        File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
        assertTrue("Database file SHOULD exist: " + expectedDatabaseFile, expectedDatabaseFile.exists());
    }
    // Tear down
    TestClient clientB = new TestClient("B", testConnection);
    clientB.down();
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) DatabaseRemoteFile(org.syncany.plugins.transfer.files.DatabaseRemoteFile) CleanupOperationOptions(org.syncany.operations.cleanup.CleanupOperationOptions) DatabaseRemoteFile(org.syncany.plugins.transfer.files.DatabaseRemoteFile) File(java.io.File) Test(org.junit.Test)

Example 13 with TestClient

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

the class ManySyncUpsAndOtherClientSyncDownScenarioTest method testManySyncUpsAndOtherClientSyncDown.

@Test
public void testManySyncUpsAndOtherClientSyncDown() throws Exception {
    // Setup 
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // ROUND 1: many sync up (cleanups expected)
    for (int i = 1; i <= 50; i++) {
        clientA.createNewFile("file" + i, 1);
        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 14 with TestClient

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

the class IdenticalFileMoveScenarioTest method testIdenticalFileMove.

@Test
public void testIdenticalFileMove() throws Exception {
    // Setup 
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    // Create folder structure
    clientA.createNewFolder("folder");
    clientA.createNewFolder("folder/subfolder1");
    clientA.createNewFolder("folder/subfolder2");
    // Create identical files
    clientA.createNewFile("folder/subfolder1/A-file1.jpg", 100);
    clientA.copyFile("folder/subfolder1/A-file1.jpg", "folder/subfolder2/A-file1.jpg");
    clientA.up();
    // Move the two identical files
    clientA.moveFile("folder", "moved_folder");
    clientA.up();
    // A just upped, so there should not be changes.
    assertFalse(clientA.status().getChangeSet().hasChanges());
    // Check if the file histories were based on the correct originals
    LsOperationOptions options = new LsOperationOptions();
    options.setFetchHistories(true);
    options.setPathExpression("moved_folder/subfolder1/");
    LsOperationResult lsOperationResult = clientA.ls(options);
    for (PartialFileHistory fileHistory : lsOperationResult.getFileVersions().values()) {
        assertTrue(fileHistory.getFileVersion(2).getPath().endsWith(fileHistory.getFileVersion(1).getPath()));
    }
    options.setPathExpression("moved_folder/subfolder2/");
    lsOperationResult = clientA.ls(options);
    for (PartialFileHistory fileHistory : lsOperationResult.getFileVersions().values()) {
        assertTrue(fileHistory.getFileVersion(2).getPath().endsWith(fileHistory.getFileVersion(1).getPath()));
    }
    // Tear down
    clientA.deleteTestData();
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) LsOperationOptions(org.syncany.operations.ls.LsOperationOptions) PartialFileHistory(org.syncany.database.PartialFileHistory) LsOperationResult(org.syncany.operations.ls.LsOperationResult) Test(org.junit.Test)

Example 15 with TestClient

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

the class IgnoredFileScenarioTest method testIgnoredDirectory.

@Test
public void testIgnoredDirectory() throws Exception {
    // Scenario: A ignores files with a regular expression, creates it then ups, B should not have the file
    // Setup 
    File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    //Create ignore file and reload it
    File syncanyIgnore = clientA.getLocalFile(Config.FILE_IGNORE);
    TestFileUtil.createFileWithContent(syncanyIgnore, "builds");
    clientA.getConfig().getIgnoredFiles().loadPatterns();
    // A new/up
    clientA.createNewFolder("builds");
    clientA.createNewFile("builds/test.txt");
    clientA.up();
    clientB.down();
    // The ignored file should not exist at B
    assertTrue(clientA.getLocalFile("builds/test.txt").exists());
    assertFalse(clientB.getLocalFile("builds/test.txt").exists());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
    TestFileUtil.deleteDirectory(tempDir);
}
Also used : TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) File(java.io.File) 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