Package org.syncany.database.dao

Examples of org.syncany.database.dao.ChunkSqlDao


    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set1.sql");
   
    ChunkSqlDao chunkDao = new ChunkSqlDao(databaseConnection);
    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
    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);
View Full Code Here


    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set1.sql");
   
    ChunkSqlDao chunkDao = new ChunkSqlDao(databaseConnection);
    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
    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);
View Full Code Here

    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set3.sql");
   
    ChunkSqlDao chunkDao = new ChunkSqlDao(databaseConnection);
    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
    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);
View Full Code Here

    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set1.sql");
   
    ChunkSqlDao chunkDao = new ChunkSqlDao(databaseConnection);
    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
    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);
   
    // 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());
    assertNotNull(multiChunkIds);
    assertEquals(1, multiChunkIds.size());
View Full Code Here

    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set3.sql");
   
    ChunkSqlDao chunkDao = new ChunkSqlDao(databaseConnection);
    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
    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);
View Full Code Here

    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set1.sql");
   
    ChunkSqlDao chunkDao = new ChunkSqlDao(databaseConnection);
    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
    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);
View Full Code Here

    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set1.sql");
   
    ChunkSqlDao chunkDao = new ChunkSqlDao(databaseConnection);
    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
    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);
View Full Code Here

    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set2.sql");
   
    ChunkSqlDao chunkDao = new ChunkSqlDao(databaseConnection);
    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
    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);
View Full Code Here

    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set1.sql");
   
    ChunkSqlDao chunkDao = new ChunkSqlDao(databaseConnection);
    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
    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);

    // a. Test before
    List<DatabaseVersion> dirtyDatabaseVersionsBefore = TestCollectionUtil.toList(databaseVersionDao.getDirtyDatabaseVersions());   
    assertNotNull(dirtyDatabaseVersionsBefore);
    assertNotNull(chunkDao.getChunk(ChunkChecksum.parseChunkChecksum("beefbeefbeefbeefbeefbeefbeefbeefbeefbeef")));
    assertNotNull(multiChunkDao.getDirtyMultiChunkIds());
    assertEquals(1, multiChunkDao.getDirtyMultiChunkIds().size());
   
    // b. Add new database version with DIRTY multichunk; remove DIRTY version   
    DatabaseVersion newDatabaseVersion = new DatabaseVersion();
    newDatabaseVersion.setVectorClock(TestDatabaseUtil.createVectorClock("A5,B2"));
   
    long newDatabaseVersionId = databaseVersionDao.persistDatabaseVersion(newDatabaseVersion);   
    databaseVersionDao.removeDirtyDatabaseVersions(newDatabaseVersionId);
       
    // c. Test after   
   
    // Database version
    List<DatabaseVersion> dirtyDatabaseVersionsAfter = TestCollectionUtil.toList(databaseVersionDao.getDirtyDatabaseVersions());   
    assertNotNull(dirtyDatabaseVersionsAfter);
    assertEquals(0, dirtyDatabaseVersionsAfter.size());
   
    // Multichunk from dirty version "moved" to new version
    Map<MultiChunkId, MultiChunkEntry> multiChunksA5B2 = multiChunkDao.getMultiChunks(TestDatabaseUtil.createVectorClock("A5,B2"));   
    assertNotNull(multiChunksA5B2);
    assertEquals(1, multiChunksA5B2.size());
    assertNotNull(multiChunksA5B2.get(MultiChunkId.parseMultiChunkId("1234567890987654321123456789098765433222")));
   
    // File version/history/content ARE removed
    assertNull(fileContentDao.getFileContent(FileChecksum.parseFileChecksum("beefbeefbeefbeefbeefbeefbeefbeefbeefbeef"), true));
   
    // TODO [low] Test file version and file history removal   
   
    // Chunks and multichunks are NOT removed!
    assertNotNull(chunkDao.getChunk(ChunkChecksum.parseChunkChecksum("beefbeefbeefbeefbeefbeefbeefbeefbeefbeef")));
   
    assertNotNull(multiChunkDao.getMultiChunks(TestDatabaseUtil.createVectorClock("B1")));
    assertEquals(0, multiChunkDao.getMultiChunks(TestDatabaseUtil.createVectorClock("B1")).size());
   
    assertNotNull(multiChunkDao.getDirtyMultiChunkIds());
View Full Code Here

    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set3.sql");
   
    ChunkSqlDao chunkDao = new ChunkSqlDao(databaseConnection);
   
    ChunkEntry chunk1 = chunkDao.getChunk(ChunkChecksum.parseChunkChecksum("615fba8c2281d5bee891eb092a252d235c237457"));
    ChunkEntry chunk2 = chunkDao.getChunk(ChunkChecksum.parseChunkChecksum("ab85720d3f31bd08ca1cd25dcd8a490e5f00783b"));
    ChunkEntry chunkNonExistent = chunkDao.getChunk(ChunkChecksum.parseChunkChecksum("beefbeefbeefbeefbeefbeefbeefbeefbeefbeef"));
   
    // Test
    assertNotNull(chunk1);
    assertEquals("615fba8c2281d5bee891eb092a252d235c237457", chunk1.getChecksum().toString());
    assertEquals(8387, chunk1.getSize());
View Full Code Here

TOP

Related Classes of org.syncany.database.dao.ChunkSqlDao

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.