Search in sources :

Example 61 with TransferSettings

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

the class EmptyFolderScenarioTest method testEmptyFolderCreateAndSync.

@Test
public void testEmptyFolderCreateAndSync() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Run
    clientA.createNewFolder("A-folder1");
    clientA.createNewFolder("A-folder2");
    clientA.createNewFolder("A-folder3");
    clientA.up();
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    clientB.createNewFolder("B-folder4");
    clientB.createNewFolder("B-folder5");
    clientB.up();
    SqlDatabase databaseB = clientB.loadLocalDatabase();
    DatabaseVersionHeader beforeDatabaseVersionHeader = databaseB.getLastDatabaseVersionHeader();
    // double-up, has caused problems
    clientB.up();
    DatabaseVersionHeader afterDatabaseVersionHeader = databaseB.getLastDatabaseVersionHeader();
    assertEquals("Nothing changed. Local database file should not change.", beforeDatabaseVersionHeader, afterDatabaseVersionHeader);
    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 62 with TransferSettings

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

the class FileTreeMoveToSubfolderScenarioTest method testCreateFileTreeAndMoveSubfolder.

@Test
public void testCreateFileTreeAndMoveSubfolder() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Run
    clientA.createNewFolder("A-folder1");
    clientA.createNewFolder("A-folder1/A-subfolder1");
    clientA.createNewFolder("A-folder1/A-subfolder2");
    clientA.createNewFolder("A-folder1/A-subfolder2/A-subsubfolder1");
    clientA.createNewFolder("A-folder1/A-subfolder2/A-subsubfolder2");
    TestFileUtil.createRandomFilesInDirectory(clientA.getLocalFile("A-folder1/A-subfolder1"), 500 * 1024, 15);
    clientA.up();
    clientB.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
    assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
    clientB.moveFile("A-folder1/A-subfolder1", "A-folder1/A-subfolder2/B-subsubfolder1");
    clientB.up();
    clientA.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 63 with TransferSettings

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

the class FilenameCapitalizationWindowsScenarioTest method testFilenameNonASCII.

@Test
public void testFilenameNonASCII() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Run
    // Non-ASCII
    clientA.createNewFile("Exposé");
    // Non-ASCII
    clientA.createNewFile("這是一個測試");
    // & is not allowed in XML
    clientA.createNewFile("One&Two");
    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 64 with TransferSettings

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

the class FolderPermissionChangeScenarioTest method testFolderPermissionChange.

@Test
public void testFolderPermissionChange() throws Exception {
    // Setup
    TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Run
    clientA.createNewFolder("Somefolder");
    clientA.upWithForceChecksum();
    clientB.createNewFolder("Somefolder");
    if (EnvironmentUtil.isUnixLikeOperatingSystem()) {
        Set<PosixFilePermission> expectedPosixPermissions = Files.getPosixFilePermissions(clientB.getLocalFile("Somefolder").toPath());
        Set<PosixFilePermission> changedPosixPermissions = PosixFilePermissions.fromString("rwxrwxrwx");
        Files.setPosixFilePermissions(clientB.getLocalFile("Somefolder").toPath(), changedPosixPermissions);
        clientB.down();
        assertEquals(1, clientB.getLocalFiles().size());
        assertEquals(PosixFilePermissions.toString(expectedPosixPermissions), PosixFilePermissions.toString(Files.getPosixFilePermissions(clientB.getLocalFile("Somefolder").toPath())));
    } else if (EnvironmentUtil.isWindows()) {
        DosFileAttributes expectedDosAttrs = Files.readAttributes(clientB.getLocalFile("Somefolder").toPath(), DosFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
        Files.setAttribute(clientB.getLocalFile("Somefolder").toPath(), "dos:hidden", true);
        Files.setAttribute(clientB.getLocalFile("Somefolder").toPath(), "dos:archive", true);
        Files.setAttribute(clientB.getLocalFile("Somefolder").toPath(), "dos:system", true);
        Files.setAttribute(clientB.getLocalFile("Somefolder").toPath(), "dos:readonly", true);
        clientB.down();
        assertEquals(1, clientB.getLocalFiles().size());
        DosFileAttributes actualDosAttrs = Files.readAttributes(clientB.getLocalFile("Somefolder").toPath(), DosFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
        assertEquals(LimitedDosFileAttributes.toString(expectedDosAttrs), LimitedDosFileAttributes.toString(actualDosAttrs));
    }
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : LimitedDosFileAttributes(org.syncany.util.LimitedDosFileAttributes) DosFileAttributes(java.nio.file.attribute.DosFileAttributes) TestClient(org.syncany.tests.util.TestClient) TransferSettings(org.syncany.plugins.transfer.TransferSettings) PosixFilePermission(java.nio.file.attribute.PosixFilePermission) Test(org.junit.Test)

Example 65 with TransferSettings

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

the class IgnoredFileScenarioTest method testIgnoredFileWildcard.

@Test
public void testIgnoredFileWildcard() throws Exception {
    // Scenario: A ignores files using wildcards, 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, "*.bak\nignoredarchive.r??");
    clientA.getConfig().getIgnoredFiles().loadPatterns();
    // A new/up
    clientA.createNewFile("ignoredfile.bak");
    clientA.createNewFile("nonignoredfile.bar");
    clientA.createNewFile("ignoredarchive.r01");
    clientA.up();
    clientB.down();
    // The ignored file should not exist at B
    assertTrue(clientA.getLocalFile("ignoredfile.bak").exists());
    assertFalse(clientB.getLocalFile("ignoredfile.bak").exists());
    assertTrue(clientA.getLocalFile("nonignoredfile.bar").exists());
    assertTrue(clientB.getLocalFile("nonignoredfile.bar").exists());
    assertTrue(clientA.getLocalFile("ignoredarchive.r01").exists());
    assertFalse(clientB.getLocalFile("ignoredarchive.r01").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

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