Browse Source

🎉 增加单元测试demo

test
smallchill 6 years ago
parent
commit
e77e8f39cb
  1. 6
      blade-service/blade-demo/pom.xml
  2. 4
      blade-service/blade-demo/src/main/java/com/example/demo/launcher/DemoLauncherServiceImpl.java
  3. 23
      blade-service/blade-demo/src/test/java/BladeDemoTest.java
  4. 46
      blade-service/blade-demo/src/test/java/launcher/DemoTestLauncherServiceImpl.java
  5. 10
      blade-service/blade-demo/src/test/resources/application-test.yml
  6. 21
      blade-service/blade-demo/src/test/resources/application.yml

6
blade-service/blade-demo/pom.xml

@ -42,6 +42,12 @@
<artifactId>blade-demo-api</artifactId>
<version>${bladex.project.version}</version>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-test</artifactId>
<version>${bladex.tool.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springblade</groupId>
<artifactId>blade-core-auto</artifactId>

4
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;
}
}

23
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("测试~~~~~~");
}
}

46
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;
}
}

10
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}

21
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
Loading…
Cancel
Save