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();
}
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();
}
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();
}
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();
}
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);
}
Aggregations