@Test
  public void testHttpFileSystemReadTimeouts() throws Exception {
    HttpServer server = new HttpServer("/", 0, null, new ServletHolder(DefaultServlet.class));
    try {
      server.addServlet("/download", new PartialFileFetchServlet());
      server.start();
      String serverUrl = server.getUrl().toString() + "download";
      FileSystemClientThread fileSystemClientThread = new FileSystemClientThread(new URI(serverUrl));
      fileSystemClientThread.start();
      fileSystemClientThread.join();
      Assert.assertEquals(fileSystemClientThread.getTotalBytesRead(), THRESHOLD_BYTES);
      Assert.assertNull(clientException);
      Assert.assertNull(serverException);
    } finally {
      server.stop();
    }
  }
A {@link HttpServlet} implementation that streams its response to the client one byte at a time.
samza-yarn/src/test/java/org/apache/samza/job/yarn/util/hadoop/TestHttpFileSystem.java