use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class ManyRenamesScenarioTest method testManyRenames.
@Test
public void testManyRenames() throws Exception {
// Setup
TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
// A new/up
clientA.createNewFile("A-original");
clientA.up();
// B down/move/up
clientB.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
clientB.moveFile("A-original", "B-moved");
clientB.up();
// A down/move/up
clientA.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
clientA.moveFile("B-moved", "A-moved");
clientA.up();
// B down only
clientB.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
// A down/move/up
clientA.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
clientA.moveFile("A-moved", "A-moved-again");
clientA.up();
// B down/move/up
clientB.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
// same filename as above!
clientB.moveFile("A-moved-again", "B-moved");
clientB.up();
// A down/move/up
clientA.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
// same filename as above!
clientA.moveFile("B-moved", "A-moved");
clientA.up();
// B down only
clientB.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
// Tear down
clientA.deleteTestData();
clientB.deleteTestData();
}
use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class ManySyncUpsAndOtherClientSyncDownScenarioTest method testManySyncUpsAndOtherClientSyncDownSameFileAddRemove.
@Test
public void testManySyncUpsAndOtherClientSyncDownSameFileAddRemove() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
// TODO Test not finished
// ROUND 1: many sync up (cleanups expected)
String[] names = new String[] { "one", "two", "three", "four", "five" };
int nameIndex = 0;
for (int i = 1; i <= 20; i++) {
String filename = names[nameIndex++ % names.length];
if (clientA.getLocalFile(filename).exists()) {
clientA.deleteFile(filename);
} else {
clientA.createNewFile(filename);
}
clientA.up();
}
// ROUND 2: sync down by B
clientB.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
// Tear down
clientA.deleteTestData();
clientB.deleteTestData();
}
use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class LongRunningLargeFileScenarioTest method testLargeFile.
private void testLargeFile(long size) throws Exception {
// Setup
TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
Logging.disableLogging();
logln("NOTE: This test can take several minutes!");
logln("Disabling console logging for this test; Too much output/overhead.");
logln("");
// A
logln("Creating large file for scenario (" + (size / 1024L / 1024L) + " MB) ...");
clientA.createNewFile("A-large-file.zip", size);
logln("Done creating large file. Now creating checksum ...");
String checksumFileA = StringUtil.toHex(TestFileUtil.createChecksum(clientA.getLocalFile("A-large-file.zip")));
logln("Done. Checksum is: " + checksumFileA);
logln("clientA.up() started.");
clientA.up();
logln("clientA.up() completed.");
logln("Freeing up space, deleting file at client A ...");
clientA.deleteFile("A-large-file.zip");
logln("Deleting done.");
// B
logln("clientB.down(); started.");
clientB.down();
logln("clientB.down(); completed.");
String checksumFileB = StringUtil.toHex(TestFileUtil.createChecksum(clientB.getLocalFile("A-large-file.zip")));
logln("Done. Checksum is: " + checksumFileB);
logln("Freeing up space, deleting file at client B ...");
clientB.deleteFile("A-large-file.zip");
logln("Deleting done.");
try {
assertEquals("File checksum should be equal. ", checksumFileA, checksumFileB);
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
} finally {
// Tear down
clientA.deleteTestData();
clientB.deleteTestData();
}
}
use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class LongRunningNewAndDeleteScenarioTest method testLongRunningNewAndDeleteFilesNoConflicts.
@Test
public void testLongRunningNewAndDeleteFilesNoConflicts() throws Exception {
// Setup
TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
// Disable logging
logger.log(Level.INFO, "NOTE: This test can take several minutes!");
logger.log(Level.INFO, "Disabling console logging for this test; Too much output/overhead.");
Logging.disableLogging();
// Run
for (int round = 1; round < 30; round++) {
// A
for (int i = 1; i < 100; i++) {
clientA.createNewFile("A-file-with-size-" + i + ".jpg", i);
}
clientA.up();
// B
clientB.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
for (int i = 1; i < 100; i++) {
clientB.changeFile("A-file-with-size-" + i + ".jpg");
}
clientB.up();
// A
clientA.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
for (int i = 1; i < 100; i++) {
clientA.deleteFile("A-file-with-size-" + i + ".jpg");
}
clientA.up();
// B
clientB.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
}
fail("No asserts yet.");
// Tear down
clientA.deleteTestData();
clientB.deleteTestData();
}
use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class SingleFileNoConflictsScenarioTest method testSingleFileDeleteNoConflicts.
@Test
public void testSingleFileDeleteNoConflicts() throws Exception {
// Setup
TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
// Create files and upload
clientA.createNewFile("file");
clientA.up();
clientB.down();
assertFileEquals(clientA.getLocalFile("file"), clientB.getLocalFile("file"));
clientB.deleteFile("file");
clientB.up();
clientA.down();
assertFalse("Deleted file should not exist.", clientA.getLocalFile("file").exists());
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
// Cleanup
clientA.deleteTestData();
clientB.deleteTestData();
}
Aggregations