if (uri.hasScheme()) { String warnMsg = "The URI scheme \"{}\" is ignored and not required in URIs passed to" + " the Alluxio Filesystem client.";
/** * Tests the {@link AlluxioURI#hasScheme()} method. */ @Test public void hasScheme() { assertFalse(new AlluxioURI("/").hasScheme()); assertTrue(new AlluxioURI("file:/").hasScheme()); assertTrue(new AlluxioURI("file://localhost/").hasScheme()); assertTrue(new AlluxioURI("file://localhost:8080/").hasScheme()); assertFalse(new AlluxioURI("//localhost:8080/").hasScheme()); }
/** * Tests the {@link AlluxioURI#AlluxioURI(String)} constructor for an empty URI. */ @Test public void emptyURI() { AlluxioURI uri = new AlluxioURI(""); assertEquals("", uri.getAuthority().toString()); assertTrue(uri.getAuthority() instanceof NoAuthority); assertEquals(0, uri.getDepth()); assertEquals("", uri.getName()); assertEquals("", uri.getPath()); assertEquals(null, uri.getScheme()); assertFalse(uri.hasAuthority()); assertFalse(uri.hasScheme()); assertFalse(uri.isAbsolute()); assertFalse(uri.isPathAbsolute()); assertEquals("/d", uri.join("/d").toString()); assertEquals("/d", uri.join(new AlluxioURI("/d")).toString()); assertEquals("", uri.toString()); }
@Test public void basicMultiMasterUri() { AlluxioURI uri = new AlluxioURI("alluxio://host1:19998,host2:19998,host3:19998/xy z/a b c"); assertTrue(uri.hasAuthority()); assertEquals("host1:19998,host2:19998,host3:19998", uri.getAuthority().toString()); assertTrue(uri.getAuthority() instanceof MultiMasterAuthority); assertEquals(2, uri.getDepth()); assertEquals("a b c", uri.getName()); assertEquals("alluxio://host1:19998,host2:19998,host3:19998/xy z", uri.getParent().toString()); assertEquals("alluxio://host1:19998,host2:19998,host3:19998/", uri.getParent().getParent().toString()); assertEquals("/xy z/a b c", uri.getPath()); assertEquals("alluxio", uri.getScheme()); assertTrue(uri.hasScheme()); assertTrue(uri.isAbsolute()); assertTrue(uri.isPathAbsolute()); assertEquals("alluxio://host1:19998,host2:19998,host3:19998/xy z/a b c/d", uri.join("/d").toString()); assertEquals("alluxio://host1:19998,host2:19998,host3:19998/xy z/a b c/d", uri.join(new AlluxioURI("/d")).toString()); assertEquals("alluxio://host1:19998,host2:19998,host3:19998/xy z/a b c", uri.toString()); }
@Test public void basicTwoPartUri() { AlluxioURI uri = new AlluxioURI("scheme:part2://localhost:8000/xy z/a b c"); assertEquals(uri, new AlluxioURI("scheme:part2//localhost:8000/xy z/a b c")); assertEquals("scheme:part2", uri.getScheme()); assertTrue(uri.hasAuthority()); assertEquals("localhost:8000", uri.getAuthority().toString()); assertTrue(uri.getAuthority() instanceof SingleMasterAuthority); SingleMasterAuthority authority = (SingleMasterAuthority) uri.getAuthority(); assertEquals("localhost", authority.getHost()); assertEquals(8000, authority.getPort()); assertEquals(2, uri.getDepth()); assertEquals("a b c", uri.getName()); assertEquals("scheme:part2://localhost:8000/xy z", uri.getParent().toString()); assertEquals("scheme:part2://localhost:8000/", uri.getParent().getParent().toString()); assertEquals("/xy z/a b c", uri.getPath()); assertTrue(uri.hasScheme()); assertTrue(uri.isAbsolute()); assertTrue(uri.isPathAbsolute()); assertEquals("scheme:part2://localhost:8000/xy z/a b c/d", uri.join("/d").toString()); assertEquals("scheme:part2://localhost:8000/xy z/a b c/d", uri.join(new AlluxioURI("/d")) .toString()); assertEquals("scheme:part2://localhost:8000/xy z/a b c", uri.toString()); }
/** * Tests the {@link AlluxioURI#AlluxioURI(String)} constructor for basic Alluxio paths. */ @Test public void basicAlluxioUri() { AlluxioURI uri = new AlluxioURI("alluxio://localhost:19998/xy z/a b c"); assertTrue(uri.hasAuthority()); assertEquals("localhost:19998", uri.getAuthority().toString()); assertTrue(uri.getAuthority() instanceof SingleMasterAuthority); SingleMasterAuthority authority = (SingleMasterAuthority) uri.getAuthority(); assertEquals("localhost", authority.getHost()); assertEquals(19998, authority.getPort()); assertEquals(2, uri.getDepth()); assertEquals("a b c", uri.getName()); assertEquals("alluxio://localhost:19998/xy z", uri.getParent().toString()); assertEquals("alluxio://localhost:19998/", uri.getParent().getParent().toString()); assertEquals("/xy z/a b c", uri.getPath()); assertEquals("alluxio", uri.getScheme()); assertTrue(uri.hasScheme()); assertTrue(uri.isAbsolute()); assertTrue(uri.isPathAbsolute()); assertEquals("alluxio://localhost:19998/xy z/a b c/d", uri.join("/d").toString()); assertEquals("alluxio://localhost:19998/xy z/a b c/d", uri.join(new AlluxioURI("/d")) .toString()); assertEquals("alluxio://localhost:19998/xy z/a b c", uri.toString()); }
/** * Tests the {@link AlluxioURI#AlluxioURI(String)} constructor for basic HDFS paths. */ @Test public void basicHdfsUri() { AlluxioURI uri = new AlluxioURI("hdfs://localhost:8020/xy z/a b c"); assertTrue(uri.hasAuthority()); assertEquals("localhost:8020", uri.getAuthority().toString()); assertTrue(uri.getAuthority() instanceof SingleMasterAuthority); SingleMasterAuthority authority = (SingleMasterAuthority) uri.getAuthority(); assertEquals("localhost", authority.getHost()); assertEquals(8020, authority.getPort()); assertEquals(2, uri.getDepth()); assertEquals("a b c", uri.getName()); assertEquals("hdfs://localhost:8020/xy z", uri.getParent().toString()); assertEquals("hdfs://localhost:8020/", uri.getParent().getParent().toString()); assertEquals("/xy z/a b c", uri.getPath()); assertEquals("hdfs", uri.getScheme()); assertTrue(uri.hasScheme()); assertTrue(uri.isAbsolute()); assertTrue(uri.isPathAbsolute()); assertEquals("hdfs://localhost:8020/xy z/a b c/d", uri.join("/d").toString()); assertEquals("hdfs://localhost:8020/xy z/a b c/d", uri.join(new AlluxioURI("/d")) .toString()); assertEquals("hdfs://localhost:8020/xy z/a b c", uri.toString()); }
@Test public void basicZookeeperUri() { AlluxioURI uri = new AlluxioURI("alluxio://zk@host1:2181,host2:2181,host3:2181/xy z/a b c"); assertEquals(uri, new AlluxioURI("alluxio://zk@host1:2181,host2:2181,host3:2181/xy z/a b c")); assertEquals("alluxio", uri.getScheme()); assertEquals("zk@host1:2181,host2:2181,host3:2181", uri.getAuthority().toString()); assertTrue(uri.getAuthority() instanceof ZookeeperAuthority); ZookeeperAuthority zkAuthority = (ZookeeperAuthority) uri.getAuthority(); assertEquals("host1:2181,host2:2181,host3:2181", zkAuthority.getZookeeperAddress()); assertEquals(2, uri.getDepth()); assertEquals("a b c", uri.getName()); assertEquals("alluxio://zk@host1:2181,host2:2181,host3:2181/xy z", uri.getParent().toString()); assertEquals("alluxio://zk@host1:2181,host2:2181,host3:2181/", uri.getParent().getParent().toString()); assertEquals("/xy z/a b c", uri.getPath()); assertTrue(uri.hasAuthority()); assertTrue(uri.hasScheme()); assertTrue(uri.isAbsolute()); assertTrue(uri.isPathAbsolute()); assertEquals("alluxio://zk@host1:2181,host2:2181,host3:2181/xy z/a b c/d", uri.join("/d").toString()); assertEquals("alluxio://zk@host1:2181,host2:2181,host3:2181/xy z/a b c/d", uri.join(new AlluxioURI("/d")) .toString()); assertEquals("alluxio://zk@host1:2181,host2:2181,host3:2181/xy z/a b c", uri.toString()); }