Config { public void setMachineName(String machineName) throws ConfigException { if (machineName == null || !VectorClock.MACHINE_PATTERN.matcher(machineName).matches()) { throw new ConfigException("Machine name cannot be empty and must be only characters (A-Z)."); } this.machineName = machineName; } Config(File aLocalDir, ConfigTO configTO, RepoTO repoTO); java.sql.Connection createDatabaseConnection(); java.sql.Connection createDatabaseConnection(boolean readOnly); File getCacheDir(); File getAppDir(); String getMachineName(); void setMachineName(String machineName); String getDisplayName(); void setDisplayName(String displayName); TransferPlugin getTransferPlugin(); TransferSettings getConnection(); void setConnection(TransferSettings connection); byte[] getRepoId(); Chunker getChunker(); Cache getCache(); IgnoredFiles getIgnoredFiles(); MultiChunker getMultiChunker(); Transformer getTransformer(); void setCache(Cache cache); File getLocalDir(); File getDatabaseDir(); File getLogDir(); File getStateDir(); SaltedSecretKey getMasterKey(); File getDatabaseFile(); File getPortFile(); File getTransactionFile(); File getTransactionDatabaseFile(); File getTransactionListFile(); File getTransactionFile(long databaseVersionNumber); File getTransactionDatabaseFile(long databaseVersionNumber); static final String DIR_APPLICATION; static final String DIR_CACHE; static final String DIR_DATABASE; static final String DIR_LOG; static final String DIR_STATE; static final String FILE_IGNORE; static final String FILE_CONFIG; static final String FILE_REPO; static final String FILE_MASTER; static final String FILE_DATABASE; static final String FILE_PORT; static final String FILE_TRANSACTION; static final String FILE_TRANSACTION_DATABASE; static final String FILE_TRANSACTION_PATTERN; static final String FILE_TRANSACTION_DATABASE_PATTERN; static final String FILE_TRANSACTION_LIST; }
@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"); try { new Config(localDir, configTO, repoTO); fail("Machine name should not have been accepted."); } catch (ConfigException e) { TestAssertUtil.assertErrorStackTraceContains("Machine name", e); } }
@Test public void testConfigMachineNameInvalidNull() throws Exception { File localDir = new File("/some/folder"); ConfigTO configTO = new ConfigTO(); RepoTO repoTO = new RepoTO(); configTO.setMachineName(null); try { new Config(localDir, configTO, repoTO); fail("Machine name should not have been accepted."); } catch (ConfigException e) { TestAssertUtil.assertErrorStackTraceContains("Machine name", e); } }
@Test public void testConfigMultiChunkerNull() throws Exception { File localDir = new File("/some/folder"); ConfigTO configTO = new ConfigTO(); RepoTO repoTO = new RepoTO(); configTO.setMachineName("somevalidmachinename"); repoTO.setChunkerTO(TestConfigUtil.createFixedChunkerTO()); repoTO.setRepoId(new byte[] { 0x01, 0x02 }); repoTO.setTransformers(null); repoTO.setMultiChunker(null); try { new Config(localDir, configTO, repoTO); fail("Config should not been have initialized."); } catch (ConfigException e) { TestAssertUtil.assertErrorStackTraceContains("No multichunker", e); } }
@Test @Ignore public void testConfigChunkerNull() throws Exception { File localDir = new File("/some/folder"); ConfigTO configTO = new ConfigTO(); RepoTO repoTO = new RepoTO(); configTO.setMachineName("somevalidmachinename"); repoTO.setMultiChunker(TestConfigUtil.createZipMultiChunkerTO()); repoTO.setRepoId(new byte[] { 0x01, 0x02 }); repoTO.setTransformers(null); repoTO.setChunkerTO(null); try { new Config(localDir, configTO, repoTO); fail("Config should not been have initialized."); } catch (ConfigException e) { TestAssertUtil.assertErrorStackTraceContains("No multichunker", e); } }
@Test public void testConfigCipherTransformersInvalidType() throws Exception { File localDir = new File("/some/folder"); ConfigTO configTO = new ConfigTO(); RepoTO repoTO = new RepoTO(); configTO.setMachineName("somevalidmachinename"); repoTO.setChunkerTO(TestConfigUtil.createFixedChunkerTO()); repoTO.setMultiChunker(TestConfigUtil.createZipMultiChunkerTO()); repoTO.setRepoId(new byte[] { 0x01, 0x02 }); TransformerTO invalidTransformerTO = new TransformerTO(); invalidTransformerTO.setType("invalid-typeXXX"); invalidTransformerTO.setSettings(new HashMap<String, String>()); List<TransformerTO> transformers = new ArrayList<TransformerTO>(); transformers.add(invalidTransformerTO); repoTO.setTransformers(transformers); try { new Config(localDir, configTO, repoTO); fail("Transformer should NOT have been found."); } catch (ConfigException e) { TestAssertUtil.assertErrorStackTraceContains("invalid-typeXXX", e); } }
@Test @SuppressWarnings("serial") public void testConfigCipherTransformersCipherNotFound() throws Exception { File localDir = new File("/some/folder"); ConfigTO configTO = new ConfigTO(); RepoTO repoTO = new RepoTO(); configTO.setMachineName("somevalidmachinename"); repoTO.setChunkerTO(TestConfigUtil.createFixedChunkerTO()); repoTO.setMultiChunker(TestConfigUtil.createZipMultiChunkerTO()); repoTO.setRepoId(new byte[] { 0x01, 0x02 }); configTO.setMasterKey(createDummyMasterKey()); TransformerTO invalidTransformerTO = new TransformerTO(); invalidTransformerTO.setType("cipher"); invalidTransformerTO.setSettings(new HashMap<String, String>() { { put("cipherspecs", "1,INVALIDXXXX"); } }); List<TransformerTO> transformers = new ArrayList<TransformerTO>(); transformers.add(invalidTransformerTO); repoTO.setTransformers(transformers); try { new Config(localDir, configTO, repoTO); fail("Transformer should NOT have been able to initialize."); } catch (ConfigException e) { TestAssertUtil.assertErrorStackTraceContains("INVALIDXXXX", e); } }