OCT
REM: 1. 添加获取版本信息的响应报文内容判断 2. 添加获取设备信息的响应报文内容判断 3. 添加获取节点能力的响应报文内容判断 4. 添加获取防护IP的响应报文内容判断 5. 添加获取能力节点列表的响应报文内容判断 6. 添加获取能力节点详细信息的响应报文内容判断 7. 添加获取链接状态的响应报文内容判断
This commit is contained in:
parent
542478e5e3
commit
1bbe6125fb
7
pom.xml
7
pom.xml
|
@ -74,6 +74,13 @@
|
|||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.58</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.json-lib</groupId>
|
||||
<artifactId>json-lib</artifactId>
|
||||
<version>2.4</version>
|
||||
<classifier>jdk15</classifier>
|
||||
</dependency>
|
||||
|
||||
<!--mysql -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
|
|
|
@ -7,11 +7,16 @@ import com.dispose.service.UserAccountService;
|
|||
import javax.annotation.Resource;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* The type Init test environment.
|
||||
*/
|
||||
|
@ -31,6 +36,10 @@ public class InitTestEnvironment {
|
|||
* The Password.
|
||||
*/
|
||||
private final String PASSWORD = "c3855e6b6bb120450f160ba91134522868f89d36062f2061ebeefd80817e1d58";
|
||||
/**
|
||||
* The connect timeout.
|
||||
*/
|
||||
public static final int HTTP_CONNECT_TIMEOUT = 10000;
|
||||
/**
|
||||
* The User account service.
|
||||
*/
|
||||
|
@ -70,4 +79,48 @@ public class InitTestEnvironment {
|
|||
public String getLogToken() {
|
||||
return logToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check response body.
|
||||
*/
|
||||
public EnumMap<ErrorCode, String> verifyRep(String data, Long reqTime) throws JSONException {
|
||||
Long verValue = 2L;
|
||||
ErrorCode err = ErrorCode.ERR_OK;
|
||||
EnumMap<ErrorCode, String> ret = new EnumMap<>(ErrorCode.class);
|
||||
|
||||
JSONObject jsonObject = new JSONObject(data);
|
||||
Iterator it = jsonObject.keys();
|
||||
System.out.println();
|
||||
while (it.hasNext()) {
|
||||
// 获得key
|
||||
String key = (String) it.next();
|
||||
String value = jsonObject.getString(key);
|
||||
System.out.println("key: " + key + ",value:" + value);
|
||||
}
|
||||
|
||||
Long repTime = Long.valueOf(jsonObject.getString("timeStamp"));
|
||||
if ((jsonObject.getString("timeStamp").length() == 0) || (repTime - reqTime) > HTTP_CONNECT_TIMEOUT) {
|
||||
err = ErrorCode.ERR_REQTIMEOUT;
|
||||
}
|
||||
|
||||
Long ver = Long.valueOf(jsonObject.getString("ver"));
|
||||
if ((jsonObject.getString("ver").length() == 0) || (!ver.equals(verValue))) {
|
||||
err = ErrorCode.ERR_VERSION;
|
||||
}
|
||||
|
||||
long cryptoType = Long.parseLong(jsonObject.getString("cryptoType"));
|
||||
if ((String.valueOf(cryptoType).length() == 0) || (cryptoType < 0)) {
|
||||
err = ErrorCode.ERR_INPUTMISS;
|
||||
}
|
||||
|
||||
if((jsonObject.getString("code").length() == 0) ||
|
||||
Long.parseLong(jsonObject.getString("code")) != 200){
|
||||
err = ErrorCode.ERR_UNKNOWNCMD;
|
||||
}
|
||||
|
||||
String msgContent = jsonObject.getString("msgContent");
|
||||
|
||||
ret.put(err, msgContent);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue