HftpFileSystem.open(..) first opens an URL connection to namenode's FileDataServlet and then is redirected to datanode's StreamFile servlet. Such redirection does not work in the unit test environment because the redirect URL uses real hostname instead of localhost.
One way to get around it is to use fault-injection in order to replace the real hostname with localhost.
- is related to
HDFS-1085 hftp read failing silently