// -- make 1, 2, 4 fail with a session exception; 3 will succeed. once all are back, SUT should request session.
// out of order on purpose. --
// 1 fails
((AsyncCallback) paramInt01.getParam(1)).onSuccess(new ActionRequest[] { new ActionResponse(
((ActionRequest[]) paramInt01.getParam(0))[0], new SessionException()) });
// 4 fails
((AsyncCallback) paramInt04.getParam(1)).onSuccess(new ActionRequest[] { new ActionResponse(
((ActionRequest[]) paramInt04.getParam(0))[0], new SessionException()) });
// 3 succeeds
context.checking(new Expectations()
{
{
oneOf(actionCb03).onSuccess(with(same(result03)));
}
});
((AsyncCallback) paramInt03.getParam(1)).onSuccess(new ActionRequest[] { new ActionResponse(
((ActionRequest[]) paramInt03.getParam(0))[0], result03) });
context.assertIsSatisfied();
// 2 fails. since it's the last outstanding, the return will trigger re-establishment
context.checking(new Expectations()
{
{
oneOf(service).establishSession(with(any(AsyncCallback.class)));
will(paramInt);
}
});
((AsyncCallback) paramInt02.getParam(1)).onSuccess(new ActionRequest[] { new ActionResponse(
((ActionRequest[]) paramInt02.getParam(0))[0], new SessionException()) });
context.assertIsSatisfied();
// -- establishing new session should send request for all 3 that failed in one message --
context.checking(new Expectations()
{