use of org.syncany.database.DatabaseVersionHeader in project syncany by syncany.
the class DatabaseReconciliatorTest method testUpdateDetectorConflict7AtMachineC.
@Test
public void testUpdateDetectorConflict7AtMachineC() throws Exception {
System.out.println("CONFLICT 7");
System.out.println("----------------");
/// Input data ///
String localMachineName = "C";
DatabaseVersionHeader currentLocalVersion = null;
DatabaseBranches allBranches = new DatabaseBranches();
// B
allBranches.put("B", TestDatabaseUtil.createBranch(new String[] { "C/(C1)/T=1", "C/(C2)/T=2", "C/(C3)/T=3", "C/(C4)/T=5", "A/(A1,C4)/T=8", "A/(A2,C4)/T=9", "A/(A3,C4)/T=10", "A/(A3,B2,C4)/T=16", "A/(A3,B3,C4)/T=17", // db-b-4
"A/(A3,B4,C4)/T=18", // db-b-5
"A/(A3,B5,C4)/T=20", // db-b-6
"B/(A3,B6,C4)/T=23" }));
// C
allBranches.put("C", TestDatabaseUtil.createBranch(new String[] { "C/(C1)/T=1", "C/(C2)/T=2", "C/(C3)/T=3", "C/(C4)/T=5", "A/(A1,C4)/T=8", "A/(A2,C4)/T=9", "A/(A3,C4)/T=10", "A/(A4,C4)/T=11", "A/(A5,C4)/T=12", "A/(A6,C4)/T=19", "C/(A6,C9)/T=22" }));
/// Expected results ///
TestResult expectedTestResult = new TestResult();
expectedTestResult.winnersLastDatabaseVersionHeader = TestDatabaseUtil.createMapWithMachineKey(new String[] { "C", "C/(A6,C9)/T=22" }).firstEntry();
/// Perform test ///
testFromMachinePerspective(localMachineName, currentLocalVersion, allBranches, expectedTestResult);
}
use of org.syncany.database.DatabaseVersionHeader in project syncany by syncany.
the class EmptyFolderScenarioTest method testEmptyFolderCreateAndSync.
@Test
public void testEmptyFolderCreateAndSync() throws Exception {
// Setup
TransferSettings testConnection = TestConfigUtil.createTestLocalConnection();
TestClient clientA = new TestClient("A", testConnection);
TestClient clientB = new TestClient("B", testConnection);
// Run
clientA.createNewFolder("A-folder1");
clientA.createNewFolder("A-folder2");
clientA.createNewFolder("A-folder3");
clientA.up();
clientB.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
clientB.createNewFolder("B-folder4");
clientB.createNewFolder("B-folder5");
clientB.up();
SqlDatabase databaseB = clientB.loadLocalDatabase();
DatabaseVersionHeader beforeDatabaseVersionHeader = databaseB.getLastDatabaseVersionHeader();
// double-up, has caused problems
clientB.up();
DatabaseVersionHeader afterDatabaseVersionHeader = databaseB.getLastDatabaseVersionHeader();
assertEquals("Nothing changed. Local database file should not change.", beforeDatabaseVersionHeader, afterDatabaseVersionHeader);
clientA.down();
assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
assertSqlDatabaseEquals(clientA.getDatabaseFile(), clientB.getDatabaseFile());
Map<String, File> beforeSyncDownFileList = clientB.getLocalFilesExcludeLockedAndNoRead();
// double-down, has caused problems
clientA.down();
assertFileListEquals("No change in file lists expected. Nothing changed", beforeSyncDownFileList, clientA.getLocalFilesExcludeLockedAndNoRead());
// Tear down
clientA.deleteTestData();
clientB.deleteTestData();
}
use of org.syncany.database.DatabaseVersionHeader in project syncany by syncany.
the class TestDatabaseUtil method createMapWithMachineKey.
public static TreeMap<String, DatabaseVersionHeader> createMapWithMachineKey(String[] keysAndDatabaseVersionHeaderStrings) throws Exception {
TreeMap<String, DatabaseVersionHeader> databaseVersionHeaderMap = new TreeMap<String, DatabaseVersionHeader>();
for (int i = 0; i < keysAndDatabaseVersionHeaderStrings.length; i += 2) {
String machineName = keysAndDatabaseVersionHeaderStrings[i];
DatabaseVersionHeader databaseVersionHeader = createFromString(keysAndDatabaseVersionHeaderStrings[i + 1]);
databaseVersionHeaderMap.put(machineName, databaseVersionHeader);
}
return databaseVersionHeaderMap;
}
Aggregations