@Test
public void testHeadersUpdate() {

	final String origin = "http://something";
	final String reqHeader = "POST";
	ResponseCorsFilter filter = new ResponseCorsFilter();
	ContainerRequest req = Mockito.mock( ContainerRequest.class );
	// There are request headers
	ContainerResponse resp = new ContainerResponse( null, null, null );
	Mockito.verifyZeroInteractions( req );
	Mockito.when( req.getHeaderValue( ORIGIN )).thenReturn( origin );
	Mockito.when( req.getHeaderValue( CORS_REQ_HEADERS )).thenReturn( reqHeader );
	ContainerResponse result = filter.filter( req, resp );
	Assert.assertNotNull( result );
	Assert.assertEquals( 4, result.getHttpHeaders().size());
	Assert.assertEquals( Arrays.asList( VALUE_ALLOW_CREDENTIALS ), result.getHttpHeaders().get( CORS_ALLOW_CREDENTIALS ));
	Assert.assertEquals( Arrays.asList( reqHeader ), result.getHttpHeaders().get( CORS_ALLOW_HEADERS ));
	Assert.assertEquals( Arrays.asList( VALUE_ALLOWED_METHODS ), result.getHttpHeaders().get( CORS_ALLOW_METHODS ));
	Assert.assertEquals( Arrays.asList( origin ), result.getHttpHeaders().get( CORS_ALLOW_ORIGIN ));
	Mockito.verify( req ).getHeaderValue( CORS_REQ_HEADERS );
	Mockito.verify( req ).getHeaderValue( ORIGIN );
	Mockito.verifyNoMoreInteractions( req );
	// No request header
	resp = new ContainerResponse( null, null, null );
	Mockito.reset( req );
	Mockito.when( req.getHeaderValue( ORIGIN )).thenReturn( "http://something" );
	result = filter.filter( req, resp );
	Assert.assertNotNull( result );
	Assert.assertEquals( 3, result.getHttpHeaders().size());
	Assert.assertEquals( Arrays.asList( VALUE_ALLOW_CREDENTIALS ), result.getHttpHeaders().get( CORS_ALLOW_CREDENTIALS ));
	Assert.assertEquals( Arrays.asList( VALUE_ALLOWED_METHODS ), result.getHttpHeaders().get( CORS_ALLOW_METHODS ));
	Assert.assertEquals( Arrays.asList( origin ), result.getHttpHeaders().get( CORS_ALLOW_ORIGIN ));
	Mockito.verify( req ).getHeaderValue( ResponseCorsFilter.CORS_REQ_HEADERS );
	Mockito.verify( req ).getHeaderValue( ResponseCorsFilter.ORIGIN );
	Mockito.verifyNoMoreInteractions( req );
}