xiaozhi-esp32-server/main/manager-api/src/test/java/xiaozhi/RedisTest.java
2025-03-10 13:44:08 +08:00

30 lines
No EOL
1.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package xiaozhi;
import xiaozhi.common.redis.RedisUtils;
import xiaozhi.modules.sys.entity.SysUserEntity;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.builder.ToStringBuilder;
// 若使用 JUnit 5,应导入以下包
import org.junit.jupiter.api.Test;
// 由于代码中使用了 JUnit 5 的 @Test 注解,应移除 JUnit 4 的 @RunWith 相关导入
// import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
// 由于代码中使用了 JUnit 5 的 @Test 注解,应移除 JUnit 4 的 @RunWith 相关代码
// @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class RedisTest {
@Resource
private RedisUtils redisUtils;
@Test
public void contextLoads() {
SysUserEntity user = new SysUserEntity();
user.setEmail("123456@qq.com");
redisUtils.set("user", user);
System.out.println(ToStringBuilder.reflectionToString(redisUtils.get("user")));
}
}