CandlepinPersistFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { unitOfWork.begin(); try { chain.doFilter(request, response); } finally { unitOfWork.end(); } } @Inject  CandlepinPersistFilter(UnitOfWork unitOfWork); @Override void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain); @Override void init(FilterConfig arg0); @Override void destroy();  }
@Test public void transaction() throws IOException, ServletException { ServletRequest req = mock(ServletRequest.class); ServletResponse rsp = mock(ServletResponse.class); FilterChain chain = mock(FilterChain.class); filter.doFilter(req, rsp, chain); verify(work, atLeastOnce()).begin(); verify(work, atLeastOnce()).end(); verify(chain, atLeastOnce()).doFilter(eq(req), eq(rsp)); }