Search in sources :

Example 91 with TestClient

use of org.syncany.tests.util.TestClient in project syncany by syncany.

the class Issue247ScenarioTest method testIssue247.

@Test
public void testIssue247() throws Exception {
    // Setup
    File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient clientDzHome = new TestClient("Dz", testConnection);
    TestClient clientUxWork = new TestClient("Ux", testConnection);
    UpOperationOptions upOptionsWithForce = new UpOperationOptions();
    upOptionsWithForce.setForceUploadEnabled(true);
    // home -- generate some database versions so that the cleanup/merge will have something to merge
    clientDzHome.createNewFile("someotherfile0.xml");
    clientDzHome.upWithForceChecksum();
    for (int i = 0; i < 30; i++) {
        clientDzHome.changeFile("someotherfile0.xml");
        clientDzHome.upWithForceChecksum();
    }
    // home
    // <<<<< This is the file/checksum causing the issue
    clientDzHome.createNewFile("config.xml");
    clientDzHome.upWithForceChecksum();
    // Make a copy (for later)
    TestFileUtil.copyFile(clientDzHome.getLocalFile("config.xml"), new File(tempDir, "config.xml"));
    // work
    clientUxWork.down();
    clientUxWork.changeFile("config.xml");
    clientUxWork.upWithForceChecksum();
    clientUxWork.createNewFile("someotherfile1.xml");
    clientUxWork.upWithForceChecksum();
    clientUxWork.createNewFile("someotherfile2.xml");
    clientUxWork.upWithForceChecksum();
    clientUxWork.createNewFile("someotherfile3.xml");
    clientUxWork.upWithForceChecksum();
    // home
    clientDzHome.down();
    clientDzHome.changeFile("config.xml");
    clientDzHome.upWithForceChecksum();
    clientDzHome.changeFile("config.xml");
    clientDzHome.upWithForceChecksum();
    // work
    clientUxWork.down();
    CleanupOperationOptions cleanupOptions = new CleanupOperationOptions();
    clientUxWork.cleanup(cleanupOptions);
    // home
    clientDzHome.down();
    // Recreate problematic config.xml/checksum
    clientDzHome.deleteFile("config.xml");
    TestFileUtil.copyFile(new File(tempDir, "config.xml"), clientDzHome.getLocalFile("config.xml"));
    clientDzHome.upWithForceChecksum();
    // work
    clientUxWork.down();
    // Tear down
    TestFileUtil.deleteDirectory(tempDir);
    clientUxWork.deleteTestData();
    clientDzHome.deleteTestData();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) CleanupOperationOptions(org.syncany.operations.cleanup.CleanupOperationOptions) UpOperationOptions(org.syncany.operations.up.UpOperationOptions) File(java.io.File) Test(org.junit.Test)

Example 92 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 93 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)

Example 94 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 95 with TestClient

use of org.syncany.tests.util.TestClient in project syncany by syncany.

the class ManySyncUpsLargeFileScenarioTest method testManySyncUpsWithLargeFile.

@Test
public void testManySyncUpsWithLargeFile() throws Exception {
    // Setup
    LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
    TestClient clientA = new TestClient("A", testConnection);
    TestClient clientB = new TestClient("B", testConnection);
    // Cause Cleanup with a moderately large file
    for (int i = 1; i <= 16; i++) {
        clientA.createNewFile("file" + i, 600181);
        TestFileUtil.changeRandomPartOfBinaryFile(clientA.getLocalFile("file" + i));
        if (i > 2) {
            TestFileUtil.changeRandomPartOfBinaryFile(clientA.getLocalFile("file" + (i - 1)));
            TestFileUtil.changeRandomPartOfBinaryFile(clientA.getLocalFile("file1"));
        }
        clientA.up();
    }
    clientB.down();
    for (int i = 1; i <= 16; i++) {
        assertTrue(clientA.getLocalFile("file" + i).exists());
        assertTrue(clientB.getLocalFile("file" + i).exists());
    }
    clientA.deleteTestData();
    clientB.deleteTestData();
}
Also used : LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) TestClient(org.syncany.tests.util.TestClient) 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