SpringCloud运行环境,排除system模块jar中的application*.yaml配置文件
测试类默认注释掉,减少启动问题 yml格式不规范,导致启动报错
This commit is contained in:
parent
2e90f73da2
commit
a6ae4080cb
|
@ -61,10 +61,28 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!--微服务模式下修改为true,跳过SpringBoot启动打包插件,否则微服务模块无法引用-->
|
<!--SpringCloud运行环境 ,值改为true跳过SpringBoot启动打包插件 -->
|
||||||
<skip>${skip.springboot.maven}</skip>
|
<skip>${skip.springboot.maven}</skip>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<!-- SpringCloud运行环境 -->
|
||||||
|
<profile>
|
||||||
|
<id>SpringCloud</id>
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<excludes>
|
||||||
|
<exclude>application.yml</exclude>
|
||||||
|
<exclude>application-*.yml</exclude>
|
||||||
|
</excludes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
</project>
|
</project>
|
|
@ -174,16 +174,16 @@ mybatis-plus:
|
||||||
# 返回类型为Map,显示null对应的字段
|
# 返回类型为Map,显示null对应的字段
|
||||||
call-setters-on-nulls: true
|
call-setters-on-nulls: true
|
||||||
#jeecg专用配置
|
#jeecg专用配置
|
||||||
minidao :
|
minidao:
|
||||||
base-package: org.jeecg.modules.jmreport.*
|
base-package: org.jeecg.modules.jmreport.*
|
||||||
jeecg :
|
jeecg:
|
||||||
# 是否启用安全模式
|
# 是否启用安全模式
|
||||||
safeMode: false
|
safeMode: false
|
||||||
# 签名密钥串(前后端要一致,正式发布请自行修改)
|
# 签名密钥串(前后端要一致,正式发布请自行修改)
|
||||||
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
|
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
|
||||||
# 本地:local\Minio:minio\阿里云:alioss
|
# 本地:local\Minio:minio\阿里云:alioss
|
||||||
uploadType: local
|
uploadType: local
|
||||||
path :
|
path:
|
||||||
#文件上传根目录 设置
|
#文件上传根目录 设置
|
||||||
upload: /opt/upFiles
|
upload: /opt/upFiles
|
||||||
#webapp文件路径
|
#webapp文件路径
|
||||||
|
@ -268,7 +268,7 @@ cas:
|
||||||
#Mybatis输出sql日志
|
#Mybatis输出sql日志
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
org.jeecg.modules.system.mapper : info
|
org.jeecg.modules.system.mapper: info
|
||||||
#swagger
|
#swagger
|
||||||
knife4j:
|
knife4j:
|
||||||
#开启增强配置
|
#开启增强配置
|
||||||
|
|
|
@ -79,8 +79,8 @@ spring:
|
||||||
static-path-pattern: /**
|
static-path-pattern: /**
|
||||||
resource:
|
resource:
|
||||||
static-locations: classpath:/static/,classpath:/public/
|
static-locations: classpath:/static/,classpath:/public/
|
||||||
# autoconfigure:
|
# autoconfigure:
|
||||||
# exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
|
# exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
|
||||||
datasource:
|
datasource:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
druid:
|
druid:
|
||||||
|
@ -132,14 +132,14 @@ mybatis-plus:
|
||||||
# 返回类型为Map,显示null对应的字段
|
# 返回类型为Map,显示null对应的字段
|
||||||
call-setters-on-nulls: true
|
call-setters-on-nulls: true
|
||||||
#jeecg专用配置
|
#jeecg专用配置
|
||||||
jeecg :
|
jeecg:
|
||||||
# 是否启用安全模式
|
# 是否启用安全模式
|
||||||
safeMode: false
|
safeMode: false
|
||||||
# 签名密钥串(前后端要一致,正式发布请自行修改)
|
# 签名密钥串(前后端要一致,正式发布请自行修改)
|
||||||
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
|
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
|
||||||
# 本地:local\Minio:minio\阿里云:alioss
|
# 本地:local\Minio:minio\阿里云:alioss
|
||||||
uploadType: alioss
|
uploadType: alioss
|
||||||
path :
|
path:
|
||||||
#文件上传根目录 设置
|
#文件上传根目录 设置
|
||||||
upload: D://opt//upFiles
|
upload: D://opt//upFiles
|
||||||
#webapp文件路径
|
#webapp文件路径
|
||||||
|
@ -215,7 +215,7 @@ cas:
|
||||||
#Mybatis输出sql日志
|
#Mybatis输出sql日志
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
org.jeecg.modules.system.mapper : info
|
org.jeecg.modules.system.mapper: info
|
||||||
#enable swagger
|
#enable swagger
|
||||||
swagger:
|
swagger:
|
||||||
enable: true
|
enable: true
|
||||||
|
|
|
@ -174,16 +174,16 @@ mybatis-plus:
|
||||||
# 返回类型为Map,显示null对应的字段
|
# 返回类型为Map,显示null对应的字段
|
||||||
call-setters-on-nulls: true
|
call-setters-on-nulls: true
|
||||||
#jeecg专用配置
|
#jeecg专用配置
|
||||||
minidao :
|
minidao:
|
||||||
base-package: org.jeecg.modules.jmreport.*
|
base-package: org.jeecg.modules.jmreport.*
|
||||||
jeecg :
|
jeecg:
|
||||||
# 是否启用安全模式
|
# 是否启用安全模式
|
||||||
safeMode: false
|
safeMode: false
|
||||||
# 签名密钥串(前后端要一致,正式发布请自行修改)
|
# 签名密钥串(前后端要一致,正式发布请自行修改)
|
||||||
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
|
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
|
||||||
# 本地:local\Minio:minio\阿里云:alioss
|
# 本地:local\Minio:minio\阿里云:alioss
|
||||||
uploadType: alioss
|
uploadType: alioss
|
||||||
path :
|
path:
|
||||||
#文件上传根目录 设置
|
#文件上传根目录 设置
|
||||||
upload: /opt/jeecg-boot/upload
|
upload: /opt/jeecg-boot/upload
|
||||||
#webapp文件路径
|
#webapp文件路径
|
||||||
|
@ -262,7 +262,7 @@ cas:
|
||||||
#Mybatis输出sql日志
|
#Mybatis输出sql日志
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
org.jeecg.modules.system.mapper : info
|
org.jeecg.modules.system.mapper: info
|
||||||
#swagger
|
#swagger
|
||||||
knife4j:
|
knife4j:
|
||||||
#开启增强配置
|
#开启增强配置
|
||||||
|
|
|
@ -174,16 +174,16 @@ mybatis-plus:
|
||||||
# 返回类型为Map,显示null对应的字段
|
# 返回类型为Map,显示null对应的字段
|
||||||
call-setters-on-nulls: true
|
call-setters-on-nulls: true
|
||||||
#jeecg专用配置
|
#jeecg专用配置
|
||||||
minidao :
|
minidao:
|
||||||
base-package: org.jeecg.modules.jmreport.*
|
base-package: org.jeecg.modules.jmreport.*
|
||||||
jeecg :
|
jeecg:
|
||||||
# 是否启用安全模式
|
# 是否启用安全模式
|
||||||
safeMode: false
|
safeMode: false
|
||||||
# 签名密钥串(前后端要一致,正式发布请自行修改)
|
# 签名密钥串(前后端要一致,正式发布请自行修改)
|
||||||
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
|
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
|
||||||
# 本地:local\Minio:minio\阿里云:alioss
|
# 本地:local\Minio:minio\阿里云:alioss
|
||||||
uploadType: local
|
uploadType: local
|
||||||
path :
|
path:
|
||||||
#文件上传根目录 设置
|
#文件上传根目录 设置
|
||||||
upload: D://opt//upFiles
|
upload: D://opt//upFiles
|
||||||
#webapp文件路径
|
#webapp文件路径
|
||||||
|
@ -259,7 +259,7 @@ jeecg :
|
||||||
#Mybatis输出sql日志
|
#Mybatis输出sql日志
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
org.jeecg.modules.system.mapper : info
|
org.jeecg.modules.system.mapper: info
|
||||||
#cas单点登录
|
#cas单点登录
|
||||||
cas:
|
cas:
|
||||||
prefixUrl: http://cas.example.org:8443/cas
|
prefixUrl: http://cas.example.org:8443/cas
|
||||||
|
|
|
@ -1,64 +1,64 @@
|
||||||
package org.jeecg;
|
//package org.jeecg;
|
||||||
|
//
|
||||||
import org.jeecg.modules.demo.mock.MockController;
|
//import org.jeecg.modules.demo.mock.MockController;
|
||||||
import org.jeecg.modules.demo.test.entity.JeecgDemo;
|
//import org.jeecg.modules.demo.test.entity.JeecgDemo;
|
||||||
import org.jeecg.modules.demo.test.mapper.JeecgDemoMapper;
|
//import org.jeecg.modules.demo.test.mapper.JeecgDemoMapper;
|
||||||
import org.jeecg.modules.demo.test.service.IJeecgDemoService;
|
//import org.jeecg.modules.demo.test.service.IJeecgDemoService;
|
||||||
import org.jeecg.modules.system.service.ISysDataLogService;
|
//import org.jeecg.modules.system.service.ISysDataLogService;
|
||||||
import org.junit.Assert;
|
//import org.junit.Assert;
|
||||||
import org.junit.Test;
|
//import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
//import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
//import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
//import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
//
|
||||||
import javax.annotation.Resource;
|
//import javax.annotation.Resource;
|
||||||
import java.util.List;
|
//import java.util.List;
|
||||||
|
//
|
||||||
@RunWith(SpringRunner.class)
|
//@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
|
//@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
|
||||||
public class SampleTest {
|
//public class SampleTest {
|
||||||
|
//
|
||||||
@Resource
|
// @Resource
|
||||||
private JeecgDemoMapper jeecgDemoMapper;
|
// private JeecgDemoMapper jeecgDemoMapper;
|
||||||
@Resource
|
// @Resource
|
||||||
private IJeecgDemoService jeecgDemoService;
|
// private IJeecgDemoService jeecgDemoService;
|
||||||
@Resource
|
// @Resource
|
||||||
private ISysDataLogService sysDataLogService;
|
// private ISysDataLogService sysDataLogService;
|
||||||
@Resource
|
// @Resource
|
||||||
private MockController mock;
|
// private MockController mock;
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void testSelect() {
|
// public void testSelect() {
|
||||||
System.out.println(("----- selectAll method test ------"));
|
// System.out.println(("----- selectAll method test ------"));
|
||||||
List<JeecgDemo> userList = jeecgDemoMapper.selectList(null);
|
// List<JeecgDemo> userList = jeecgDemoMapper.selectList(null);
|
||||||
Assert.assertEquals(5, userList.size());
|
// Assert.assertEquals(5, userList.size());
|
||||||
userList.forEach(System.out::println);
|
// userList.forEach(System.out::println);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Test
|
// @Test
|
||||||
public void testXmlSql() {
|
// public void testXmlSql() {
|
||||||
System.out.println(("----- selectAll method test ------"));
|
// System.out.println(("----- selectAll method test ------"));
|
||||||
List<JeecgDemo> userList = jeecgDemoMapper.getDemoByName("Sandy12");
|
// List<JeecgDemo> userList = jeecgDemoMapper.getDemoByName("Sandy12");
|
||||||
userList.forEach(System.out::println);
|
// userList.forEach(System.out::println);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 测试事务
|
// * 测试事务
|
||||||
*/
|
// */
|
||||||
@Test
|
// @Test
|
||||||
public void testTran() {
|
// public void testTran() {
|
||||||
jeecgDemoService.testTran();
|
// jeecgDemoService.testTran();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 测试数据日志添加
|
// * 测试数据日志添加
|
||||||
*/
|
// */
|
||||||
@Test
|
// @Test
|
||||||
public void testDataLogSave() {
|
// public void testDataLogSave() {
|
||||||
System.out.println(("----- datalog test ------"));
|
// System.out.println(("----- datalog test ------"));
|
||||||
String tableName = "jeecg_demo";
|
// String tableName = "jeecg_demo";
|
||||||
String dataId = "4028ef81550c1a7901550c1cd6e70001";
|
// String dataId = "4028ef81550c1a7901550c1cd6e70001";
|
||||||
String dataContent = mock.sysDataLogJson();
|
// String dataContent = mock.sysDataLogJson();
|
||||||
sysDataLogService.addDataLog(tableName, dataId, dataContent);
|
// sysDataLogService.addDataLog(tableName, dataId, dataContent);
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
@ -1,179 +1,179 @@
|
||||||
package org.jeecg.modules.system.test;
|
//package org.jeecg.modules.system.test;
|
||||||
|
//
|
||||||
import org.jeecg.JeecgSystemApplication;
|
//import org.jeecg.JeecgSystemApplication;
|
||||||
import org.jeecg.common.constant.CommonConstant;
|
//import org.jeecg.common.constant.CommonConstant;
|
||||||
import org.jeecg.common.system.util.JwtUtil;
|
//import org.jeecg.common.system.util.JwtUtil;
|
||||||
import org.jeecg.common.util.RedisUtil;
|
//import org.jeecg.common.util.RedisUtil;
|
||||||
import org.jeecg.common.util.RestUtil;
|
//import org.jeecg.common.util.RestUtil;
|
||||||
import org.junit.Test;
|
//import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
//import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
//import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
//import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
//import org.springframework.test.context.junit4.SpringRunner;
|
||||||
import org.springframework.http.HttpHeaders;
|
//import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
//import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.MediaType;
|
//import org.springframework.http.MediaType;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
//import com.alibaba.fastjson.JSONObject;
|
||||||
import org.springframework.http.ResponseEntity;
|
//import org.springframework.http.ResponseEntity;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* 系统用户单元测试
|
// * 系统用户单元测试
|
||||||
*/
|
// */
|
||||||
@RunWith(SpringRunner.class)
|
//@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
|
//@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
|
||||||
@SuppressWarnings({"FieldCanBeLocal", "SpringJavaAutowiredMembersInspection"})
|
//@SuppressWarnings({"FieldCanBeLocal", "SpringJavaAutowiredMembersInspection"})
|
||||||
public class SysUserTest {
|
//public class SysUserTest {
|
||||||
/**
|
// /**
|
||||||
* 测试地址:实际使用时替换成你自己的地址
|
// * 测试地址:实际使用时替换成你自己的地址
|
||||||
*/
|
// */
|
||||||
private final String BASE_URL = "http://localhost:8080/jeecg-boot/sys/user/";
|
// private final String BASE_URL = "http://localhost:8080/jeecg-boot/sys/user/";
|
||||||
//测试:用户名和密码
|
// //测试:用户名和密码
|
||||||
private final String USERNAME = "admin";
|
// private final String USERNAME = "admin";
|
||||||
private final String PASSWORD = "123456";
|
// private final String PASSWORD = "123456";
|
||||||
@Autowired
|
// @Autowired
|
||||||
private RedisUtil redisUtil;
|
// private RedisUtil redisUtil;
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 测试用例:查询记录
|
// * 测试用例:查询记录
|
||||||
*/
|
// */
|
||||||
@Test
|
// @Test
|
||||||
public void testQuery() {
|
// public void testQuery() {
|
||||||
// 请求地址
|
// // 请求地址
|
||||||
String url = BASE_URL + "list";
|
// String url = BASE_URL + "list";
|
||||||
// 请求 Header (用于传递Token)
|
// // 请求 Header (用于传递Token)
|
||||||
HttpHeaders headers = this.getHeaders();
|
// HttpHeaders headers = this.getHeaders();
|
||||||
// 请求方式是 GET 代表获取数据
|
// // 请求方式是 GET 代表获取数据
|
||||||
HttpMethod method = HttpMethod.GET;
|
// HttpMethod method = HttpMethod.GET;
|
||||||
|
//
|
||||||
System.out.println("请求地址:" + url);
|
// System.out.println("请求地址:" + url);
|
||||||
System.out.println("请求方式:" + method);
|
// System.out.println("请求方式:" + method);
|
||||||
|
//
|
||||||
// 利用 RestUtil 请求该url
|
// // 利用 RestUtil 请求该url
|
||||||
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, null, JSONObject.class);
|
// ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, null, JSONObject.class);
|
||||||
if (result != null && result.getBody() != null) {
|
// if (result != null && result.getBody() != null) {
|
||||||
System.out.println("返回结果:" + result.getBody().toJSONString());
|
// System.out.println("返回结果:" + result.getBody().toJSONString());
|
||||||
} else {
|
// } else {
|
||||||
System.out.println("查询失败");
|
// System.out.println("查询失败");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 测试用例:新增
|
// * 测试用例:新增
|
||||||
*/
|
// */
|
||||||
@Test
|
// @Test
|
||||||
public void testAdd() {
|
// public void testAdd() {
|
||||||
// 请求地址
|
// // 请求地址
|
||||||
String url = BASE_URL + "add" ;
|
// String url = BASE_URL + "add" ;
|
||||||
// 请求 Header (用于传递Token)
|
// // 请求 Header (用于传递Token)
|
||||||
HttpHeaders headers = this.getHeaders();
|
// HttpHeaders headers = this.getHeaders();
|
||||||
// 请求方式是 POST 代表提交新增数据
|
// // 请求方式是 POST 代表提交新增数据
|
||||||
HttpMethod method = HttpMethod.POST;
|
// HttpMethod method = HttpMethod.POST;
|
||||||
|
//
|
||||||
System.out.println("请求地址:" + url);
|
// System.out.println("请求地址:" + url);
|
||||||
System.out.println("请求方式:" + method);
|
// System.out.println("请求方式:" + method);
|
||||||
|
//
|
||||||
JSONObject params = new JSONObject();
|
// JSONObject params = new JSONObject();
|
||||||
params.put("username", "wangwuTest");
|
// params.put("username", "wangwuTest");
|
||||||
params.put("password", "123456");
|
// params.put("password", "123456");
|
||||||
params.put("confirmpassword","123456");
|
// params.put("confirmpassword","123456");
|
||||||
params.put("realname", "单元测试");
|
// params.put("realname", "单元测试");
|
||||||
params.put("activitiSync", "1");
|
// params.put("activitiSync", "1");
|
||||||
params.put("userIdentity","1");
|
// params.put("userIdentity","1");
|
||||||
params.put("workNo","0025");
|
// params.put("workNo","0025");
|
||||||
|
//
|
||||||
System.out.println("请求参数:" + params.toJSONString());
|
// System.out.println("请求参数:" + params.toJSONString());
|
||||||
|
//
|
||||||
// 利用 RestUtil 请求该url
|
// // 利用 RestUtil 请求该url
|
||||||
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, params, JSONObject.class);
|
// ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, params, JSONObject.class);
|
||||||
if (result != null && result.getBody() != null) {
|
// if (result != null && result.getBody() != null) {
|
||||||
System.out.println("返回结果:" + result.getBody().toJSONString());
|
// System.out.println("返回结果:" + result.getBody().toJSONString());
|
||||||
} else {
|
// } else {
|
||||||
System.out.println("查询失败");
|
// System.out.println("查询失败");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 测试用例:修改
|
// * 测试用例:修改
|
||||||
*/
|
// */
|
||||||
@Test
|
// @Test
|
||||||
public void testEdit() {
|
// public void testEdit() {
|
||||||
// 数据Id
|
// // 数据Id
|
||||||
String dataId = "1331795062924374018";
|
// String dataId = "1331795062924374018";
|
||||||
// 请求地址
|
// // 请求地址
|
||||||
String url = BASE_URL + "edit";
|
// String url = BASE_URL + "edit";
|
||||||
// 请求 Header (用于传递Token)
|
// // 请求 Header (用于传递Token)
|
||||||
HttpHeaders headers = this.getHeaders();
|
// HttpHeaders headers = this.getHeaders();
|
||||||
// 请求方式是 PUT 代表提交修改数据
|
// // 请求方式是 PUT 代表提交修改数据
|
||||||
HttpMethod method = HttpMethod.PUT;
|
// HttpMethod method = HttpMethod.PUT;
|
||||||
|
//
|
||||||
System.out.println("请求地址:" + url);
|
// System.out.println("请求地址:" + url);
|
||||||
System.out.println("请求方式:" + method);
|
// System.out.println("请求方式:" + method);
|
||||||
|
//
|
||||||
JSONObject params = new JSONObject();
|
// JSONObject params = new JSONObject();
|
||||||
params.put("username", "wangwuTest");
|
// params.put("username", "wangwuTest");
|
||||||
params.put("realname", "单元测试1111");
|
// params.put("realname", "单元测试1111");
|
||||||
params.put("activitiSync", "1");
|
// params.put("activitiSync", "1");
|
||||||
params.put("userIdentity","1");
|
// params.put("userIdentity","1");
|
||||||
params.put("workNo","0025");
|
// params.put("workNo","0025");
|
||||||
params.put("id",dataId);
|
// params.put("id",dataId);
|
||||||
|
//
|
||||||
System.out.println("请求参数:" + params.toJSONString());
|
// System.out.println("请求参数:" + params.toJSONString());
|
||||||
|
//
|
||||||
// 利用 RestUtil 请求该url
|
// // 利用 RestUtil 请求该url
|
||||||
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, params, JSONObject.class);
|
// ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, params, JSONObject.class);
|
||||||
if (result != null && result.getBody() != null) {
|
// if (result != null && result.getBody() != null) {
|
||||||
System.out.println("返回结果:" + result.getBody().toJSONString());
|
// System.out.println("返回结果:" + result.getBody().toJSONString());
|
||||||
} else {
|
// } else {
|
||||||
System.out.println("查询失败");
|
// System.out.println("查询失败");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 测试用例:删除
|
// * 测试用例:删除
|
||||||
*/
|
// */
|
||||||
@Test
|
// @Test
|
||||||
public void testDelete() {
|
// public void testDelete() {
|
||||||
// 数据Id
|
// // 数据Id
|
||||||
String dataId = "1331795062924374018";
|
// String dataId = "1331795062924374018";
|
||||||
// 请求地址
|
// // 请求地址
|
||||||
String url = BASE_URL + "delete" + "?id=" + dataId;
|
// String url = BASE_URL + "delete" + "?id=" + dataId;
|
||||||
// 请求 Header (用于传递Token)
|
// // 请求 Header (用于传递Token)
|
||||||
HttpHeaders headers = this.getHeaders();
|
// HttpHeaders headers = this.getHeaders();
|
||||||
// 请求方式是 DELETE 代表删除数据
|
// // 请求方式是 DELETE 代表删除数据
|
||||||
HttpMethod method = HttpMethod.DELETE;
|
// HttpMethod method = HttpMethod.DELETE;
|
||||||
|
//
|
||||||
System.out.println("请求地址:" + url);
|
// System.out.println("请求地址:" + url);
|
||||||
System.out.println("请求方式:" + method);
|
// System.out.println("请求方式:" + method);
|
||||||
|
//
|
||||||
// 利用 RestUtil 请求该url
|
// // 利用 RestUtil 请求该url
|
||||||
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, null, JSONObject.class);
|
// ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, null, JSONObject.class);
|
||||||
if (result != null && result.getBody() != null) {
|
// if (result != null && result.getBody() != null) {
|
||||||
System.out.println("返回结果:" + result.getBody().toJSONString());
|
// System.out.println("返回结果:" + result.getBody().toJSONString());
|
||||||
} else {
|
// } else {
|
||||||
System.out.println("查询失败");
|
// System.out.println("查询失败");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
private String getToken() {
|
// private String getToken() {
|
||||||
String token = JwtUtil.sign(USERNAME, PASSWORD);
|
// String token = JwtUtil.sign(USERNAME, PASSWORD);
|
||||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
// redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, 60);
|
// redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, 60);
|
||||||
return token;
|
// return token;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private HttpHeaders getHeaders() {
|
// private HttpHeaders getHeaders() {
|
||||||
String token = this.getToken();
|
// String token = this.getToken();
|
||||||
System.out.println("请求Token:" + token);
|
// System.out.println("请求Token:" + token);
|
||||||
|
//
|
||||||
HttpHeaders headers = new HttpHeaders();
|
// HttpHeaders headers = new HttpHeaders();
|
||||||
String mediaType = MediaType.APPLICATION_JSON_VALUE;
|
// String mediaType = MediaType.APPLICATION_JSON_VALUE;
|
||||||
headers.setContentType(MediaType.parseMediaType(mediaType));
|
// headers.setContentType(MediaType.parseMediaType(mediaType));
|
||||||
headers.set("Accept", mediaType);
|
// headers.set("Accept", mediaType);
|
||||||
headers.set("X-Access-Token", token);
|
// headers.set("X-Access-Token", token);
|
||||||
return headers;
|
// return headers;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
Loading…
Reference in New Issue