Search in sources :

Example 31 with DatabaseVersionHeader

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);
}
Also used : DatabaseVersionHeader(org.syncany.database.DatabaseVersionHeader) DatabaseBranches(org.syncany.operations.down.DatabaseBranches) Test(org.junit.Test)

Example 32 with DatabaseVersionHeader

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();
}
Also used : TestClient(org.syncany.tests.util.TestClient) SqlDatabase(org.syncany.database.SqlDatabase) TransferSettings(org.syncany.plugins.transfer.TransferSettings) DatabaseVersionHeader(org.syncany.database.DatabaseVersionHeader) File(java.io.File) Test(org.junit.Test)

Example 33 with DatabaseVersionHeader

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;
}
Also used : TreeMap(java.util.TreeMap) DatabaseVersionHeader(org.syncany.database.DatabaseVersionHeader)

Aggregations

DatabaseVersionHeader (org.syncany.database.DatabaseVersionHeader)33 Test (org.junit.Test)17 DatabaseBranches (org.syncany.operations.down.DatabaseBranches)14 File (java.io.File)4 Date (java.util.Date)4 VectorClock (org.syncany.database.VectorClock)4 PreparedStatement (java.sql.PreparedStatement)3 DatabaseVersion (org.syncany.database.DatabaseVersion)3 MultiChunkEntry (org.syncany.database.MultiChunkEntry)3 DatabaseBranch (org.syncany.operations.down.DatabaseBranch)3 DatabaseRemoteFile (org.syncany.plugins.transfer.files.DatabaseRemoteFile)3 IOException (java.io.IOException)2 Connection (java.sql.Connection)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 Config (org.syncany.config.Config)2 ChunkEntry (org.syncany.database.ChunkEntry)2 FileContent (org.syncany.database.FileContent)2 MemoryDatabase (org.syncany.database.MemoryDatabase)2 MultiChunkId (org.syncany.database.MultiChunkEntry.MultiChunkId)2