@Test public void testAddInterceptor() throws Exception { InterceptorChain chain = new InterceptorChain(); Interceptor interceptor = new Interceptor() { @Override public boolean postRequestHandle(RequestContext context) throws Exception { receivePostRequestHandleCount += 1; return false; } @Override public boolean postResponseHandle(int command, Packet responsePacket) throws Exception { receivePostResponseHandleCount += 1; return false; } }; chain.addInterceptor(interceptor); chain.addInterceptor(interceptor); chain.invokePostRequestHandle(new RequestContext(null,null,null)); chain.invokePesponseHandle(1, new SamplePacket()); assertEquals(receivePostRequestHandleCount,1); assertEquals(receivePostResponseHandleCount,1); }
public void addInterceptor(Interceptor interceptor) { if (!interceptors.contains(interceptor)) { interceptors.add(interceptor); } }
InterceptorChain { public void addInterceptor(Interceptor interceptor) { if (!interceptors.contains(interceptor)) { interceptors.add(interceptor); } } }
InterceptorChain { public void addInterceptor(Interceptor interceptor) { if (!interceptors.contains(interceptor)) { interceptors.add(interceptor); } }  }
InterceptorChain { public void addInterceptor(Interceptor interceptor) { if (!interceptors.contains(interceptor)) { interceptors.add(interceptor); } }  void addInterceptor(Interceptor interceptor); void removeInterceptor(Interceptor interceptor); boolean invokePostRequestHandle(RequestContext context); boolean invokePesponseHandle(int command, Packet responsePacket); }
InterceptorChain { public void addInterceptor(Interceptor interceptor) { if (!interceptors.contains(interceptor)) { interceptors.add(interceptor); } }  void addInterceptor(Interceptor interceptor); void removeInterceptor(Interceptor interceptor); boolean invokePostRequestHandle(RequestContext context); boolean invokePesponseHandle(int command, Packet responsePacket);  }