use of org.syncany.plugins.local.LocalTransferSettings 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.plugins.local.LocalTransferSettings 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.plugins.local.LocalTransferSettings 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();
}
use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.
the class MoveFolderWithQuotesOnWindowsScenario method testMoveFolderWithQuotes_issue124.
@Test
public void testMoveFolderWithQuotes_issue124() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
// Create folder with file without quotes
clientA.createNewFolder("folder_without_quotes");
clientA.createNewFile("folder_without_quotes/file");
clientA.up();
// Sync to B
clientB.down();
// Now we should move to a folder with quotes, e.g. folder "with" quotes
// To make this work on Windows, we first move the folder and then modify
// the database file on the remote storage to mock it
clientA.moveFile("folder_without_quotes", "folder_with_quotes");
clientA.up();
for (File databaseFile : new File(testConnection.getPath() + "/databases/").listFiles()) {
String databaseFileA2Content = IOUtils.toString(new FileInputStream(databaseFile), "UTF-8");
String databaseFileA2NewContent = databaseFileA2Content.replaceAll("folder_with_quotes", "folder "with" quotes");
IOUtils.write(databaseFileA2NewContent, new FileOutputStream(databaseFile));
}
// << In issue 124, this failed because we tried to move the inner "file" to the folder with quotes
clientB.down();
if (EnvironmentUtil.isWindows()) {
assertTrue(clientB.getLocalFile("folder with quotes (filename conflict)").exists());
assertTrue(clientB.getLocalFile("folder with quotes (filename conflict)/file").exists());
} else {
assertTrue(clientB.getLocalFile("folder \"with\" quotes").exists());
assertTrue(clientB.getLocalFile("folder \"with\" quotes/file").exists());
}
// Tear down
clientA.deleteTestData();
clientB.deleteTestData();
}
use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.
the class ConnectOperationTest method testConnectOperationWithLink.
@Test
public void testConnectOperationWithLink() throws Exception {
// A.init()
InitOperationOptions initOperationOptionsA = TestConfigUtil.createTestInitOperationOptions("A");
InitOperation initOperationA = new InitOperation(initOperationOptionsA, null);
InitOperationResult initOperationResultA = initOperationA.execute();
String connectLinkA = initOperationResultA.getGenLinkResult().getShareLink();
assertNotNull(connectLinkA);
// B.connect()
File localDirB = TestFileUtil.createTempDirectoryInSystemTemp(TestConfigUtil.createUniqueName("clientB", initOperationOptionsA));
File localConnectDirB = new File(localDirB, Config.DIR_APPLICATION);
ConfigTO connectionConfigToB = initOperationOptionsA.getConfigTO();
connectionConfigToB.setMachineName("clientB" + Math.abs(new Random().nextInt()));
connectionConfigToB.setMasterKey(null);
ConnectOperationOptions connectOperationOptionsB = new ConnectOperationOptions();
connectOperationOptionsB.setStrategy(ConnectOptionsStrategy.CONNECTION_LINK);
connectOperationOptionsB.setConnectLink(connectLinkA);
connectOperationOptionsB.setConfigTO(connectionConfigToB);
connectOperationOptionsB.setPassword(initOperationOptionsA.getPassword());
connectOperationOptionsB.setLocalDir(localDirB);
ConnectOperation connectOperationB = new ConnectOperation(connectOperationOptionsB, null);
ConnectOperationResult connectOperationResultB = connectOperationB.execute();
assertEquals(ConnectResultCode.OK, connectOperationResultB.getResultCode());
assertTrue(new File(localConnectDirB, Config.DIR_DATABASE).exists());
assertTrue(new File(localConnectDirB, Config.DIR_CACHE).exists());
assertTrue(new File(localConnectDirB, Config.FILE_CONFIG).exists());
assertTrue(new File(localConnectDirB, Config.DIR_LOG).exists());
assertTrue(new File(localConnectDirB, Config.FILE_REPO).exists());
assertEquals(new File(localConnectDirB, Config.FILE_MASTER).exists(), TestConfigUtil.getCrypto());
File repoDir = ((LocalTransferSettings) initOperationOptionsA.getConfigTO().getTransferSettings()).getPath();
// Tear down
TestFileUtil.deleteDirectory(repoDir);
TestFileUtil.deleteDirectory(localConnectDirB);
TestFileUtil.deleteDirectory(initOperationOptionsA.getLocalDir());
TestFileUtil.deleteDirectory(connectOperationOptionsB.getLocalDir());
}
Aggregations