From 3320f42bd7cfb0c8c1c7e63bb5aab181c2a4e169 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 1 Mar 2021 00:21:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20redis=20=E5=92=8C=20mysql?= =?UTF-8?q?=20=E5=9C=A8=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E4=BC=9A?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/QuartzTestConfiguration.java | 6 +++--- .../dashboard/config/RedisTestConfiguration.java | 16 ++++++++++++++-- src/test/resources/sql/create_tables.sql | 12 ++++++------ 3 files changed, 23 insertions(+), 11 deletions(-) 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 '',