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