mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-26 16:26:41 +08:00
JeecgBoot 3.6.0大版本发布
This commit is contained in:
@ -1,64 +0,0 @@
|
||||
//package org.jeecg;
|
||||
//
|
||||
//import org.jeecg.modules.demo.mock.MockController;
|
||||
//import org.jeecg.modules.demo.test.entity.JeecgDemo;
|
||||
//import org.jeecg.modules.demo.test.mapper.JeecgDemoMapper;
|
||||
//import org.jeecg.modules.demo.test.service.IJeecgDemoService;
|
||||
//import org.jeecg.modules.system.service.ISysDataLogService;
|
||||
//import org.junit.Assert;
|
||||
//import org.junit.Test;
|
||||
//import org.junit.runner.RunWith;
|
||||
//import org.springframework.boot.test.context.SpringBootTest;
|
||||
//import org.springframework.test.context.junit4.SpringRunner;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@RunWith(SpringRunner.class)
|
||||
//@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
|
||||
//public class SampleTest {
|
||||
//
|
||||
// @Resource
|
||||
// private JeecgDemoMapper jeecgDemoMapper;
|
||||
// @Resource
|
||||
// private IJeecgDemoService jeecgDemoService;
|
||||
// @Resource
|
||||
// private ISysDataLogService sysDataLogService;
|
||||
// @Resource
|
||||
// private MockController mock;
|
||||
//
|
||||
// @Test
|
||||
// public void testSelect() {
|
||||
// System.out.println(("----- selectAll method test ------"));
|
||||
// List<JeecgDemo> userList = jeecgDemoMapper.selectList(null);
|
||||
// Assert.assertEquals(5, userList.size());
|
||||
// userList.forEach(System.out::println);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testXmlSql() {
|
||||
// System.out.println(("----- selectAll method test ------"));
|
||||
// List<JeecgDemo> userList = jeecgDemoMapper.getDemoByName("Sandy12");
|
||||
// userList.forEach(System.out::println);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 测试事务
|
||||
// */
|
||||
// @Test
|
||||
// public void testTran() {
|
||||
// jeecgDemoService.testTran();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 测试数据日志添加
|
||||
// */
|
||||
// @Test
|
||||
// public void testDataLogSave() {
|
||||
// System.out.println(("----- datalog test ------"));
|
||||
// String tableName = "jeecg_demo";
|
||||
// String dataId = "4028ef81550c1a7901550c1cd6e70001";
|
||||
// String dataContent = mock.sysDataLogJson();
|
||||
// sysDataLogService.addDataLog(tableName, dataId, dataContent);
|
||||
// }
|
||||
//}
|
||||
@ -1,47 +1,47 @@
|
||||
package org.jeecg;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.util.RestUtil;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
/**
|
||||
* @Description: TODO
|
||||
* @author: scott
|
||||
* @date: 2022年05月10日 14:02
|
||||
*/
|
||||
public class TestMain {
|
||||
public static void main(String[] args) {
|
||||
// 请求地址
|
||||
String url = "https://api.boot.jeecg.com/sys/user/list";
|
||||
// 请求 Header (用于传递Token)
|
||||
HttpHeaders headers = getHeaders();
|
||||
// 请求方式是 GET 代表获取数据
|
||||
HttpMethod method = HttpMethod.GET;
|
||||
|
||||
System.out.println("请求地址:" + url);
|
||||
System.out.println("请求方式:" + method);
|
||||
|
||||
// 利用 RestUtil 请求该url
|
||||
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, null, JSONObject.class);
|
||||
if (result != null && result.getBody() != null) {
|
||||
System.out.println("返回结果:" + result.getBody().toJSONString());
|
||||
} else {
|
||||
System.out.println("查询失败");
|
||||
}
|
||||
}
|
||||
private static HttpHeaders getHeaders() {
|
||||
String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.50h-g6INOZRVnznExiawFb1U6PPjcVVA4POeYRA5a5Q";
|
||||
System.out.println("请求Token:" + token);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
String mediaType = MediaType.APPLICATION_JSON_VALUE;
|
||||
headers.setContentType(MediaType.parseMediaType(mediaType));
|
||||
headers.set("Accept", mediaType);
|
||||
headers.set("X-Access-Token", token);
|
||||
return headers;
|
||||
}
|
||||
|
||||
}
|
||||
//package org.jeecg;
|
||||
//
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import org.jeecg.common.util.RestUtil;
|
||||
//import org.springframework.http.HttpHeaders;
|
||||
//import org.springframework.http.HttpMethod;
|
||||
//import org.springframework.http.MediaType;
|
||||
//import org.springframework.http.ResponseEntity;
|
||||
//
|
||||
///**
|
||||
// * @Description: TODO
|
||||
// * @author: scott
|
||||
// * @date: 2022年05月10日 14:02
|
||||
// */
|
||||
//public class TestMain {
|
||||
// public static void main(String[] args) {
|
||||
// // 请求地址
|
||||
// String url = "https://api.boot.jeecg.com/sys/user/list";
|
||||
// // 请求 Header (用于传递Token)
|
||||
// HttpHeaders headers = getHeaders();
|
||||
// // 请求方式是 GET 代表获取数据
|
||||
// HttpMethod method = HttpMethod.GET;
|
||||
//
|
||||
// System.out.println("请求地址:" + url);
|
||||
// System.out.println("请求方式:" + method);
|
||||
//
|
||||
// // 利用 RestUtil 请求该url
|
||||
// ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, null, JSONObject.class);
|
||||
// if (result != null && result.getBody() != null) {
|
||||
// System.out.println("返回结果:" + result.getBody().toJSONString());
|
||||
// } else {
|
||||
// System.out.println("查询失败");
|
||||
// }
|
||||
// }
|
||||
// private static HttpHeaders getHeaders() {
|
||||
// String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.50h-g6INOZRVnznExiawFb1U6PPjcVVA4POeYRA5a5Q";
|
||||
// System.out.println("请求Token:" + token);
|
||||
//
|
||||
// HttpHeaders headers = new HttpHeaders();
|
||||
// String mediaType = MediaType.APPLICATION_JSON_VALUE;
|
||||
// headers.setContentType(MediaType.parseMediaType(mediaType));
|
||||
// headers.set("Accept", mediaType);
|
||||
// headers.set("X-Access-Token", token);
|
||||
// return headers;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@ -0,0 +1,139 @@
|
||||
package org.jeecg.modules.message.test;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import org.jeecg.JeecgSystemApplication;
|
||||
import org.jeecg.common.api.dto.message.BusMessageDTO;
|
||||
import org.jeecg.common.api.dto.message.BusTemplateMessageDTO;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.common.api.dto.message.TemplateMessageDTO;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.enums.DySmsEnum;
|
||||
import org.jeecg.common.constant.enums.EmailTemplateEnum;
|
||||
import org.jeecg.common.constant.enums.MessageTypeEnum;
|
||||
import org.jeecg.common.constant.enums.SysAnnmentTypeEnum;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.util.DySmsHelper;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description: 消息推送测试
|
||||
* @Author: lsq
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = JeecgSystemApplication.class)
|
||||
public class SendMessageTest {
|
||||
|
||||
@Autowired
|
||||
ISysBaseAPI sysBaseAPI;
|
||||
|
||||
/**
|
||||
* 发送系统消息
|
||||
*/
|
||||
@Test
|
||||
public void sendSysAnnouncement() {
|
||||
//发送人
|
||||
String fromUser = "admin";
|
||||
//接收人
|
||||
String toUser = "jeecg";
|
||||
//标题
|
||||
String title = "系统消息";
|
||||
//内容
|
||||
String msgContent = "TEST:今日份日程计划已送达!";
|
||||
//发送系统消息
|
||||
sysBaseAPI.sendSysAnnouncement(new MessageDTO(fromUser, toUser, title, msgContent));
|
||||
//消息类型
|
||||
String msgCategory = CommonConstant.MSG_CATEGORY_1;
|
||||
//业务类型
|
||||
String busType = SysAnnmentTypeEnum.EMAIL.getType();
|
||||
//业务ID
|
||||
String busId = "11111";
|
||||
//发送带业务参数的系统消息
|
||||
BusMessageDTO busMessageDTO = new BusMessageDTO(fromUser, toUser, title, msgContent, msgCategory, busType,busId);
|
||||
sysBaseAPI.sendBusAnnouncement(busMessageDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送模版消息
|
||||
*/
|
||||
@Test
|
||||
public void sendTemplateAnnouncement() {
|
||||
//发送人
|
||||
String fromUser = "admin";
|
||||
//接收人
|
||||
String toUser = "jeecg";
|
||||
//标题
|
||||
String title = "通知公告";
|
||||
//模版编码
|
||||
String templateCode = "412358";
|
||||
//模版参数
|
||||
Map templateParam = new HashMap<>();
|
||||
templateParam.put("realname","JEECG用户");
|
||||
sysBaseAPI.sendTemplateAnnouncement(new TemplateMessageDTO(fromUser,toUser,title,templateParam,templateCode));
|
||||
//业务类型
|
||||
String busType = SysAnnmentTypeEnum.EMAIL.getType();
|
||||
//业务ID
|
||||
String busId = "11111";
|
||||
//发送带业务参数的模版消息
|
||||
BusTemplateMessageDTO busMessageDTO = new BusTemplateMessageDTO(fromUser, toUser, title, templateParam ,templateCode, busType,busId);
|
||||
sysBaseAPI.sendBusTemplateAnnouncement(busMessageDTO);
|
||||
//新发送模版消息
|
||||
MessageDTO messageDTO = new MessageDTO();
|
||||
messageDTO.setType(MessageTypeEnum.XT.getType());
|
||||
messageDTO.setToAll(false);
|
||||
messageDTO.setToUser(toUser);
|
||||
messageDTO.setTitle("【流程错误】");
|
||||
messageDTO.setFromUser("admin");
|
||||
HashMap data = new HashMap<>();
|
||||
data.put(CommonConstant.NOTICE_MSG_BUS_TYPE, "msg_node");
|
||||
messageDTO.setData(data);
|
||||
messageDTO.setContent("TEST:流程执行失败!任务节点未找到");
|
||||
sysBaseAPI.sendTemplateMessage(messageDTO);
|
||||
}
|
||||
/**
|
||||
* 发送邮件
|
||||
*/
|
||||
@Test
|
||||
public void sendEmailMsg() {
|
||||
String title = "【日程提醒】您的日程任务即将开始";
|
||||
String content = "TEST:尊敬的王先生,您购买的演唱会将于本周日10:08分在国家大剧院如期举行,届时请携带好您的门票和身份证到场";
|
||||
String email = "250678106@qq.com";
|
||||
sysBaseAPI.sendEmailMsg(email,title,content);
|
||||
}
|
||||
/**
|
||||
* 发送html模版邮件
|
||||
*/
|
||||
@Test
|
||||
public void sendTemplateEmailMsg() {
|
||||
String title = "收到一个催办";
|
||||
String email = "250678106@qq.com";
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("bpm_name","高级设置");
|
||||
params.put("bpm_task","审批人");
|
||||
params.put("datetime","2023-10-07 18:00:49");
|
||||
params.put("url","http://boot3.jeecg.com/message/template");
|
||||
params.put("remark","快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点快点");
|
||||
sysBaseAPI.sendHtmlTemplateEmail(email,title, EmailTemplateEnum.BPM_CUIBAN_EMAIL,params);
|
||||
}
|
||||
/**
|
||||
* 发送短信
|
||||
*/
|
||||
@Test
|
||||
public void sendSms() throws ClientException {
|
||||
//手机号
|
||||
String mobile = "159***";
|
||||
//消息模版
|
||||
DySmsEnum templateCode = DySmsEnum.LOGIN_TEMPLATE_CODE;
|
||||
//模版所需参数
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("code", "4XDP");
|
||||
DySmsHelper.sendSms(mobile, obj, templateCode);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package org.jeecg.modules.system.test;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.JeecgSystemApplication;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.RestUtil;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* 系统用户单元测试
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
|
||||
public class InsertDemoTest {
|
||||
/**
|
||||
* 测试地址:实际使用时替换成你自己的地址
|
||||
*/
|
||||
private final String BASE_URL = "http://localhost:8080/jeecg-boot//test/jeecgDemo/";
|
||||
//测试:用户名和密码
|
||||
private final String USERNAME = "admin";
|
||||
private final String PASSWORD = "123456";
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/**
|
||||
* 测试用例:新增
|
||||
*/
|
||||
@Test
|
||||
public void testAdd() {
|
||||
// 请求地址
|
||||
String url = BASE_URL + "add" ;
|
||||
// 请求 Header (用于传递Token)
|
||||
HttpHeaders headers = this.getHeaders();
|
||||
// 请求方式是 POST 代表提交新增数据
|
||||
HttpMethod method = HttpMethod.POST;
|
||||
|
||||
System.out.println("请求地址:" + url);
|
||||
System.out.println("请求方式:" + method);
|
||||
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
String name = "李哈哈" + i;
|
||||
JSONObject params = new JSONObject();
|
||||
params.put("name", name);
|
||||
System.out.println("请求参数:" + params.toJSONString());
|
||||
|
||||
// 利用 RestUtil 请求该url
|
||||
ResponseEntity<JSONObject> result = RestUtil.request(url, method, headers, null, params, JSONObject.class);
|
||||
if (result != null && result.getBody() != null) {
|
||||
System.out.println("返回结果:" + result.getBody().toJSONString());
|
||||
} else {
|
||||
System.out.println("查询失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getToken() {
|
||||
String token = JwtUtil.sign(USERNAME, PASSWORD);
|
||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, 60);
|
||||
return token;
|
||||
}
|
||||
|
||||
private HttpHeaders getHeaders() {
|
||||
String token = this.getToken();
|
||||
System.out.println("请求Token:" + token);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
String mediaType = MediaType.APPLICATION_JSON_VALUE;
|
||||
headers.setContentType(MediaType.parseMediaType(mediaType));
|
||||
headers.set("Accept", mediaType);
|
||||
headers.set("X-Access-Token", token);
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
package org.jeecg.modules.system.test;
|
||||
|
||||
import org.jeecg.JeecgSystemApplication;
|
||||
import org.jeecg.modules.demo.mock.MockController;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgDemo;
|
||||
import org.jeecg.modules.demo.test.mapper.JeecgDemoMapper;
|
||||
import org.jeecg.modules.demo.test.service.IJeecgDemoService;
|
||||
import org.jeecg.modules.system.service.ISysDataLogService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
|
||||
public class SampleTest {
|
||||
|
||||
@Resource
|
||||
private JeecgDemoMapper jeecgDemoMapper;
|
||||
@Resource
|
||||
private IJeecgDemoService jeecgDemoService;
|
||||
@Resource
|
||||
private ISysDataLogService sysDataLogService;
|
||||
@Resource
|
||||
private MockController mock;
|
||||
|
||||
@Test
|
||||
public void testSelect() {
|
||||
System.out.println(("----- selectAll method test ------"));
|
||||
List<JeecgDemo> userList = jeecgDemoMapper.selectList(null);
|
||||
Assert.assertEquals(5, userList.size());
|
||||
userList.forEach(System.out::println);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmlSql() {
|
||||
System.out.println(("----- selectAll method test ------"));
|
||||
List<JeecgDemo> userList = jeecgDemoMapper.getDemoByName("Sandy12");
|
||||
userList.forEach(System.out::println);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试事务
|
||||
*/
|
||||
@Test
|
||||
public void testTran() {
|
||||
jeecgDemoService.testTran();
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试数据日志添加
|
||||
*/
|
||||
@Test
|
||||
public void testDataLogSave() {
|
||||
System.out.println(("----- datalog test ------"));
|
||||
String tableName = "jeecg_demo";
|
||||
String dataId = "4028ef81550c1a7901550c1cd6e70001";
|
||||
String dataContent = mock.sysDataLogJson();
|
||||
sysDataLogService.addDataLog(tableName, dataId, dataContent);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
package org.jeecg.modules.system.test;
|
||||
|
||||
import org.jeecg.JeecgSystemApplication;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.config.JeecgBaseConfig;
|
||||
import org.jeecg.config.firewall.SqlInjection.IDictTableWhiteListHandler;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @Description: 系统表白名单测试
|
||||
* @Author: sunjianlei
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = JeecgSystemApplication.class)
|
||||
public class SysTableWhiteCheckTest {
|
||||
|
||||
@Autowired
|
||||
IDictTableWhiteListHandler whiteListHandler;
|
||||
@Autowired
|
||||
ISysBaseAPI sysBaseAPI;
|
||||
|
||||
@Autowired
|
||||
JeecgBaseConfig jeecgBaseConfig;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
String lowCodeMode = this.jeecgBaseConfig.getFirewall().getLowCodeMode();
|
||||
System.out.println("当前 LowCode 模式为: " + lowCodeMode);
|
||||
// 清空缓存,防止影响测试
|
||||
whiteListHandler.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSql() {
|
||||
System.out.println("=== 开始测试 SQL 方式 ===");
|
||||
String[] sqlArr = new String[]{
|
||||
"select username from sys_user",
|
||||
"select username, CONCAT(realname, SEX) from SYS_USER",
|
||||
"select username, CONCAT(realname, sex) from sys_user",
|
||||
};
|
||||
for (String sql : sqlArr) {
|
||||
System.out.println("- 测试Sql: " + sql);
|
||||
try {
|
||||
sysBaseAPI.dictTableWhiteListCheckBySql(sql);
|
||||
System.out.println("-- 测试通过");
|
||||
} catch (Exception e) {
|
||||
System.out.println("-- 测试未通过: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
System.out.println("=== 结束测试 SQL 方式 ===");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDict() {
|
||||
System.out.println("=== 开始测试 DICT 方式 ===");
|
||||
|
||||
String table = "sys_user";
|
||||
String code = "username";
|
||||
String text = "realname";
|
||||
this.testDict(table, code, text);
|
||||
|
||||
table = "sys_user";
|
||||
code = "username";
|
||||
text = "CONCAT(realname, sex)";
|
||||
this.testDict(table, code, text);
|
||||
|
||||
table = "SYS_USER";
|
||||
code = "username";
|
||||
text = "CONCAT(realname, SEX)";
|
||||
this.testDict(table, code, text);
|
||||
|
||||
System.out.println("=== 结束测试 DICT 方式 ===");
|
||||
}
|
||||
|
||||
private void testDict(String table, String code, String text) {
|
||||
try {
|
||||
sysBaseAPI.dictTableWhiteListCheckByDict(table, code, text);
|
||||
System.out.println("- 测试通过");
|
||||
} catch (Exception e) {
|
||||
System.out.println("- 测试未通过: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -21,7 +21,6 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = JeecgSystemApplication.class)
|
||||
@SuppressWarnings({"FieldCanBeLocal", "SpringJavaAutowiredMembersInspection"})
|
||||
public class SysUserTest {
|
||||
/**
|
||||
* 测试地址:实际使用时替换成你自己的地址
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
package org.jeecg.smallTools;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 测试sql分割、替换等操作
|
||||
*
|
||||
* @author: scott
|
||||
* @date: 2023年09月05日 16:13
|
||||
*/
|
||||
public class TestSqlHandle {
|
||||
|
||||
/**
|
||||
* Where 分割测试
|
||||
*/
|
||||
@Test
|
||||
public void testSqlSplitWhere() {
|
||||
String tableFilterSql = " select * from data.sys_user Where name='12312' and age>100";
|
||||
String[] arr = tableFilterSql.split(" (?i)where ");
|
||||
for (String sql : arr) {
|
||||
System.out.println("sql片段:" + sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Where 替换
|
||||
*/
|
||||
@Test
|
||||
public void testSqlWhereReplace() {
|
||||
String input = " Where name='12312' and age>100";
|
||||
String pattern = "(?i)where "; // (?i) 表示不区分大小写
|
||||
|
||||
String replacedString = input.replaceAll(pattern, "");
|
||||
|
||||
System.out.println("替换前的字符串:" + input);
|
||||
System.out.println("替换后的字符串:" + replacedString);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package org.jeecg.smallTools;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 字符串处理测试
|
||||
*
|
||||
* @author: scott
|
||||
* @date: 2023年03月30日 15:27
|
||||
*/
|
||||
public class TestStr {
|
||||
|
||||
/**
|
||||
* 测试参数格式化的问题,数字值有问题
|
||||
*/
|
||||
@Test
|
||||
public void testParameterFormat() {
|
||||
String url = "/pages/lowApp/process/taskDetail?tenantId={0}&procInsId={1}&taskId={2}&taskDefKey={3}";
|
||||
String cc = MessageFormat.format(url, "6364", "111", "22", "333");
|
||||
System.out.println("参数是字符串:" + cc);
|
||||
|
||||
String cc2 = MessageFormat.format(url, 6364, 111, 22, 333);
|
||||
System.out.println("参数是数字(出问题):" + cc2);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStringSplitError() {
|
||||
String conditionValue = "qweqwe";
|
||||
String[] conditionValueArray = conditionValue.split(",");
|
||||
System.out.println("length = "+ conditionValueArray.length);
|
||||
Arrays.stream(conditionValueArray).forEach(System.out::println);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJSONArrayJoin() {
|
||||
JSONArray valArray = new JSONArray();
|
||||
valArray.add("123");
|
||||
valArray.add("qwe");
|
||||
System.out.println("值: " + StringUtils.join(valArray, ","));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user