### Question:
AjaxUploadServletRequestFilter implements HttpServletRequestFilter { @Override public boolean service(HttpServletRequest request, HttpServletResponse response, HttpServletRequestHandler handler) throws IOException { if (decoder.isAjaxUploadRequest(request)) { decoder.setupUploadedFile(request); } return handler.service(request, response); } AjaxUploadServletRequestFilter(AjaxUploadDecoder decoder); @Override boolean service(HttpServletRequest request, HttpServletResponse response, HttpServletRequestHandler handler);  }### Answer:
@Test public void check_non_ajax_upload_request_does_not_setup_ajax_upload_decoder() throws Exception { AjaxUploadDecoder decoder = mockAjaxUploadDecoder(); AjaxUploadServletRequestFilter filter = new AjaxUploadServletRequestFilter(decoder); HttpServletRequest request = mockHttpServletRequest(); HttpServletResponse response = mockHttpServletResponse(); HttpServletRequestHandler handler = mockHttpServletRequestHandler(); expect(handler.service(request, response)).andReturn(true); expect(decoder.isAjaxUploadRequest(request)).andReturn(false); replay(); filter.service(request, response, handler); verify(); }
@Test public void check_ajax_upload_request_does_setup_ajax_upload_decoder() throws Exception { AjaxUploadDecoder decoder = mockAjaxUploadDecoder(); AjaxUploadServletRequestFilter filter = new AjaxUploadServletRequestFilter(decoder); HttpServletRequest request = mockHttpServletRequest(); HttpServletResponse response = mockHttpServletResponse(); HttpServletRequestHandler handler = mockHttpServletRequestHandler(); expect(handler.service(request, response)).andReturn(true); expect(decoder.isAjaxUploadRequest(request)).andReturn(true); decoder.setupUploadedFile(request); replay(); filter.service(request, response, handler); verify(); }