When credentials object reads a token from file, it clears all exisiting credentials. Therefore, merging the two will require another job and mapper implementation. It will be cleaner to have a separate test. Also, the mechanism to pass tokens via a file is not much related to TokenCache except that it uses obtainTokensFromNamenodeInternal method.
> Also, in the mapper, we should look at the credentials via the APIs (as is done in TestTokenCache) instead of reading the file
The map task in the new test gets the tokens from credentials and verifies it against the token in the file, therefore it also reads the file.