Buried in the EasyMock 1.2 documentation is a single setence that explains this issue:
The following code configures the MockObject to answer 42 to voteForRemoval("Document") once and -1 for subsequent calls as well as all other arguments to voteForRemoval():
mock.voteForRemoval("Document");
control.setReturnValue(42);
control.setDefaultReturnValue(-1);
(Empahsis mine)
In other words, setDefaultReturnValue()
not only returns -1 for voteForRemoval("Document")
after the first time, but also returns -1 if any other parameter is passed in. It looks like the person who wrote the test you're looking at knew this and just figured he'd throw in a placeholder, not caring about the actual parameter.
The EasyMock 2/3 equivalent of your code would be:
expect(service.convertValue(isA(String.class))).andReturn(new Integer(1)).anyTimes();
EasyMock 2 cleaned up a lot of ambiguities like this and forced developers to explicitly define what they were looking for. It's probably for the best, given the unintended side effects that can occur with the old style.