Search in sources :

Example 16 with TransferSettings

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

the class EmptyFileScenarioTest 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);
    // Run 
    clientA.createNewFile("A-file1.jpg", 0);
    clientA.up();
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    clientB.createNewFile("B-file2", 0);
    clientB.moveFile("A-file1.jpg", "B-file1-moved");
    clientB.up();
    SqlDatabase database = clientB.loadLocalDatabase();
    DatabaseVersionHeader lastDatabaseVersionHeaderBeforeUp = database.getLastDatabaseVersionHeader();
    // double-up, has caused problems
    clientB.up();
    DatabaseVersionHeader lastDatabaseVersionHeaderAfterUp = database.getLastDatabaseVersionHeader();
    assertEquals("Nothing changed. Local database file should not change.", lastDatabaseVersionHeaderBeforeUp, lastDatabaseVersionHeaderAfterUp);
    clientA.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    Map<String, File> beforeSyncDownFileList = clientB.getLocalFilesExcludeLockedAndNoRead();
    // double-down, has caused problems		
    clientA.down();
    assertFileListEquals("No change in file lists expected. Nothing changed", beforeSyncDownFileList, clientA.getLocalFilesExcludeLockedAndNoRead());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : TestClient(org.syncany.tests.util.TestClient) SqlDatabase(org.syncany.database.SqlDatabase) TransferSettings(org.syncany.plugins.transfer.TransferSettings) DatabaseVersionHeader(org.syncany.database.DatabaseVersionHeader) File(java.io.File) Test(org.junit.Test)

Example 17 with TransferSettings

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

the class FileLockedScenarioTest method testPermissionDeniedNotReadable.

@Test
public void testPermissionDeniedNotReadable() throws Exception {
    if (EnvironmentUtil.isWindows()) {
        // Not possible in windows
        return;
    }
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    // Run
    File noReadPermissionFile = clientA.createNewFile("no-read-permission-file");
    Path filePath = Paths.get(noReadPermissionFile.getAbsolutePath());
    Set<PosixFilePermission> perms = new HashSet<PosixFilePermission>();
    perms.add(PosixFilePermission.OWNER_READ);
    perms.add(PosixFilePermission.GROUP_READ);
    perms.add(PosixFilePermission.OTHERS_READ);
    Files.setPosixFilePermissions(filePath, perms);
    runUpAndTestForConsistentDatabase(testConnection, clientA);
    // Tear down
    clientA.deleteTestData();
}
Also used : Path(java.nio.file.Path) TestClient(org.syncany.tests.util.TestClient) LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TransferSettings(org.syncany.plugins.transfer.TransferSettings) PosixFilePermission(java.nio.file.attribute.PosixFilePermission) RandomAccessFile(java.io.RandomAccessFile) LockFile(org.syncany.tests.integration.scenarios.framework.LockFile) File(java.io.File) UnlockFile(org.syncany.tests.integration.scenarios.framework.UnlockFile) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 18 with TransferSettings

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

the class FileLockedScenarioTest method testLockUnlockFile.

@Test
public void testLockUnlockFile() throws Exception {
    final TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    final TestClient clientA = new TestClient("A", testConnection);
    final TestClient clientB = new TestClient("B", testConnection);
    ClientActions.run(clientA, null, new CreateFileTree(), new Executable() {

        @Override
        public void execute() throws Exception {
            clientA.upWithForceChecksum();
            clientB.down();
            assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
            assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
        }
    });
    ClientActions.run(clientA, null, new LockFile(), new Executable() {

        @Override
        public void execute() throws Exception {
            clientA.upWithForceChecksum();
            clientB.down();
            assertEquals(clientA.getLocalFilesExcludeLockedAndNoRead().size(), clientB.getLocalFilesExcludeLockedAndNoRead().size() - 1);
        }
    });
    ClientActions.run(clientA, null, new UnlockFile(), new Executable() {

        @Override
        public void execute() throws Exception {
            clientA.upWithForceChecksum();
            clientB.down();
            assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
            assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
        }
    });
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : UnlockFile(org.syncany.tests.integration.scenarios.framework.UnlockFile) LockFile(org.syncany.tests.integration.scenarios.framework.LockFile) TestClient(org.syncany.tests.util.TestClient) CreateFileTree(org.syncany.tests.integration.scenarios.framework.CreateFileTree) LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TransferSettings(org.syncany.plugins.transfer.TransferSettings) Executable(org.syncany.tests.integration.scenarios.framework.Executable) Test(org.junit.Test)

Example 19 with TransferSettings

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

the class FilenameCapitalizationWindowsScenarioTest method testFilenameCapitalizationWindows.

// TODO [medium] Windows: LARGE/small capitalization --> Dropbox makes a file "name (Case Conflict 1)"; define expected/desired behavior
@Test
public void testFilenameCapitalizationWindows() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Run
    clientA.createNewFile("FILENAME-FOR-WINDOWS");
    clientA.createNewFile("filename-for-windows");
    clientA.createNewFile("Filename-For-Windows");
    clientA.upWithForceChecksum();
    assertEquals("There should be three files.", 3, clientA.getLocalFilesExcludeLockedAndNoRead().size());
    clientB.down();
    assertEquals("There should be three files.", 3, clientB.getLocalFilesExcludeLockedAndNoRead().size());
    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 20 with TransferSettings

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

the class SingleFileNoConflictsScenarioTest method testComplexNoConflicts.

@Test
public void testComplexNoConflicts() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    TestClient clientC = new TestClient("C", testConnection);
    // Test
    clientA.createNewFile("1");
    clientA.upWithForceChecksum();
    clientB.down();
    assertFileEquals(clientA.getLocalFile("1"), clientB.getLocalFile("1"));
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    clientA.moveFile("1", "2");
    assertFileEquals(clientA.getLocalFile("2"), clientB.getLocalFile("1"));
    clientA.upWithForceChecksum();
    clientA.upWithForceChecksum();
    clientB.down();
    assertFileEquals(clientA.getLocalFile("2"), clientB.getLocalFile("2"));
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    clientC.down();
    assertFileEquals(clientA.getLocalFile("2"), clientC.getLocalFile("2"));
    assertFileEquals(clientB.getLocalFile("2"), clientC.getLocalFile("2"));
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientC.getLocalFilesExcludeLockedAndNoRead());
    assertFileListEquals(clientB.getLocalFilesExcludeLockedAndNoRead(), clientC.getLocalFilesExcludeLockedAndNoRead());
    clientC.createNewFile("3");
    clientC.changeFile("2");
    clientC.upWithForceChecksum();
    clientA.down();
    assertFileEquals(clientC.getLocalFile("3"), clientA.getLocalFile("3"));
    assertFileListEquals(clientC.getLocalFilesExcludeLockedAndNoRead(), clientA.getLocalFilesExcludeLockedAndNoRead());
    clientB.down();
    assertFileEquals(clientC.getLocalFile("3"), clientB.getLocalFile("3"));
    assertFileListEquals(clientC.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    clientC.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientC.getLocalFilesExcludeLockedAndNoRead());
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
    clientC.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