diff --git a/src/test/java/cn/iocoder/dashboard/config/QuartzTestConfiguration.java b/src/test/java/cn/iocoder/dashboard/config/QuartzTestConfiguration.java index 24aa88169..2d44487e4 100644 --- a/src/test/java/cn/iocoder/dashboard/config/QuartzTestConfiguration.java +++ b/src/test/java/cn/iocoder/dashboard/config/QuartzTestConfiguration.java @@ -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); } } diff --git a/src/test/java/cn/iocoder/dashboard/config/RedisTestConfiguration.java b/src/test/java/cn/iocoder/dashboard/config/RedisTestConfiguration.java index f5df9ab3e..904fd0a88 100644 --- a/src/test/java/cn/iocoder/dashboard/config/RedisTestConfiguration.java +++ b/src/test/java/cn/iocoder/dashboard/config/RedisTestConfiguration.java @@ -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; } } diff --git a/src/test/resources/sql/create_tables.sql b/src/test/resources/sql/create_tables.sql index 7a24ed567..183554519 100644 --- a/src/test/resources/sql/create_tables.sql +++ b/src/test/resources/sql/create_tables.sql @@ -1,6 +1,6 @@ -- inf 开头的 DB -CREATE TABLE "inf_config" ( +CREATE TABLE IF NOT EXISTS "inf_config" ( "id" int NOT NULL GENERATED BY DEFAULT AS IDENTITY, "group" varchar(50) NOT NULL, "type" tinyint NOT NULL, @@ -19,7 +19,7 @@ CREATE TABLE "inf_config" ( -- sys 开头的 DB -CREATE TABLE "sys_dept" ( +CREATE TABLE IF NOT EXISTS "sys_dept" ( "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" varchar(30) NOT NULL DEFAULT '', "parent_id" bigint NOT NULL DEFAULT '0', @@ -36,7 +36,7 @@ CREATE TABLE "sys_dept" ( PRIMARY KEY ("id") ) COMMENT '部门表'; -CREATE TABLE "sys_dict_data" ( +CREATE TABLE IF NOT EXISTS "sys_dict_data" ( "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "sort" int NOT NULL DEFAULT '0', "label" varchar(100) NOT NULL DEFAULT '', @@ -52,7 +52,7 @@ CREATE TABLE "sys_dict_data" ( PRIMARY KEY ("id") ) COMMENT '字典数据表'; -CREATE TABLE "sys_role" ( +CREATE TABLE IF NOT EXISTS "sys_role" ( "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" varchar(30) NOT NULL, "code" varchar(100) NOT NULL, @@ -70,7 +70,7 @@ CREATE TABLE "sys_role" ( PRIMARY KEY ("id") ) COMMENT '角色信息表'; -CREATE TABLE "sys_role_menu" ( +CREATE TABLE IF NOT EXISTS "sys_role_menu" ( "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "role_id" bigint NOT NULL, "menu_id" bigint NOT NULL, @@ -82,7 +82,7 @@ CREATE TABLE "sys_role_menu" ( PRIMARY KEY ("id") ) COMMENT '角色和菜单关联表'; -CREATE TABLE "sys_menu" ( +CREATE TABLE IF NOT EXISTS "sys_menu" ( "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "name" varchar(50) NOT NULL, "permission" varchar(100) NOT NULL DEFAULT '',