@Test
  public void testFilesMethodsThrow() throws IOException {
    Path file = fs.getPath("/file");
    Path dir = fs.getPath("/dir");
    Path nothing = fs.getPath("/nothing");

    Files.createDirectory(dir);
    Files.createFile(file);

    fs.close();

    // not exhaustive, but should cover every major type of functionality accessible through Files
    // TODO(cgdecker): reflectively invoke all methods with default arguments?

    try {
      Files.delete(file);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.createDirectory(nothing);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.createFile(nothing);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.write(nothing, ImmutableList.of("hello world"), UTF_8);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.newInputStream(file);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.newOutputStream(file);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.newByteChannel(file);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.newDirectoryStream(dir);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.copy(file, nothing);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.move(file, nothing);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.copy(dir, nothing);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.move(dir, nothing);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.createSymbolicLink(nothing, file);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.createLink(nothing, file);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.exists(file);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.getAttribute(file, "size");
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.setAttribute(file, "lastModifiedTime", FileTime.fromMillis(0));
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.getFileAttributeView(file, BasicFileAttributeView.class);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.readAttributes(file, "basic:size,lastModifiedTime");
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.readAttributes(file, BasicFileAttributes.class);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.isDirectory(dir);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.readAllBytes(file);
      fail();
    } catch (ClosedFileSystemException expected) {
    }

    try {
      Files.isReadable(file);
      fail();
    } catch (ClosedFileSystemException expected) {
    }
  }
Tests for what happens when a file system is closed.

@author Colin Decker
jimfs/src/test/java/com/google/common/jimfs/JimfsFileSystemCloseTest.java