@Test public void testConstructingUserHomeDirectory() throws Exception { String[] sources = new String[] { "output+", "/user/hadoop/output", "hdfs://container", "hdfs://container/", "hdfs://container/path", "output#link", "hdfs://cointaner/output#link", "hdfs://container@acc/test" }; String[] expectedResults = new String[] { "/user/webhcat/output+", "/user/hadoop/output", "hdfs://container/user/webhcat", "hdfs://container/", "hdfs://container/path", "/user/webhcat/output#link", "hdfs://cointaner/output#link", "hdfs://container@acc/test" }; for (int i = 0; i < sources.length; i++) { String source = sources[i]; String expectedResult = expectedResults[i]; String result = TempletonUtils.addUserHomeDirectoryIfApplicable(source, "webhcat"); Assert.assertEquals(result, expectedResult); } String badUri = "c:\\some\\path"; try { TempletonUtils.addUserHomeDirectoryIfApplicable(badUri, "webhcat"); Assert.fail("addUserHomeDirectoryIfApplicable should fail for bad URI: " + badUri); } catch (URISyntaxException ex) { } }