Search in sources :

Example 66 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class RenameToExistingFileScenarioTest method testRenameFileButDestinationExists.

@Test
public void testRenameFileButDestinationExists() throws Exception {
    // Scenario: A moves a file, but B creates another file at the same destination
    // 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());
    // A moves, and up
    clientA.moveFile("A-original", "A-moved");
    clientA.up();
    // B creates file at same location
    // << same as above
    clientB.createNewFile("A-moved");
    clientB.down();
    assertConflictingFileExists("A-moved", clientB.getLocalFilesExcludeLockedAndNoRead());
    // Sync them
    clientB.sync();
    clientA.sync();
    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 67 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class RestrictedXmlCharInFilenameScenarioTest method testEmptyFileCreateAndSync.

@Test
public void testEmptyFileCreateAndSync() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // A
    clientA.createNewFile("File|\u0002|", 100);
    clientA.up();
    // B
    clientB.down();
    assertFileEquals(clientA.getLocalFile("File|\u0002|"), clientB.getLocalFile("File|\u0002|"));
    assertEquals(clientB.getLocalFile("File|\u0002|").length(), 100);
    // 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 68 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class SingleFolderNoConflictsScenarioTest method testFolderNonEmptyMove1NoConflicts.

@Test
public void testFolderNonEmptyMove1NoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Create files and upload
    clientA.createNewFolder("folder");
    clientA.createNewFile("folder/file");
    clientA.up();
    clientB.down();
    clientB.moveFile("folder", "moved");
    clientB.up();
    clientA.down();
    assertFalse("Deleted folder should not exist.", clientA.getLocalFile("folder").exists());
    assertFalse("Deleted file should not exist.", clientA.getLocalFile("folder/file").exists());
    assertFileEquals(clientA.getLocalFile("moved"), clientB.getLocalFile("moved"));
    assertFileEquals(clientA.getLocalFile("moved/file"), clientB.getLocalFile("moved/file"));
    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)

Example 69 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class SingleFolderNoConflictsScenarioTest method testFolderEmptyDeleteNoConflicts.

@Test
public void testFolderEmptyDeleteNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Create files and upload
    clientA.createNewFolder("folder");
    clientA.up();
    clientB.down();
    clientB.deleteFile("folder");
    clientB.up();
    clientA.down();
    assertFalse("Deleted folder should not exist.", clientA.getLocalFile("folder").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)

Example 70 with TransferSettings

use of org.syncany.plugins.transfer.TransferSettings in project syncany by syncany.

the class SingleFolderNoConflictsScenarioTest method testFolderNonEmptyNewNoConflicts.

@Test
public void testFolderNonEmptyNewNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Create files and upload
    clientA.createNewFolder("folder");
    clientA.createNewFile("folder/file");
    clientA.up();
    clientB.down();
    assertFileEquals(clientA.getLocalFile("folder"), clientB.getLocalFile("folder"));
    assertFileEquals(clientA.getLocalFile("folder/file"), clientB.getLocalFile("folder/file"));
    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

TransferSettings (org.syncany.plugins.transfer.TransferSettings)78 Test (org.junit.Test)67 TestClient (org.syncany.tests.util.TestClient)65 File (java.io.File)20 LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)10 TransferPlugin (org.syncany.plugins.transfer.TransferPlugin)7 SqlDatabase (org.syncany.database.SqlDatabase)5 DownOperationResult (org.syncany.operations.down.DownOperationResult)4 StatusOperationResult (org.syncany.operations.status.StatusOperationResult)4 UpOperationOptions (org.syncany.operations.up.UpOperationOptions)4 UpOperationResult (org.syncany.operations.up.UpOperationResult)4 CreateFileTree (org.syncany.tests.integration.scenarios.framework.CreateFileTree)4 IOException (java.io.IOException)3 RandomAccessFile (java.io.RandomAccessFile)3 Path (java.nio.file.Path)3 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)3 Config (org.syncany.config.Config)3 ConfigTO (org.syncany.config.to.ConfigTO)3 PartialFileHistory (org.syncany.database.PartialFileHistory)3 FileHistoryId (org.syncany.database.PartialFileHistory.FileHistoryId)3