The following issues were found
src/test/java/com/alibaba/json/bvt/bug/Bug_for_javaeye_litterJava.java
4 issues
Line: 11
import com.alibaba.fastjson.JSON;
public class Bug_for_javaeye_litterJava extends TestCase {
public void test_for_bug() throws Exception {
Group group = new Group();
group.setId(123L);
group.setName("xxx");
group.getClzes().add(Group.class);
Reported by PMD.
Line: 11
import com.alibaba.fastjson.JSON;
public class Bug_for_javaeye_litterJava extends TestCase {
public void test_for_bug() throws Exception {
Group group = new Group();
group.setId(123L);
group.setName("xxx");
group.getClzes().add(Group.class);
Reported by PMD.
Line: 15
Group group = new Group();
group.setId(123L);
group.setName("xxx");
group.getClzes().add(Group.class);
String text = JSON.toJSONString(group);
JSON.parseObject(text, Group.class);
}
Reported by PMD.
Line: 21
JSON.parseObject(text, Group.class);
}
public static class Group {
private Long id;
private String name;
private List<Class> clzes = new ArrayList<Class>();
Reported by PMD.
src/test/java/com/alibaba/fastjson/deserializer/issue1463/beans/Person.java
4 issues
Line: 16
private static final long serialVersionUID = 248616267815851026L;
private String name;
private Integer age;
public Person(String name, Integer age) {
this.name = name;
Reported by PMD.
Line: 16
private static final long serialVersionUID = 248616267815851026L;
private String name;
private Integer age;
public Person(String name, Integer age) {
this.name = name;
Reported by PMD.
Line: 18
private String name;
private Integer age;
public Person(String name, Integer age) {
this.name = name;
this.age = age;
}
Reported by PMD.
Line: 18
private String name;
private Integer age;
public Person(String name, Integer age) {
this.name = name;
this.age = age;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue804.java
4 issues
Line: 11
import java.util.List;
public class Issue804 extends TestCase {
public void test_issue() throws Exception {
String json = "{\n" +
" \"@type\":\"com.alibaba.json.bvt.bug.Issue804$Room\",\n" +
" \"children\":[],\n" +
" \"name\":\"Room2_1\",\n" +
" \"parent\":{\n" +
Reported by PMD.
Line: 40
Room room = (Room) JSON.parse(json);
assertSame(room, room.parent.children.get(0));
}
@JSONType
public static class Node {
protected String name;
Reported by PMD.
Line: 40
Room room = (Room) JSON.parse(json);
assertSame(room, room.parent.children.get(0));
}
@JSONType
public static class Node {
protected String name;
Reported by PMD.
Line: 44
}
@JSONType
public static class Node {
protected String name;
protected Node parent;
protected List<Node> children = new ArrayList<Node>();
public String getName() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/bug201806/Bug_for_weiqiang.java
4 issues
Line: 15
sw.config(SerializerFeature.WriteNullStringAsEmpty, Boolean.TRUE);
JSONSerializer js = new JSONSerializer(sw);
js.write(JSON.parseObject("{'operator':null, 'status':1}"));
System.out.println(js);
String json2 = JSON.toJSONString(JSON.parseObject("{'operator':null, 'status':1}"), SerializerFeature.WriteNullStringAsEmpty);
System.out.println(json2);
}
}
Reported by PMD.
Line: 18
System.out.println(js);
String json2 = JSON.toJSONString(JSON.parseObject("{'operator':null, 'status':1}"), SerializerFeature.WriteNullStringAsEmpty);
System.out.println(json2);
}
}
Reported by PMD.
Line: 10
import junit.framework.TestCase;
public class Bug_for_weiqiang extends TestCase {
public void test_for_bug() throws Exception {
SerializeWriter sw = new SerializeWriter();
sw.config(SerializerFeature.WriteNullStringAsEmpty, Boolean.TRUE);
JSONSerializer js = new JSONSerializer(sw);
js.write(JSON.parseObject("{'operator':null, 'status':1}"));
System.out.println(js);
Reported by PMD.
Line: 10
import junit.framework.TestCase;
public class Bug_for_weiqiang extends TestCase {
public void test_for_bug() throws Exception {
SerializeWriter sw = new SerializeWriter();
sw.config(SerializerFeature.WriteNullStringAsEmpty, Boolean.TRUE);
JSONSerializer js = new JSONSerializer(sw);
js.write(JSON.parseObject("{'operator':null, 'status':1}"));
System.out.println(js);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_xiayucai2012.java
4 issues
Line: 16
public class Bug_for_xiayucai2012 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_xiayucai2012() throws Exception {
Reported by PMD.
Line: 21
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_xiayucai2012() throws Exception {
String text = "{\"date\":\"0000-00-00 00:00:00\"}";
JSONObject json = JSON.parseObject(text);
Date date = json.getObject("date", Date.class);
SimpleDateFormat dateFormat = new SimpleDateFormat(JSON.DEFFAULT_DATE_FORMAT, JSON.defaultLocale);
Reported by PMD.
Line: 24
public void test_for_xiayucai2012() throws Exception {
String text = "{\"date\":\"0000-00-00 00:00:00\"}";
JSONObject json = JSON.parseObject(text);
Date date = json.getObject("date", Date.class);
SimpleDateFormat dateFormat = new SimpleDateFormat(JSON.DEFFAULT_DATE_FORMAT, JSON.defaultLocale);
dateFormat.setTimeZone(JSON.defaultTimeZone);
Assert.assertEquals(dateFormat.parse(json.getString("date")), date);
Reported by PMD.
Line: 29
SimpleDateFormat dateFormat = new SimpleDateFormat(JSON.DEFFAULT_DATE_FORMAT, JSON.defaultLocale);
dateFormat.setTimeZone(JSON.defaultTimeZone);
Assert.assertEquals(dateFormat.parse(json.getString("date")), date);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue801.java
4 issues
Line: 13
* Created by wenshao on 16/9/2.
*/
public class Issue801 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"date\":\"0001-01-01T00:00:00\"}";
Model model = JSON.parseObject(json, Model.class);
}
public static class Model {
Reported by PMD.
Line: 13
* Created by wenshao on 16/9/2.
*/
public class Issue801 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"date\":\"0001-01-01T00:00:00\"}";
Model model = JSON.parseObject(json, Model.class);
}
public static class Model {
Reported by PMD.
Line: 15
public class Issue801 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"date\":\"0001-01-01T00:00:00\"}";
Model model = JSON.parseObject(json, Model.class);
}
public static class Model {
@JSONField(format = "yyyy-MM-ddTHH:mm:ss.SSS")
public Date date;
Reported by PMD.
Line: 15
public class Issue801 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"date\":\"0001-01-01T00:00:00\"}";
Model model = JSON.parseObject(json, Model.class);
}
public static class Model {
@JSONField(format = "yyyy-MM-ddTHH:mm:ss.SSS")
public Date date;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ListFloatFieldTest.java
4 issues
Line: 19
user.getValue().add(1F);
String text = JSON.toJSONString(user);
System.out.println(text);
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
Reported by PMD.
Line: 13
public class ListFloatFieldTest extends TestCase {
public void test_codec() throws Exception {
User user = new User();
user.setValue(new ArrayList<Float>());
user.getValue().add(1F);
String text = JSON.toJSONString(user);
Reported by PMD.
Line: 16
public void test_codec() throws Exception {
User user = new User();
user.setValue(new ArrayList<Float>());
user.getValue().add(1F);
String text = JSON.toJSONString(user);
System.out.println(text);
User user1 = JSON.parseObject(text, User.class);
Reported by PMD.
Line: 23
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
public static class User {
private List<Float> value;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue798_1.java
4 issues
Line: 19
*/
public class Issue798_1 extends TestCase {
public void test_for_issue() throws Exception {
String str = "<p>主要学校:密歇根大学 安娜堡分校、东密西根大学、 克莱利学院、康考迪亚学院 、瓦什特洛社区学院</p>";
String json = JSON.toJSONString(str);
assertEquals("\"<p>主要学校:密歇根大学 安娜堡分校、东密西根大学、 克莱利学院\\u007F、康考迪亚学院 \\u007F、瓦什特洛社区学院\\u007F</p>\"", json);
String parsedStr = (String) JSON.parse(json);
Reported by PMD.
Line: 19
*/
public class Issue798_1 extends TestCase {
public void test_for_issue() throws Exception {
String str = "<p>主要学校:密歇根大学 安娜堡分校、东密西根大学、 克莱利学院、康考迪亚学院 、瓦什特洛社区学院</p>";
String json = JSON.toJSONString(str);
assertEquals("\"<p>主要学校:密歇根大学 安娜堡分校、东密西根大学、 克莱利学院\\u007F、康考迪亚学院 \\u007F、瓦什特洛社区学院\\u007F</p>\"", json);
String parsedStr = (String) JSON.parse(json);
Reported by PMD.
Line: 22
public void test_for_issue() throws Exception {
String str = "<p>主要学校:密歇根大学 安娜堡分校、东密西根大学、 克莱利学院、康考迪亚学院 、瓦什特洛社区学院</p>";
String json = JSON.toJSONString(str);
assertEquals("\"<p>主要学校:密歇根大学 安娜堡分校、东密西根大学、 克莱利学院\\u007F、康考迪亚学院 \\u007F、瓦什特洛社区学院\\u007F</p>\"", json);
String parsedStr = (String) JSON.parse(json);
assertEquals(str, parsedStr);
}
}
Reported by PMD.
Line: 25
assertEquals("\"<p>主要学校:密歇根大学 安娜堡分校、东密西根大学、 克莱利学院\\u007F、康考迪亚学院 \\u007F、瓦什特洛社区学院\\u007F</p>\"", json);
String parsedStr = (String) JSON.parse(json);
assertEquals(str, parsedStr);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3600/Issue3629.java
4 issues
Line: 8
import junit.framework.TestCase;
public class Issue3629 extends TestCase {
public void test_for_issue() throws Exception {
String text1 = "[\n" +
" {\n" +
" \"author\": \"Nigel Rees\",\n" +
" \"category\": \"reference\",\n" +
" \"price\": 8.95,\n" +
Reported by PMD.
Line: 10
public class Issue3629 extends TestCase {
public void test_for_issue() throws Exception {
String text1 = "[\n" +
" {\n" +
" \"author\": \"Nigel Rees\",\n" +
" \"category\": \"reference\",\n" +
" \"price\": 8.95,\n" +
" \"title\": \"Sayings of the Century\"\n" +
" },\n" +
Reported by PMD.
Line: 40
List<Object> extract = (List) JSONPath.extract(text1, "$..[?(@.price < 10)]");
assertEquals(2, extract.size());
}
}
Reported by PMD.
Line: 40
List<Object> extract = (List) JSONPath.extract(text1, "$..[?(@.price < 10)]");
assertEquals(2, extract.size());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2400/Issue2428.java
4 issues
Line: 24
private String myId;
}
public void test_for_issue() {
Issue2428 demoBean = new Issue2428();
demoBean.setMyName("test name");
demoBean.setNestedBean(new NestedBean("test id"));
String text = JSON.toJSONString(JSON.toJSON(demoBean), SerializerFeature.SortField);
assertEquals("{\"nestedBean\":{\"myId\":\"test id\"},\"myName\":\"test name\"}", text);
Reported by PMD.
Line: 24
private String myId;
}
public void test_for_issue() {
Issue2428 demoBean = new Issue2428();
demoBean.setMyName("test name");
demoBean.setNestedBean(new NestedBean("test id"));
String text = JSON.toJSONString(JSON.toJSON(demoBean), SerializerFeature.SortField);
assertEquals("{\"nestedBean\":{\"myId\":\"test id\"},\"myName\":\"test name\"}", text);
Reported by PMD.
Line: 29
demoBean.setMyName("test name");
demoBean.setNestedBean(new NestedBean("test id"));
String text = JSON.toJSONString(JSON.toJSON(demoBean), SerializerFeature.SortField);
assertEquals("{\"nestedBean\":{\"myId\":\"test id\"},\"myName\":\"test name\"}", text);
SerializeConfig serializeConfig = new SerializeConfig();
serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
text = JSON.toJSONString(JSON.toJSON(demoBean, serializeConfig), SerializerFeature.SortField);
assertEquals("{\"my_name\":\"test name\",\"nested_bean\":{\"my_id\":\"test id\"}}", text);
Reported by PMD.
Line: 34
SerializeConfig serializeConfig = new SerializeConfig();
serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
text = JSON.toJSONString(JSON.toJSON(demoBean, serializeConfig), SerializerFeature.SortField);
assertEquals("{\"my_name\":\"test name\",\"nested_bean\":{\"my_id\":\"test id\"}}", text);
}
}
Reported by PMD.