@Override
public LocatedBlocks answer(InvocationOnMock arg0) throws Throwable {
LocatedBlocks locatedBlocks = (LocatedBlocks)arg0.callRealMethod();
for (LocatedBlock lb : locatedBlocks.getLocatedBlocks()) {
Token<BlockTokenIdentifier> token = lb.getBlockToken();
BlockTokenIdentifier id = new BlockTokenIdentifier();
ByteArrayInputStream idBytes = new ByteArrayInputStream(
lb.getBlockToken().getIdentifier());
id.readFields(new DataInputStream(idBytes));
// This will make the token invalid, since the password
// won't match anymore
id.setExpiryDate(System.currentTimeMillis() + 10);
Token<BlockTokenIdentifier> newToken =
new Token<BlockTokenIdentifier>(id.getBytes(),
token.getPassword(), token.getKind(), token.getService());
lb.setBlockToken(newToken);
}
return locatedBlocks;
}