Search in sources :

Example 86 with TestClient

use of org.syncany.tests.util.TestClient 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 87 with TestClient

use of org.syncany.tests.util.TestClient 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 88 with TestClient

use of org.syncany.tests.util.TestClient 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 89 with TestClient

use of org.syncany.tests.util.TestClient 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 90 with TestClient

use of org.syncany.tests.util.TestClient 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

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