Package org.syncany.database.dao

Examples of org.syncany.database.dao.MultiChunkSqlDao


    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set3.sql");

    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
    List<ChunkChecksum> checksums = new ArrayList<ChunkChecksum>();
    checksums.add(ChunkChecksum.parseChunkChecksum("eba69a8e359ce3258520138a50ed9860127ab6e0"));
    checksums.add(ChunkChecksum.parseChunkChecksum("0fecbac8ac8a5f8b7aa12b2741a4ef5db88c5dea"));
    checksums.add(ChunkChecksum.parseChunkChecksum("38a18897e94a901b833e750e8604d9616a02ca84"));
    checksums.add(ChunkChecksum.parseChunkChecksum("beefbeefbeefbeefbeefbeefbeefbeefbeefbeef"));
   
    //Ensure that uniqueness is not required
    checksums.add(ChunkChecksum.parseChunkChecksum("38a18897e94a901b833e750e8604d9616a02ca84"));
   
    Map<ChunkChecksum,MultiChunkId> multiChunkIds = multiChunkDao.getMultiChunkIdsByChecksums(checksums);   

    // Test
    assertNotNull(multiChunkIds.get(checksums.get(0)));
    assertEquals("0d79eed3fd8ac866b5872ea3f3f079c46dd15ac9", multiChunkIds.get(checksums.get(0)).toString());
   
    assertNotNull(multiChunkIds.get(checksums.get(1)));
    assertEquals("51aaca5c1280b1cf95cff8a3266a6bb44b482ad4", multiChunkIds.get(checksums.get(1)).toString());
   
    assertNotNull(multiChunkIds.get(checksums.get(2)));
    assertEquals("51aaca5c1280b1cf95cff8a3266a6bb44b482ad4", multiChunkIds.get(checksums.get(2)).toString());
    assertEquals(multiChunkIds.get(checksums.get(1)), multiChunkIds.get(checksums.get(2)));
   
    assertNull(multiChunkIds.get(checksums.get(3)));
   
    Map<ChunkChecksum,MultiChunkId> multiChunkIdsEmpty = multiChunkDao.getMultiChunkIdsByChecksums(new ArrayList<ChunkChecksum>());
    assertTrue(multiChunkIdsEmpty.isEmpty());

    // Tear down
    databaseConnection.close();
    TestConfigUtil.deleteTestLocalConfigAndData(testConfig);


    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set3.sql");

    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
   
    Map<MultiChunkId, MultiChunkEntry> multiChunksA6 = multiChunkDao.getMultiChunks(TestDatabaseUtil.createVectorClock("A6"));
    Map<MultiChunkId, MultiChunkEntry> multiChunksA7B2 = multiChunkDao.getMultiChunks(TestDatabaseUtil.createVectorClock("A7,B2"));   

    // Test
   
    // - Database version "A6"
    assertNotNull(multiChunksA6);

    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set1.sql");

    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
   
    Map<MultiChunkId, MultiChunkEntry> multiChunksA4 = multiChunkDao.getMultiChunks(TestDatabaseUtil.createVectorClock("A4"));   
    Map<MultiChunkId, MultiChunkEntry> multiChunksA5 = multiChunkDao.getMultiChunks(TestDatabaseUtil.createVectorClock("A5"));

    // Test
   
    // - Database version "A4"   
    assertNotNull(multiChunksA4);

    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set3.sql");

    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
   
    List<MultiChunkId> multiChunkIds1 = multiChunkDao.getMultiChunkIds(FileChecksum.parseFileChecksum("254416e71ae50431fc6ced6751075b3366db7cc8"));
    List<MultiChunkId> multiChunkIds2 = multiChunkDao.getMultiChunkIds(FileChecksum.parseFileChecksum("7666fd3b860c9d7588d9ca1807eebdf8cfaa8be3"));
    List<MultiChunkId> multiChunkIdsDoesNotExist = multiChunkDao.getMultiChunkIds(FileChecksum.parseFileChecksum("beefbeefbeefbeefbeefbeefbeefbeefbeefbeef"));
   
    // Test
   
    // - Multi chunk for file 254416e71ae50431fc6ced6751075b3366db7cc8
    assertNotNull(multiChunkIds1);

    Connection databaseConnection = testConfig.createDatabaseConnection();

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set1.sql");

    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnection);
    List<MultiChunkId> dirtyMultiChunkIds = multiChunkDao.getDirtyMultiChunkIds();
       
    // Test
    assertNotNull(dirtyMultiChunkIds);
    assertEquals(1, dirtyMultiChunkIds.size());
    assertEquals(MultiChunkId.parseMultiChunkId("1234567890987654321123456789098765433222"), dirtyMultiChunkIds.get(0));

    this.applicationDao = new ApplicationSqlDao(connection);
    this.chunkDao = new ChunkSqlDao(connection);
    this.fileContentDao = new FileContentSqlDao(connection);
    this.fileVersionDao = new FileVersionSqlDao(connection);
    this.fileHistoryDao = new FileHistorySqlDao(connection, fileVersionDao);
    this.multiChunkDao = new MultiChunkSqlDao(connection);
    this.databaseVersionDao = new DatabaseVersionSqlDao(connection, chunkDao, fileContentDao, fileVersionDao, fileHistoryDao, multiChunkDao);
  }

    // Test (for dirty database existence)
    Config configB = clientB.getConfig();
    java.sql.Connection databaseConnectionB = configB.createDatabaseConnection();

    ChunkSqlDao chunkDao = new ChunkSqlDao(databaseConnectionB);
    MultiChunkSqlDao multiChunkDao = new MultiChunkSqlDao(databaseConnectionB);
    FileVersionSqlDao fileVersionDao = new FileVersionSqlDao(databaseConnectionB);
    FileHistorySqlDao fileHistoryDao = new FileHistorySqlDao(databaseConnectionB, fileVersionDao);
    FileContentSqlDao fileContentDao = new FileContentSqlDao(databaseConnectionB);
    DatabaseVersionSqlDao databaseVersionDao = new DatabaseVersionSqlDao(databaseConnectionB, chunkDao, fileContentDao, fileVersionDao, fileHistoryDao, multiChunkDao);
   

TOP

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

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.