mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Start building against Spring Data Bom 2023.1.0 snapshots
See gh-36190
This commit is contained in:
parent
e847e662c2
commit
ec8e1e2c95
@ -69,6 +69,7 @@ import org.springframework.data.couchbase.CouchbaseClientFactory;
|
||||
import org.springframework.data.couchbase.cache.CouchbaseCache;
|
||||
import org.springframework.data.couchbase.cache.CouchbaseCacheConfiguration;
|
||||
import org.springframework.data.couchbase.cache.CouchbaseCacheManager;
|
||||
import org.springframework.data.redis.cache.FixedDurationTtlFunction;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
@ -273,7 +274,10 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
|
||||
RedisCacheManager cacheManager = getCacheManager(context, RedisCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames()).isEmpty();
|
||||
RedisCacheConfiguration redisCacheConfiguration = getDefaultRedisCacheConfiguration(cacheManager);
|
||||
assertThat(redisCacheConfiguration.getTtl()).isEqualTo(java.time.Duration.ofSeconds(15));
|
||||
assertThat(redisCacheConfiguration).extracting(RedisCacheConfiguration::getTtlFunction)
|
||||
.isInstanceOf(FixedDurationTtlFunction.class)
|
||||
.extracting("duration")
|
||||
.isEqualTo(java.time.Duration.ofSeconds(15));
|
||||
assertThat(redisCacheConfiguration.getAllowCacheNullValues()).isFalse();
|
||||
assertThat(redisCacheConfiguration.getKeyPrefixFor("MyCache")).isEqualTo("prefixMyCache::");
|
||||
assertThat(redisCacheConfiguration.usePrefix()).isTrue();
|
||||
@ -289,7 +293,10 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
|
||||
RedisCacheManager cacheManager = getCacheManager(context, RedisCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames()).isEmpty();
|
||||
RedisCacheConfiguration redisCacheConfiguration = getDefaultRedisCacheConfiguration(cacheManager);
|
||||
assertThat(redisCacheConfiguration.getTtl()).isEqualTo(java.time.Duration.ofSeconds(30));
|
||||
assertThat(redisCacheConfiguration).extracting(RedisCacheConfiguration::getTtlFunction)
|
||||
.isInstanceOf(FixedDurationTtlFunction.class)
|
||||
.extracting("duration")
|
||||
.isEqualTo(java.time.Duration.ofSeconds(30));
|
||||
assertThat(redisCacheConfiguration.getKeyPrefixFor("")).isEqualTo("bar::");
|
||||
});
|
||||
}
|
||||
@ -301,7 +308,10 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
|
||||
.run((context) -> {
|
||||
RedisCacheManager cacheManager = getCacheManager(context, RedisCacheManager.class);
|
||||
RedisCacheConfiguration redisCacheConfiguration = getDefaultRedisCacheConfiguration(cacheManager);
|
||||
assertThat(redisCacheConfiguration.getTtl()).isEqualTo(java.time.Duration.ofSeconds(10));
|
||||
assertThat(redisCacheConfiguration).extracting(RedisCacheConfiguration::getTtlFunction)
|
||||
.isInstanceOf(FixedDurationTtlFunction.class)
|
||||
.extracting("duration")
|
||||
.isEqualTo(java.time.Duration.ofSeconds(10));
|
||||
});
|
||||
}
|
||||
|
||||
@ -321,7 +331,10 @@ class CacheAutoConfigurationTests extends AbstractCacheAutoConfigurationTests {
|
||||
RedisCacheManager cacheManager = getCacheManager(context, RedisCacheManager.class);
|
||||
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
|
||||
RedisCacheConfiguration redisCacheConfiguration = getDefaultRedisCacheConfiguration(cacheManager);
|
||||
assertThat(redisCacheConfiguration.getTtl()).isEqualTo(java.time.Duration.ofMinutes(0));
|
||||
assertThat(redisCacheConfiguration).extracting(RedisCacheConfiguration::getTtlFunction)
|
||||
.isInstanceOf(FixedDurationTtlFunction.class)
|
||||
.extracting("duration")
|
||||
.isEqualTo(java.time.Duration.ofSeconds(0));
|
||||
assertThat(redisCacheConfiguration.getAllowCacheNullValues()).isTrue();
|
||||
assertThat(redisCacheConfiguration.getKeyPrefixFor("test")).isEqualTo("test::");
|
||||
assertThat(redisCacheConfiguration.usePrefix()).isTrue();
|
||||
|
@ -18,10 +18,14 @@ package org.springframework.boot.autoconfigure.data.mongo;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.mongodb.ConnectionString;
|
||||
import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoClients;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.gridfs.GridFSBucket;
|
||||
import org.assertj.core.api.InstanceOfAssertFactories;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
@ -78,32 +82,43 @@ class MongoDataAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void whenGridFsDatabaseIsConfiguredThenGridFsTemplateIsAutoConfiguredAndUsesIt() {
|
||||
this.contextRunner.withPropertyValues("spring.data.mongodb.gridfs.database:grid").run((context) -> {
|
||||
assertThat(context).hasSingleBean(GridFsTemplate.class);
|
||||
GridFsTemplate template = context.getBean(GridFsTemplate.class);
|
||||
MongoDatabaseFactory factory = (MongoDatabaseFactory) ReflectionTestUtils.getField(template, "dbFactory");
|
||||
assertThat(factory.getMongoDatabase().getName()).isEqualTo("grid");
|
||||
GridFSBucket bucket = ((Supplier<GridFSBucket>) ReflectionTestUtils.getField(template, "bucketSupplier"))
|
||||
.get();
|
||||
assertThat(bucket).extracting("filesCollection", InstanceOfAssertFactories.type(MongoCollection.class))
|
||||
.extracting((collection) -> collection.getNamespace().getDatabaseName())
|
||||
.isEqualTo("grid");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void usesMongoConnectionDetailsIfAvailable() {
|
||||
this.contextRunner.withUserConfiguration(ConnectionDetailsConfiguration.class).run((context) -> {
|
||||
assertThat(context).hasSingleBean(GridFsTemplate.class);
|
||||
GridFsTemplate template = context.getBean(GridFsTemplate.class);
|
||||
assertThat(template).hasFieldOrPropertyWithValue("bucket", "connection-details-bucket");
|
||||
MongoDatabaseFactory factory = (MongoDatabaseFactory) ReflectionTestUtils.getField(template, "dbFactory");
|
||||
assertThat(factory.getMongoDatabase().getName()).isEqualTo("grid-database-1");
|
||||
GridFSBucket bucket = ((Supplier<GridFSBucket>) ReflectionTestUtils.getField(template, "bucketSupplier"))
|
||||
.get();
|
||||
assertThat(bucket.getBucketName()).isEqualTo("connection-details-bucket");
|
||||
assertThat(bucket).extracting("filesCollection", InstanceOfAssertFactories.type(MongoCollection.class))
|
||||
.extracting((collection) -> collection.getNamespace().getDatabaseName())
|
||||
.isEqualTo("grid-database-1");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void whenGridFsBucketIsConfiguredThenGridFsTemplateIsAutoConfiguredAndUsesIt() {
|
||||
this.contextRunner.withPropertyValues("spring.data.mongodb.gridfs.bucket:test-bucket").run((context) -> {
|
||||
assertThat(context).hasSingleBean(GridFsTemplate.class);
|
||||
GridFsTemplate template = context.getBean(GridFsTemplate.class);
|
||||
assertThat(template).hasFieldOrPropertyWithValue("bucket", "test-bucket");
|
||||
GridFSBucket bucket = ((Supplier<GridFSBucket>) ReflectionTestUtils.getField(template, "bucketSupplier"))
|
||||
.get();
|
||||
assertThat(bucket.getBucketName()).isEqualTo("test-bucket");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1393,7 +1393,7 @@ bom {
|
||||
]
|
||||
}
|
||||
}
|
||||
library("Spring Data Bom", "2023.0.1") {
|
||||
library("Spring Data Bom", "2023.1.0-SNAPSHOT") {
|
||||
group("org.springframework.data") {
|
||||
imports = [
|
||||
"spring-data-bom"
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@ -19,8 +19,7 @@ package org.springframework.boot.docs.data.nosql.elasticsearch.connectingusingsp
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
@Suppress("DEPRECATION")
|
||||
class MyBean(private val template: org.springframework.data.elasticsearch.client.erhlc.ElasticsearchRestTemplate ) {
|
||||
class MyBean(private val template: org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate ) {
|
||||
|
||||
// @fold:on // ...
|
||||
fun someMethod(id: String): Boolean {
|
||||
|
Loading…
Reference in New Issue
Block a user