SystemUtil { static List<String> splitIntoProcessArguments(String line) { List<String> list = new ArrayList<>(); Matcher m = Pattern.compile(SPLIT_REGEX).matcher(line); while (m.find()) { list.add(m.group(1).replace("'", "").replace("\"", "").trim()); } return list; }  @Deprecated static long getSystemTimeMillis(); static long getTimeBasedSeed(); static int getTimeBasedIntSeed(); static long getRelativeTimeMillis(); static long getFreeMemory(); static String getPropertyOrEnvironmentVariable(String name); static boolean runProcessAndWait(String exec, String params); static boolean runProcessAndWait(String exec, String params, String workingDirPath); static int runProcessAndGetExitCode(String exec, String params); static int runProcessAndGetExitCode(String exec, String params, String workingDirPath); static String runProcessAndGetOutput(String command, String params); static StringBuilder runProcessAndCollectErrors(String execPath, String params);  }
@Test public void splitIntoProcessArgumentsGsParamsTest() { List<String> processArguments = SystemUtil.splitIntoProcessArguments( " -dSAFER -dNOPAUSE -dBATCH -sDEVICE=png16m -r150 -sOutputFile='./target/test/com/itextpdf/kernel/utils/CompareToolTest/cmp_simple_pdf_with_space .pdf-%03d.png' './src/test/resources/com/itextpdf/kernel/utils/CompareToolTest/cmp_simple_pdf_with_space .pdf'"); Assert.assertEquals(Arrays.asList( "-dSAFER", "-dNOPAUSE", "-dBATCH", "-sDEVICE=png16m", "-r150", "-sOutputFile=./target/test/com/itextpdf/kernel/utils/CompareToolTest/cmp_simple_pdf_with_space .pdf-%03d.png", "./src/test/resources/com/itextpdf/kernel/utils/CompareToolTest/cmp_simple_pdf_with_space .pdf"), processArguments); }
@Test public void splitIntoProcessArgumentsMagickCompareParamsTest() { List<String> processArguments = SystemUtil.splitIntoProcessArguments( "'D:\\itext\\java\\itextcore\\kernel\\.\\target\\test\\com\\itextpdf\\kernel\\utils\\CompareToolTest\\simple_pdf.pdf-001.png' 'D:\\itext\\java\\itextcore\\kernel\\.\\target\\test\\com\\itextpdf\\kernel\\utils\\CompareToolTest\\cmp_simple_pdf_with_space .pdf-001.png' './target/test/com/itextpdf/kernel/utils/CompareToolTest/diff_simple_pdf.pdf_1.png'"); Assert.assertEquals(Arrays.asList( "D:\\itext\\java\\itextcore\\kernel\\.\\target\\test\\com\\itextpdf\\kernel\\utils\\CompareToolTest\\simple_pdf.pdf-001.png", "D:\\itext\\java\\itextcore\\kernel\\.\\target\\test\\com\\itextpdf\\kernel\\utils\\CompareToolTest\\cmp_simple_pdf_with_space .pdf-001.png", "./target/test/com/itextpdf/kernel/utils/CompareToolTest/diff_simple_pdf.pdf_1.png"), processArguments); }
@Test public void splitIntoProcessArgumentsPathInQuotesTest() { List<String> processArguments = SystemUtil .splitIntoProcessArguments("\"C:\\Test directory with spaces\\file.exe\""); Assert.assertEquals(Collections.singletonList( "C:\\Test directory with spaces\\file.exe"), processArguments); }