Search in sources :

Example 16 with ChunkEntry

use of org.syncany.database.ChunkEntry in project syncany by syncany.

the class ChunkDaoTest method testGetChunk.

@Test
public void testGetChunk() throws Exception {
    // Setup
    Config testConfig = TestConfigUtil.createTestLocalConfig();
    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());
    assertNotNull(chunk2);
    assertEquals("ab85720d3f31bd08ca1cd25dcd8a490e5f00783b", chunk2.getChecksum().toString());
    assertEquals(5176, chunk2.getSize());
    assertNull(chunkNonExistent);
    // Tear down
    databaseConnection.close();
    TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
}
Also used : ChunkSqlDao(org.syncany.database.dao.ChunkSqlDao) Config(org.syncany.config.Config) ChunkEntry(org.syncany.database.ChunkEntry) Connection(java.sql.Connection) Test(org.junit.Test)

Aggregations

ChunkEntry (org.syncany.database.ChunkEntry)16 MultiChunkEntry (org.syncany.database.MultiChunkEntry)12 ChunkChecksum (org.syncany.database.ChunkEntry.ChunkChecksum)11 DatabaseVersion (org.syncany.database.DatabaseVersion)11 Test (org.junit.Test)10 MemoryDatabase (org.syncany.database.MemoryDatabase)7 FileContent (org.syncany.database.FileContent)5 MultiChunkId (org.syncany.database.MultiChunkEntry.MultiChunkId)5 Connection (java.sql.Connection)3 Config (org.syncany.config.Config)3 PartialFileHistory (org.syncany.database.PartialFileHistory)3 ChunkSqlDao (org.syncany.database.dao.ChunkSqlDao)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 DatabaseVersionHeader (org.syncany.database.DatabaseVersionHeader)2 FileChecksum (org.syncany.database.FileContent.FileChecksum)2 FileVersion (org.syncany.database.FileVersion)2 FileHistoryId (org.syncany.database.PartialFileHistory.FileHistoryId)2 File (java.io.File)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1