@Test
  public void testFileTimeUpdates() throws IOException {
    RegularFile file = regularFile(10);
    FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
    FileChannel channel =
        new JimfsFileChannel(
            file,
            ImmutableSet.<OpenOption>of(READ, WRITE),
            new FileSystemState(fileTimeSource, Runnables.doNothing()));

    // accessedTime
    FileTime accessTime = file.getLastAccessTime();
    fileTimeSource.advance(Duration.ofMillis(2));

    channel.read(ByteBuffer.allocate(10));
    assertNotEquals(accessTime, file.getLastAccessTime());

    accessTime = file.getLastAccessTime();
    fileTimeSource.advance(Duration.ofMillis(2));

    channel.read(ByteBuffer.allocate(10), 0);
    assertNotEquals(accessTime, file.getLastAccessTime());

    accessTime = file.getLastAccessTime();
    fileTimeSource.advance(Duration.ofMillis(2));

    channel.read(new ByteBuffer[] {ByteBuffer.allocate(10)});
    assertNotEquals(accessTime, file.getLastAccessTime());

    accessTime = file.getLastAccessTime();
    fileTimeSource.advance(Duration.ofMillis(2));

    channel.read(new ByteBuffer[] {ByteBuffer.allocate(10)}, 0, 1);
    assertNotEquals(accessTime, file.getLastAccessTime());

    accessTime = file.getLastAccessTime();
    fileTimeSource.advance(Duration.ofMillis(2));

    channel.transferTo(0, 10, new ByteBufferChannel(10));
    assertNotEquals(accessTime, file.getLastAccessTime());

    // modified
    FileTime modifiedTime = file.getLastModifiedTime();
    fileTimeSource.advance(Duration.ofMillis(2));

    channel.write(ByteBuffer.allocate(10));
    assertNotEquals(modifiedTime, file.getLastModifiedTime());

    modifiedTime = file.getLastModifiedTime();
    fileTimeSource.advance(Duration.ofMillis(2));

    channel.write(ByteBuffer.allocate(10), 0);
    assertNotEquals(modifiedTime, file.getLastModifiedTime());

    modifiedTime = file.getLastModifiedTime();
    fileTimeSource.advance(Duration.ofMillis(2));

    channel.write(new ByteBuffer[] {ByteBuffer.allocate(10)});
    assertNotEquals(modifiedTime, file.getLastModifiedTime());

    modifiedTime = file.getLastModifiedTime();
    fileTimeSource.advance(Duration.ofMillis(2));

    channel.write(new ByteBuffer[] {ByteBuffer.allocate(10)}, 0, 1);
    assertNotEquals(modifiedTime, file.getLastModifiedTime());

    modifiedTime = file.getLastModifiedTime();
    fileTimeSource.advance(Duration.ofMillis(2));

    channel.truncate(0);
    assertNotEquals(modifiedTime, file.getLastModifiedTime());

    modifiedTime = file.getLastModifiedTime();
    fileTimeSource.advance(Duration.ofMillis(2));

    channel.transferFrom(new ByteBufferChannel(10), 0, 10);
    assertNotEquals(modifiedTime, file.getLastModifiedTime());
  }
Most of the behavior of {@link JimfsFileChannel} is handled by the {@link RegularFile}
implementations, so the thorough tests of that are in {@link RegularFileTest}. This mostly tests
interactions with the file and channel positions.

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