Package org.syncany.database

Examples of org.syncany.database.DatabaseVersionHeader


    FileVersionSqlDao fileVersionDao = new FileVersionSqlDao(databaseConnection);
    FileHistorySqlDao fileHistoryDao = new FileHistorySqlDao(databaseConnection, fileVersionDao);
    FileContentSqlDao fileContentDao = new FileContentSqlDao(databaseConnection);
    DatabaseVersionSqlDao databaseVersionDao = new DatabaseVersionSqlDao(databaseConnection, chunkDao, fileContentDao, fileVersionDao, fileHistoryDao, multiChunkDao);
   
    DatabaseVersionHeader lastDatabaseVersionHeader = databaseVersionDao.getLastDatabaseVersionHeader();
   
    // Test
    assertNotNull(lastDatabaseVersionHeader);
    assertEquals("(A8,B3)", lastDatabaseVersionHeader.getVectorClock().toString());
    assertEquals("A/(A8,B3)/T=1389977288000", lastDatabaseVersionHeader.toString());   
   
    // Tear down
    databaseConnection.close();
    TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
  }
View Full Code Here


    FileHistorySqlDao fileHistoryDao = new FileHistorySqlDao(databaseConnection, fileVersionDao);
    FileContentSqlDao fileContentDao = new FileContentSqlDao(databaseConnection);
    DatabaseVersionSqlDao databaseVersionDao = new DatabaseVersionSqlDao(databaseConnection, chunkDao, fileContentDao, fileVersionDao, fileHistoryDao, multiChunkDao);
   
    // a. Capture database version header (now)
    DatabaseVersionHeader lastDatabaseVersionHeaderBefore = databaseVersionDao.getLastDatabaseVersionHeader();
   
    // b. Add new database header (with one file history)
    DatabaseVersion newDatabaseVersion = new DatabaseVersion();
    DatabaseVersionHeader newDatabaseVersionHeader = new DatabaseVersionHeader();
   
    newDatabaseVersionHeader.setClient("C");
    newDatabaseVersionHeader.setDate(new Date(1489977288000L));
    newDatabaseVersionHeader.setVectorClock(TestDatabaseUtil.createVectorClock("A5,C1"));
   
    newDatabaseVersion.setHeader(newDatabaseVersionHeader);
   
    PartialFileHistory newFileHistory = new PartialFileHistory(FileHistoryId.secureRandomFileId());
    FileVersion newFileVersion = new FileVersion();
   
    newFileVersion.setVersion(1L);
    newFileVersion.setPath("newfile");
    newFileVersion.setChecksum(FileChecksum.parseFileChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f"));
    newFileVersion.setLinkTarget(null);
    newFileVersion.setPosixPermissions("rwxrwxrwx");
    newFileVersion.setDosAttributes(null);
    newFileVersion.setStatus(FileStatus.NEW);
    newFileVersion.setLastModified(new Date());
    newFileVersion.setUpdated(new Date());
    newFileVersion.setSize(1L);
    newFileVersion.setType(FileType.FILE);

    newFileHistory.addFileVersion(newFileVersion);
    newDatabaseVersion.addFileHistory(newFileHistory);

    ChunkEntry newChunkEntry = new ChunkEntry(ChunkChecksum.parseChunkChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f"), 1);
    newDatabaseVersion.addChunk(newChunkEntry);
   
    MultiChunkEntry newMultiChunkEntry = new MultiChunkEntry(MultiChunkId.parseMultiChunkId("1234567890987654321234567876543456555555"), 10);
    newMultiChunkEntry.addChunk(newChunkEntry.getChecksum());
    newDatabaseVersion.addMultiChunk(newMultiChunkEntry);
   
    FileContent newFileContent = new FileContent();
    newFileContent.setChecksum(FileChecksum.parseFileChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f"));
    newFileContent.setSize(1L);   
    newFileContent.addChunk(newChunkEntry.getChecksum());
    newDatabaseVersion.addFileContent(newFileContent);   
   
    // c. Persist database version
    databaseVersionDao.persistDatabaseVersion(newDatabaseVersion);
   
    // d. Capture new last database version header
    DatabaseVersionHeader lastDatabaseVersionHeaderAfter = databaseVersionDao.getLastDatabaseVersionHeader()
   
    // Test
    assertNotNull(lastDatabaseVersionHeaderBefore);
    assertEquals("A/(A5)/T=1388935689000", lastDatabaseVersionHeaderBefore.toString());
   
    assertNotNull(lastDatabaseVersionHeaderAfter);
    assertEquals("C/(A5,C1)/T=1489977288000", lastDatabaseVersionHeaderAfter.toString());
    assertEquals(newDatabaseVersionHeader.getVectorClock(), lastDatabaseVersionHeaderAfter.getVectorClock());
   
    assertEquals(newChunkEntry, chunkDao.getChunk(ChunkChecksum.parseChunkChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f")));
    assertEquals(newFileContent, fileContentDao.getFileContent(FileChecksum.parseFileChecksum("aaaaaaaaaaaaaaaaaaaaab2b263ffa4cc48e282f"), true));
   
    Map<MultiChunkId, MultiChunkEntry> multiChunkIds = multiChunkDao.getMultiChunks(newDatabaseVersionHeader.getVectorClock());
View Full Code Here

    clientB.createNewFile("B-file2", 0);
    clientB.moveFile("A-file1.jpg", "B-file1-moved");
    clientB.up();
   
    SqlDatabase database = clientB.loadLocalDatabase();
    DatabaseVersionHeader lastDatabaseVersionHeaderBeforeUp = database.getLastDatabaseVersionHeader();
   
    clientB.up(); // double-up, has caused problems
    DatabaseVersionHeader lastDatabaseVersionHeaderAfterUp = database.getLastDatabaseVersionHeader();

    assertEquals("Nothing changed. Local database file should not change.", lastDatabaseVersionHeaderBeforeUp, lastDatabaseVersionHeaderAfterUp);
   
    clientA.down();
    assertFileListEquals(clientA.getLocalFilesExcludeLockedAndNoRead(), clientB.getLocalFilesExcludeLockedAndNoRead());
View Full Code Here

    clientB.createNewFolder("B-folder4");
    clientB.createNewFolder("B-folder5");
    clientB.up();
   
    SqlDatabase databaseB = clientB.loadLocalDatabase();
    DatabaseVersionHeader beforeDatabaseVersionHeader = databaseB.getLastDatabaseVersionHeader();
   
    clientB.up(); // double-up, has caused problems
   
    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());
View Full Code Here

    System.out.println("CONFLICT 1");
    System.out.println("----------------");
   
    /// Input data ///
    String localMachineName = "B";
    DatabaseVersionHeader currentLocalVersion = null;
    DatabaseBranches allBranches = new DatabaseBranches();
    
    // A
    allBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
      "A/(A1,C4)/T=8",
View Full Code Here

    System.out.println("----------------");
   
    /// Input data ///
    String localMachineName = "A";

    DatabaseVersionHeader currentLocalVersion = null;
    DatabaseBranches allBranches = new DatabaseBranches();
   
    // A
    allBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
      "C/(C1)/T=1",
View Full Code Here

    System.out.println("----------------");
   
    /// Input data ///
    String localMachineName = "C";

    DatabaseVersionHeader currentLocalVersion = null;
    DatabaseBranches allBranches = new DatabaseBranches();
   
    // A
    allBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
      "A/(A1,C4)/T=8",
View Full Code Here

    System.out.println("----------------");
   
    /// Input data ///
    String localMachineName = "B";

    DatabaseVersionHeader currentLocalVersion = null;
    DatabaseBranches allBranches = new DatabaseBranches();
   
    // A
    allBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
      "A/(A4,C4)/T=11",
View Full Code Here

    System.out.println("----------------");
   
    /// Input data ///
    String localMachineName = "A";

    DatabaseVersionHeader currentLocalVersion = null;
    DatabaseBranches allBranches = new DatabaseBranches();
   
    // A
    allBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
      "C/(C1)/T=1",
View Full Code Here

    System.out.println("----------------");
   
    /// Input data ///
    String localMachineName = "C";

    DatabaseVersionHeader currentLocalVersion = null;
    DatabaseBranches allBranches = new DatabaseBranches();
   
    // A
    allBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
      "A/(A4,C4)/T=11",
View Full Code Here

TOP

Related Classes of org.syncany.database.DatabaseVersionHeader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.