EasyMock.verify(response, method);
assertNull(this.storage.getResultOrReturnNull(key));
}
public void testManyCallbacksSuccess() throws Exception{
Response response = EasyMock.createMock(Response.class);
Method method = EasyMock.createMock(Method.class);
EasyMock.expect(method.getData()).andReturn(new HashMap<String,String>());
RequestCallback[] myCallbacks = new RequestCallback[4];
for( int i = 0; i < myCallbacks.length; i++){
myCallbacks[i] = EasyMock.createMock(RequestCallback.class);
myCallbacks[i].onResponseReceived(null, null);
EasyMock.replay(myCallbacks[i]);
}
EasyMock.expect(response.getStatusCode()).andReturn(200);
EasyMock.replay(response, method);
for( int i = 0; i < myCallbacks.length; i++){
this.storage.addCallback(key, myCallbacks[i]);
}
RequestCallback callback = filter.filter(method, response, myCallbacks[0]);
assertNotSame(callback, myCallbacks[0]);
callback.onResponseReceived(null, null);
EasyMock.verify(response, method);
for(RequestCallback rc: myCallbacks){
EasyMock.verify(rc);
}
// hashCode should be good enough
assertEquals(response.hashCode(), this.storage.getResultOrReturnNull(key).hashCode());
}