Source:
public void testCustomCorsConfig() { CorsConfiguration corsConfiguration = new CorsConfiguration(); corsConfiguration.applyPermitDefaultValues(); corsConfiguration.setAllowedMethods(Arrays.asList(new String[] { "*" })); corsConfiguration.setExposedHeaders(Arrays.asList(new String[] { "Content-Location", "Date", "ETag", "Location", "X-Request-Id", "X-Correlation-Id" })); CorsInterceptor corsInterceptor = new CorsInterceptor(corsConfiguration); System.err.println("Custom CorsConfiguration"); System.err.println("allowCredentials = " + corsConfiguration.getAllowCredentials()); System.err.println("allowedHeaders = " + Arrays.toString(corsConfiguration.getAllowedHeaders().toArray())); System.err.println("allowedMethods = " + Arrays.toString(corsConfiguration.getAllowedMethods().toArray())); System.err.println("allowedOrigins = " + Arrays.toString(corsConfiguration.getAllowedOrigins().toArray())); System.err.println("exposedHeaders = " + Arrays.toString(corsConfiguration.getExposedHeaders().toArray())); System.err.println("maxAge = " + corsConfiguration.getMaxAge()); assertSame(corsConfiguration, corsInterceptor.getConfig()); assertNull(corsConfiguration.getAllowCredentials()); assertNotNull(corsConfiguration.getAllowedHeaders()); assertNotNull(corsConfiguration.getAllowedMethods()); assertNotNull(corsConfiguration.getAllowedOrigins()); assertNotNull(corsConfiguration.getExposedHeaders()); assertEquals(Long.valueOf(1800l),corsConfiguration.getMaxAge()); assertNotNull(corsConfiguration.checkHeaders(Arrays.asList(new String[] {"Content-Type"}))); assertNotNull(corsConfiguration.checkHeaders(Arrays.asList(new String[] {"Authorization"}))); assertNotNull(corsConfiguration.checkHeaders(Arrays.asList(new String[] {"Authorization", "Content-Type"}))); assertNotNull(corsConfiguration.checkHttpMethod(HttpMethod.GET)); assertNotNull(corsConfiguration.checkOrigin("<LINK_0>")); }

Target:
public void testCustomCorsConfig() { CorsConfiguration corsConfiguration = new CorsConfiguration(); corsConfiguration.applyPermitDefaultValues(); corsConfiguration.setAllowedMethods(Arrays.asList(new String[] { "*" })); corsConfiguration.setExposedHeaders(Arrays.asList(new String[] { "Content-Location", "Date", "ETag", "Location", "X-Request-Id", "X-Correlation-Id" })); CorsInterceptor corsInterceptor = new CorsInterceptor(corsConfiguration); assertSame(corsConfiguration, corsInterceptor.getConfig()); assertNull(corsConfiguration.getAllowCredentials()); assertNotNull(corsConfiguration.getAllowedHeaders()); assertNotNull(corsConfiguration.getAllowedMethods()); assertNotNull(corsConfiguration.getAllowedOrigins()); assertNotNull(corsConfiguration.getExposedHeaders()); assertEquals(Long.valueOf(1800l),corsConfiguration.getMaxAge()); assertNotNull(corsConfiguration.checkHeaders(Arrays.asList(new String[] {"Content-Type"}))); assertNotNull(corsConfiguration.checkHeaders(Arrays.asList(new String[] {"Authorization"}))); assertNotNull(corsConfiguration.checkHeaders(Arrays.asList(new String[] {"Authorization", "Content-Type"}))); assertNotNull(corsConfiguration.checkHttpMethod(HttpMethod.GET)); assertNotNull(corsConfiguration.checkOrigin("<LINK_0>")); ourLog.info("Custom CorsConfiguration: allowCredentials = {}; allowedHeaders = {}; " + "allowedMethods = {}; allowedOrigins = {}; exposedHeaders = {}; maxAge = {}", corsConfiguration.getAllowCredentials(), Arrays.toString(corsConfiguration.getAllowedHeaders().toArray()), Arrays.toString(corsConfiguration.getAllowedMethods().toArray()), Arrays.toString(corsConfiguration.getAllowedOrigins().toArray()), Arrays.toString(corsConfiguration.getExposedHeaders().toArray()), corsConfiguration.getMaxAge()); }