public static String[] toStringArray(ByteArrayOutputStream bos) { return toString(bos).split("[\\r\\n]|[\\n\\r]|[\\n]"); }
public static Map<String, String> createLocalTestEnvAndConnect(String machineName, Map<String, String> connectionProperties) throws Exception { Map<String, String> client = createLocalTestEnv(machineName, connectionProperties); // Init String[] connectArgs = new String[] { "--localdir", client.get("localdir"), "connect", "--plugin", "local", "--plugin-option", "path=" + client.get("repopath") }; logger.log(Level.INFO, "Running syncany with argument: " + StringUtil.join(connectArgs, " ")); new CommandLineClient(connectArgs).start(); fixMachineName(client); return client; }
public static String[] runAndCaptureOutput(CommandLineClient cli) throws Exception { ByteArrayOutputStream bufferedCliOut = new ByteArrayOutputStream(); cli.setOut(new SplitOutputStream(bufferedCliOut, System.out)); cli.start(); logger.log(Level.INFO, "CLI output: "); logger.log(Level.INFO, toString(bufferedCliOut)); return toStringArray(bufferedCliOut); }
public static Map<String, String> createLocalTestEnvAndInit(String machineName, Map<String, String> connectionProperties) throws Exception { Map<String, String> client = createLocalTestEnv(machineName, connectionProperties); // Init String[] initArgs = new String[] { "--localdir", client.get("localdir"), "init", "--plugin", "local", "--plugin-option", "path=" + client.get("repopath"), "--no-encryption", "--no-compression", }; logger.log(Level.INFO, "Running syncany with argument: " + StringUtil.join(initArgs, " ")); new CommandLineClient(initArgs).start(); fixMachineName(client); return client; }