@Test
public void testRemoveExpiredEntriesFromListing() {

  long ttl = 9;
  long oldTime = 100;
  long newTime = 110;
  long now = 110;
  Path path = new Path("/path");
  PathMetadata pathMeta1 = new PathMetadata(
      new S3AFileStatus(true, new Path(path, "dir1"), TEST_OWNER));
  PathMetadata pathMeta2 = new PathMetadata(
      new S3AFileStatus(true, new Path(path, "dir2"), TEST_OWNER));
  PathMetadata pathMeta3 = new PathMetadata(
      new S3AFileStatus(123, 456, new Path(path, "file1"), 8192, TEST_OWNER,
          TEST_ETAG, TEST_VERSION_ID));
  pathMeta1.setLastUpdated(oldTime);
  pathMeta2.setLastUpdated(0);
  pathMeta3.setLastUpdated(newTime);
  List<PathMetadata> listing = Arrays.asList(pathMeta1, pathMeta2, pathMeta3);
  DirListingMetadata meta = new DirListingMetadata(path, listing, false);
  List<PathMetadata> expired = meta.removeExpiredEntriesFromListing(ttl,
      now);
  Assertions.assertThat(meta.getListing())
      .describedAs("Metadata listing for %s", path)
      .doesNotContain(pathMeta1)
      .contains(pathMeta2)
      .contains(pathMeta3);
  Assertions.assertThat(expired)
      .describedAs("Expire entries underr %s", path)
      .doesNotContain(pathMeta2)
      .contains(pathMeta1);
}