DATAREST-1543 - Deprecate RepositoryRestConfiguration.getCorsRegistry().

Slightly tweaked the configuration model to rather handle the CorsRegistry via RepositoryRestConfigurer.configureRepositoryRestConfiguration(…) rather than RepositoryRestConfiguration itself. That allows moving of Spring WebMVC as a dependency in the core module.

The original methods exposing access to the CorsRegistry are now still available in deprecated form to not break existing clients.

Follow-up ticket: DATAREST-1542.
This commit is contained in:
Oliver Drotbohm
2020-07-03 14:53:59 +02:00
parent 239a86cc2d
commit 9f62237dd3
9 changed files with 187 additions and 29 deletions

View File

@@ -18,19 +18,15 @@ package org.springframework.data.rest.core;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.springframework.data.rest.core.config.EnumTranslationConfiguration;
import org.springframework.data.rest.core.config.MetadataConfiguration;
import org.springframework.data.rest.core.config.ProjectionDefinitionConfiguration;
import org.springframework.data.rest.core.config.RepositoryCorsRegistry;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.core.domain.Profile;
import org.springframework.data.rest.core.domain.ProfileRepository;
import org.springframework.http.MediaType;
import org.springframework.web.cors.CorsConfiguration;
/**
* Unit tests for {@link RepositoryRestConfiguration}.
@@ -119,19 +115,6 @@ public class RepositoryRestConfigurationUnitTests {
assertThat(configuration.isLookupType(Profile.class)).isTrue();
}
@Test // DATAREST-573
public void configuresCorsProcessing() {
RepositoryCorsRegistry registry = configuration.getCorsRegistry();
registry.addMapping("/hello").maxAge(1234);
Map<String, CorsConfiguration> corsConfigurations = registry.getCorsConfigurations();
assertThat(corsConfigurations).containsKey("/hello");
CorsConfiguration corsConfiguration = corsConfigurations.get("/hello");
assertThat(corsConfiguration.getMaxAge()).isEqualTo(1234L);
}
@Test // DATAREST-1076
public void rejectsNullRelProvider() {
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> configuration.setRelProvider(null));