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);
}
Aggregations