public static Map<String, String> createLocalTestEnv(String machineName, Map<String, String> connectionProperties) throws Exception { Map<String, String> clientSettings = new HashMap<String, String>(); File tempLocalDir = TestFileUtil.createTempDirectoryInSystemTemp(TestConfigUtil.createUniqueName("client-" + machineName, connectionProperties)); tempLocalDir.mkdirs(); // Client settings clientSettings.put("machinename", machineName); clientSettings.put("localdir", tempLocalDir.getAbsolutePath()); clientSettings.put("repopath", connectionProperties.get("path")); return clientSettings; }
public static Map<String, String> createTestLocalConnectionSettings() throws Exception { Map<String, String> pluginSettings = new HashMap<String, String>(); File tempRepoDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("repo", new Random().nextFloat())); pluginSettings.put("path", tempRepoDir.getAbsolutePath()); return pluginSettings; }
public static UnreliableLocalTransferSettings createTestUnreliableLocalConnectionWithoutInit(UnreliableLocalTransferPlugin unreliableLocalPlugin, List<String> failingOperationPatterns) throws Exception { UnreliableLocalTransferSettings unreliableLocalConnection = unreliableLocalPlugin.createEmptySettings(); File tempRepoDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("repo", new Random().nextFloat())); unreliableLocalConnection.setPath(tempRepoDir); unreliableLocalConnection.setFailingOperationPatterns(failingOperationPatterns); return unreliableLocalConnection; }
public static TransferSettings createTestLocalConnection() throws Exception { TransferPlugin plugin = Plugins.get("local", TransferPlugin.class); LocalTransferSettings conn = plugin.createEmptySettings(); File tempRepoDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("repo", conn)); conn.setPath(tempRepoDir); // TODO [medium] : possible problem plugin.createTransferManager(conn, null).init(true); return conn; }
public static Config createTestLocalConfig(String machineName, TransferSettings connection) throws Exception { File tempLocalDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("client-" + machineName, connection)); tempLocalDir.mkdirs(); RepoTO repoTO = createRepoTO(); // Create config TO ConfigTO configTO = new ConfigTO(); configTO.setMachineName(machineName + CipherUtil.createRandomAlphabeticString(20)); // Get Masterkey SaltedSecretKey masterKey = getMasterKey(); configTO.setMasterKey(masterKey); LocalTransferSettings localConnection = (LocalTransferSettings) connection; // Create connection TO Map<String, String> localConnectionSettings = new HashMap<String, String>(); localConnectionSettings.put("path", localConnection.getPath().getAbsolutePath()); configTO.setTransferSettings(connection); // Create Config config = new Config(tempLocalDir, configTO, repoTO); config.setConnection(connection); config.getAppDir().mkdirs(); config.getCacheDir().mkdirs(); config.getDatabaseDir().mkdirs(); config.getLogDir().mkdirs(); config.getStateDir().mkdirs(); // Write to config folder (required for some tests) new Persister().write(configTO, new File(config.getAppDir() + "/" + Config.FILE_CONFIG)); new Persister().write(repoTO, new File(config.getAppDir() + "/" + Config.FILE_REPO)); return config; }
public static InitOperationOptions createTestInitOperationOptions(String machineName) throws Exception { File tempLocalDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("client-" + machineName, machineName)); File tempRepoDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("repo", machineName)); tempLocalDir.mkdirs(); tempRepoDir.mkdirs(); RepoTO repoTO = createRepoTO(); // Create config TO ConfigTO configTO = new ConfigTO(); configTO.setMachineName(machineName + Math.abs(new Random().nextInt())); // Get Masterkey SaltedSecretKey masterKey = getMasterKey(); configTO.setMasterKey(masterKey); // Generic connection settings wont work anymore, because they are plugin dependent now. LocalTransferSettings transferSettings = Plugins.get("local", TransferPlugin.class).createEmptySettings(); transferSettings.setPath(tempRepoDir); configTO.setTransferSettings(transferSettings); InitOperationOptions operationOptions = new InitOperationOptions(); operationOptions.setLocalDir(tempLocalDir); operationOptions.setConfigTO(configTO); operationOptions.setRepoTO(repoTO); operationOptions.setEncryptionEnabled(cryptoEnabled); operationOptions.setCipherSpecs(CipherSpecs.getDefaultCipherSpecs()); operationOptions.setPassword(cryptoEnabled ? "some password" : null); return operationOptions; }