use of org.syncany.tests.util.TestClient 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.tests.util.TestClient 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.tests.util.TestClient 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();
}
use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class IdenticalFileMoveScenarioTest method testIdenticalFileMove.
@Test
public void testIdenticalFileMove() throws Exception {
// Setup
TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
// Create folder structure
clientA.createNewFolder("folder");
clientA.createNewFolder("folder/subfolder1");
clientA.createNewFolder("folder/subfolder2");
// Create identical files
clientA.createNewFile("folder/subfolder1/A-file1.jpg", 100);
clientA.copyFile("folder/subfolder1/A-file1.jpg", "folder/subfolder2/A-file1.jpg");
clientA.up();
// Move the two identical files
clientA.moveFile("folder", "moved_folder");
clientA.up();
// A just upped, so there should not be changes.
assertFalse(clientA.status().getChangeSet().hasChanges());
// Check if the file histories were based on the correct originals
LsOperationOptions options = new LsOperationOptions();
options.setFetchHistories(true);
options.setPathExpression("moved_folder/subfolder1/");
LsOperationResult lsOperationResult = clientA.ls(options);
for (PartialFileHistory fileHistory : lsOperationResult.getFileVersions().values()) {
assertTrue(fileHistory.getFileVersion(2).getPath().endsWith(fileHistory.getFileVersion(1).getPath()));
}
options.setPathExpression("moved_folder/subfolder2/");
lsOperationResult = clientA.ls(options);
for (PartialFileHistory fileHistory : lsOperationResult.getFileVersions().values()) {
assertTrue(fileHistory.getFileVersion(2).getPath().endsWith(fileHistory.getFileVersion(1).getPath()));
}
// Tear down
clientA.deleteTestData();
}
use of org.syncany.tests.util.TestClient in project syncany by syncany.
the class IgnoredFileScenarioTest method testIgnoredDirectory.
@Test
public void testIgnoredDirectory() throws Exception {
// Scenario: A ignores files with a regular expression, creates it then ups, B should not have the file
// Setup
File tempDir = TestFileUtil.createTempDirectoryInSystemTemp();
TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
//Create ignore file and reload it
File syncanyIgnore = clientA.getLocalFile(Config.FILE_IGNORE);
TestFileUtil.createFileWithContent(syncanyIgnore, "builds");
clientA.getConfig().getIgnoredFiles().loadPatterns();
// A new/up
clientA.createNewFolder("builds");
clientA.createNewFile("builds/test.txt");
clientA.up();
clientB.down();
// The ignored file should not exist at B
assertTrue(clientA.getLocalFile("builds/test.txt").exists());
assertFalse(clientB.getLocalFile("builds/test.txt").exists());
// Tear down
clientA.deleteTestData();
clientB.deleteTestData();
TestFileUtil.deleteDirectory(tempDir);
}
Aggregations