### Question:
CORSFilter implements ContainerResponseFilter { @Override public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException { responseContext.getHeaders().add("Access-Control-Allow-Origin", "*"); responseContext.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); responseContext.getHeaders().add("Access-Control-Max-Age", "-1"); responseContext.getHeaders().add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); }  @Override void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext);  }### Answer:
@Test void testFilter() throws IOException { ContainerRequestContext requestContext = mock(ContainerRequestContext.class); ContainerResponseContext responseContext = mock(ContainerResponseContext.class); MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>(); when(responseContext.getHeaders()).thenReturn(headers); CORSFilter corsFilter = new CORSFilter(); corsFilter.filter(requestContext, responseContext); assertEquals("*", headers.get("Access-Control-Allow-Origin").get(0)); assertEquals("GET, POST, PUT, DELETE, OPTIONS", headers.get("Access-Control-Allow-Methods").get(0)); }