The following issues were found
src/test/java/com/alibaba/json/bvt/bug/Issue912.java
12 issues
Line: 14
* 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);
Reported by PMD.
Line: 14
* 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);
Reported by PMD.
Line: 18
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> T getJsonData(String json, Class<T> clazz) {
Reported by PMD.
Line: 18
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> T getJsonData(String json, Class<T> clazz) {
Reported by PMD.
Line: 18
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> T getJsonData(String json, Class<T> clazz) {
Reported by PMD.
Line: 19
JsonBean jsonBean = getJsonData(allMethods, JsonBean.class);
assertEquals(2, jsonBean.getmList().size());
SCFMethod m1 = jsonBean.getmList().get(0);
assertNotNull(m1);
}
public static <T> T getJsonData(String json, Class<T> clazz) {
T jd = (T) JSON.parseObject(json, clazz,
Reported by PMD.
Line: 19
JsonBean jsonBean = getJsonData(allMethods, JsonBean.class);
assertEquals(2, jsonBean.getmList().size());
SCFMethod m1 = jsonBean.getmList().get(0);
assertNotNull(m1);
}
public static <T> T getJsonData(String json, Class<T> clazz) {
T jd = (T) JSON.parseObject(json, clazz,
Reported by PMD.
Line: 20
assertEquals(2, jsonBean.getmList().size());
SCFMethod m1 = jsonBean.getmList().get(0);
assertNotNull(m1);
}
public static <T> T getJsonData(String json, Class<T> clazz) {
T jd = (T) JSON.parseObject(json, clazz,
Feature.IgnoreNotMatch,
Reported by PMD.
Line: 32
}
public static class JsonBean {
private List<SCFMethod> mList;
public List<SCFMethod> getmList() {
return mList;
}
Reported by PMD.
Line: 43
}
}
public static class SCFMethod {
public String className;
public String url;
public String methodName;
public int parameterSize;
public List<SCFMethodParameter> parameters = new LinkedList<SCFMethodParameter>();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1233.java
12 issues
Line: 17
* Created by wenshao on 30/05/2017.
*/
public class Issue1233 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(Area.class, new ObjectDeserializer() {
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONObject jsonObject = (JSONObject) parser.parse();
String areaType;
Reported by PMD.
Line: 17
* Created by wenshao on 30/05/2017.
*/
public class Issue1233 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(Area.class, new ObjectDeserializer() {
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONObject jsonObject = (JSONObject) parser.parse();
String areaType;
Reported by PMD.
Line: 23
JSONObject jsonObject = (JSONObject) parser.parse();
String areaType;
if (jsonObject.get("type") instanceof String) {
areaType = (String) jsonObject.get("type");
} else {
return null;
}
if (Area.TYPE_SECTION.equals(areaType)) {
Reported by PMD.
Line: 28
} else {
return null;
}
if (Area.TYPE_SECTION.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, Section.class);
} else if (Area.TYPE_FLOORV1.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
} else if (Area.TYPE_FLOORV2.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
Reported by PMD.
Line: 30
}
if (Area.TYPE_SECTION.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, Section.class);
} else if (Area.TYPE_FLOORV1.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
} else if (Area.TYPE_FLOORV2.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
}
return null;
Reported by PMD.
Line: 32
return (T) JSON.toJavaObject(jsonObject, Section.class);
} else if (Area.TYPE_FLOORV1.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
} else if (Area.TYPE_FLOORV2.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
}
return null;
}
Reported by PMD.
Line: 45
JSONObject jsonObject = JSON.parseObject("{\"type\":\"floorV2\",\"templateId\":\"x123\"}");
FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
assertNotNull(floorV2);
assertEquals("x123", floorV2.templateId);
}
public interface Area {
Reported by PMD.
Line: 46
JSONObject jsonObject = JSON.parseObject("{\"type\":\"floorV2\",\"templateId\":\"x123\"}");
FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
assertNotNull(floorV2);
assertEquals("x123", floorV2.templateId);
}
public interface Area {
public static final String TYPE_SECTION = "section";
Reported by PMD.
Line: 47
FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
assertNotNull(floorV2);
assertEquals("x123", floorV2.templateId);
}
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
Reported by PMD.
Line: 63
public String type;
public String templateId;
public String getName() {
return templateId;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1235_noasm.java
12 issues
Line: 12
* Created by wenshao on 30/05/2017.
*/
public class Issue1235_noasm extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
Reported by PMD.
Line: 12
* Created by wenshao on 30/05/2017.
*/
public class Issue1235_noasm extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
Reported by PMD.
Line: 16
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 17
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
Reported by PMD.
Line: 18
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
Reported by PMD.
Line: 19
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
Reported by PMD.
Line: 22
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
Reported by PMD.
Line: 27
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
Reported by PMD.
Line: 28
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
private static class FloorV2 implements Area {
Reported by PMD.
Line: 29
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
private static class FloorV2 implements Area {
public String type;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1235.java
12 issues
Line: 12
* Created by wenshao on 30/05/2017.
*/
public class Issue1235 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
Reported by PMD.
Line: 12
* Created by wenshao on 30/05/2017.
*/
public class Issue1235 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
Reported by PMD.
Line: 16
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 17
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
Reported by PMD.
Line: 18
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
Reported by PMD.
Line: 19
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
Reported by PMD.
Line: 22
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
Reported by PMD.
Line: 27
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
Reported by PMD.
Line: 28
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
public static class FloorV2 implements Area {
Reported by PMD.
Line: 29
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
public static class FloorV2 implements Area {
public String type;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_long_field.java
12 issues
Line: 15
public class NameFilterTest_long_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
return "ID";
}
return name;
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
return "ID";
}
return name;
Reported by PMD.
Line: 31
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Bean a = new Bean();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 40
Assert.assertEquals("{\"ID\":0}", text);
}
public void test_namefilter_1() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 44
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 44
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 55
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 0);
serializer.write(map);
Reported by PMD.
Line: 16
public class NameFilterTest_long_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
return "ID";
Reported by PMD.
Line: 16
public class NameFilterTest_long_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
return "ID";
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1246.java
12 issues
Line: 19
b.setX("xx");
String test = JSON.toJSONString( b );
System.out.println(test);
assertEquals("{}", test);
C c = new C();
c.ab = b ;
Reported by PMD.
Line: 26
c.ab = b ;
String testC = JSON.toJSONString( c );
System.out.println(testC);
assertEquals("{\"ab\":{}}",testC);
D d = new D();
d.setAb( b );
Reported by PMD.
Line: 33
d.setAb( b );
String testD = JSON.toJSONString( d );
System.out.println(testD);
assertEquals("{\"ab\":{}}",testD);
}
public static class C{
public A ab;
Reported by PMD.
Line: 14
* Created by kimmking on 06/06/2017.
*/
public class Issue1246 extends TestCase {
public void test_for_issue() throws Exception {
B b = new B();
b.setX("xx");
String test = JSON.toJSONString( b );
System.out.println(test);
Reported by PMD.
Line: 14
* Created by kimmking on 06/06/2017.
*/
public class Issue1246 extends TestCase {
public void test_for_issue() throws Exception {
B b = new B();
b.setX("xx");
String test = JSON.toJSONString( b );
System.out.println(test);
Reported by PMD.
Line: 20
String test = JSON.toJSONString( b );
System.out.println(test);
assertEquals("{}", test);
C c = new C();
c.ab = b ;
String testC = JSON.toJSONString( c );
Reported by PMD.
Line: 27
String testC = JSON.toJSONString( c );
System.out.println(testC);
assertEquals("{\"ab\":{}}",testC);
D d = new D();
d.setAb( b );
String testD = JSON.toJSONString( d );
Reported by PMD.
Line: 34
String testD = JSON.toJSONString( d );
System.out.println(testD);
assertEquals("{\"ab\":{}}",testD);
}
public static class C{
public A ab;
}
Reported by PMD.
Line: 38
}
public static class C{
public A ab;
}
public static class D{
private A ab;
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import org.springframework.util.LinkedMultiValueMap;
/**
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/BigDecimalCodec.java
12 issues
Line: 38
public final static BigDecimalCodec instance = new BigDecimalCodec();
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.out;
if (object == null) {
out.writeNull(SerializerFeature.WriteNullNumberAsZero);
} else {
Reported by PMD.
Line: 45
out.writeNull(SerializerFeature.WriteNullNumberAsZero);
} else {
BigDecimal val = (BigDecimal) object;
int scale = val.scale();
String outText;
if (SerializerFeature.isEnabled(features, out.features, SerializerFeature.WriteBigDecimalAsPlain)
&& scale >= -100 && scale < 100) {
outText = val.toPlainString();
Reported by PMD.
Line: 50
String outText;
if (SerializerFeature.isEnabled(features, out.features, SerializerFeature.WriteBigDecimalAsPlain)
&& scale >= -100 && scale < 100) {
outText = val.toPlainString();
} else {
outText = val.toString();
}
if (scale == 0) {
Reported by PMD.
Line: 52
&& scale >= -100 && scale < 100) {
outText = val.toPlainString();
} else {
outText = val.toString();
}
if (scale == 0) {
if (outText.length() >= 16
&& SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
Reported by PMD.
Line: 56
}
if (scale == 0) {
if (outText.length() >= 16
&& SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
&& (val.compareTo(LOW) < 0
|| val.compareTo(HIGH) > 0))
{
out.writeString(outText);
Reported by PMD.
Line: 56
}
if (scale == 0) {
if (outText.length() >= 16
&& SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
&& (val.compareTo(LOW) < 0
|| val.compareTo(HIGH) > 0))
{
out.writeString(outText);
Reported by PMD.
Line: 58
if (scale == 0) {
if (outText.length() >= 16
&& SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
&& (val.compareTo(LOW) < 0
|| val.compareTo(HIGH) > 0))
{
out.writeString(outText);
return;
}
Reported by PMD.
Line: 59
if (outText.length() >= 16
&& SerializerFeature.isEnabled(features, out.features, SerializerFeature.BrowserCompatible)
&& (val.compareTo(LOW) < 0
|| val.compareTo(HIGH) > 0))
{
out.writeString(outText);
return;
}
}
Reported by PMD.
Line: 68
out.write(outText);
if (out.isEnabled(SerializerFeature.WriteClassName) && fieldType != BigDecimal.class && val.scale() == 0) {
out.write('.');
}
}
}
Reported by PMD.
Line: 78
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
try {
return (T) deserialze(parser);
} catch (Exception ex) {
throw new JSONException("parseDecimal error, field : " + fieldName, ex);
}
}
@SuppressWarnings("unchecked")
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue72.java
12 issues
Line: 27
} else if (fileBatchBytes == null) {
fileBatchBytes = reader.readObject(byte[].class);
} else {
throw new Exception("archive data json parse failed!");
}
}
reader.endArray();
} finally {
Reported by PMD.
Line: 13
public class Issue72 extends TestCase {
public void test_for_issue() throws Exception {
InputStream is = Issue72.class.getClassLoader().getResourceAsStream("issue72.json");
JSONReader reader = null;
try {
byte[] rowBatchBytes = null;
byte[] fileBatchBytes = null;
Reported by PMD.
Line: 13
public class Issue72 extends TestCase {
public void test_for_issue() throws Exception {
InputStream is = Issue72.class.getClassLoader().getResourceAsStream("issue72.json");
JSONReader reader = null;
try {
byte[] rowBatchBytes = null;
byte[] fileBatchBytes = null;
Reported by PMD.
Line: 14
public class Issue72 extends TestCase {
public void test_for_issue() throws Exception {
InputStream is = Issue72.class.getClassLoader().getResourceAsStream("issue72.json");
JSONReader reader = null;
try {
byte[] rowBatchBytes = null;
byte[] fileBatchBytes = null;
reader = new JSONReader(new InputStreamReader(is));
Reported by PMD.
Line: 14
public class Issue72 extends TestCase {
public void test_for_issue() throws Exception {
InputStream is = Issue72.class.getClassLoader().getResourceAsStream("issue72.json");
JSONReader reader = null;
try {
byte[] rowBatchBytes = null;
byte[] fileBatchBytes = null;
reader = new JSONReader(new InputStreamReader(is));
Reported by PMD.
Line: 14
public class Issue72 extends TestCase {
public void test_for_issue() throws Exception {
InputStream is = Issue72.class.getClassLoader().getResourceAsStream("issue72.json");
JSONReader reader = null;
try {
byte[] rowBatchBytes = null;
byte[] fileBatchBytes = null;
reader = new JSONReader(new InputStreamReader(is));
Reported by PMD.
Line: 14
public class Issue72 extends TestCase {
public void test_for_issue() throws Exception {
InputStream is = Issue72.class.getClassLoader().getResourceAsStream("issue72.json");
JSONReader reader = null;
try {
byte[] rowBatchBytes = null;
byte[] fileBatchBytes = null;
reader = new JSONReader(new InputStreamReader(is));
Reported by PMD.
Line: 15
public void test_for_issue() throws Exception {
InputStream is = Issue72.class.getClassLoader().getResourceAsStream("issue72.json");
JSONReader reader = null;
try {
byte[] rowBatchBytes = null;
byte[] fileBatchBytes = null;
reader = new JSONReader(new InputStreamReader(is));
reader.startArray();
Reported by PMD.
Line: 17
InputStream is = Issue72.class.getClassLoader().getResourceAsStream("issue72.json");
JSONReader reader = null;
try {
byte[] rowBatchBytes = null;
byte[] fileBatchBytes = null;
reader = new JSONReader(new InputStreamReader(is));
reader.startArray();
while (reader.hasNext()) {
if (rowBatchBytes == null) {
Reported by PMD.
Line: 18
JSONReader reader = null;
try {
byte[] rowBatchBytes = null;
byte[] fileBatchBytes = null;
reader = new JSONReader(new InputStreamReader(is));
reader.startArray();
while (reader.hasNext()) {
if (rowBatchBytes == null) {
rowBatchBytes = reader.readObject(byte[].class);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3300/Issue3343.java
12 issues
Line: 7
import junit.framework.TestCase;
public class Issue3343 extends TestCase {
public void test_for_issue() throws Exception {
assertFalse(
JSONValidator.from("{\"name\":\"999}")
.validate());
assertTrue(
Reported by PMD.
Line: 7
import junit.framework.TestCase;
public class Issue3343 extends TestCase {
public void test_for_issue() throws Exception {
assertFalse(
JSONValidator.from("{\"name\":\"999}")
.validate());
assertTrue(
Reported by PMD.
Line: 8
public class Issue3343 extends TestCase {
public void test_for_issue() throws Exception {
assertFalse(
JSONValidator.from("{\"name\":\"999}")
.validate());
assertTrue(
JSONValidator.from("false")
Reported by PMD.
Line: 9
public class Issue3343 extends TestCase {
public void test_for_issue() throws Exception {
assertFalse(
JSONValidator.from("{\"name\":\"999}")
.validate());
assertTrue(
JSONValidator.from("false")
.validate());
Reported by PMD.
Line: 12
JSONValidator.from("{\"name\":\"999}")
.validate());
assertTrue(
JSONValidator.from("false")
.validate());
assertEquals(JSONValidator.Type.Value,
JSONValidator.from("false")
.getType());
Reported by PMD.
Line: 13
.validate());
assertTrue(
JSONValidator.from("false")
.validate());
assertEquals(JSONValidator.Type.Value,
JSONValidator.from("false")
.getType());
Reported by PMD.
Line: 15
assertTrue(
JSONValidator.from("false")
.validate());
assertEquals(JSONValidator.Type.Value,
JSONValidator.from("false")
.getType());
assertTrue(
JSONValidator.from("999").validate());
Reported by PMD.
Line: 16
JSONValidator.from("false")
.validate());
assertEquals(JSONValidator.Type.Value,
JSONValidator.from("false")
.getType());
assertTrue(
JSONValidator.from("999").validate());
assertEquals(JSONValidator.Type.Value,
Reported by PMD.
Line: 19
JSONValidator.from("false")
.getType());
assertTrue(
JSONValidator.from("999").validate());
assertEquals(JSONValidator.Type.Value,
JSONValidator.from("999")
.getType());
}
Reported by PMD.
Line: 20
.getType());
assertTrue(
JSONValidator.from("999").validate());
assertEquals(JSONValidator.Type.Value,
JSONValidator.from("999")
.getType());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_int_field.java
12 issues
Line: 15
public class NameFilterTest_int_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Integer);
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Integer);
return "ID";
}
return name;
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Integer);
return "ID";
}
return name;
Reported by PMD.
Line: 31
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Bean a = new Bean();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 40
Assert.assertEquals("{\"ID\":0}", text);
}
public void test_namefilter_1() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 44
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 44
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 55
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 0);
serializer.write(map);
Reported by PMD.
Line: 16
public class NameFilterTest_int_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Integer);
return "ID";
Reported by PMD.
Line: 16
public class NameFilterTest_int_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Integer);
return "ID";
Reported by PMD.