Yeah it is really a tough work. `MiniDFSCluster` is provided by hadoop-test, however, there is a naughty bug. The `MiniDFSCluster` is depend on the [umask](https://issues.apache.org/jira/browse/HDFS-4313) on Linux system, if the umask is not set properly, a permission error will occur. 

I use `conf.set("dfs.datanode.data.dir.perm", "775")` in my code to fit with the umask 0002 in my system. However, the umask may be different in different OS, so it is not a good solution.