mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 16:35:06 +08:00
解决 redis 和 mysql 在单元测试会报错的问题
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.dashboard.config;
|
||||
|
||||
import io.reactivex.rxjava3.core.Scheduler;
|
||||
import org.mockito.Mockito;
|
||||
import org.quartz.impl.StdScheduler;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@ -11,8 +11,8 @@ import org.springframework.context.annotation.Lazy;
|
||||
public class QuartzTestConfiguration {
|
||||
|
||||
@Bean
|
||||
public Scheduler scheduler() {
|
||||
return Mockito.mock(Scheduler.class);
|
||||
public StdScheduler scheduler() {
|
||||
return Mockito.mock(StdScheduler.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,12 +18,24 @@ import java.io.IOException;
|
||||
@AutoConfigureBefore({RedisAutoConfiguration.class, RedissonAutoConfiguration.class}) // 在 Redis 自动配置前,进行初始化
|
||||
public class RedisTestConfiguration {
|
||||
|
||||
// /**
|
||||
// * 创建模拟的 Redis Server 服务器
|
||||
// */
|
||||
// @Bean(initMethod = "start", destroyMethod = "stop")
|
||||
// public RedisServer redisServer(RedisProperties properties) throws IOException {
|
||||
// return new RedisServer(properties.getPort());
|
||||
// }
|
||||
|
||||
/**
|
||||
* 创建模拟的 Redis Server 服务器
|
||||
*/
|
||||
@Bean(initMethod = "start", destroyMethod = "stop")
|
||||
@Bean(destroyMethod = "stop")
|
||||
public RedisServer redisServer(RedisProperties properties) throws IOException {
|
||||
return new RedisServer(properties.getPort());
|
||||
RedisServer redisServer = new RedisServer(properties.getPort());
|
||||
try {
|
||||
redisServer.start();
|
||||
} catch (Exception ignore) {}
|
||||
return redisServer;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user