CorsFilter implements Filter { @Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { HttpServletResponse httpResponse = (HttpServletResponse) response; httpResponse.setHeader("Access-Control-Allow-Origin", "*"); httpResponse.setHeader("Access-Control-Allow-Headers", "origin, content-type, accept, authorization, x-requested-with"); httpResponse.setHeader("Access-Control-Allow-Credentials", "true"); httpResponse.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD"); httpResponse.setHeader("Access-Control-Max-Age", "1209600"); chain.doFilter(request, response); }  @Override void doFilter(final ServletRequest request, final ServletResponse response,
			final FilterChain chain); @Override void init(final FilterConfig filterConfig); @Override void destroy();  }
@Test public void testDoFilter() throws Exception { unit.doFilter(request, response, chain); verify(response).setHeader("Access-Control-Allow-Origin", "*"); verify(response).setHeader("Access-Control-Allow-Headers", "origin, content-type, accept, authorization, x-requested-with"); verify(response).setHeader("Access-Control-Allow-Credentials", "true"); verify(response).setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD"); verify(response).setHeader("Access-Control-Max-Age", "1209600"); verify(chain).doFilter(request, response); }