add: ControlResponseTest

This commit is contained in:
ChessNineeee
2021-05-14 13:01:15 +08:00
parent c236412ee6
commit fd783fa807
2 changed files with 26 additions and 0 deletions
+5
View File
@@ -1,5 +1,6 @@
package mgmt;
import com.fasterxml.jackson.annotation.JsonProperty;
import util.JSONHelper;
import util.JSONHelperException;
@@ -28,15 +29,19 @@ public class ControlResponse {
public static final String ControlResponseTypeBytes = "bytes";
// Data类型
@JsonProperty("Type")
public String type;
// 状态码
@JsonProperty("Code")
public int code;
// 信息
@JsonProperty("Msg")
public String msg;
// 数据
public class ControlResponseData<E>{
public E value;
}
@JsonProperty("Data")
public ControlResponseData data=new ControlResponseData();
public ControlResponse(){
@@ -0,0 +1,21 @@
package mgmt;
import minsecurity.identity.TestIdentity;
import org.junit.Test;
import org.slf4j.LoggerFactory;
public class ControlResponseTest {
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ControlResponseTest.class);
@Test
public void testUnmarshal(){
try{
ControlResponse response = new ControlResponse();
String jsonString = "{\"Code\": 1, \"Type\": \"string\", \"Msg\": \"bbb\", \"Data\": \"abcd\"}";
// Data无法解析
response.UnmarshalJSON(jsonString.getBytes());
}catch (Exception ex){
logger.debug(ex.getMessage());
}
}
}