Skip to content

Commit 9a10c1a

Browse files
committed
Merge pull request #43774 from hezean
* pr/43774: Polish "Prevent redis pool to initialize in unit test" Prevent redis pool to initialize in unit test Closes gh-43774
2 parents 15b63fa + 7b04cdd commit 9a10c1a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -152,18 +152,20 @@ void testPasswordInUrlStartsWithColon() {
152152
@Test
153153
void testRedisConfigurationWithPool() {
154154
this.contextRunner
155-
.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.jedis.pool.min-idle:1",
155+
.withPropertyValues("spring.data.redis.host:foo", "spring.data.redis.jedis.pool.min-idle:0",
156156
"spring.data.redis.jedis.pool.max-idle:4", "spring.data.redis.jedis.pool.max-active:16",
157157
"spring.data.redis.jedis.pool.max-wait:2000",
158158
"spring.data.redis.jedis.pool.time-between-eviction-runs:30000")
159159
.run((context) -> {
160160
JedisConnectionFactory cf = context.getBean(JedisConnectionFactory.class);
161161
assertThat(cf.getHostName()).isEqualTo("foo");
162-
assertThat(cf.getPoolConfig().getMinIdle()).isOne();
163-
assertThat(cf.getPoolConfig().getMaxIdle()).isEqualTo(4);
164-
assertThat(cf.getPoolConfig().getMaxTotal()).isEqualTo(16);
165-
assertThat(cf.getPoolConfig().getMaxWaitDuration()).isEqualTo(Duration.ofSeconds(2));
166-
assertThat(cf.getPoolConfig().getDurationBetweenEvictionRuns()).isEqualTo(Duration.ofSeconds(30));
162+
assertThat(cf.getPoolConfig()).satisfies((poolConfig) -> {
163+
assertThat(poolConfig.getMinIdle()).isEqualTo(0);
164+
assertThat(poolConfig.getMaxIdle()).isEqualTo(4);
165+
assertThat(poolConfig.getMaxTotal()).isEqualTo(16);
166+
assertThat(poolConfig.getMaxWaitDuration()).isEqualTo(Duration.ofSeconds(2));
167+
assertThat(poolConfig.getDurationBetweenEvictionRuns()).isEqualTo(Duration.ofSeconds(30));
168+
});
167169
});
168170
}
169171

0 commit comments

Comments
 (0)