assertEquals(4, Handler2.requests);
assertEquals(3, Handler3.requests);
}
public void testResponseChain() throws Throwable {
ResponseHandlersChain chain = new ResponseHandlersChain();
chain.addHandler(new Handler1());
chain.addHandler(new Handler2());
chain.addHandler(new Handler3());
chain.run(null);
assertEquals(1, Handler1.responses);
assertEquals(1, Handler2.responses);
assertEquals(1, Handler3.responses);
chain.run(null);
assertEquals(2, Handler1.responses);
assertEquals(2, Handler2.responses);
assertEquals(3, Handler3.responses);
chain.run(null);
assertEquals(3, Handler1.responses);
assertEquals(4, Handler2.responses);
assertEquals(3, Handler3.responses);
chain.run(null);
assertEquals(4, Handler1.responses);
assertEquals(4, Handler2.responses);
assertEquals(3, Handler3.responses);
}