Search in sources :

Example 31 with Config

use of org.syncany.config.Config 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);
}
Also used : Config(org.syncany.config.Config) DatabaseRemoteFile(org.syncany.plugins.transfer.files.DatabaseRemoteFile) Connection(java.sql.Connection) ApplicationSqlDao(org.syncany.database.dao.ApplicationSqlDao) Test(org.junit.Test)

Example 32 with Config

use of org.syncany.config.Config in project syncany by syncany.

the class ConfigHelperTest method testConfigHelperFindLocalDirInPath.

@Test
public void testConfigHelperFindLocalDirInPath() throws Exception {
    // Setup
    Config testConfig = TestConfigUtil.createTestLocalConfig();
    File startingPath = testConfig.getLocalDir();
    // Run
    File actualLocalDir = ConfigHelper.findLocalDirInPath(startingPath);
    // Test
    assertNotNull(actualLocalDir);
    assertEquals(testConfig.getLocalDir(), actualLocalDir.getCanonicalFile());
    // Tear down
    TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
}
Also used : Config(org.syncany.config.Config) File(java.io.File) Test(org.junit.Test)

Example 33 with Config

use of org.syncany.config.Config in project syncany by syncany.

the class ConfigTest method testConfigMultiChunkerNull.

@Test
public void testConfigMultiChunkerNull() throws Exception {
    // Setup
    File localDir = new File("/some/folder");
    ConfigTO configTO = new ConfigTO();
    RepoTO repoTO = new RepoTO();
    // <<< valid
    configTO.setMachineName("somevalidmachinename");
    // <<< valid
    repoTO.setChunkerTO(TestConfigUtil.createFixedChunkerTO());
    // <<< valid
    repoTO.setRepoId(new byte[] { 0x01, 0x02 });
    // <<< valid
    repoTO.setTransformers(null);
    // <<< INVALID !!
    repoTO.setMultiChunker(null);
    // Run!
    try {
        new Config(localDir, configTO, repoTO);
        fail("Config should not been have initialized.");
    } catch (ConfigException e) {
        TestAssertUtil.assertErrorStackTraceContains("No multichunker", e);
    }
}
Also used : Config(org.syncany.config.Config) ConfigException(org.syncany.config.ConfigException) ConfigTO(org.syncany.config.to.ConfigTO) RepoTO(org.syncany.config.to.RepoTO) File(java.io.File) Test(org.junit.Test)

Example 34 with Config

use of org.syncany.config.Config in project syncany by syncany.

the class ConfigTest method testConfigMachineNameInvalidChars.

@Test
public void testConfigMachineNameInvalidChars() throws Exception {
    File localDir = new File("/some/folder");
    ConfigTO configTO = new ConfigTO();
    RepoTO repoTO = new RepoTO();
    configTO.setMachineName("invalid machine name");
    // Run!
    try {
        new Config(localDir, configTO, repoTO);
        fail("Machine name should not have been accepted.");
    } catch (ConfigException e) {
        TestAssertUtil.assertErrorStackTraceContains("Machine name", e);
    }
}
Also used : Config(org.syncany.config.Config) ConfigException(org.syncany.config.ConfigException) ConfigTO(org.syncany.config.to.ConfigTO) RepoTO(org.syncany.config.to.RepoTO) File(java.io.File) Test(org.junit.Test)

Example 35 with Config

use of org.syncany.config.Config in project syncany by syncany.

the class ConfigTest method testConfigInitLocalDirNull.

@Test(expected = ConfigException.class)
public void testConfigInitLocalDirNull() throws Exception {
    File localDir = null;
    ConfigTO configTO = new ConfigTO();
    RepoTO repoTO = new RepoTO();
    new Config(localDir, configTO, repoTO);
}
Also used : Config(org.syncany.config.Config) ConfigTO(org.syncany.config.to.ConfigTO) RepoTO(org.syncany.config.to.RepoTO) File(java.io.File) Test(org.junit.Test)

Aggregations

Config (org.syncany.config.Config)55 Test (org.junit.Test)52 Connection (java.sql.Connection)25 File (java.io.File)24 MultiChunkSqlDao (org.syncany.database.dao.MultiChunkSqlDao)18 ConfigTO (org.syncany.config.to.ConfigTO)15 RepoTO (org.syncany.config.to.RepoTO)14 ChunkSqlDao (org.syncany.database.dao.ChunkSqlDao)14 FileContentSqlDao (org.syncany.database.dao.FileContentSqlDao)14 FileVersionSqlDao (org.syncany.database.dao.FileVersionSqlDao)13 DatabaseVersionSqlDao (org.syncany.database.dao.DatabaseVersionSqlDao)12 FileHistorySqlDao (org.syncany.database.dao.FileHistorySqlDao)12 MultiChunkId (org.syncany.database.MultiChunkEntry.MultiChunkId)10 DatabaseVersion (org.syncany.database.DatabaseVersion)9 ConfigException (org.syncany.config.ConfigException)7 FileVersion (org.syncany.database.FileVersion)7 ArrayList (java.util.ArrayList)6 MultiChunkEntry (org.syncany.database.MultiChunkEntry)6 UpOperation (org.syncany.operations.up.UpOperation)6 Date (java.util.Date)5