@Test
public void test_FileSystem_UploadSystemFile_ReturnsError() throws Exception {

  // Prepare
  assert myFileSystem != null;
  assert myMockDevice != null;
  TestDevices.addEmulatorApi25Commands(myMockDevice.getShellCommands());
  myMockDevice.addRemoteRestrictedAccessFile("/system/build.prop", 1_024);
  DeviceFileEntry dataEntry = waitForFuture(myFileSystem.getEntry("/system"));
  Path tempFile = FileUtil.createTempFile("localFile", "tmp").toPath();
  Files.write(tempFile, new byte[1024]);
  // Act
  AtomicReference<Long> totalBytesRef = new AtomicReference<>();
  Throwable error = waitForFutureException(dataEntry.uploadFile(tempFile, "build.prop", new FileTransferProgress() {
    @Override
    public void progress(long currentBytes, long totalBytes) {
      totalBytesRef.set(totalBytes);
    }
    @Override
    public boolean isCancelled() {
      return false;
    }
  }));
  // Ensure all progress callbacks have been executed
  myCallbackExecutor.submit(EmptyRunnable.getInstance()).get(TIMEOUT_MILLISECONDS, TimeUnit.MILLISECONDS);
  // Assert
  assertThat(error).isNotNull();
  assertThat(error).isInstanceOf(AdbShellCommandException.class);
  assertThat(error.getMessage()).isEqualTo("cp: /system/build.prop: Read-only file system");
}