use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.
the class Issue374Pre1965DateScenarioTest method testIssue316CleanupThenDeleteFile.
@Test
public void testIssue316CleanupThenDeleteFile() throws Exception {
/*
* This test simulates files with a timestamp before 1965 (unix time < 0).
*/
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
clientA.createNewFile("pre1965.txt");
Date dateBefore1965 = new SimpleDateFormat("dd-MM-yyyy").parse("31-12-1964");
Files.setLastModifiedTime(clientA.getLocalFile("pre1965.txt").toPath(), FileTime.fromMillis(dateBefore1965.getTime()));
clientA.upWithForceChecksum();
// This was throwing an exception in FileSystemAction.setLastModified()
clientB.down();
// Tear down
clientB.deleteTestData();
clientA.deleteTestData();
}
use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.
the class Issue429ScenarioTest method testSameFileDifferentNameFuzzy.
@Ignore
public void testSameFileDifferentNameFuzzy() throws Exception {
for (int seed = 0; seed < 1000; seed++) {
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
Random randomA = new Random(2 * seed);
Random randomB = new Random(2 * seed + 1);
Queue<String> queue = new ConcurrentLinkedQueue<>();
activeThread A = new activeThread(randomA, clientA, queue);
activeThread B = new activeThread(randomB, clientB, queue);
Thread AThread = new Thread(A, "A");
Thread BThread = new Thread(B, "B");
try {
AThread.start();
BThread.start();
for (int i = 0; i < 50; i++) {
TestClient clientC = new TestClient("C", testConnection);
clientC.down();
if (!AThread.isAlive() || !BThread.isAlive()) {
throw new RuntimeException("One of the threads died");
}
FileUtils.deleteDirectory(clientC.getLocalFile(""));
Thread.sleep(2000);
}
AThread.interrupt();
BThread.interrupt();
} catch (Exception e) {
logger.log(Level.INFO, "Queue:" + queue.toString());
logger.log(Level.INFO, "Something went wrong at seed: " + seed);
throw e;
}
clientA.deleteTestData();
clientB.deleteTestData();
}
}
use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.
the class Issue429ScenarioTest method testSpecificQueue.
@Ignore
public void testSpecificQueue() throws Exception {
String[] commands = new String[] { "A5", "B5", "B0", "B0", "A7", "A3", "B6", "B1", "A7", "A6", "A7", "B5", "A1", "A0", "B6", "A5", "B0", "B6", "A7", "A0", "B7", "A5", "B1", "B7", "A6", "B7", "A0", "A3", "B4", "B7", "A2", "A7", "A4", "B1", "B4", "A3", "B0", "A0", "A4", "A6", "B3", "B3", "B2", "A1", "B1", "B3", "A1", "A7", "B7", "B7", "A1", "B4", "A4", "A4", "A1", "B4", "A6", "B2", "B5", "B7", "A5", "B2", "B2", "B3", "B1", "B5", "B3", "B1", "B3", "B2", "B4" };
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
for (String command : commands) {
int choice = Integer.parseInt(command.substring(1));
if (command.contains("A")) {
performAction(clientA, choice);
} else {
performAction(clientB, choice);
}
}
clientA.deleteTestData();
clientB.deleteTestData();
}
use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.
the class ManySyncUpsAndDatabaseFileCleanupScenarioTest method testManySyncUpsAndDatabaseFileCleanup.
@Test
public void testManySyncUpsAndDatabaseFileCleanup() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
// ROUND 1: many sync up (no cleanup expected here)
for (int i = 1; i <= 15; i++) {
clientA.createNewFile("file" + i, 1);
clientA.up();
}
for (int i = 1; i <= 15; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
assertTrue("Database file SHOULD exist: " + expectedDatabaseFile, expectedDatabaseFile.exists());
}
// ROUND 2: 1x sync up (cleanup expected!)
clientA.createNewFile("file16", 1);
clientA.up();
// Force cleanup
clientA.cleanup();
for (int i = 1; i <= 15; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
assertTrue("Database file should NOT exist: " + expectedDatabaseFile, !expectedDatabaseFile.exists());
}
for (int i = 17; i <= 17; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
assertTrue("Database file SHOULD exist: " + expectedDatabaseFile, expectedDatabaseFile.exists());
}
// ROUND 3: many sync up (no cleanup expected here)
for (int i = 17; i <= 30; i++) {
clientA.createNewFile("file" + i, 1);
clientA.up();
}
for (int i = 1; i <= 16; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
assertTrue("Database file should NOT exist: " + expectedDatabaseFile, !expectedDatabaseFile.exists());
}
for (int i = 17; i <= 31; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
assertTrue("Database file SHOULD exist: " + expectedDatabaseFile, expectedDatabaseFile.exists());
}
// ROUND 4: 1x sync up (cleanup expected!)
clientA.createNewFile("file31", 1);
clientA.up();
CleanupOperationOptions options = new CleanupOperationOptions();
options.setForce(true);
// Force cleanup
clientA.cleanup(options);
for (int i = 1; i <= 32; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
assertTrue("Database file should NOT exist: " + expectedDatabaseFile, !expectedDatabaseFile.exists());
}
for (int i = 33; i <= 33; i++) {
DatabaseRemoteFile expectedDatabaseRemoteFile = new DatabaseRemoteFile("A", i);
File expectedDatabaseFile = new File(testConnection.getPath() + "/databases/" + expectedDatabaseRemoteFile.getName());
assertTrue("Database file SHOULD exist: " + expectedDatabaseFile, expectedDatabaseFile.exists());
}
// Tear down
TestClient clientB = new TestClient("B", testConnection);
clientB.down();
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
clientA.deleteTestData();
clientB.deleteTestData();
}
use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.
the class ManySyncUpsAndOtherClientSyncDownScenarioTest method testManySyncUpsAndOtherClientSyncDown.
@Test
public void testManySyncUpsAndOtherClientSyncDown() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
// ROUND 1: many sync up (cleanups expected)
for (int i = 1; i <= 50; i++) {
clientA.createNewFile("file" + i, 1);
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();
}
Aggregations