use of org.syncany.database.dao.ApplicationSqlDao in project syncany by syncany.
the class ApplicationDaoTest method testShutdown.
@Test
public void testShutdown() throws Exception {
// Setup
Config testConfig = TestConfigUtil.createTestLocalConfig();
Connection databaseConnection = testConfig.createDatabaseConnection();
// Prepare
ApplicationSqlDao applicationDao = new ApplicationSqlDao(databaseConnection);
List<DatabaseRemoteFile> expectedKnownDatabases = Arrays.asList(new DatabaseRemoteFile[] { new DatabaseRemoteFile("database-A-0000000001") });
applicationDao.writeKnownRemoteDatabases(expectedKnownDatabases);
// Run & Test
assertTrue(new File(testConfig.getDatabaseFile() + ".lck").exists());
applicationDao.shutdown();
assertFalse(new File(testConfig.getDatabaseFile() + ".lck").exists());
// Tear down
databaseConnection.close();
TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
}
use of org.syncany.database.dao.ApplicationSqlDao in project syncany by syncany.
the class ApplicationDaoTest method testGetKnownDatabases.
@Test
public void testGetKnownDatabases() throws Exception {
// Setup
Config testConfig = TestConfigUtil.createTestLocalConfig();
Connection databaseConnection = testConfig.createDatabaseConnection();
// Run
TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set3.sql");
ApplicationSqlDao applicationDao = new ApplicationSqlDao(databaseConnection);
List<DatabaseRemoteFile> actualKnownDatabases = applicationDao.getKnownDatabases();
// Test
assertTrue(CollectionUtil.containsExactly(Arrays.asList(new DatabaseRemoteFile[] { new DatabaseRemoteFile("database-B-0000000001"), new DatabaseRemoteFile("database-B-0000000002"), new DatabaseRemoteFile("database-B-0000000003") }), actualKnownDatabases));
// Tear down
databaseConnection.close();
TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
}
use of org.syncany.database.dao.ApplicationSqlDao in project syncany by syncany.
the class ApplicationDaoTest method testPersistAndGetKnownDatabases.
@Test
public void testPersistAndGetKnownDatabases() throws Exception {
// Setup
Config testConfig = TestConfigUtil.createTestLocalConfig();
Connection databaseConnection = testConfig.createDatabaseConnection();
// Run
ApplicationSqlDao applicationDao = new ApplicationSqlDao(databaseConnection);
List<DatabaseRemoteFile> expectedKnownDatabases = Arrays.asList(new DatabaseRemoteFile[] { new DatabaseRemoteFile("database-A-0000000001"), new DatabaseRemoteFile("database-V-0000000001"), new DatabaseRemoteFile("database-B-0000000001"), new DatabaseRemoteFile("database-A-0000000002") });
applicationDao.writeKnownRemoteDatabases(expectedKnownDatabases);
List<DatabaseRemoteFile> actualKnownDatabases = applicationDao.getKnownDatabases();
// Test
assertTrue(CollectionUtil.containsExactly(expectedKnownDatabases, actualKnownDatabases));
// Tear down
databaseConnection.close();
TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
}
Aggregations