REM:
1. 增加清洗中IP的流量信息的类
2. 增加浩瀚设备错误码
3. 增加取消清洗接口和获取清洗中IP的流量信息接口的测试用例
This commit is contained in:
chenlinghy 2020-06-23 11:17:13 +08:00
parent 92db13a726
commit 2c3eee5f57
4 changed files with 89 additions and 18 deletions

View File

@ -25,6 +25,14 @@ public enum HaoHanErrorCode {
* Err orderFrom format error code.
*/
ERR_ORDERFROMFORMA("厂家信息参数格式不正确,请检查!"),
/**
* Err cleanTaskId format error code.
*/
ERR_CLEANTASKIDFORMA("清洗任务id参数格式不正确请检查"),
/**
* Err no running task error code.
*/
ERR_NORUNNINGTASK("没有正在清洗的ip"),
;
private final String errMsg;

View File

@ -137,54 +137,88 @@ public class HaoHanInterfaceTestCase {
@Test
public void b1_delTowTest() {
public void b1_delTowTest() throws JsonProcessingException {
String jsonRequest = "{\"cleanTaskId\":105,\"orderFrom\":\"hangyan\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/delTow",
null,
jsonRequest);
log.info("Server Return: [{}]", svrReturn);
log.info("ServerReturn length: [{}]", svrReturn.length());
Assert.assertNotNull(svrReturn);
Assert.assertNotEquals(svrReturn.length(), 0);
sendTowResult result = objectMapper.readValue(svrReturn, sendTowResult.class);
Assert.assertNotNull(result);
if (result.getState() == 0) {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_OK.getMsg());
} else {
Assert.assertNotEquals(result.getMsg(), HaoHanErrorCode.ERR_OK.getMsg());
}
}
@Test
public void b2_delTowCleanTaskIdErrorTest() {
public void b2_delTowCleanTaskIdErrorTest() throws JsonProcessingException {
String jsonRequest = "{\"cleanTaskId\":\"105\",\"orderFrom\":\"hangyan\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/delTow",
null,
jsonRequest);
log.info("Server Return: [{}]", svrReturn);
log.info("ServerReturn length: [{}]", svrReturn.length());
Assert.assertNotNull(svrReturn);
Assert.assertNotEquals(svrReturn.length(), 0);
sendTowResult result = objectMapper.readValue(svrReturn, sendTowResult.class);
Assert.assertNotNull(result);
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_CLEANTASKIDFORMA.getMsg());
Assert.assertEquals(result.getState(), Integer.valueOf(1));
}
@Test
public void b3_delTowOrderFromErrorTest() {
String jsonRequest = "{\"cleanTaskId\":\"105\",\"orderFrom\":123}";
public void b3_delTowOrderFromErrorTest() throws JsonProcessingException {
String jsonRequest = "{\"cleanTaskId\":105,\"orderFrom\":123}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/delTow",
null,
jsonRequest);
log.info("Server Return: [{}]", svrReturn);
log.info("ServerReturn length: [{}]", svrReturn.length());
Assert.assertNotNull(svrReturn);
Assert.assertNotEquals(svrReturn.length(), 0);
sendTowResult result = objectMapper.readValue(svrReturn, sendTowResult.class);
Assert.assertNotNull(result);
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_ORDERFROMFORMA.getMsg());
Assert.assertEquals(result.getState(), Integer.valueOf(1));
}
@Test
public void b2_delTowTest() {
String jsonRequest = "{\"orderFrom\":\"haohandata\"}";
public void c1_delTowTest() throws JsonProcessingException {
String jsonRequest = "{\"orderFrom\":\"hangyan\"}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/allIpFlow",
null,
jsonRequest);
log.info("+++++++++++Server Return: [{}]", svrReturn);
Assert.assertNotNull(svrReturn);
Assert.assertNotEquals(svrReturn.length(), 0);
log.info("Server Return: [{}]", svrReturn);
allIpFlowResult result = objectMapper.readValue(svrReturn, allIpFlowResult.class);
Assert.assertNotNull(result);
if (result.getState() == 0) {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_OK.getMsg());
for (allIpFlowData data : result.getData()
) {
Assert.assertNotNull(data.getIp());
}
} else {
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_NORUNNINGTASK.getMsg());
}
}
@Test
public void c2_delTowTest() throws JsonProcessingException {
String jsonRequest = "{\"orderFrom\":123}";
String svrReturn = Http.postJson("http://10.88.77.88:18080/DDoSClean/clean/allIpFlow",
null,
jsonRequest);
log.info("Server Return: [{}]", svrReturn);
sendTowResult result = objectMapper.readValue(svrReturn, sendTowResult.class);
Assert.assertNotNull(result);
Assert.assertEquals(result.getMsg(), HaoHanErrorCode.ERR_ORDERFROMFORMA.getMsg());
Assert.assertEquals(result.getState(), Integer.valueOf(1));
}
}

View File

@ -0,0 +1,14 @@
package com.dispose.test.haohan;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class allIpFlowData {
String ip; //ip地址
Double inFlow; //输入流量
Integer inPackets; //输入包数
Double outFlow; //输出流量
Integer outPackets; //输出包数
}

View File

@ -0,0 +1,15 @@
package com.dispose.test.haohan;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class allIpFlowResult {
private Integer state;
private String msg;
private List<allIpFlowData> data;
}