Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自动化测试用例 #130

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
websocket自动化测试用例
  • Loading branch information
yimfeng committed Jan 21, 2022
commit 6b962315832454a1dd965fc3cfa94847df0aa08a
41 changes: 24 additions & 17 deletions case-server/src/test/java/com/xiaoju/framework/CaseEditTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public void PingPongTest() {

try {
do {
session.getBasicRemote().sendText("0pong pong pong"); // 发送ping信号
Thread.sleep(10000);
session.getBasicRemote().sendText("0pong pong pong"); // 发送pong信号
Thread.sleep(5000);
} while(true) ;
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -80,7 +80,7 @@ public void addMessage() {
// 添加数据
String caseContent1 = "1{\"case\": {\"root\": {\"data\": {\"id\": \"bv8nxhi3c800\",\"created\": 1562059643204,\"text\": \"websocket\"},\"children\": [{\"data\": {\"id\": \"ch3l66s9zlc0\",\"created\": 1641979547721,\"text\": \"分支主题\"},\"children\": []}]},\"template\": \"default\",\"theme\": \"fresh-blue\",\"version\": \"1.4.43\",\"base\": 2,\"right\": 1},\"patch\": [[{\"op\": \"add\",\"path\": \"/root/children/0\",\"value\": {\"data\": {\"id\": \"ch3l66s9zlc0\",\"created\": 1641979547721,\"text\": \"分支主题\"},\"children\": []}}]]}";
session.getBasicRemote().sendText(caseContent1); // 新增节点分为两步,首先创建一个分支主题
Thread.sleep(1000);
Thread.sleep(5000);
String caseContent2 = "1{\"case\":{\"root\":{\"data\":{\"id\":\"bv8nxhi3c800\",\"created\":1562059643204,\"text\":\"websocket\"},\"children\":[{\"data\":{\"id\":\"ch3lialqzkg0\",\"created\":1641980496404,\"text\":\"新增节点\"},\"children\":[]}]},\"template\":\"default\",\"theme\":\"fresh-blue\",\"version\":\"1.4.43\",\"base\":3,\"right\":1},\"patch\":[[{\"op\":\"replace\",\"path\":\"/root/children/0/data/text\",\"value\":\"新增节点\"}]]}";
session.getBasicRemote().sendText(caseContent2); // 修改分支主题的数据
Thread.sleep(5000);
Expand Down Expand Up @@ -108,7 +108,7 @@ public void deleteMessage() {
try{
String caseContent = "1{\"case\":{\"root\":{\"data\":{\"id\":\"bv8nxhi3c800\",\"created\":1562059643204,\"text\":\"websocket\"},\"children\":[]},\"template\":\"default\",\"theme\":\"fresh-blue\",\"version\":\"1.4.43\",\"base\":4,\"right\":1},\"patch\":[[{\"op\":\"remove\",\"path\":\"/root/children/0\"}]]}"; // 将新增节点删除
session.getBasicRemote().sendText(caseContent);
Thread.sleep(10000);
Thread.sleep(5000);
session.close();
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -132,7 +132,7 @@ public void editMessage() {
try{
String caseContent = "1{\"case\":{\"root\":{\"data\":{\"id\":\"bv8nxhi3c800\",\"created\":1562059643204,\"text\":\"case\"},\"children\":[]},\"template\":\"default\",\"theme\":\"fresh-blue\",\"version\":\"1.4.43\",\"base\":5,\"right\":1},\"patch\":[[{\"op\":\"replace\",\"path\":\"/root/data/text\",\"value\":\"case\"}]]}"; // 将websocket修改为case
session.getBasicRemote().sendText(caseContent);
Thread.sleep(10000);
Thread.sleep(5000);
session.close();
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -158,7 +158,7 @@ public void addRemarks() {
Thread.sleep(5000);
String caseContent2 = "1{\"case\":{\"root\":{\"data\":{\"id\":\"bv8nxhi3c800\",\"created\":1562059643204,\"text\":\"case\",\"note\":\"# test\\n1111\"},\"children\":[]},\"template\":\"default\",\"theme\":\"fresh-blue\",\"version\":\"1.4.43\",\"base\":10,\"right\":1},\"patch\":[[{\"op\":\"replace\",\"path\":\"/root/data/note\",\"value\":\"# test\\n1111\"}]]}";
session.getBasicRemote().sendText(caseContent2);
Thread.sleep(10000);
Thread.sleep(5000);
session.close();
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -252,16 +252,16 @@ public void addLink() {
try{
String caseContent = "1{\"case\":{\"root\":{\"data\":{\"id\":\"bv8nxhi3c800\",\"created\":1562059643204,\"text\":\"case\",\"note\":\"# test\\n1111\",\"image\":\"http://localhost:8094/2022/01/13/1511cca7-b9b0-4a54-b99e-7fe45a906dc5.png\",\"imageSize\":{\"width\":200,\"height\":142},\"priority\":1,\"resource\":[\"前置条件\"],\"hyperlink\":\"www.baidu.com\"},\"children\":[]},\"template\":\"default\",\"theme\":\"fresh-blue\",\"version\":\"1.4.43\",\"base\":10,\"right\":1},\"patch\":[[{\"op\":\"add\",\"path\":\"/root/data/hyperlink\",\"value\":\"www.baidu.com\"}]]}";
session.getBasicRemote().sendText(caseContent);
Thread.sleep(10000);
Thread.sleep(5000);
session.close();
} catch (Exception e) {
e.printStackTrace();
}
}

// redo操作
// undo操作
@Test
public void redo() {
public void undo() {
Session session = null;
try {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
Expand All @@ -272,18 +272,22 @@ public void redo() {
}

try{
String caseContent = "1redo";
session.getBasicRemote().sendText(caseContent);
Thread.sleep(10000);
String caseContent1 = "1{\"case\":{\"root\":{\"data\":{\"id\":\"bv8nxhi3c800\",\"created\":1562059643204,\"text\":\"case\"},\"children\":[]},\"template\":\"default\",\"theme\":\"fresh-blue\",\"version\":\"1.4.43\",\"base\":5,\"right\":1},\"patch\":[[{\"op\":\"replace\",\"path\":\"/root/data/text\",\"value\":\"case\"}]]}"; // 将websocket修改为case
session.getBasicRemote().sendText(caseContent1); // 发送删除消息
String caseContent2 = "1undo";
Thread.sleep(5000);
session.getBasicRemote().sendText(caseContent2); // 发送undo消息
Thread.sleep(5000);
session.close();
} catch (Exception e) {
e.printStackTrace();
}
}

// undo操作

// redo操作
@Test
public void undo() {
public void redo() {
Session session = null;
try {
WebSocketContainer container = ContainerProvider.getWebSocketContainer();
Expand All @@ -296,10 +300,13 @@ public void undo() {
try{
String caseContent1 = "1{\"case\":{\"root\":{\"data\":{\"id\":\"bv8nxhi3c800\",\"created\":1562059643204,\"text\":\"case\"},\"children\":[]},\"template\":\"default\",\"theme\":\"fresh-blue\",\"version\":\"1.4.43\",\"base\":5,\"right\":1},\"patch\":[[{\"op\":\"replace\",\"path\":\"/root/data/text\",\"value\":\"case\"}]]}"; // 将websocket修改为case
session.getBasicRemote().sendText(caseContent1); // 发送删除消息
String caseContent2 = "1undo";
Thread.sleep(5000);
String caseContent2 = "1undo";
session.getBasicRemote().sendText(caseContent2); // 发送undo消息
Thread.sleep(10000);
Thread.sleep(5000);
String caseContent3 = "1redo";
session.getBasicRemote().sendText(caseContent3); // 发送redo消息
Thread.sleep(5000);
session.close();
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -323,7 +330,7 @@ public void CaseControllTest() {
try{
String caseContent = "2lock";
session.getBasicRemote().sendText(caseContent);
Thread.sleep(10000);
Thread.sleep(5000);
session.close();
} catch (Exception e) {
e.printStackTrace();
Expand Down