The following issues were found
src/test/java/com/alibaba/json/bvt/issue_1600/Issue1635.java
7 issues
Line: 12
import java.util.List;
public class Issue1635 extends TestCase {
public static class Foo {
public String name;
public Integer BarCount;
public Boolean flag;
public List list;
Reported by PMD.
Line: 13
public class Issue1635 extends TestCase {
public static class Foo {
public String name;
public Integer BarCount;
public Boolean flag;
public List list;
public Foo(String name, Integer barCount) {
Reported by PMD.
Line: 14
public class Issue1635 extends TestCase {
public static class Foo {
public String name;
public Integer BarCount;
public Boolean flag;
public List list;
public Foo(String name, Integer barCount) {
this.name = name;
Reported by PMD.
Line: 24
}
}
public void test_issue() throws Exception {
SerializeConfig config = new SerializeConfig();
config.setAsmEnable(false);
Foo foo = new Foo(null, null);
String json = JSON.toJSONString(foo
, config, new PascalNameFilter()
Reported by PMD.
Line: 35
, SerializerFeature.WriteNullStringAsEmpty
, SerializerFeature.WriteNullListAsEmpty
);
assertEquals("{\"BarCount\":0,\"Flag\":false,\"List\":[],\"Name\":\"\"}", json);
}
public void test_issue_1() throws Exception {
SerializeConfig config = new SerializeConfig();
config.setAsmEnable(false);
Reported by PMD.
Line: 38
assertEquals("{\"BarCount\":0,\"Flag\":false,\"List\":[],\"Name\":\"\"}", json);
}
public void test_issue_1() throws Exception {
SerializeConfig config = new SerializeConfig();
config.setAsmEnable(false);
Foo foo = new Foo(null, null);
String json = JSON.toJSONString(foo
, config, new PascalNameFilter()
Reported by PMD.
Line: 50
, SerializerFeature.WriteNullListAsEmpty
, SerializerFeature.BeanToArray
);
assertEquals("[0,false,[],\"\"]", json);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1800/Issue1871.java
7 issues
Line: 21
m.map.put("b", "2");
String json = JSON.toJSONString(m, SerializerFeature.WriteClassName);
System.out.println(json);
}
public static class UnwrapClass {
private String name;
Reported by PMD.
Line: 13
import java.util.Map;
public class Issue1871 extends TestCase {
public void test_for_issue() throws Exception {
UnwrapClass m = new UnwrapClass();
m.map = new HashMap();
m.name = "ljw";
m.map.put("a", "1");
m.map.put("b", "2");
Reported by PMD.
Line: 13
import java.util.Map;
public class Issue1871 extends TestCase {
public void test_for_issue() throws Exception {
UnwrapClass m = new UnwrapClass();
m.map = new HashMap();
m.name = "ljw";
m.map.put("a", "1");
m.map.put("b", "2");
Reported by PMD.
Line: 17
UnwrapClass m = new UnwrapClass();
m.map = new HashMap();
m.name = "ljw";
m.map.put("a", "1");
m.map.put("b", "2");
String json = JSON.toJSONString(m, SerializerFeature.WriteClassName);
System.out.println(json);
}
Reported by PMD.
Line: 18
m.map = new HashMap();
m.name = "ljw";
m.map.put("a", "1");
m.map.put("b", "2");
String json = JSON.toJSONString(m, SerializerFeature.WriteClassName);
System.out.println(json);
}
Reported by PMD.
Line: 24
System.out.println(json);
}
public static class UnwrapClass {
private String name;
@JSONField(unwrapped = true)
private Map<String, String> map;
Reported by PMD.
Line: 9
import junit.framework.TestCase;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public class Issue1871 extends TestCase {
public void test_for_issue() throws Exception {
UnwrapClass m = new UnwrapClass();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1900/Issue1939.java
7 issues
Line: 18
@XmlType(name = "", propOrder = {
"any"
})
public static class Container implements Serializable {
@XmlAnyElement(lax = true)
public List<Object> any;
}
private static final String MESSAGE = "<Container>" +
"<WeightMajor measurementSystem=\"English\" unit=\"lbs\">0</WeightMajor>" +
Reported by PMD.
Line: 26
"<WeightMajor measurementSystem=\"English\" unit=\"lbs\">0</WeightMajor>" +
"</Container>";
public void test_for_issue() throws Exception {
JAXBContext context = JAXBContext.newInstance(Container.class, Issue1939.class);
Container con = (Container) context.createUnmarshaller().unmarshal(new StringReader(MESSAGE));
assertEquals("{\"any\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><WeightMajor measurementSystem=\\\"English\\\" unit=\\\"lbs\\\">0</WeightMajor>\"]}",
JSON.toJSONString(con));
}
Reported by PMD.
Line: 29
public void test_for_issue() throws Exception {
JAXBContext context = JAXBContext.newInstance(Container.class, Issue1939.class);
Container con = (Container) context.createUnmarshaller().unmarshal(new StringReader(MESSAGE));
assertEquals("{\"any\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><WeightMajor measurementSystem=\\\"English\\\" unit=\\\"lbs\\\">0</WeightMajor>\"]}",
JSON.toJSONString(con));
}
public void test_for_issue_1() throws Exception {
JAXBContext context = JAXBContext.newInstance(Container.class, Issue1939.class);
Reported by PMD.
Line: 33
JSON.toJSONString(con));
}
public void test_for_issue_1() throws Exception {
JAXBContext context = JAXBContext.newInstance(Container.class, Issue1939.class);
Container con = (Container) context.createUnmarshaller().unmarshal(new StringReader(MESSAGE));
assertEquals("{\"any\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><WeightMajor measurementSystem=\\\"English\\\" unit=\\\"lbs\\\">0</WeightMajor>\"]}",
JSON.toJSON(con).toString());
}
Reported by PMD.
Line: 36
public void test_for_issue_1() throws Exception {
JAXBContext context = JAXBContext.newInstance(Container.class, Issue1939.class);
Container con = (Container) context.createUnmarshaller().unmarshal(new StringReader(MESSAGE));
assertEquals("{\"any\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><WeightMajor measurementSystem=\\\"English\\\" unit=\\\"lbs\\\">0</WeightMajor>\"]}",
JSON.toJSON(con).toString());
}
}
Reported by PMD.
Line: 37
JAXBContext context = JAXBContext.newInstance(Container.class, Issue1939.class);
Container con = (Container) context.createUnmarshaller().unmarshal(new StringReader(MESSAGE));
assertEquals("{\"any\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><WeightMajor measurementSystem=\\\"English\\\" unit=\\\"lbs\\\">0</WeightMajor>\"]}",
JSON.toJSON(con).toString());
}
}
Reported by PMD.
Line: 7
import junit.framework.TestCase;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
import java.io.StringReader;
import java.util.List;
public class Issue1939 extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1900/Issue1996.java
7 issues
Line: 7
import junit.framework.TestCase;
public class Issue1996 extends TestCase {
public void test_for_issue() throws Exception {
StringBuilder sb = new StringBuilder();
char start = '\uD800';
char end = '\uDFFF';
Reported by PMD.
Line: 7
import junit.framework.TestCase;
public class Issue1996 extends TestCase {
public void test_for_issue() throws Exception {
StringBuilder sb = new StringBuilder();
char start = '\uD800';
char end = '\uDFFF';
Reported by PMD.
Line: 22
// ok
String json1 = JSON.toJSONString(s);
byte[] bytes = json1.getBytes("utf-8");
byte[] bytes2 = JSON.toJSONBytes(s);
assertEquals(new String(bytes), new String(bytes2));
assertEquals(bytes.length, bytes2.length);
Reported by PMD.
Line: 25
byte[] bytes = json1.getBytes("utf-8");
byte[] bytes2 = JSON.toJSONBytes(s);
assertEquals(new String(bytes), new String(bytes2));
assertEquals(bytes.length, bytes2.length);
for (int i = 0; i < bytes.length; i++) {
assertEquals(bytes[i], bytes[i]);
}
Reported by PMD.
Line: 27
byte[] bytes2 = JSON.toJSONBytes(s);
assertEquals(new String(bytes), new String(bytes2));
assertEquals(bytes.length, bytes2.length);
for (int i = 0; i < bytes.length; i++) {
assertEquals(bytes[i], bytes[i]);
}
}
}
Reported by PMD.
Line: 28
assertEquals(new String(bytes), new String(bytes2));
assertEquals(bytes.length, bytes2.length);
for (int i = 0; i < bytes.length; i++) {
assertEquals(bytes[i], bytes[i]);
}
}
}
Reported by PMD.
Line: 29
assertEquals(bytes.length, bytes2.length);
for (int i = 0; i < bytes.length; i++) {
assertEquals(bytes[i], bytes[i]);
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2000/Issue2088.java
7 issues
Line: 13
import java.util.TimeZone;
public class Issue2088 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
Reported by PMD.
Line: 18
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
String json = "{\"date\":\"20181011103607186+0800\"}";
Model m = JSON.parseObject(json, Model.class);
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSZ");
format.setTimeZone(JSON.defaultTimeZone);
Reported by PMD.
Line: 22
String json = "{\"date\":\"20181011103607186+0800\"}";
Model m = JSON.parseObject(json, Model.class);
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSZ");
format.setTimeZone(JSON.defaultTimeZone);
Date date = format.parse("20181011103607186+0800");
assertEquals(date, m.date);
}
Reported by PMD.
Line: 26
format.setTimeZone(JSON.defaultTimeZone);
Date date = format.parse("20181011103607186+0800");
assertEquals(date, m.date);
}
public void test_for_issue_1() throws Exception {
String json = "{\"date\":\"20181011103607186-0800\"}";
Model m = JSON.parseObject(json, Model.class);
Reported by PMD.
Line: 29
assertEquals(date, m.date);
}
public void test_for_issue_1() throws Exception {
String json = "{\"date\":\"20181011103607186-0800\"}";
Model m = JSON.parseObject(json, Model.class);
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSZ", JSON.defaultLocale);
format.setTimeZone(JSON.defaultTimeZone);
Reported by PMD.
Line: 37
format.setTimeZone(JSON.defaultTimeZone);
Date date = format.parse("20181011103607186-0800");
assertEquals(date, m.date);
}
public static class Model {
@JSONField(format = "yyyyMMddHHmmssSSSZ")
public Date date;
Reported by PMD.
Line: 42
public static class Model {
@JSONField(format = "yyyyMMddHHmmssSSSZ")
public Date date;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2200/Issue2214.java
7 issues
Line: 22
Type[] types = method.getGenericParameterTypes();
List argList = JSON.parseArray(text, types);
Object res = new User().testGenericArrayArray2((List[][]) argList.get(0));
System.out.println(res);
}
public static class User {
public List[][] testGenericArrayArray2(List[][] res){
return res;
Reported by PMD.
Line: 12
import java.util.List;
public class Issue2214 extends TestCase {
public void test_for_issue() throws Exception {
List list = new ArrayList();
list.add("robin");
Object[] args = new Object[]{new List[][]{new List[]{list}}};
String text = JSON.toJSONString(args);
Class clazz = User.class;
Reported by PMD.
Line: 12
import java.util.List;
public class Issue2214 extends TestCase {
public void test_for_issue() throws Exception {
List list = new ArrayList();
list.add("robin");
Object[] args = new Object[]{new List[][]{new List[]{list}}};
String text = JSON.toJSONString(args);
Class clazz = User.class;
Reported by PMD.
Line: 18
Object[] args = new Object[]{new List[][]{new List[]{list}}};
String text = JSON.toJSONString(args);
Class clazz = User.class;
Method method = clazz.getMethod("testGenericArrayArray2", List[][].class);
Type[] types = method.getGenericParameterTypes();
List argList = JSON.parseArray(text, types);
Object res = new User().testGenericArrayArray2((List[][]) argList.get(0));
System.out.println(res);
}
Reported by PMD.
Line: 19
String text = JSON.toJSONString(args);
Class clazz = User.class;
Method method = clazz.getMethod("testGenericArrayArray2", List[][].class);
Type[] types = method.getGenericParameterTypes();
List argList = JSON.parseArray(text, types);
Object res = new User().testGenericArrayArray2((List[][]) argList.get(0));
System.out.println(res);
}
Reported by PMD.
Line: 21
Method method = clazz.getMethod("testGenericArrayArray2", List[][].class);
Type[] types = method.getGenericParameterTypes();
List argList = JSON.parseArray(text, types);
Object res = new User().testGenericArrayArray2((List[][]) argList.get(0));
System.out.println(res);
}
public static class User {
public List[][] testGenericArrayArray2(List[][] res){
Reported by PMD.
Line: 26
}
public static class User {
public List[][] testGenericArrayArray2(List[][] res){
return res;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2200/Issue2253.java
7 issues
Line: 15
import java.util.Map;
public class Issue2253 extends TestCase {
public void test_for_issue() throws Exception {
List<Map<String, Object>> result = new ArrayList();
result.add(new LinkedHashMap());
result.get(0).put("3", 3);
result.get(0).put("2", 2);
result.get(0).put("7", 7);
Reported by PMD.
Line: 15
import java.util.Map;
public class Issue2253 extends TestCase {
public void test_for_issue() throws Exception {
List<Map<String, Object>> result = new ArrayList();
result.add(new LinkedHashMap());
result.get(0).put("3", 3);
result.get(0).put("2", 2);
result.get(0).put("7", 7);
Reported by PMD.
Line: 18
public void test_for_issue() throws Exception {
List<Map<String, Object>> result = new ArrayList();
result.add(new LinkedHashMap());
result.get(0).put("3", 3);
result.get(0).put("2", 2);
result.get(0).put("7", 7);
assertEquals("[{\"3\":3,\"2\":2,\"7\":7}]", JSON.toJSONString(result, SerializerFeature.WriteMapNullValue));
Reported by PMD.
Line: 19
List<Map<String, Object>> result = new ArrayList();
result.add(new LinkedHashMap());
result.get(0).put("3", 3);
result.get(0).put("2", 2);
result.get(0).put("7", 7);
assertEquals("[{\"3\":3,\"2\":2,\"7\":7}]", JSON.toJSONString(result, SerializerFeature.WriteMapNullValue));
result = JSON.parseObject(JSON.toJSONString(result, SerializerFeature.WriteMapNullValue), new TypeReference<List<Map<String, Object>>>() {}, Feature.OrderedField);
Reported by PMD.
Line: 20
result.add(new LinkedHashMap());
result.get(0).put("3", 3);
result.get(0).put("2", 2);
result.get(0).put("7", 7);
assertEquals("[{\"3\":3,\"2\":2,\"7\":7}]", JSON.toJSONString(result, SerializerFeature.WriteMapNullValue));
result = JSON.parseObject(JSON.toJSONString(result, SerializerFeature.WriteMapNullValue), new TypeReference<List<Map<String, Object>>>() {}, Feature.OrderedField);
Reported by PMD.
Line: 22
result.get(0).put("2", 2);
result.get(0).put("7", 7);
assertEquals("[{\"3\":3,\"2\":2,\"7\":7}]", JSON.toJSONString(result, SerializerFeature.WriteMapNullValue));
result = JSON.parseObject(JSON.toJSONString(result, SerializerFeature.WriteMapNullValue), new TypeReference<List<Map<String, Object>>>() {}, Feature.OrderedField);
assertEquals("[{\"3\":3,\"2\":2,\"7\":7}]", JSON.toJSONString(result, SerializerFeature.WriteMapNullValue));
}
Reported by PMD.
Line: 26
result = JSON.parseObject(JSON.toJSONString(result, SerializerFeature.WriteMapNullValue), new TypeReference<List<Map<String, Object>>>() {}, Feature.OrderedField);
assertEquals("[{\"3\":3,\"2\":2,\"7\":7}]", JSON.toJSONString(result, SerializerFeature.WriteMapNullValue));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2700/Issue2779.java
7 issues
Line: 1
package com.alibaba.json.bvt.issue_2700;
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import java.util.List;
public class Issue2779 extends TestCase {
Reported by PMD.
Line: 8
import java.util.List;
public class Issue2779 extends TestCase {
public void test_for_issue() throws Exception {
String str = JSON.toJSONString(new Model());
JSON.parseObject(str, Model.class);
}
Reported by PMD.
Line: 10
public class Issue2779 extends TestCase {
public void test_for_issue() throws Exception {
String str = JSON.toJSONString(new Model());
JSON.parseObject(str, Model.class);
}
public static class Model {
Reported by PMD.
Line: 10
public class Issue2779 extends TestCase {
public void test_for_issue() throws Exception {
String str = JSON.toJSONString(new Model());
JSON.parseObject(str, Model.class);
}
public static class Model {
Reported by PMD.
Line: 15
JSON.parseObject(str, Model.class);
}
public static class Model {
private List f000;
private List f001;
private List f002;
private List f003;
private List f004;
Reported by PMD.
Line: 15
JSON.parseObject(str, Model.class);
}
public static class Model {
private List f000;
private List f001;
private List f002;
private List f003;
private List f004;
Reported by PMD.
Line: 15
JSON.parseObject(str, Model.class);
}
public static class Model {
private List f000;
private List f001;
private List f002;
private List f003;
private List f004;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3200/Issue3206.java
7 issues
Line: 9
import junit.framework.TestCase;
public class Issue3206 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.date = new java.util.Date(1590819204293L);
assertEquals(JSON.toJSONString(vo), "{\"date\":\"2020-05-30\"}");
Reported by PMD.
Line: 9
import junit.framework.TestCase;
public class Issue3206 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.date = new java.util.Date(1590819204293L);
assertEquals(JSON.toJSONString(vo), "{\"date\":\"2020-05-30\"}");
Reported by PMD.
Line: 14
vo.date = new java.util.Date(1590819204293L);
assertEquals(JSON.toJSONString(vo), "{\"date\":\"2020-05-30\"}");
String str = JSON.toJSONString(vo, new NameFilter() {
public String process(Object object, String name, Object value) {
return name;
}
Reported by PMD.
Line: 21
return name;
}
});
assertEquals(str, "{\"date\":\"2020-05-30\"}");
}
public static class VO {
@JSONField(format="yyyy-MM-dd")
public java.util.Date date;
Reported by PMD.
Line: 26
public static class VO {
@JSONField(format="yyyy-MM-dd")
public java.util.Date date;
}
}
Reported by PMD.
Line: 16
assertEquals(JSON.toJSONString(vo), "{\"date\":\"2020-05-30\"}");
String str = JSON.toJSONString(vo, new NameFilter() {
public String process(Object object, String name, Object value) {
return name;
}
});
assertEquals(str, "{\"date\":\"2020-05-30\"}");
Reported by PMD.
Line: 16
assertEquals(JSON.toJSONString(vo), "{\"date\":\"2020-05-30\"}");
String str = JSON.toJSONString(vo, new NameFilter() {
public String process(Object object, String name, Object value) {
return name;
}
});
assertEquals(str, "{\"date\":\"2020-05-30\"}");
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3200/Issue3245.java
7 issues
Line: 7
import junit.framework.TestCase;
public class Issue3245 extends TestCase {
public void test_for_issue() throws Exception {
JSONValidator v = JSONValidator.from("[]");
v.validate();
assertEquals(JSONValidator.Type.Array, v.getType());
}
Reported by PMD.
Line: 9
public class Issue3245 extends TestCase {
public void test_for_issue() throws Exception {
JSONValidator v = JSONValidator.from("[]");
v.validate();
assertEquals(JSONValidator.Type.Array, v.getType());
}
public void test_for_issue_1() throws Exception {
assertEquals(JSONValidator.Type.Array, JSONValidator.from("[]").getType());
Reported by PMD.
Line: 10
public void test_for_issue() throws Exception {
JSONValidator v = JSONValidator.from("[]");
v.validate();
assertEquals(JSONValidator.Type.Array, v.getType());
}
public void test_for_issue_1() throws Exception {
assertEquals(JSONValidator.Type.Array, JSONValidator.from("[]").getType());
}
Reported by PMD.
Line: 10
public void test_for_issue() throws Exception {
JSONValidator v = JSONValidator.from("[]");
v.validate();
assertEquals(JSONValidator.Type.Array, v.getType());
}
public void test_for_issue_1() throws Exception {
assertEquals(JSONValidator.Type.Array, JSONValidator.from("[]").getType());
}
Reported by PMD.
Line: 13
assertEquals(JSONValidator.Type.Array, v.getType());
}
public void test_for_issue_1() throws Exception {
assertEquals(JSONValidator.Type.Array, JSONValidator.from("[]").getType());
}
}
Reported by PMD.
Line: 14
}
public void test_for_issue_1() throws Exception {
assertEquals(JSONValidator.Type.Array, JSONValidator.from("[]").getType());
}
}
Reported by PMD.
Line: 14
}
public void test_for_issue_1() throws Exception {
assertEquals(JSONValidator.Type.Array, JSONValidator.from("[]").getType());
}
}
Reported by PMD.