first commit
This commit is contained in:
38
base-fast/src/test/java/com/boge/DynamicDataSourceTest.java
Normal file
38
base-fast/src/test/java/com/boge/DynamicDataSourceTest.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) 2016-2019 人人开源 All rights reserved.
|
||||
*
|
||||
* https://www.renren.io
|
||||
*
|
||||
* 版权所有,侵权必究!
|
||||
*/
|
||||
|
||||
package com.boge;
|
||||
|
||||
import com.boge.service.DynamicDataSourceTestService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 多数据源测试
|
||||
*
|
||||
* @author Mark sunlightcs@gmail.com
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class DynamicDataSourceTest {
|
||||
@Autowired
|
||||
private DynamicDataSourceTestService dynamicDataSourceTestService;
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
Long id = 1L;
|
||||
|
||||
dynamicDataSourceTestService.updateUser(id);
|
||||
dynamicDataSourceTestService.updateUserBySlave1(id);
|
||||
dynamicDataSourceTestService.updateUserBySlave2(id);
|
||||
}
|
||||
|
||||
}
|
||||
105
base-fast/src/test/java/com/boge/FlowableTest.java
Normal file
105
base-fast/src/test/java/com/boge/FlowableTest.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package com.boge;
|
||||
|
||||
import com.boge.modules.flow.controller.FlwDeModelController;
|
||||
import com.boge.modules.flow.service.FlwDeModelService;
|
||||
import org.flowable.bpmn.model.*;
|
||||
import org.flowable.bpmn.model.Process;
|
||||
import org.flowable.engine.*;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.repository.Deployment;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.idm.api.User;
|
||||
import org.flowable.task.api.Task;
|
||||
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.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class FlowableTest {
|
||||
|
||||
@Autowired
|
||||
private FlwDeModelService service;
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
@Autowired
|
||||
private RuntimeService runtimeService;
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@Autowired
|
||||
private IdentityService identityService;
|
||||
|
||||
@Autowired
|
||||
private HistoryService historyService;
|
||||
|
||||
@Test
|
||||
public void testFlowDeploy(){
|
||||
service.deployFlow(9);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryDeployInfo(){
|
||||
List<Deployment> list = repositoryService.createDeploymentQuery().list();
|
||||
for (Deployment deployment : list) {
|
||||
System.out.println(deployment);
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void queryDeployDefInfo(){
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel("Process_1:2:c8d49f45-d2f6-11ef-a6ee-c03c59ad2248");
|
||||
Process mainProcess = bpmnModel.getMainProcess();
|
||||
Collection<FlowElement> flowElements = mainProcess.getFlowElements();
|
||||
for (FlowElement flowElement : flowElements) {
|
||||
//System.out.println(flowElement.getName()+"" + flowElement);
|
||||
if(flowElement instanceof UserTask){
|
||||
UserTask userTask = (UserTask) flowElement;
|
||||
/*Map<String, List<ExtensionAttribute>> attributes = userTask.getAttributes();
|
||||
Set<String> keys = attributes.keySet();
|
||||
for (String key : keys) {
|
||||
List<ExtensionAttribute> extensionAttributes = attributes.get(key);
|
||||
for (ExtensionAttribute extensionAttribute : extensionAttributes) {
|
||||
System.out.println(extensionAttribute.getName()+"===" + extensionAttribute.getValue());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void test1(){
|
||||
String str = "${user1},${user2}";
|
||||
Pattern pattern = Pattern.compile("\\$\\{([^}]+)}");
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
while (matcher.find()) {
|
||||
String user = matcher.group(1);
|
||||
System.out.println(user);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void startFlow(){
|
||||
String defId = "Process_1:7:eede6209-d2f0-11ef-9de1-c03c59ad2248";
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("user1","boge111");
|
||||
runtimeService.startProcessInstanceById(defId,map);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2(){
|
||||
String instanceId = "dd13ee97-d306-11ef-be90-c03c59ad2248";
|
||||
|
||||
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(instanceId).singleResult();
|
||||
String startUserId = historicProcessInstance.getStartUserId();
|
||||
System.out.println("startUserId = " + startUserId);
|
||||
}
|
||||
|
||||
}
|
||||
27
base-fast/src/test/java/com/boge/RedisTest.java
Normal file
27
base-fast/src/test/java/com/boge/RedisTest.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.boge;
|
||||
|
||||
import com.boge.modules.sys.entity.SysUserEntity;
|
||||
import com.boge.common.utils.RedisUtils;
|
||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||
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;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class RedisTest {
|
||||
@Autowired
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
SysUserEntity user = new SysUserEntity();
|
||||
user.setEmail("qqq@qq.com");
|
||||
redisUtils.set("user", user);
|
||||
|
||||
System.out.println(ToStringBuilder.reflectionToString(redisUtils.get("user", SysUserEntity.class)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Copyright (c) 2016-2019 人人开源 All rights reserved.
|
||||
*
|
||||
* https://www.renren.io
|
||||
*
|
||||
* 版权所有,侵权必究!
|
||||
*/
|
||||
|
||||
package com.boge.service;
|
||||
|
||||
import com.boge.datasource.annotation.DataSource;
|
||||
import com.boge.modules.sys.dao.SysUserDao;
|
||||
import com.boge.modules.sys.entity.SysUserEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 测试多数据源
|
||||
*
|
||||
* @author Mark sunlightcs@gmail.com
|
||||
*/
|
||||
@Service
|
||||
//@DataSource("slave1")
|
||||
public class DynamicDataSourceTestService {
|
||||
@Autowired
|
||||
private SysUserDao sysUserDao;
|
||||
|
||||
@Transactional
|
||||
public void updateUser(Long id){
|
||||
SysUserEntity user = new SysUserEntity();
|
||||
user.setUserId(id);
|
||||
user.setMobile("13500000000");
|
||||
sysUserDao.updateById(user);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@DataSource("slave1")
|
||||
public void updateUserBySlave1(Long id){
|
||||
SysUserEntity user = new SysUserEntity();
|
||||
user.setUserId(id);
|
||||
user.setMobile("13500000001");
|
||||
sysUserDao.updateById(user);
|
||||
}
|
||||
|
||||
@DataSource("slave2")
|
||||
@Transactional
|
||||
public void updateUserBySlave2(Long id){
|
||||
SysUserEntity user = new SysUserEntity();
|
||||
user.setUserId(id);
|
||||
user.setMobile("13500000002");
|
||||
sysUserDao.updateById(user);
|
||||
|
||||
//测试事物
|
||||
int i = 1/0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user