public static URI getUri(String path) {
    try {
      URI uri = new URI(path);
      if (uri.getScheme() != null) {
        return uri;
      } else {
        return new URI(CommonConstants.Segment.LOCAL_SEGMENT_SCHEME + ":" + path);
      }
    } catch (URISyntaxException e) {
      throw new IllegalArgumentException("Illegal URI path: " + path, e);
    }
  }
@Test
  public void testGetUri() {
    assertEquals(URIUtils.getUri("http://foo/bar").toString(), "http://foo/bar");
    assertEquals(URIUtils.getUri("http://foo/bar", "table").toString(), "http://foo/bar/table");
    assertEquals(URIUtils.getUri("http://foo/bar", "table", "segment+%25").toString(),
        "http://foo/bar/table/segment+%25");
    assertEquals(URIUtils.getUri("/foo/bar", "table", "segment+%25").toString(), "file:/foo/bar/table/segment+%25");
    assertEquals(URIUtils.getUri("file:/foo/bar", "table", "segment+%25").toString(),
        "file:/foo/bar/table/segment+%25");
  }