use of org.syncany.database.dao.FileVersionSqlDao in project syncany by syncany.
the class DatabaseVersionDaoTest method testNonEmptyDatabaseVersionHeaders.
@Test
public void testNonEmptyDatabaseVersionHeaders() throws Exception {
// Setup
Config testConfig = TestConfigUtil.createTestLocalConfig();
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);
List<DatabaseVersionHeader> databaseVersionHeaders = databaseVersionDao.getNonEmptyDatabaseVersionHeaders();
Collection<String> databaseVersionHeaderStrings = databaseVersionHeaders.stream().map(dbv -> dbv.toString()).collect(Collectors.toCollection(ArrayList::new));
// Test
assertNotNull(databaseVersionHeaders);
assertEquals(6, databaseVersionHeaders.size());
assertTrue(CollectionUtil.containsExactly(Arrays.asList(new String[] { "A/(A1)/T=1388589969000", "A/(A2)/T=1388676369000", "A/(A3)/T=1388762769000", "A/(A4)/T=1388849289000", "A/(A5)/T=1388935689000", "B/(B1)/T=1388849289000" }), databaseVersionHeaderStrings));
TestSqlUtil.runSql("DELETE FROM fileversion WHERE databaseversion_id = 0", databaseConnection);
// Tear down
databaseConnection.close();
TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
}
use of org.syncany.database.dao.FileVersionSqlDao in project syncany by syncany.
the class DatabaseVersionDaoTest method testMarkDatabaseVersionDirty.
@Test
public void testMarkDatabaseVersionDirty() throws Exception {
// Setup
Config testConfig = TestConfigUtil.createTestLocalConfig();
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);
databaseVersionDao.markDatabaseVersionDirty(TestDatabaseUtil.createVectorClock("A48"));
databaseVersionDao.markDatabaseVersionDirty(TestDatabaseUtil.createVectorClock("A49"));
databaseVersionDao.markDatabaseVersionDirty(TestDatabaseUtil.createVectorClock("A50"));
List<DatabaseVersion> dirtyDatabaseVersions = TestCollectionUtil.toList(databaseVersionDao.getDirtyDatabaseVersions());
// Test
assertNotNull(dirtyDatabaseVersions);
assertEquals(3, dirtyDatabaseVersions.size());
assertEquals("(A48)", dirtyDatabaseVersions.get(0).getVectorClock().toString());
assertEquals("(A49)", dirtyDatabaseVersions.get(1).getVectorClock().toString());
assertEquals("(A50)", dirtyDatabaseVersions.get(2).getVectorClock().toString());
// Tear down
databaseConnection.close();
TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
}
use of org.syncany.database.dao.FileVersionSqlDao in project syncany by syncany.
the class DatabaseVersionDaoTest method testGetLastDatabaseVersionHeader1.
@Test
public void testGetLastDatabaseVersionHeader1() throws Exception {
// Setup
Config testConfig = TestConfigUtil.createTestLocalConfig();
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);
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);
}
use of org.syncany.database.dao.FileVersionSqlDao in project syncany by syncany.
the class FileVersionDaoTest method testFileVersionGetCurrentFileTree.
@Test
public void testFileVersionGetCurrentFileTree() throws Exception {
// Setup
Config testConfig = TestConfigUtil.createTestLocalConfig();
Connection databaseConnection = testConfig.createDatabaseConnection();
// Run
TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set2.sql");
FileVersionSqlDao fileVersionDao = new FileVersionSqlDao(databaseConnection);
Map<String, FileVersion> currentFileTree = fileVersionDao.getCurrentFileTree();
// Test
assertEquals(50, currentFileTree.size());
assertNotNull(currentFileTree.get("file1"));
assertNotNull(currentFileTree.get("file1").getChecksum());
assertEquals("fe83f217d464f6fdfa5b2b1f87fe3a1a47371196", currentFileTree.get("file1").getChecksum().toString());
// Tear down
databaseConnection.close();
TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
}
use of org.syncany.database.dao.FileVersionSqlDao in project syncany by syncany.
the class DatabaseVersionDaoTest method testGetLocalDatabaseBranch1.
@Test
public void testGetLocalDatabaseBranch1() throws Exception {
// Setup
Config testConfig = TestConfigUtil.createTestLocalConfig();
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);
DatabaseBranch localDatabaseBranch = databaseVersionDao.getLocalDatabaseBranch();
// Test
assertNotNull(localDatabaseBranch);
assertEquals(11, localDatabaseBranch.size());
assertEquals(11, localDatabaseBranch.getAll().size());
assertEquals(TestDatabaseUtil.createBranch(new String[] { "A/(A1)/T=1389977166000", "A/(A2)/T=1389977199000", "A/(A3)/T=1389977203000", "A/(A4)/T=1389977207000", "A/(A5)/T=1389977214000", "A/(A6)/T=1389977222000", "B/(A6,B1)/T=1389977233000", "A/(A7,B1)/T=1389977234000", "B/(A7,B2)/T=1389977258000", "B/(A7,B3)/T=1389977264000", "A/(A8,B3)/T=1389977288000" }), localDatabaseBranch);
// Tear down
databaseConnection.close();
TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
}
Aggregations