@Test
  public void testSymbolicLinks() throws IOException {
    Files.createSymbolicLink(path("/link.txt"), path("/file.txt"));
    assertThatPath("/link.txt", NOFOLLOW_LINKS).isSymbolicLink().withTarget("/file.txt");
    assertThatPath("/link.txt").doesNotExist(); // following the link; target doesn't exist

    try {
      Files.createFile(path("/link.txt"));
      fail();
    } catch (FileAlreadyExistsException expected) {
    }

    try {
      Files.readAllBytes(path("/link.txt"));
      fail();
    } catch (NoSuchFileException expected) {
    }

    Files.createFile(path("/file.txt"));
    assertThatPath("/link.txt").isRegularFile(); // following the link; target does exist
    assertThatPath("/link.txt").containsNoBytes();

    Files.createSymbolicLink(path("/foo"), path("/bar/baz"));
    assertThatPath("/foo", NOFOLLOW_LINKS).isSymbolicLink().withTarget("/bar/baz");
    assertThatPath("/foo").doesNotExist(); // following the link; target doesn't exist

    Files.createDirectories(path("/bar/baz"));
    assertThatPath("/foo").isDirectory(); // following the link; target does exist

    Files.createFile(path("/bar/baz/test.txt"));
    assertThatPath("/foo/test.txt", NOFOLLOW_LINKS).isRegularFile(); // follow intermediate link

    try {
      Files.readSymbolicLink(path("/none"));
      fail();
    } catch (NoSuchFileException expected) {
      assertEquals("/none", expected.getMessage());
    }

    try {
      Files.readSymbolicLink(path("/file.txt"));
      fail();
    } catch (NotLinkException expected) {
      assertEquals("/file.txt", expected.getMessage());
    }
  }
");
    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