EasyMock
Local
External
Supplying Answers
EasyMock.expect(rasterlike.getTile(EasyMock.anyInt(), EasyMock.anyInt())).andAnswer(new IAnswer() {
public Raster answer() {
Object[] args = EasyMock.getCurrentArguments();
int tileX = (Integer)(args[0]);
int tileY = (Integer)(args[1]);
return somehowGenerateGetTile(tileX, tileY);
}
}).anyTimes();
Difficult Cases
public interface ReturnClass {
}
public interface GenericifiedInterface {
<T> T find(Class<T> theClass, Object someKey);
}
ReturnClass theReturn;
GenericifiedInterface ps = EasyMock.createMock(GenericifiedInterface.class);
EasyMock.expect(ps.find(EasyMock.isA(Class.class), EasyMock.anyObject())).andReturn(theReturn).anyTimes();