use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.
the class FileLockedScenarioTest method runUpAndTestForConsistentDatabase.
private void runUpAndTestForConsistentDatabase(TransferSettings connection, TestClient client) throws Exception {
UpOperationResult upResult = client.up();
StatusOperationResult statusResult = upResult.getStatusResult();
// Test 1: Check result sets for inconsistencies
assertTrue("Status command expected to return changes.", statusResult.getChangeSet().hasChanges());
assertTrue("File should be uploaded while it is read-only.", upResult.getChangeSet().hasChanges());
// Test 2: Check database for inconsistencies
SqlDatabase database = client.loadLocalDatabase();
assertNotNull("There should be a new database version, because files should have been added.", database.getLastDatabaseVersionHeader());
// Test 3: Check file system for inconsistencies
File repoPath = ((LocalTransferSettings) connection).getPath();
assertEquals("Repository should contain any files.", 5, repoPath.list().length);
}
use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.
the class Issue227_2_ScenarioTest method testIssue227_MOM.
@Test
public void testIssue227_MOM() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientIH = new TestClient("iH", testConnection);
TestClient clientMOM = new TestClient("MOM", testConnection);
TestClient clientHSE = new TestClient("hSE", testConnection);
UpOperationOptions upOptionsWithForce = new UpOperationOptions();
upOptionsWithForce.setForceUploadEnabled(true);
clientIH.createNewFile("file1.jpg");
clientIH.up();
clientIH.createNewFile("file2.jpg");
clientIH.up();
clientMOM.down();
clientHSE.down();
// -
clientMOM.createNewFile("file3.jpg");
clientMOM.up();
clientMOM.createNewFile("file4.jpg");
clientMOM.up();
clientIH.down();
clientHSE.down();
// All in sync
/*
* We want to create a time difference situation here between different clients.
*
* In reality:
* - Client "hSE" uploads a new database AFTER client "MOM"
*
* In this test:
* 1. Client "hSE" uploads a new database BEFORE client "MOM"
* 2. We hide "hSE"'s database by moving it to a temp. file
* // ...
* 5. When we do 'down' at client "IH", the databases of client "MOM" are considered DIRTY
*
*/
// 1. Upload new database for hSE
clientHSE.createNewFile("fileHSE-1.jpg");
clientHSE.up(upOptionsWithForce);
File[] hSEDatabaseFiles = new File(testConnection.getPath() + "/databases/").listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.contains("hSE");
}
});
assertEquals(1, hSEDatabaseFiles.length);
// 2. Hide database from other clients
File hSEDatabaseFile = hSEDatabaseFiles[0];
File hSEDatabaseFileHidden = new File(hSEDatabaseFile.getParentFile(), "HIDE_THIS_FILE_" + hSEDatabaseFile.getName());
hSEDatabaseFile.renameTo(hSEDatabaseFileHidden);
// 3. This shouldn't do anything; no new databases!
DownOperationResult downOperationResult = clientIH.down();
assertEquals(0, downOperationResult.getDownloadedUnknownDatabases().size());
// 4. Upload database from client "MOM" (later considered DIRTY)
clientMOM.createNewFile("fileMOM-1.jpg");
clientMOM.up(upOptionsWithForce);
clientMOM.createNewFile("fileMOM-2.jpg");
clientMOM.up(upOptionsWithForce);
// 5. Download changes from "MOM" (apply databases and files that will later be DIRTY)
downOperationResult = clientIH.down();
assertEquals(0, downOperationResult.getDirtyDatabasesCreated().size());
// 6. Rename hidden database (= the later winner!)Now download the changes that
// Databases of client "MOM" will be considered "DIRTY"
hSEDatabaseFileHidden.renameTo(hSEDatabaseFile);
downOperationResult = clientIH.down();
assertEquals(2, downOperationResult.getDirtyDatabasesCreated().size());
// 7. This should remove DIRTY database versions from the database
// and ADD the multichunks from the previous database versions to the new database version (<< this is what kills MOM)
clientIH.up();
// <<<<<<<< This should produce Pim's stack trace from issue #227
clientMOM.down();
// Tear down
clientIH.deleteTestData();
clientMOM.deleteTestData();
clientHSE.deleteTestData();
}
use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.
the class Issue227_2_ScenarioTest method testIssue227_IH.
@Test
public void testIssue227_IH() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientIH = new TestClient("iH", testConnection);
TestClient clientMOM = new TestClient("MOM", testConnection);
TestClient clientHSE = new TestClient("hSE", testConnection);
TestClient clientMee = new TestClient("Mee", testConnection);
UpOperationOptions upOptionsWithForce = new UpOperationOptions();
upOptionsWithForce.setForceUploadEnabled(true);
clientIH.createNewFile("file1.jpg");
clientIH.up();
clientIH.createNewFile("file2.jpg");
clientIH.up();
clientMOM.down();
clientHSE.down();
// -
clientMOM.createNewFile("file3.jpg");
clientMOM.up();
clientMOM.createNewFile("file4.jpg");
clientMOM.up();
clientIH.down();
clientHSE.down();
// All in sync
/*
* We want to create a time difference situation here between different clients.
*
* In reality:
* - Client "hSE" uploads a new database AFTER client "MOM"
*
* In this test:
* 1. Client "hSE" uploads a new database BEFORE client "MOM"
* 2. We hide "hSE"'s database by moving it to a temp. file
* // ...
* 5. When we do 'down' at client "IH", the databases of client "MOM" are considered DIRTY
*
*/
// 1. Upload new database for hSE
clientHSE.createNewFile("fileHSE-1.jpg");
clientHSE.up(upOptionsWithForce);
File[] hSEDatabaseFiles = new File(testConnection.getPath() + "/databases/").listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.contains("hSE");
}
});
assertEquals(1, hSEDatabaseFiles.length);
// 2. Hide database from other clients
File hSEDatabaseFile = hSEDatabaseFiles[0];
File hSEDatabaseFileHidden = new File(hSEDatabaseFile.getParentFile(), "HIDE_THIS_FILE_" + hSEDatabaseFile.getName());
hSEDatabaseFile.renameTo(hSEDatabaseFileHidden);
// 3. This shouldn't do anything; no new databases!
DownOperationResult downOperationResult = clientIH.down();
assertEquals(0, downOperationResult.getDownloadedUnknownDatabases().size());
// 4. Upload database from client "MOM" (later considered DIRTY)
clientMOM.createNewFile("fileMOM-1.jpg");
clientMOM.changeFile("file1.jpg");
clientMOM.up(upOptionsWithForce);
clientMOM.createNewFile("fileMOM-2.jpg");
clientMOM.up(upOptionsWithForce);
// 5. Download changes from "MOM" (apply databases and files that will later be DIRTY)
downOperationResult = clientIH.down();
assertEquals(0, downOperationResult.getDirtyDatabasesCreated().size());
// 6. Rename hidden database (= the later winner!)Now download the changes that
// Databases of client "MOM" will be considered "DIRTY"
hSEDatabaseFileHidden.renameTo(hSEDatabaseFile);
downOperationResult = clientIH.down();
assertEquals(2, downOperationResult.getDirtyDatabasesCreated().size());
// 7. This should remove DIRTY database versions from the database
// and ADD the multichunks from the previous database versions to the new database version (<< this is what kills MOM)
clientIH.up();
clientIH.down();
// <<< This copies a file for which the filecontent has been deleted
clientIH.copyFile("file2.jpg", "file2copy.jpg");
clientIH.up();
// << This should throw Philipp's stack trace in #227
clientMee.down();
// Tear down
clientIH.deleteTestData();
clientMOM.deleteTestData();
clientHSE.deleteTestData();
clientMee.deleteTestData();
}
use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.
the class Issue227_2_ScenarioTest method testIssue227_multiple_resolve.
@Test
public void testIssue227_multiple_resolve() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientIH = new TestClient("iH", testConnection);
TestClient clientMOM = new TestClient("MOM", testConnection);
TestClient clientHSE = new TestClient("hSE", testConnection);
TestClient clientMee = new TestClient("Mee", testConnection);
TestClient clientIHtwo = new TestClient("IHtwo", testConnection);
UpOperationOptions upOptionsWithForce = new UpOperationOptions();
upOptionsWithForce.setForceUploadEnabled(true);
clientIH.createNewFile("file1.jpg");
clientIH.up();
clientIH.createNewFile("file2.jpg");
clientIH.up();
clientMOM.down();
clientHSE.down();
// -
clientMOM.createNewFile("file3.jpg");
clientMOM.up();
clientMOM.createNewFile("file4.jpg");
clientMOM.up();
clientIH.down();
clientIHtwo.down();
clientHSE.down();
// All in sync
/*
* We want to create a time difference situation here between different clients.
*
* In reality:
* - Client "hSE" uploads a new database AFTER client "MOM"
*
* In this test:
* 1. Client "hSE" uploads a new database BEFORE client "MOM"
* 2. We hide "hSE"'s database by moving it to a temp. file
* // ...
* 5. When we do 'down' at client "IH", the databases of client "MOM" are considered DIRTY
*
*/
// 1. Upload new database for hSE
clientHSE.createNewFile("fileHSE-1.jpg");
clientHSE.up(upOptionsWithForce);
File[] hSEDatabaseFiles = new File(testConnection.getPath() + "/databases/").listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.contains("hSE");
}
});
assertEquals(1, hSEDatabaseFiles.length);
// 2. Hide database from other clients
File hSEDatabaseFile = hSEDatabaseFiles[0];
File hSEDatabaseFileHidden = new File(hSEDatabaseFile.getParentFile(), "HIDE_THIS_FILE_" + hSEDatabaseFile.getName());
hSEDatabaseFile.renameTo(hSEDatabaseFileHidden);
// 3. This shouldn't do anything; no new databases!
DownOperationResult downOperationResult = clientIH.down();
assertEquals(0, downOperationResult.getDownloadedUnknownDatabases().size());
// same as IH!
clientIHtwo.down();
// 4. Upload database from client "MOM" (later considered DIRTY)
clientMOM.createNewFile("fileMOM-1.jpg");
clientMOM.changeFile("file1.jpg");
clientMOM.up(upOptionsWithForce);
clientMOM.createNewFile("fileMOM-2.jpg");
clientMOM.up(upOptionsWithForce);
// 5. Download changes from "MOM" (apply databases and files that will later be DIRTY)
downOperationResult = clientIH.down();
assertEquals(0, downOperationResult.getDirtyDatabasesCreated().size());
// same as IH!
clientIHtwo.down();
// 6. Rename hidden database (= the later winner!)Now download the changes that
// Databases of client "MOM" will be considered "DIRTY"
hSEDatabaseFileHidden.renameTo(hSEDatabaseFile);
downOperationResult = clientIH.down();
assertEquals(2, downOperationResult.getDirtyDatabasesCreated().size());
// same as IH!
clientIHtwo.down();
// 7. This should remove DIRTY database versions from the database
// and ADD the multichunks from the previous database versions to the new database version (<< this is what kills MOM)
clientIH.up(upOptionsWithForce);
clientIHtwo.up(upOptionsWithForce);
/*clientIH.down();
clientIH.copyFile("file2.jpg", "file2copy.jpg"); // <<< This copies a file for which the filecontent has been deleted
clientIH.up();*/
// << This should throw Philipp's stack trace in #227
clientMee.down();
// Tear down
clientIH.deleteTestData();
clientMOM.deleteTestData();
clientHSE.deleteTestData();
clientMee.deleteTestData();
clientIHtwo.deleteTestData();
}
use of org.syncany.plugins.local.LocalTransferSettings in project syncany by syncany.
the class Issue429ScenarioTest method testIssue492UploadDuplicateFile.
@Ignore
public void testIssue492UploadDuplicateFile() throws Exception {
// Setup
LocalTransferSettings testConnection = (LocalTransferSettings) TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
TestClient clientC = new TestClient("C", testConnection);
clientA.createNewFile("file1.txt", 1024);
clientA.upWithForceChecksum();
FileUtils.copyFile(clientA.getLocalFile("file1.txt"), clientB.getLocalFile("file2.txt"));
clientB.down();
clientB.up();
clientA.deleteFile("file1.txt");
clientA.deleteFile("file2.txt");
clientA.upWithForceChecksum();
clientB.cleanup();
clientC.down();
// Tear down
// clientB.deleteTestData();
// clientA.deleteTestData();
}
Aggregations