use of org.syncany.tests.util.TestSqlDatabase in project syncany by syncany.
the class RenameFileWithDiffModifiedDateScenarioTest method testChangedModifiedDate.
@Test
public void testChangedModifiedDate() throws Exception {
// Setup
TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
// Run
// A, create two files with identical content and change mod. date of one of them
clientA.createNewFile("A-file1.jpg", 50 * 1024);
clientA.copyFile("A-file1.jpg", "A-file1-with-different-modified-date.jpg");
clientA.getLocalFile("A-file1.jpg").setLastModified(0);
clientA.up();
// B, down, then move BOTH files
clientB.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
clientB.moveFile("A-file1.jpg", "A-file1-moved.jpg");
clientB.moveFile("A-file1-with-different-modified-date.jpg", "A-file1-with-different-modified-date-moved.jpg");
clientB.up();
TestSqlDatabase clientDatabaseB = clientB.loadLocalDatabase();
PartialFileHistory file1Orig = clientDatabaseB.getFileHistoryWithFileVersions("A-file1-moved.jpg");
PartialFileHistory file1WithDiffLastModDate = clientDatabaseB.getFileHistoryWithFileVersions("A-file1-with-different-modified-date-moved.jpg");
assertNotNull(file1Orig);
assertNotNull(file1WithDiffLastModDate);
FileVersion fileVersion1OrigV1 = file1Orig.getFileVersion(1);
FileVersion fileVersion1OrigV2 = file1Orig.getFileVersion(2);
FileVersion fileVersion1WithDiffLastModDateV1 = file1WithDiffLastModDate.getFileVersion(1);
FileVersion fileVersion1WithDiffLastModDateV2 = file1WithDiffLastModDate.getFileVersion(2);
assertNotNull(fileVersion1OrigV1);
assertNotNull(fileVersion1OrigV2);
assertNotNull(fileVersion1WithDiffLastModDateV1);
assertNotNull(fileVersion1WithDiffLastModDateV2);
assertEquals("A-file1.jpg", fileVersion1OrigV1.getName());
assertEquals("A-file1-moved.jpg", fileVersion1OrigV2.getName());
assertEquals("A-file1-with-different-modified-date.jpg", fileVersion1WithDiffLastModDateV1.getName());
assertEquals("A-file1-with-different-modified-date-moved.jpg", fileVersion1WithDiffLastModDateV2.getName());
// Tear down
clientA.deleteTestData();
clientB.deleteTestData();
}
use of org.syncany.tests.util.TestSqlDatabase in project syncany by syncany.
the class FileSystemActionReconciliatorTest method testFileSystemActionReconDeleteNonExistingFolder.
@Test
public void testFileSystemActionReconDeleteNonExistingFolder() throws Exception {
// Setup
TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
Config testConfigA = clientA.getConfig();
// - Create first database version
clientA.createNewFolder("new folder/some subfolder");
clientA.upWithForceChecksum();
// Delete this!
clientA.deleteFile("new folder/some subfolder");
// - Create new version (delete folder)
TestSqlDatabase sqlDatabaseA = new TestSqlDatabase(testConfigA);
PartialFileHistory folderFileHistoryWithLastVersion = sqlDatabaseA.getFileHistoryWithLastVersion("new folder/some subfolder");
FileVersion deletedFolderVersion = folderFileHistoryWithLastVersion.getLastVersion().clone();
deletedFolderVersion.setStatus(FileStatus.DELETED);
deletedFolderVersion.setVersion(deletedFolderVersion.getVersion() + 1);
PartialFileHistory deletedFolderVersionHistory = new PartialFileHistory(folderFileHistoryWithLastVersion.getFileHistoryId());
deletedFolderVersionHistory.addFileVersion(deletedFolderVersion);
DatabaseVersion winnersDatabaseVersion = TestDatabaseUtil.createDatabaseVersion(sqlDatabaseA.getLastDatabaseVersionHeader());
winnersDatabaseVersion.addFileHistory(deletedFolderVersionHistory);
// - Create memory database with this version
MemoryDatabase winnersDatabase = new MemoryDatabase();
winnersDatabase.addDatabaseVersion(winnersDatabaseVersion);
// Run! Finally!
DownOperationResult outDownOperationResult = new DownOperationResult();
FileSystemActionReconciliator fileSystemActionReconciliator = new FileSystemActionReconciliator(testConfigA, outDownOperationResult.getChangeSet());
List<FileSystemAction> fileSystemActions = fileSystemActionReconciliator.determineFileSystemActions(winnersDatabase);
assertNotNull(fileSystemActions);
assertEquals(0, fileSystemActions.size());
// Tear down
clientA.deleteTestData();
}
Aggregations