- 初始化中间件
使用
init目录下的run_mysql.sh和run_redis.sh启动中间件(需要先安装Docker)。 如果是 MySQL,需要用init_db.sql初始化数据库。 - 初始化配置
tidp-test中有一些测试代码。
- 如果是 MySQL,在
resources/properties/mysql.properties中设置配置项。 - 如果是 Redis,在
resources/properties/redis.properties中设置配置项。
- 启动 因为测试代码是基于SpringBoot的,如果要使用一个中间件的客户端,只需要将对应的 starter 包作为依赖引入即可。
<!--如果测试MySQL,放开这里-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<!--如果测试Redis,放开这里-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>SpringBoot 实际上是将配置转移到了离代码更近的地方,比如测试 MySQL 时可以使用TestMySQLIdpApplication启动,而测试 Redis 时可以使用TestRedisIdpApplication。
- 测试
tidp-test的test目录下是一些简单的测试用例。