### Question:
PathQuoteUtil { public static String quoteIfRequired(final String original) { if (LauncherUtil.isWindows() && original != null && original.contains(WHITESPACE) && !original.startsWith(DOUBLE_QUOTE)) { return DOUBLE_QUOTE + original + DOUBLE_QUOTE; } return original; }  static String quoteIfRequired(final String original);  }### Answer:
@Test public void testUnquotedClasspathWithoutSpaces() { final String classpathWithoutSpaces = "c:\\Applications\\OpenWebStart\\javaws.jar"; final String expected = "c:\\Applications\\OpenWebStart\\javaws.jar"; final String transformed = PathQuoteUtil.quoteIfRequired(classpathWithoutSpaces); Assertions.assertEquals(expected, transformed); }
@Test public void testUnqotedClasspathWithSpaces() { final String classpathWithSpaces = "c:\\Program Files\\OpenWebStart\\javaws.jar"; final String expectedWindows = "\"c:\\Program Files\\OpenWebStart\\javaws.jar\""; final String expectedUnix = "c:\\Program Files\\OpenWebStart\\javaws.jar"; final String transformed = PathQuoteUtil.quoteIfRequired(classpathWithSpaces); if (LauncherUtil.isWindows()) { Assertions.assertEquals(expectedWindows, transformed); } else { Assertions.assertEquals(expectedUnix, transformed); } }
@Test public void testAlreadyQuotedClasspathWithSpaces() { final String quotedClasspathWithSpaces = "\"c:\\Program Files\\OpenWebStart\\javaws.jar\""; final String expected = "\"c:\\Program Files\\OpenWebStart\\javaws.jar\""; final String transformed = PathQuoteUtil.quoteIfRequired(quotedClasspathWithSpaces); Assertions.assertEquals(expected, transformed); }
@Test public void testNullClasspath() { Assertions.assertNull(PathQuoteUtil.quoteIfRequired(null)); }