✅Test: Redis 连接池测试
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package cn.hezhaohui.redis;
|
||||
|
||||
import org.junit.jupiter.api.*;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class RedisPoolConnectionTest {
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void getJedis() {
|
||||
System.out.println("开始Redis连接测试...");
|
||||
Jedis jedis = RedisPoolConnection.getJedis();
|
||||
assertNotNull(jedis);
|
||||
System.out.println("Redis连接测试通过!");
|
||||
System.out.println("Redis服务器状态:" + jedis.ping());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
void closeJedis() throws InterruptedException {
|
||||
// Thread.sleep(10000);
|
||||
System.out.println("开始关闭Redis连接...");
|
||||
Jedis jedis = RedisPoolConnection.getJedis();
|
||||
assertNotNull(jedis);
|
||||
RedisPoolConnection.closeJedis(jedis);
|
||||
System.out.println("Redis连接已关闭!");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
void closePool() throws InterruptedException {
|
||||
// Thread.sleep(10000);
|
||||
System.out.println("开始关闭Redis连接池...");
|
||||
RedisPoolConnection.closePool();
|
||||
System.out.println("Redis连接池已关闭!");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user