public void test2()
{
initFlags();
final Response originalResponse = newResponse();
final RequestHandlerStack stack = newStack(originalResponse);
final IRequestHandler handler4 = new IRequestHandler()
{
public void respond(IRequestCycle requestCycle)
{
testFlag4 = false;
assertEquals(stack.getResponse(), originalResponse);
stack.setResponse(newResponse());
}
public void detach(IRequestCycle requestCycle)
{
detachedFlag4 = true;
}
};
final IRequestHandler handler3 = new IRequestHandler()
{
public void respond(IRequestCycle requestCycle)
{
testFlag3 = false;
stack.setResponse(newResponse());
stack.replaceAllRequestHandlers(handler4);
// code must not be reached
testFlag3 = true;
}
public void detach(IRequestCycle requestCycle)
{
detachedFlag3 = true;
}
};
final IRequestHandler handler2 = new IRequestHandler()
{
public void respond(IRequestCycle requestCycle)
{
testFlag2 = false;
stack.setResponse(newResponse());
stack.executeRequestHandler(handler3);
// code must not be reached
testFlag2 = true;
}
public void detach(IRequestCycle requestCycle)
{
detachedFlag2 = true;
}
};
IRequestHandler handler1 = new IRequestHandler()
{
public void respond(IRequestCycle requestCycle)
{
testFlag1 = false;
stack.setResponse(newResponse());
stack.executeRequestHandler(handler2);
// code must not be reached
testFlag1 = true;
}
public void detach(IRequestCycle requestCycle)
{
detachedFlag1 = true;
}
};
stack.executeRequestHandler(handler1);
assertEquals(stack.getResponse(), originalResponse);
stack.detach();
assertFalse(testFlag1);
assertFalse(testFlag2);
assertFalse(testFlag3);
assertFalse(testFlag4);