diff --git a/src/test/java/com/alibaba/json/bvt/bug/Issue912.java b/src/test/java/com/alibaba/json/bvt/bug/Issue912.java new file mode 100644 index 000000000..0cb17c99f --- /dev/null +++ b/src/test/java/com/alibaba/json/bvt/bug/Issue912.java @@ -0,0 +1,138 @@ +package com.alibaba.json.bvt.bug; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.parser.Feature; +import junit.framework.TestCase; + +import java.util.LinkedList; +import java.util.List; + +/** + * Created by wenshao on 06/12/2016. + */ +public class Issue912 extends TestCase { + public void test_for_issue() throws Exception { + String allMethods = "{\"mList\":[{\"className\":\"com.qa.scftemplate.contract.ISCFServiceForDyjAction\",\"methodName\":\"getArrayInt\",\"parameterSize\":1,\"parameters\":[{\"clazz\":\"[I\",\"clsList\":null,\"isGenericity\":false,\"value\":\"\"}],\"returnType\":\"[I\",\"url\":\"tcp://SCFServiceForDyj/SCFServiceForDyjActionService\"},{\"className\":\"com.qa.scftemplate.contract.ISCFServiceForDyjAction\",\"methodName\":\"getArrayPrimative\",\"parameterSize\":7,\"parameters\":[{\"clazz\":\"[I\",\"clsList\":null,\"isGenericity\":false,\"value\":\"\"},{\"clazz\":\"[F\",\"clsList\":null,\"isGenericity\":false,\"value\":\"\"},{\"clazz\":\"[S\",\"clsList\":null,\"isGenericity\":false,\"value\":\"\"},{\"clazz\":\"[D\",\"clsList\":null,\"isGenericity\":false,\"value\":\"\"},{\"clazz\":\"[J\",\"clsList\":null,\"isGenericity\":false,\"value\":\"\"},{\"clazz\":\"[B\",\"clsList\":null,\"isGenericity\":false,\"value\":\"\"},{\"clazz\":\"[C\",\"clsList\":null,\"isGenericity\":false,\"value\":\"\"}],\"returnType\":\"[Ljava.lang.String;\",\"url\":\"tcp://SCFServiceForDyj/SCFServiceForDyjActionService\"}]}"; + JsonBean jsonBean = getJsonData(allMethods, JsonBean.class); + + assertEquals(2, jsonBean.getmList().size()); + SCFMethod m1 = jsonBean.getmList().get(0); + assertNotNull(m1); + } + + public static T getJsonData(String json, Class clazz) { + T jd = (T) JSON.parseObject(json, clazz, + Feature.IgnoreNotMatch, + Feature.AutoCloseSource + ); + return jd; + } + + public static class JsonBean { + private List mList; + + public List getmList() { + return mList; + } + + public void setmList(List mList) { + this.mList = mList; + } + } + + public static class SCFMethod { + public String className; + public String url; + public String methodName; + public int parameterSize; + public List parameters = new LinkedList(); + public Class returnType; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public Class getReturnType() { + return returnType; + } + + public void setReturnType(Class returnType) { + this.returnType = returnType; + } + + public String getMethodName() { + return methodName; + } + + public void setMethodName(String methodName) { + this.methodName = methodName; + } + + public int getParameterSize() { + return parameterSize; + } + + public void setParameterSize(int parameterSize) { + this.parameterSize = parameterSize; + } + + public List getParameters() { + return parameters; + } + + public void setParameters(List parameters) { + this.parameters = parameters; + } + } + + public static class SCFMethodParameter implements Cloneable { + public Class clazz; + public Object value; + public boolean isGenericity = false; + public List> clsList; + + public boolean getIsGenericity() { + return isGenericity; + } + + public void setIsGenericity(boolean isGenericity) { + this.isGenericity = isGenericity; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public Class getClazz() { + return clazz; + } + + public void setClazz(Class clazz) { + this.clazz = clazz; + } + + public List> getClsList() { + return clsList; + } + + public void setClsList(List> clsList) { + this.clsList = clsList; + } + } +}