JobResourceUploader { @VisibleForTesting Path stringToPath(String s) { try { URI uri = new URI(s); return new Path(uri.getScheme(), uri.getAuthority(), uri.getPath()); } catch (URISyntaxException e) { throw new IllegalArgumentException( "Error parsing argument." + " Argument must be a valid URI: " + s, e); } } JobResourceUploader(FileSystem submitFs, boolean useWildcard); void uploadResources(Job job, Path submitJobDir);  }
@Test public void testStringToPath() throws IOException { Configuration conf = new Configuration(); JobResourceUploader uploader = new JobResourceUploader(FileSystem.getLocal(conf), false); Assert.assertEquals("Failed: absolute, no scheme, with fragment", "/testWithFragment.txt", uploader.stringToPath("/testWithFragment.txt#fragment.txt").toString()); Assert.assertEquals("Failed: absolute, with scheme, with fragment", "file:/testWithFragment.txt", uploader.stringToPath("file: .toString()); Assert.assertEquals("Failed: relative, no scheme, with fragment", "testWithFragment.txt", uploader.stringToPath("testWithFragment.txt#fragment.txt").toString()); Assert.assertEquals("Failed: relative, no scheme, no fragment", "testWithFragment.txt", uploader.stringToPath("testWithFragment.txt").toString()); Assert.assertEquals("Failed: absolute, with scheme, no fragment", "file:/testWithFragment.txt", uploader.stringToPath("file: }