diff --git a/blade-service/blade-demo/pom.xml b/blade-service/blade-demo/pom.xml index b9170b28f..bcd8828f9 100644 --- a/blade-service/blade-demo/pom.xml +++ b/blade-service/blade-demo/pom.xml @@ -42,6 +42,12 @@ blade-demo-api ${bladex.project.version} + + org.springblade + blade-core-test + ${bladex.tool.version} + test + org.springblade blade-core-auto diff --git a/blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java b/blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java index bdb91b080..ca7e88d16 100644 --- a/blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java +++ b/blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java @@ -39,4 +39,8 @@ public class DemoLauncherServiceImpl implements LauncherService { props.setProperty("spring.cloud.nacos.config.ext-config[0].refresh", NacosConstant.NACOS_CONFIG_REFRESH); } + @Override + public int getOrder() { + return 20; + } } diff --git a/blade-service/blade-demo/src/test/java/BladeDemoTest.java b/blade-service/blade-demo/src/test/java/BladeDemoTest.java new file mode 100644 index 000000000..91305ccf4 --- /dev/null +++ b/blade-service/blade-demo/src/test/java/BladeDemoTest.java @@ -0,0 +1,23 @@ +import com.example.demo.DemoApplication; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springblade.core.test.BladeBootTest; +import org.springblade.core.test.BladeSpringRunner; +import org.springframework.boot.test.context.SpringBootTest; + +/** + * Blade单元测试 + * + * @author Chill + */ +@RunWith(BladeSpringRunner.class) +@SpringBootTest(classes = DemoApplication.class) +@BladeBootTest(appName = "blade-demo", profile = "test", enableLoader = true) +public class BladeDemoTest { + + @Test + public void contextLoads() { + System.out.println("测试~~~~~~"); + } + +} diff --git a/blade-service/blade-demo/src/test/java/launcher/DemoTestLauncherServiceImpl.java b/blade-service/blade-demo/src/test/java/launcher/DemoTestLauncherServiceImpl.java new file mode 100644 index 000000000..8cf5d3908 --- /dev/null +++ b/blade-service/blade-demo/src/test/java/launcher/DemoTestLauncherServiceImpl.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * Neither the name of the dreamlu.net developer nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * Author: Chill 庄骞 (smallchill@163.com) + */ +package launcher; + +import org.springblade.common.constant.CommonConstant; +import org.springblade.core.auto.service.AutoService; +import org.springblade.core.launch.service.LauncherService; +import org.springframework.boot.builder.SpringApplicationBuilder; + +import java.util.Properties; + +/** + * 启动参数拓展 + * + * @author Chill + */ +@AutoService(LauncherService.class) +public class DemoTestLauncherServiceImpl implements LauncherService { + + @Override + public void launcher(SpringApplicationBuilder builder, String appName, String profile, boolean isLocalDev) { + Properties props = System.getProperties(); + props.setProperty("spring.cloud.nacos.discovery.server-addr", CommonConstant.NACOS_DEV_ADDR); + props.setProperty("spring.cloud.nacos.config.server-addr", CommonConstant.NACOS_DEV_ADDR); + props.setProperty("spring.cloud.sentinel.transport.dashboard", CommonConstant.SENTINEL_DEV_ADDR); + } + + @Override + public int getOrder() { + return 10; + } +} diff --git a/blade-service/blade-demo/src/test/resources/application-test.yml b/blade-service/blade-demo/src/test/resources/application-test.yml new file mode 100644 index 000000000..2842aa483 --- /dev/null +++ b/blade-service/blade-demo/src/test/resources/application-test.yml @@ -0,0 +1,10 @@ +#服务器端口 +server: + port: 8200 + +#数据源配置 +spring: + datasource: + url: ${blade.datasource.test.url} + username: ${blade.datasource.test.username} + password: ${blade.datasource.test.password} diff --git a/blade-service/blade-demo/src/test/resources/application.yml b/blade-service/blade-demo/src/test/resources/application.yml new file mode 100644 index 000000000..38326ec6f --- /dev/null +++ b/blade-service/blade-demo/src/test/resources/application.yml @@ -0,0 +1,21 @@ +#mybatis-plus配置 +mybatis-plus: + mapper-locations: classpath:com/example/**/mapper/*Mapper.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.example.**.entity + +#swagger扫描路径配置 +swagger: + base-packages: + - org.springbalde + - com.example + +#oss配置 +oss: + enable: true + name: minio + tenant-mode: false + endpoint: http://127.0.0.1:9000 + access-key: D99KGE6ZTQXSATTJWU24 + secret-key: QyVqGnhIQQE734UYSUFlGOZViE6+ZlDEfUG3NjhJ + bucket-name: bladex