mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-17 18:20:25 +08:00
add: ControlResponseTest
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user