@Test
public void testGetItemName()
    throws URISyntaxException {

  // Trailing slashes are effectively stripped for returned bucket names, but not for object
  // names.
  String[] inputPaths = {
    "gs:/",
    "gs://my-bucket",
    "gs://my-bucket/",
    "gs://my-bucket/foo",
    "gs://my-bucket/foo/",
    "gs://my-bucket/foo/bar",
    "gs://my-bucket/foo/bar/",
  };
  String[] expectedNames = {
    null,
    "my-bucket",
    "my-bucket",
    "foo",
    "foo/",
    "bar",
    "bar/",
  };
  List<String> actualNames = new ArrayList<>();
  for (String inputPath : inputPaths) {
    actualNames.add(gcsfs.getItemName(new URI(inputPath)));
  }
  assertThat(actualNames.toArray(new String[0])).isEqualTo(expectedNames);
}