I've spent quite some time doing some refactoring of the Datanode code to make it more testable. It seems to be possible to master some tests with Mockito. However, they look more like end-to-end test eventually, because of high complexity of dependencies in the code. E.g. mocking of the datanode requires to spy on NameNode (i.e. actually initialize it) because there some calls between these two; then an actual files need to be added or proper blocks mocked and inserted to cover particular executed paths; and so on.
Which forced me to take a look at the current coverage situation of Datanode class. To my surprise I've discovered that recoverBlock() is pretty much well covered (except for some error conditions processing); syncBlock() looks even better. FsNameSysmtem.commitBlockSynchronization() seems to be Ok as well. It means that existing tests are covering this new functionality in a pretty decent fashion.
I'd suggest to drop these tests. For real.