use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class Issue303ScenarioTest method testIssue303DeleteMovedFile.
@Test
public void testIssue303DeleteMovedFile() throws Exception {
/*
* This test moves a file and then deletes it. In issue #303, clients
* that had not moved the file already did not delete the file. It was left over
* leading to re-synchronization with the next 'up'.
*/
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
clientA.createNewFile("Hello Christian, did something break?.txt");
clientA.upWithForceChecksum();
clientB.down();
clientB.moveFile("Hello Christian, did something break?.txt", "Hello Christian, did something break (filename conflict).txt");
clientB.upWithForceChecksum();
clientB.deleteFile("Hello Christian, did something break (filename conflict).txt");
clientB.upWithForceChecksum();
clientA.down();
assertFalse("File should have been deleted.", clientA.getLocalFile("Hello Christian, did something break?.txt").exists());
assertFalse("File should not have been created.", clientA.getLocalFile("Hello Christian, did something break (filename conflict).txt").exists());
// Tear down
clientB.deleteTestData();
clientA.deleteTestData();
}
use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class Issue316ScenarioTest method testIssue316CleanupThenDeleteFile.
@Test
public void testIssue316CleanupThenDeleteFile() throws Exception {
/*
* This is a test for issue #316. It creates a situation in which a 'down'
* fails after a cleanup. In that first down, the local database is deleted
* entirely, so that all databases are downloaded again, so all remote file
* versions are compared to "null". In this bug, comparing a deleted file version
* to a local existing file failed, because this case was thought to not happen
* ever.
*/
// Setup
UnreliableLocalTransferSettings testConnection = TestConfigUtil.createTestUnreliableLocalConnection(Arrays.asList(new String[] { // << 3 retries!
"rel=(5|6|7) .+download.+multichunk" }));
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
java.sql.Connection databaseConnectionB = clientB.getConfig().createDatabaseConnection();
CleanupOperationOptions cleanupOptionsKeepOne = new CleanupOperationOptions();
cleanupOptionsKeepOne.setMaxDatabaseFiles(1);
cleanupOptionsKeepOne.setForce(true);
clientA.createNewFile("Kazam_screencast_00010.mp4");
clientA.upWithForceChecksum();
clientB.down();
assertTrue(clientB.getLocalFile("Kazam_screencast_00010.mp4").exists());
clientA.createNewFile("SomeFileTOIncreaseTheDatabaseFileCount");
clientA.upWithForceChecksum();
CleanupOperationResult cleanupResult = clientA.cleanup(cleanupOptionsKeepOne);
assertEquals(CleanupResultCode.OK, cleanupResult.getResultCode());
clientA.deleteFile("Kazam_screencast_00010.mp4");
clientA.upWithForceChecksum();
// First 'down' of client B after the cleanup.
// This fails AFTER the local database was wiped.
boolean downFailedAtB = false;
try {
clientB.down();
} catch (Exception e) {
downFailedAtB = true;
}
assertTrue("Down operation should have failed.", downFailedAtB);
assertEquals("0", TestSqlUtil.runSqlSelect("select count(*) from databaseversion", databaseConnectionB));
assertEquals("0", TestSqlUtil.runSqlSelect("select count(*) from fileversion", databaseConnectionB));
assertEquals("0", TestSqlUtil.runSqlSelect("select count(*) from known_databases", databaseConnectionB));
// Second 'down' of client B; This should delete the file 'Kazam_screencast_00010.mp4',
// because it matches the checksum of the 'DELETED' entry
clientB.down();
assertConflictingFileNotExists("Kazam_screencast_00010.mp4", clientB.getLocalFiles());
assertFalse(clientB.getLocalFile("Kazam_screencast_00010.mp4").exists());
// Tear down
clientB.deleteTestData();
clientA.deleteTestData();
}
use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class Issue429ScenarioTest method testIssue492UploadDuplicateFile.
@Ignore
public void testIssue492UploadDuplicateFile() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
TestClient clientC = new TestClient("C", testConnection);
clientA.createNewFile("file1.txt", 1024);
clientA.upWithForceChecksum();
FileUtils.copyFile(clientA.getLocalFile("file1.txt"), clientB.getLocalFile("file2.txt"));
clientB.down();
clientB.up();
clientA.deleteFile("file1.txt");
clientA.deleteFile("file2.txt");
clientA.upWithForceChecksum();
clientB.cleanup();
clientC.down();
// Tear down
//clientB.deleteTestData();
//clientA.deleteTestData();
}
use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class Issue520NoResumeOnCorruptXmlScenarioTest method testCorruptTransactionListFile.
@Test
public void testCorruptTransactionListFile() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
clientA.createNewFile("file1.txt", 1024);
clientA.upWithForceChecksum();
TestFileUtil.createFileWithContent(new File(clientA.getConfig().getAppDir(), "/state/transaction-list.txt"), "INVALID");
clientA.createNewFile("file2.txt", 1024);
// This did FAIL due to an XML parsing exception
clientA.upWithForceChecksum();
assertEquals("There should be exactly two database files", 2, new File(testConnection.getPath() + "/databases").listFiles().length);
assertEquals("There should be exactly two multichunks", 2, new File(testConnection.getPath() + "/multichunks").listFiles().length);
// Tear down
clientA.deleteTestData();
}
use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class Issue520NoResumeOnCorruptXmlScenarioTest method testCorruptTransactionFile.
@Test
public void testCorruptTransactionFile() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
clientA.createNewFile("file1.txt", 1024);
clientA.upWithForceChecksum();
TestFileUtil.createFileWithContent(new File(clientA.getConfig().getAppDir(), "/state/transaction-list.txt"), "0000000001");
TestFileUtil.createFileWithContent(new File(clientA.getConfig().getAppDir(), "/state/transaction-database.0000000001.xml"), "invalid");
clientA.createNewFile("file2.txt", 1024);
// This did FAIL due to an XML parsing exception
clientA.upWithForceChecksum();
assertEquals("There should be exactly two database files", 2, new File(testConnection.getPath() + "/databases").listFiles().length);
assertEquals("There should be exactly two multichunks", 2, new File(testConnection.getPath() + "/multichunks").listFiles().length);
// Tear down
clientA.deleteTestData();
}
Aggregations