Search in sources :

Example 96 with TestClient

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();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) Test(org.junit.Test)

Example 97 with TestClient

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();
}
Also used : CleanupOperationResult(org.syncany.operations.cleanup.CleanupOperationResult) UnreliableLocalTransferSettings(org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) CleanupOperationOptions(org.syncany.operations.cleanup.CleanupOperationOptions) Test(org.junit.Test)

Example 98 with TestClient

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();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) Ignore(org.junit.Ignore)

Example 99 with TestClient

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();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) File(java.io.File) Test(org.junit.Test)

Example 100 with TestClient

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();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) 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