@SuppressWarnings("StreamResourceLeak")
  @Test
  public void testClosedSecureDirectoryStreamAttributeViewAndIterator() throws IOException {
    Files.createDirectory(path("/foo"));
    Files.createDirectory(path("/foo/bar"));
    SecureDirectoryStream<Path> stream =
        (SecureDirectoryStream<Path>) Files.newDirectoryStream(path("/foo"));

    Iterator<Path> iter = stream.iterator();
    BasicFileAttributeView view1 = stream.getFileAttributeView(BasicFileAttributeView.class);
    BasicFileAttributeView view2 =
        stream.getFileAttributeView(path("bar"), BasicFileAttributeView.class);

    try {
      stream.iterator();
      fail("expected IllegalStateException");
    } catch (IllegalStateException expected) {
    }

    stream.close();

    try {
      iter.next();
      fail("expected ClosedDirectoryStreamException");
    } catch (ClosedDirectoryStreamException expected) {
    }

    try {
      view1.readAttributes();
      fail("expected ClosedDirectoryStreamException");
    } catch (ClosedDirectoryStreamException expected) {
    }

    try {
      view2.readAttributes();
      fail("expected ClosedDirectoryStreamException");
    } catch (ClosedDirectoryStreamException expected) {
    }

    try {
      view1.setTimes(null, null, null);
      fail("expected ClosedDirectoryStreamException");
    } catch (ClosedDirectoryStreamException expected) {
    }

    try {
      view2.setTimes(null, null, null);
      fail("expected ClosedDirectoryStreamException");
    } catch (ClosedDirectoryStreamException expected) {
    }
  }
");
    assertThatPath("foo/bar").doesNotMatch("glob:/**");
    assertThatPath("/foo/bar/baz/stuff").matches("glob:/foo/**");
    assertThatPath("/foo/bar/baz/stuff").matches("glob:/*
jimfs/src/test/java/com/google/common/jimfs/JimfsUnixLikeFileSystemTest.java