Polish "Start building against Spring Data 2022.0.0-M5 snapshots"

See gh-31582
pull/31663/head
Andy Wilkinson 2 years ago
parent 0067611396
commit 7f00378eaf

@ -166,6 +166,9 @@ dependencies {
testImplementation("org.eclipse.jetty:jetty-webapp") {
exclude group: "javax.servlet", module: "javax.servlet-api"
}
testImplementation("org.elasticsearch.client:elasticsearch-rest-high-level-client") {
exclude(group: "commons-logging", module: "commons-logging")
}
testImplementation("org.hamcrest:hamcrest")
testImplementation("org.hsqldb:hsqldb")
testImplementation("org.junit.jupiter:junit-jupiter")
@ -186,6 +189,7 @@ dependencies {
testRuntimeOnly("jakarta.management.j2ee:jakarta.management.j2ee-api")
testRuntimeOnly("jakarta.transaction:jakarta.transaction-api")
testRuntimeOnly("org.cache2k:cache2k-core")
testRuntimeOnly("org.springframework:spring-aspects")
testRuntimeOnly("org.springframework.security:spring-security-oauth2-jose")
testRuntimeOnly("org.springframework.security:spring-security-oauth2-resource-server")
testRuntimeOnly("org.springframework.security:spring-security-saml2-service-provider")

@ -31,7 +31,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.elasticsearch.ReactiveElasticsearchClientAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient;
/**
* {@link EnableAutoConfiguration Auto-configuration} for

@ -25,7 +25,7 @@ import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.Status;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.web.reactive.function.client.ClientResponse;
@ -42,7 +42,7 @@ import org.springframework.web.reactive.function.client.WebClient;
*/
public class ElasticsearchReactiveHealthIndicator extends AbstractReactiveHealthIndicator {
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() {
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<>() {
};
private static final String RED_STATUS = "red";

@ -28,8 +28,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Status;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.reactive.DefaultReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
@ -51,11 +50,12 @@ class ElasticsearchReactiveHealthIndicatorTests {
private ElasticsearchReactiveHealthIndicator healthIndicator;
@SuppressWarnings("deprecation")
@BeforeEach
void setup() throws Exception {
this.server = new MockWebServer();
this.server.start();
ReactiveElasticsearchClient client = DefaultReactiveElasticsearchClient
ReactiveElasticsearchClient client = org.springframework.data.elasticsearch.client.erhlc.DefaultReactiveElasticsearchClient
.create(ClientConfiguration.create(this.server.getHostName() + ":" + this.server.getPort()));
this.healthIndicator = new ElasticsearchReactiveHealthIndicator(client);
}

@ -26,9 +26,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations;
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
@ -87,10 +85,9 @@ abstract class ElasticsearchDataConfiguration {
@Bean
@ConditionalOnMissingBean(value = ElasticsearchOperations.class, name = "elasticsearchTemplate")
@ConditionalOnBean(org.elasticsearch.client.RestHighLevelClient.class)
@SuppressWarnings("deprecation")
ElasticsearchRestTemplate elasticsearchTemplate(org.elasticsearch.client.RestHighLevelClient client,
ElasticsearchConverter converter) {
return new ElasticsearchRestTemplate(client, converter);
org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate elasticsearchTemplate(
org.elasticsearch.client.RestHighLevelClient client, ElasticsearchConverter converter) {
return new org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate(client, converter);
}
}
@ -103,9 +100,10 @@ abstract class ElasticsearchDataConfiguration {
@ConditionalOnMissingBean(value = ReactiveElasticsearchOperations.class, name = "reactiveElasticsearchTemplate")
@ConditionalOnBean(ReactiveElasticsearchClient.class)
@SuppressWarnings("deprecation")
ReactiveElasticsearchTemplate reactiveElasticsearchTemplate(ReactiveElasticsearchClient client,
ElasticsearchConverter converter) {
return new ReactiveElasticsearchTemplate(client, converter);
org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate reactiveElasticsearchTemplate(
ReactiveElasticsearchClient client, ElasticsearchConverter converter) {
return new org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate(client,
converter);
}
}

@ -41,7 +41,6 @@ import org.springframework.data.elasticsearch.repository.support.ReactiveElastic
matchIfMissing = true)
@ConditionalOnMissingBean(ReactiveElasticsearchRepositoryFactoryBean.class)
@Import(ReactiveElasticsearchRepositoriesRegistrar.class)
@SuppressWarnings("deprecation")
public class ReactiveElasticsearchRepositoriesAutoConfiguration {
}

@ -22,6 +22,7 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.elasticsearch.ElasticsearchException;
import reactor.netty.http.client.HttpClient;
import org.springframework.boot.autoconfigure.AutoConfiguration;
@ -32,6 +33,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchClients;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveRestClients;
import org.springframework.util.Assert;
@ -40,8 +42,6 @@ import org.springframework.util.unit.DataSize;
import org.springframework.web.reactive.function.client.ExchangeStrategies;
import org.springframework.web.reactive.function.client.WebClient;
import static org.springframework.data.elasticsearch.client.elc.ElasticsearchClients.WebClientConfigurationCallback;
/**
* {@link EnableAutoConfiguration Auto-configuration} for Elasticsearch Reactive REST
* clients.
@ -50,7 +50,7 @@ import static org.springframework.data.elasticsearch.client.elc.ElasticsearchCli
* @since 3.0.0
*/
@AutoConfiguration
@ConditionalOnClass({ ReactiveRestClients.class, WebClient.class, HttpClient.class })
@ConditionalOnClass({ ReactiveRestClients.class, ElasticsearchException.class, WebClient.class, HttpClient.class })
@EnableConfigurationProperties(ElasticsearchProperties.class)
@SuppressWarnings("deprecation")
public class ReactiveElasticsearchClientAutoConfiguration {
@ -80,7 +80,7 @@ public class ReactiveElasticsearchClientAutoConfiguration {
private void configureExchangeStrategies(PropertyMapper map,
ClientConfiguration.TerminalClientConfigurationBuilder builder) {
map.from(this.properties.getMaxInMemorySize()).asInt(DataSize::toBytes).to((maxInMemorySize) -> {
builder.withClientConfigurer(WebClientConfigurationCallback.from((webClient) -> {
builder.withClientConfigurer(ElasticsearchClients.WebClientConfigurationCallback.from((webClient) -> {
ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder()
.codecs((configurer) -> configurer.defaultCodecs().maxInMemorySize(maxInMemorySize)).build();
return webClient.mutate().exchangeStrategies(exchangeStrategies).build();

@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.data.cassandra;
import java.util.Collections;
import java.util.Set;
import com.datastax.oss.driver.api.core.CqlSession;
import org.junit.jupiter.api.AfterEach;
@ -67,7 +66,6 @@ class CassandraDataAutoConfigurationTests {
}
@Test
@SuppressWarnings("unchecked")
void entityScanShouldSetManagedTypes() {
load(EntityScanConfig.class);
CassandraMappingContext mappingContext = this.context.getBean(CassandraMappingContext.class);

@ -59,7 +59,6 @@ class CassandraReactiveDataAutoConfigurationTests {
}
@Test
@SuppressWarnings("unchecked")
void entityScanShouldSetManagedTypes() {
load(EntityScanConfig.class, "spring.data.cassandra.keyspaceName:boot_test");
CassandraMappingContext mappingContext = this.context.getBean(CassandraMappingContext.class);

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.data.cassandra;
import java.util.Set;
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
import org.junit.jupiter.api.Test;
@ -94,7 +92,6 @@ class CassandraReactiveRepositoriesAutoConfigurationTests {
.run((context) -> assertThat(context).doesNotHaveBean(ReactiveCityRepository.class));
}
@SuppressWarnings("unchecked")
private ManagedTypes getManagedTypes(ApplicationContext context) {
CassandraMappingContext mappingContext = context.getBean(CassandraMappingContext.class);
return (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes");

@ -90,7 +90,6 @@ class CassandraRepositoriesAutoConfigurationTests {
.run((context) -> assertThat(context).doesNotHaveBean(CityCassandraRepository.class));
}
@SuppressWarnings("unchecked")
private ManagedTypes getManagedTypes(AssertableApplicationContext context) {
CassandraMappingContext mappingContext = context.getBean(CassandraMappingContext.class);
return (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes");

@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.data.couchbase;
import java.util.Collections;
import java.util.Set;
import org.junit.jupiter.api.Test;
@ -66,7 +65,6 @@ class CouchbaseDataAutoConfigurationTests {
}
@Test
@SuppressWarnings("unchecked")
void entityScanShouldSetInitialEntitySet() {
this.contextRunner.withUserConfiguration(EntityScanConfig.class).run((context) -> {
CouchbaseMappingContext mappingContext = context.getBean(CouchbaseMappingContext.class);

@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.data.couchbase;
import java.util.Collections;
import java.util.Set;
import org.junit.jupiter.api.Test;
@ -65,7 +64,6 @@ class CouchbaseReactiveDataAutoConfigurationTests {
}
@Test
@SuppressWarnings("unchecked")
void entityScanShouldSetInitialEntitySet() {
this.contextRunner.withUserConfiguration(EntityScanConfig.class).run((context) -> {
CouchbaseMappingContext mappingContext = context.getBean(CouchbaseMappingContext.class);

@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -37,7 +37,6 @@ import org.springframework.data.domain.ManagedTypes;
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
import org.springframework.data.jdbc.repository.config.AbstractJdbcConfiguration;
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
import org.springframework.data.r2dbc.mapping.R2dbcMappingContext;
import org.springframework.data.repository.Repository;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
import org.springframework.test.util.ReflectionTestUtils;

@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.data.mongo;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Set;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
@ -161,7 +160,6 @@ class MongoDataAutoConfigurationTests {
}
@Test
@SuppressWarnings("unchecked")
void entityScanShouldSetManagedTypes() {
this.contextRunner.withUserConfiguration(EntityScanConfig.class).run((context) -> {
MongoMappingContext mappingContext = context.getBean(MongoMappingContext.class);
@ -211,7 +209,6 @@ class MongoDataAutoConfigurationTests {
.run((context) -> assertThat(context).hasSingleBean(MongoTemplate.class));
}
@SuppressWarnings("unchecked")
private static void assertDomainTypesDiscovered(MongoMappingContext mappingContext, Class<?>... types) {
ManagedTypes managedTypes = (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes");
assertThat(managedTypes.toList()).containsOnly(types);

@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.data.mongo;
import java.util.Set;
import com.mongodb.reactivestreams.client.MongoClient;
import org.junit.jupiter.api.Test;
@ -60,7 +58,6 @@ class MongoReactiveRepositoriesAutoConfigurationTests {
assertThat(context).hasSingleBean(ReactiveCityRepository.class);
assertThat(context).hasSingleBean(MongoClient.class);
MongoMappingContext mappingContext = context.getBean(MongoMappingContext.class);
@SuppressWarnings("unchecked")
ManagedTypes managedTypes = (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes");
assertThat(managedTypes.toList()).hasSize(1);
});

@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,8 +16,6 @@
package org.springframework.boot.autoconfigure.data.mongo;
import java.util.Set;
import com.mongodb.client.MongoClient;
import org.junit.jupiter.api.Test;
@ -56,7 +54,6 @@ class MongoRepositoriesAutoConfigurationTests {
assertThat(context).hasSingleBean(CityRepository.class);
assertThat(context).hasSingleBean(MongoClient.class);
MongoMappingContext mappingContext = context.getBean(MongoMappingContext.class);
@SuppressWarnings("unchecked")
ManagedTypes managedTypes = (ManagedTypes) ReflectionTestUtils.getField(mappingContext, "managedTypes");
assertThat(managedTypes.toList()).hasSize(1);
});

@ -191,9 +191,9 @@ class RedisAutoConfigurationJedisTests {
this.contextRunner
.withPropertyValues("spring.redis.sentinel.master:mymaster",
"spring.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380")
.withUserConfiguration(JedisConnectionFactoryCaptorConfiguration.class).run((context) -> {
assertThat(JedisConnectionFactoryCaptor.connectionFactory.isRedisSentinelAware()).isTrue();
});
.withUserConfiguration(JedisConnectionFactoryCaptorConfiguration.class)
.run((context) -> assertThat(JedisConnectionFactoryCaptor.connectionFactory.isRedisSentinelAware())
.isTrue());
}
@Test

@ -32,7 +32,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.ClientConfiguration.ClientConfigurationCallback;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchClient;
import org.springframework.data.elasticsearch.client.erhlc.ReactiveRestClients;
import org.springframework.http.HttpHeaders;
import org.springframework.http.codec.CodecConfigurer.DefaultCodecConfig;
import org.springframework.web.reactive.function.client.WebClient;
@ -45,7 +44,6 @@ import static org.mockito.Mockito.mock;
*
* @author Brian Clozel
*/
@SuppressWarnings("deprecation")
class ReactiveElasticsearchClientAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()

@ -41,7 +41,6 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Brian Clozel
*/
@Testcontainers(disabledWithoutDocker = true)
@SuppressWarnings("deprecation")
class ReactiveElasticsearchRestClientAutoConfigurationIntegrationTests {
@Container

@ -16,15 +16,15 @@
package org.springframework.boot.docs.data.nosql.elasticsearch.connectingusingspringdata;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.stereotype.Component;
@Component
@SuppressWarnings("deprecation")
public class MyBean {
private final ElasticsearchRestTemplate template;
private final org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate template;
public MyBean(ElasticsearchRestTemplate template) {
public MyBean(org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate template) {
this.template = template;
}

@ -16,11 +16,11 @@
package org.springframework.boot.docs.data.nosql.elasticsearch.connectingusingspringdata
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate
import org.springframework.stereotype.Component
@Component
class MyBean(private val template: ElasticsearchRestTemplate) {
@Suppress("DEPRECATION")
class MyBean(private val template: org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate ) {
// @fold:on // ...
fun someMethod(id: String): Boolean {

@ -28,7 +28,6 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import org.springframework.context.ApplicationContext;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
@ -54,7 +53,8 @@ class DataElasticsearchTestIntegrationTests {
}
@Autowired
private ElasticsearchRestTemplate elasticsearchRestTemplate;
@SuppressWarnings("deprecation")
private org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate elasticsearchRestTemplate;
@Autowired
private ExampleRepository exampleRepository;

@ -25,7 +25,6 @@ import org.testcontainers.junit.jupiter.Testcontainers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.testsupport.testcontainers.DockerImageNames;
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchTemplate;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
@ -51,7 +50,8 @@ class DataElasticsearchTestReactiveIntegrationTests {
}
@Autowired
private ReactiveElasticsearchTemplate elasticsearchTemplate;
@SuppressWarnings("deprecation")
private org.springframework.data.elasticsearch.client.erhlc.ReactiveElasticsearchTemplate elasticsearchTemplate;
@Autowired
private ExampleReactiveRepository exampleReactiveRepository;

@ -16,7 +16,6 @@
package org.springframework.boot.test.autoconfigure.data.elasticsearch;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.stereotype.Service;
/**
@ -25,11 +24,13 @@ import org.springframework.stereotype.Service;
* @author Eddú Meléndez
*/
@Service
@SuppressWarnings("deprecation")
public class ExampleService {
private final ElasticsearchRestTemplate elasticsearchRestTemplate;
private final org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate elasticsearchRestTemplate;
public ExampleService(ElasticsearchRestTemplate elasticsearchRestTemplate) {
public ExampleService(
org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate elasticsearchRestTemplate) {
this.elasticsearchRestTemplate = elasticsearchRestTemplate;
}

Loading…
Cancel
Save