Search in sources :

Example 16 with RepoTO

use of org.syncany.config.to.RepoTO 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 17 with RepoTO

use of org.syncany.config.to.RepoTO 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)

Example 18 with RepoTO

use of org.syncany.config.to.RepoTO in project syncany by syncany.

the class ConfigTest method testConfigCipherTransformersCipherFound.

@Test
@SuppressWarnings("serial")
public void testConfigCipherTransformersCipherFound() 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.setMultiChunker(TestConfigUtil.createZipMultiChunkerTO());
    // <<< valid
    repoTO.setRepoId(new byte[] { 0x01, 0x02 });
    // <<< valid
    configTO.setMasterKey(createDummyMasterKey());
    // Set invalid transformer
    TransformerTO invalidTransformerTO = new TransformerTO();
    invalidTransformerTO.setType("cipher");
    invalidTransformerTO.setSettings(new HashMap<String, String>() {

        {
            put("cipherspecs", "1,2");
        }
    });
    List<TransformerTO> transformers = new ArrayList<TransformerTO>();
    transformers.add(invalidTransformerTO);
    // <<< valid
    repoTO.setTransformers(transformers);
    // Run!
    Config config = new Config(localDir, configTO, repoTO);
    // Test
    assertNotNull(config.getChunker());
    assertNotNull(config.getMultiChunker());
    assertNotNull(config.getTransformer());
    assertEquals("CipherTransformer", config.getTransformer().getClass().getSimpleName());
}
Also used : TransformerTO(org.syncany.config.to.RepoTO.TransformerTO) Config(org.syncany.config.Config) ArrayList(java.util.ArrayList) ConfigTO(org.syncany.config.to.ConfigTO) RepoTO(org.syncany.config.to.RepoTO) File(java.io.File) Test(org.junit.Test)

Example 19 with RepoTO

use of org.syncany.config.to.RepoTO in project syncany by syncany.

the class ConfigTest method testConfigChunkerNull.

@Test
@Ignore
public // TODO [low] ChunkerTO is not used yet; so no test for it.
void testConfigChunkerNull() throws Exception {
    // Setup
    File localDir = new File("/some/folder");
    ConfigTO configTO = new ConfigTO();
    RepoTO repoTO = new RepoTO();
    // <<< valid
    configTO.setMachineName("somevalidmachinename");
    // <<< valid
    repoTO.setMultiChunker(TestConfigUtil.createZipMultiChunkerTO());
    // <<< valid
    repoTO.setRepoId(new byte[] { 0x01, 0x02 });
    // <<< valid
    repoTO.setTransformers(null);
    // <<< INVALID !!
    repoTO.setChunkerTO(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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 20 with RepoTO

use of org.syncany.config.to.RepoTO in project syncany by syncany.

the class TestConfigUtil method createRepoTO.

public static RepoTO createRepoTO() {
    // Create Repo TO
    RepoTO repoTO = new RepoTO();
    repoTO.setRepoId(new byte[] { 0x01, 0x02, 0x03 });
    // Create ChunkerTO and MultiChunkerTO
    MultiChunkerTO multiChunkerTO = createZipMultiChunkerTO();
    ChunkerTO chunkerTO = createFixedChunkerTO();
    // TODO [low] Chunker not configurable right now. Not used.
    repoTO.setChunkerTO(chunkerTO);
    repoTO.setMultiChunker(multiChunkerTO);
    // Create TransformerTO
    List<TransformerTO> transformerTOs = createTransformerTOs();
    repoTO.setTransformers(transformerTOs);
    return repoTO;
}
Also used : ChunkerTO(org.syncany.config.to.RepoTO.ChunkerTO) MultiChunkerTO(org.syncany.config.to.RepoTO.MultiChunkerTO) MultiChunkerTO(org.syncany.config.to.RepoTO.MultiChunkerTO) TransformerTO(org.syncany.config.to.RepoTO.TransformerTO) RepoTO(org.syncany.config.to.RepoTO)

Aggregations

RepoTO (org.syncany.config.to.RepoTO)30 ConfigTO (org.syncany.config.to.ConfigTO)29 File (java.io.File)26 Test (org.junit.Test)24 Config (org.syncany.config.Config)14 TransformerTO (org.syncany.config.to.RepoTO.TransformerTO)7 ArrayList (java.util.ArrayList)6 ConfigException (org.syncany.config.ConfigException)6 Ignore (org.junit.Ignore)2 UserConfig (org.syncany.config.UserConfig)2 SaltedSecretKey (org.syncany.crypto.SaltedSecretKey)2 InitOperationOptions (org.syncany.operations.init.InitOperationOptions)2 LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)2 TransferPlugin (org.syncany.plugins.transfer.TransferPlugin)2 UnreliableLocalTransferSettings (org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings)2 HashMap (java.util.HashMap)1 Random (java.util.Random)1 OptionParser (joptsimple.OptionParser)1 OptionSet (joptsimple.OptionSet)1 Persister (org.simpleframework.xml.core.Persister)1