The following issues were found
src/test/java/com/alibaba/json/bvt/bug/Issue119.java
6 issues
Line: 11
public class Issue119 extends TestCase {
public void test_for_issue() throws Exception {
JSONScanner lexer = new JSONScanner("-100S");
lexer.resetStringPosition();
lexer.scanNumber();
Assert.assertEquals(Short.class, lexer.integerValue().getClass());
Assert.assertEquals(-100, lexer.integerValue().shortValue());
Reported by PMD.
Line: 15
JSONScanner lexer = new JSONScanner("-100S");
lexer.resetStringPosition();
lexer.scanNumber();
Assert.assertEquals(Short.class, lexer.integerValue().getClass());
Assert.assertEquals(-100, lexer.integerValue().shortValue());
lexer.close();
}
public void test_for_issue_b() throws Exception {
Reported by PMD.
Line: 16
lexer.resetStringPosition();
lexer.scanNumber();
Assert.assertEquals(Short.class, lexer.integerValue().getClass());
Assert.assertEquals(-100, lexer.integerValue().shortValue());
lexer.close();
}
public void test_for_issue_b() throws Exception {
JSONScanner lexer = new JSONScanner("-10B");
Reported by PMD.
Line: 20
lexer.close();
}
public void test_for_issue_b() throws Exception {
JSONScanner lexer = new JSONScanner("-10B");
lexer.scanNumber();
Assert.assertEquals(Byte.class, lexer.integerValue().getClass());
Assert.assertEquals(-10, lexer.integerValue().byteValue());
lexer.close();
Reported by PMD.
Line: 23
public void test_for_issue_b() throws Exception {
JSONScanner lexer = new JSONScanner("-10B");
lexer.scanNumber();
Assert.assertEquals(Byte.class, lexer.integerValue().getClass());
Assert.assertEquals(-10, lexer.integerValue().byteValue());
lexer.close();
}
}
Reported by PMD.
Line: 24
JSONScanner lexer = new JSONScanner("-10B");
lexer.scanNumber();
Assert.assertEquals(Byte.class, lexer.integerValue().getClass());
Assert.assertEquals(-10, lexer.integerValue().byteValue());
lexer.close();
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue146.java
6 issues
Line: 18
JSON json = JSON.parseObject("{}");
vo.setName(json);
String s = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
System.out.println(s);
JSON.parseObject(s);
}
public static class VO {
Reported by PMD.
Line: 9
import com.alibaba.fastjson.serializer.SerializerFeature;
public class Issue146 extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue146.");
}
public void test_for_issue() throws Exception {
VO vo = new VO();
Reported by PMD.
Line: 10
public class Issue146 extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue146.");
}
public void test_for_issue() throws Exception {
VO vo = new VO();
JSON json = JSON.parseObject("{}");
Reported by PMD.
Line: 13
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue146.");
}
public void test_for_issue() throws Exception {
VO vo = new VO();
JSON json = JSON.parseObject("{}");
vo.setName(json);
String s = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
System.out.println(s);
Reported by PMD.
Line: 13
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue146.");
}
public void test_for_issue() throws Exception {
VO vo = new VO();
JSON json = JSON.parseObject("{}");
vo.setName(json);
String s = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
System.out.println(s);
Reported by PMD.
Line: 22
JSON.parseObject(s);
}
public static class VO {
private int id;
private Object name;
public int getId() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue177.java
6 issues
Line: 10
public class Issue177 extends TestCase {
public void test_for_issue_177() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("data", new byte[20]);
String jsonString = JSON.toJSONString(jsonObject);
JSONObject parseObject = JSON.parseObject(jsonString);
Reported by PMD.
Line: 10
public class Issue177 extends TestCase {
public void test_for_issue_177() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("data", new byte[20]);
String jsonString = JSON.toJSONString(jsonObject);
JSONObject parseObject = JSON.parseObject(jsonString);
Reported by PMD.
Line: 17
String jsonString = JSON.toJSONString(jsonObject);
JSONObject parseObject = JSON.parseObject(jsonString);
byte[] bytes = parseObject.getBytes("data");
byte[] bs = parseObject.getObject("data", byte[].class);
}
}
Reported by PMD.
Line: 19
byte[] bytes = parseObject.getBytes("data");
byte[] bs = parseObject.getObject("data", byte[].class);
}
}
Reported by PMD.
Line: 17
String jsonString = JSON.toJSONString(jsonObject);
JSONObject parseObject = JSON.parseObject(jsonString);
byte[] bytes = parseObject.getBytes("data");
byte[] bs = parseObject.getObject("data", byte[].class);
}
}
Reported by PMD.
Line: 19
byte[] bytes = parseObject.getBytes("data");
byte[] bs = parseObject.getObject("data", byte[].class);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue179.java
6 issues
Line: 28
object.put("school", school);
String jsonString = JSON.toJSONString(object);
System.out.println(jsonString);
JSONObject object2 = (JSONObject) JSON.parseObject(jsonString, JSONObject.class);
System.out.println(JSON.toJSONString(object2));
School school2 = object2.getObject("school", School.class);
Reported by PMD.
Line: 31
System.out.println(jsonString);
JSONObject object2 = (JSONObject) JSON.parseObject(jsonString, JSONObject.class);
System.out.println(JSON.toJSONString(object2));
School school2 = object2.getObject("school", School.class);
System.out.println(school2);
}
Reported by PMD.
Line: 34
System.out.println(JSON.toJSONString(object2));
School school2 = object2.getObject("school", School.class);
System.out.println(school2);
}
public static class School {
Student student;
Reported by PMD.
Line: 10
public class Issue179 extends TestCase {
public void test_for_issue_179() throws Exception {
Student student = new Student();
School school = new School();
school.setStudent(student);
student.setSchool(school);
Reported by PMD.
Line: 10
public class Issue179 extends TestCase {
public void test_for_issue_179() throws Exception {
Student student = new Student();
School school = new School();
school.setStudent(student);
student.setSchool(school);
Reported by PMD.
Line: 33
JSONObject object2 = (JSONObject) JSON.parseObject(jsonString, JSONObject.class);
System.out.println(JSON.toJSONString(object2));
School school2 = object2.getObject("school", School.class);
System.out.println(school2);
}
public static class School {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue744.java
6 issues
Line: 24
Model model =JSON.parseObject(text, Model.class);
String text2 = JSON.toJSONString(model);
System.out.println(text2);
}
public void test_reader() {
String text = "{\"date\":\"9999-09-08T00:00:00\"}";
Reported by PMD.
Line: 33
Model model = new JSONReader(new StringReader(text)).readObject(Model.class);
String text2 = JSON.toJSONString(model);
System.out.println(text2);
}
}
Reported by PMD.
Line: 19
public Date date;
}
public void test() {
String text = "{\"date\":\"9999-09-08T00:00:00\"}";
Model model =JSON.parseObject(text, Model.class);
String text2 = JSON.toJSONString(model);
System.out.println(text2);
Reported by PMD.
Line: 19
public Date date;
}
public void test() {
String text = "{\"date\":\"9999-09-08T00:00:00\"}";
Model model =JSON.parseObject(text, Model.class);
String text2 = JSON.toJSONString(model);
System.out.println(text2);
Reported by PMD.
Line: 27
System.out.println(text2);
}
public void test_reader() {
String text = "{\"date\":\"9999-09-08T00:00:00\"}";
Model model = new JSONReader(new StringReader(text)).readObject(Model.class);
String text2 = JSON.toJSONString(model);
Reported by PMD.
Line: 27
System.out.println(text2);
}
public void test_reader() {
String text = "{\"date\":\"9999-09-08T00:00:00\"}";
Model model = new JSONReader(new StringReader(text)).readObject(Model.class);
String text2 = JSON.toJSONString(model);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue779.java
6 issues
Line: 11
* Created by wenshao on 16/8/28.
*/
public class Issue779 extends TestCase {
public void test_for_issue() throws Exception {
Exception error = null;
try {
String aaa = "{'token':'token':'sign':'bb'}";
JSON.parseObject(aaa);
} catch (JSONException ex) {
Reported by PMD.
Line: 20
error = ex;
}
assertNotNull(error);
}
public void test_for_issue_deser() throws Exception {
Exception error = null;
try {
Reported by PMD.
Line: 23
assertNotNull(error);
}
public void test_for_issue_deser() throws Exception {
Exception error = null;
try {
String aaa = "{'token':'token':'sign':'bb'}";
JSON.parseObject(aaa, Model.class);
} catch (JSONException ex) {
Reported by PMD.
Line: 32
error = ex;
}
assertNotNull(error);
}
public static class Model {
public String token;
public String sign;
Reported by PMD.
Line: 12
*/
public class Issue779 extends TestCase {
public void test_for_issue() throws Exception {
Exception error = null;
try {
String aaa = "{'token':'token':'sign':'bb'}";
JSON.parseObject(aaa);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 24
}
public void test_for_issue_deser() throws Exception {
Exception error = null;
try {
String aaa = "{'token':'token':'sign':'bb'}";
JSON.parseObject(aaa, Model.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue983_1.java
6 issues
Line: 13
* Created by wenshao on 10/01/2017.
*/
public class Issue983_1 extends TestCase {
public void test_for_issue() throws Exception {
Map.Entry entry = new AbstractMap.SimpleEntry("name", "foo");
String text = JSON.toJSONString(entry);
assertEquals("{\"name\":\"foo\"}", text);
}
Reported by PMD.
Line: 16
public void test_for_issue() throws Exception {
Map.Entry entry = new AbstractMap.SimpleEntry("name", "foo");
String text = JSON.toJSONString(entry);
assertEquals("{\"name\":\"foo\"}", text);
}
public void test_for_issue_int() throws Exception {
Map.Entry entry = new AbstractMap.SimpleEntry("name", 123);
String text = JSON.toJSONString(entry);
Reported by PMD.
Line: 19
assertEquals("{\"name\":\"foo\"}", text);
}
public void test_for_issue_int() throws Exception {
Map.Entry entry = new AbstractMap.SimpleEntry("name", 123);
String text = JSON.toJSONString(entry);
assertEquals("{\"name\":123}", text);
}
Reported by PMD.
Line: 22
public void test_for_issue_int() throws Exception {
Map.Entry entry = new AbstractMap.SimpleEntry("name", 123);
String text = JSON.toJSONString(entry);
assertEquals("{\"name\":123}", text);
}
public void test_for_issue_int_int() throws Exception {
Map.Entry entry = new AbstractMap.SimpleEntry(123, 234);
String text = JSON.toJSONString(entry);
Reported by PMD.
Line: 25
assertEquals("{\"name\":123}", text);
}
public void test_for_issue_int_int() throws Exception {
Map.Entry entry = new AbstractMap.SimpleEntry(123, 234);
String text = JSON.toJSONString(entry);
assertEquals("{123:234}", text);
}
}
Reported by PMD.
Line: 28
public void test_for_issue_int_int() throws Exception {
Map.Entry entry = new AbstractMap.SimpleEntry(123, 234);
String text = JSON.toJSONString(entry);
assertEquals("{123:234}", text);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue_for_oschina_3087749_2215732.java
6 issues
Line: 15
* Created by wenshao on 29/12/2016.
*/
public class Issue_for_oschina_3087749_2215732 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"datas\":[\"a\",\"b\"]}";
JSONObject o = JSON.parseObject(json);
o.toJavaObject(JsonBean.class);
}
Reported by PMD.
Line: 15
* Created by wenshao on 29/12/2016.
*/
public class Issue_for_oschina_3087749_2215732 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"datas\":[\"a\",\"b\"]}";
JSONObject o = JSON.parseObject(json);
o.toJavaObject(JsonBean.class);
}
Reported by PMD.
Line: 18
public void test_for_issue() throws Exception {
String json = "{\"datas\":[\"a\",\"b\"]}";
JSONObject o = JSON.parseObject(json);
o.toJavaObject(JsonBean.class);
}
public static class JsonBean {
private List<String> datas = new ArrayList<String>();
public List<String> getDatas() {
Reported by PMD.
Line: 22
}
public static class JsonBean {
private List<String> datas = new ArrayList<String>();
public List<String> getDatas() {
return datas;
}
}
}
Reported by PMD.
Line: 22
}
public static class JsonBean {
private List<String> datas = new ArrayList<String>();
public List<String> getDatas() {
return datas;
}
}
}
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import junit.framework.Test;
import junit.framework.TestCase;
import java.util.ArrayList;
import java.util.List;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/StackTraceElementTest.java
6 issues
Line: 12
public class StackTraceElementTest extends TestCase {
public void test_stackTrace() throws Exception {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
String text = JSON.toJSONString(stackTrace, SerializerFeature.WriteClassName);
JSONArray array = (JSONArray) JSON.parse(text);
for (int i = 0; i < array.size(); ++i) {
StackTraceElement element = (StackTraceElement) array.get(i);
Reported by PMD.
Line: 13
public class StackTraceElementTest extends TestCase {
public void test_stackTrace() throws Exception {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
String text = JSON.toJSONString(stackTrace, SerializerFeature.WriteClassName);
JSONArray array = (JSONArray) JSON.parse(text);
for (int i = 0; i < array.size(); ++i) {
StackTraceElement element = (StackTraceElement) array.get(i);
Assert.assertEquals(stackTrace[i].getFileName(), element.getFileName());
Reported by PMD.
Line: 18
JSONArray array = (JSONArray) JSON.parse(text);
for (int i = 0; i < array.size(); ++i) {
StackTraceElement element = (StackTraceElement) array.get(i);
Assert.assertEquals(stackTrace[i].getFileName(), element.getFileName());
Assert.assertEquals(stackTrace[i].getLineNumber(), element.getLineNumber());
Assert.assertEquals(stackTrace[i].getClassName(), element.getClassName());
Assert.assertEquals(stackTrace[i].getMethodName(), element.getMethodName());
}
}
Reported by PMD.
Line: 19
for (int i = 0; i < array.size(); ++i) {
StackTraceElement element = (StackTraceElement) array.get(i);
Assert.assertEquals(stackTrace[i].getFileName(), element.getFileName());
Assert.assertEquals(stackTrace[i].getLineNumber(), element.getLineNumber());
Assert.assertEquals(stackTrace[i].getClassName(), element.getClassName());
Assert.assertEquals(stackTrace[i].getMethodName(), element.getMethodName());
}
}
}
Reported by PMD.
Line: 20
StackTraceElement element = (StackTraceElement) array.get(i);
Assert.assertEquals(stackTrace[i].getFileName(), element.getFileName());
Assert.assertEquals(stackTrace[i].getLineNumber(), element.getLineNumber());
Assert.assertEquals(stackTrace[i].getClassName(), element.getClassName());
Assert.assertEquals(stackTrace[i].getMethodName(), element.getMethodName());
}
}
}
Reported by PMD.
Line: 21
Assert.assertEquals(stackTrace[i].getFileName(), element.getFileName());
Assert.assertEquals(stackTrace[i].getLineNumber(), element.getLineNumber());
Assert.assertEquals(stackTrace[i].getClassName(), element.getClassName());
Assert.assertEquals(stackTrace[i].getMethodName(), element.getMethodName());
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/DoubleTest.java
6 issues
Line: 18
vo.setF3(Integer.MAX_VALUE);
String text = JSON.toJSONString(vo);
System.out.println(text);
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getF1(), vo1.getF1());
Assert.assertTrue(vo.getF2() == vo1.getF2());
Reported by PMD.
Line: 11
public class DoubleTest extends TestCase {
public void test_double() throws Exception {
VO vo = new VO();
vo.setF1(Integer.MAX_VALUE);
vo.setF2(Double.MAX_VALUE);
vo.setF3(Integer.MAX_VALUE);
Reported by PMD.
Line: 22
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getF1(), vo1.getF1());
Assert.assertTrue(vo.getF2() == vo1.getF2());
Assert.assertEquals(vo.getF3(), vo1.getF3());
}
public static class VO {
Reported by PMD.
Line: 23
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getF1(), vo1.getF1());
Assert.assertTrue(vo.getF2() == vo1.getF2());
Assert.assertEquals(vo.getF3(), vo1.getF3());
}
public static class VO {
Reported by PMD.
Line: 24
Assert.assertEquals(vo.getF1(), vo1.getF1());
Assert.assertTrue(vo.getF2() == vo1.getF2());
Assert.assertEquals(vo.getF3(), vo1.getF3());
}
public static class VO {
private int f1;
Reported by PMD.
Line: 27
Assert.assertEquals(vo.getF3(), vo1.getF3());
}
public static class VO {
private int f1;
private double f2;
private int f3;
Reported by PMD.