The following issues were found
src/test/java/com/alibaba/json/bvt/bug/Issue1030.java
4 issues
Line: 14
* Created by wenshao on 13/03/2017.
*/
public class Issue1030 extends TestCase {
public void test_for_issue() throws Exception {
String DOC = "{\"books\":[{\"pageWords\":[{\"num\":10},{\"num\":15}]},{\"pageWords\":[{\"num\":20}]}]}";
//fastjson包
JSONObject result = JSONObject.parseObject(DOC);
Reported by PMD.
Line: 22
List array = (List) JSONPath.eval(result, "$.books[0:].pageWords[0:]");
assertEquals(3, array.size());
}
}
Reported by PMD.
Line: 22
List array = (List) JSONPath.eval(result, "$.books[0:].pageWords[0:]");
assertEquals(3, array.size());
}
}
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.bug;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import junit.framework.TestCase;
import java.util.List;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_booleanField.java
4 issues
Line: 12
public class Bug_for_booleanField extends TestCase {
public void test_boolean() throws Exception {
Assert.assertEquals("{\"is-abc\":false}", JSON.toJSONString(new BooleanJson()));
Assert.assertTrue(JSON.parseObject("{\"is-abc\":true}", BooleanJson.class).isAbc());
}
public static class BooleanJson {
Reported by PMD.
Line: 14
public void test_boolean() throws Exception {
Assert.assertEquals("{\"is-abc\":false}", JSON.toJSONString(new BooleanJson()));
Assert.assertTrue(JSON.parseObject("{\"is-abc\":true}", BooleanJson.class).isAbc());
}
public static class BooleanJson {
@JSONField(name = "is-abc")
Reported by PMD.
Line: 20
public static class BooleanJson {
@JSONField(name = "is-abc")
private boolean isAbc;
public boolean isAbc() {
return isAbc;
}
Reported by PMD.
Line: 20
public static class BooleanJson {
@JSONField(name = "is-abc")
private boolean isAbc;
public boolean isAbc() {
return isAbc;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_builder.java
4 issues
Line: 9
public class Bug_for_builder extends TestCase {
public void test_for_longBuilderMethod() throws Exception {
VO vo = JSON.parseObject("{\"id\":123}", VO.class);
}
public static class VO {
Reported by PMD.
Line: 9
public class Bug_for_builder extends TestCase {
public void test_for_longBuilderMethod() throws Exception {
VO vo = JSON.parseObject("{\"id\":123}", VO.class);
}
public static class VO {
Reported by PMD.
Line: 10
public class Bug_for_builder extends TestCase {
public void test_for_longBuilderMethod() throws Exception {
VO vo = JSON.parseObject("{\"id\":123}", VO.class);
}
public static class VO {
private long id;
Reported by PMD.
Line: 10
public class Bug_for_builder extends TestCase {
public void test_for_longBuilderMethod() throws Exception {
VO vo = JSON.parseObject("{\"id\":123}", VO.class);
}
public static class VO {
private long id;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_6.java
4 issues
Line: 17
String jsonString = JSON.toJSONString(entity);
System.out.println(jsonString);
JSON.parseObject(jsonString, Entity.class);
}
public static class Entity {
Reported by PMD.
Line: 12
public class Bug_6 extends TestCase {
public void test_bug6() throws Exception {
Entity entity = new Entity();
String jsonString = JSON.toJSONString(entity);
System.out.println(jsonString);
Reported by PMD.
Line: 12
public class Bug_6 extends TestCase {
public void test_bug6() throws Exception {
Entity entity = new Entity();
String jsonString = JSON.toJSONString(entity);
System.out.println(jsonString);
Reported by PMD.
Line: 24
public static class Entity {
private List<HashMap<String, String>> list = null;
public List<HashMap<String, String>> getList() {
return list;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_278.java
4 issues
Line: 11
public class Bug_for_issue_278 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.setTest(true);
String text = JSON.toJSONString(vo);
Assert.assertEquals("{\"test\":true}", text);
Reported by PMD.
Line: 19
Assert.assertEquals("{\"test\":true}", text);
}
public void test_for_issue_decode() throws Exception {
VO vo = JSON.parseObject("{\"isTest\":true}", VO.class);
Assert.assertTrue(vo.isTest);
}
public static class VO {
Reported by PMD.
Line: 26
public static class VO {
private boolean isTest;
public boolean isTest() {
return isTest;
}
Reported by PMD.
Line: 26
public static class VO {
private boolean isTest;
public boolean isTest() {
return isTest;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_jiangwei1.java
4 issues
Line: 12
public class Bug_for_jiangwei1 extends TestCase {
public void test_double() throws Exception {
JSONObject json = JSON.parseObject("{\"val\":12.3}");
Assert.assertTrue(12.3D == json.getDoubleValue("val"));
}
public void test_JSONArray_double() throws Exception {
Reported by PMD.
Line: 14
public void test_double() throws Exception {
JSONObject json = JSON.parseObject("{\"val\":12.3}");
Assert.assertTrue(12.3D == json.getDoubleValue("val"));
}
public void test_JSONArray_double() throws Exception {
JSONArray json = JSON.parseArray("[12.3]");
Assert.assertTrue(12.3D == json.getDoubleValue(0));
Reported by PMD.
Line: 17
Assert.assertTrue(12.3D == json.getDoubleValue("val"));
}
public void test_JSONArray_double() throws Exception {
JSONArray json = JSON.parseArray("[12.3]");
Assert.assertTrue(12.3D == json.getDoubleValue(0));
}
}
Reported by PMD.
Line: 19
public void test_JSONArray_double() throws Exception {
JSONArray json = JSON.parseArray("[12.3]");
Assert.assertTrue(12.3D == json.getDoubleValue(0));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/asm/JSONASMUtilTest.java
4 issues
Line: 10
public class JSONASMUtilTest extends TestCase {
public void test_1() throws Exception {
Assert.assertEquals("V", ASMUtils.desc(Void.TYPE));
Assert.assertEquals("J", ASMUtils.desc(Long.TYPE));
Assert.assertEquals("[J", ASMUtils.desc(long[].class));
Assert.assertEquals("[Ljava/lang/Long;", ASMUtils.desc(Long[].class));
}
Reported by PMD.
Line: 17
Assert.assertEquals("[Ljava/lang/Long;", ASMUtils.desc(Long[].class));
}
public void test_error_1() throws Exception {
new ASMUtils();
Exception error = null;
try {
ASMUtils.getPrimitiveLetter(Long.class);
Reported by PMD.
Line: 23
Exception error = null;
try {
ASMUtils.getPrimitiveLetter(Long.class);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
}
Reported by PMD.
Line: 20
public void test_error_1() throws Exception {
new ASMUtils();
Exception error = null;
try {
ASMUtils.getPrimitiveLetter(Long.class);
} catch (Exception ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/asm/LoopTest.java
4 issues
Line: 13
public class LoopTest extends TestCase {
public void test_loop() throws Exception {
Department department = JSON.parseObject("{id:12,name:'R & D', members:[{id:2001, name:'jobs'}]}", Department.class);
Assert.assertNotNull(department);
Assert.assertEquals(12, department.getId());
}
Reported by PMD.
Line: 16
public void test_loop() throws Exception {
Department department = JSON.parseObject("{id:12,name:'R & D', members:[{id:2001, name:'jobs'}]}", Department.class);
Assert.assertNotNull(department);
Assert.assertEquals(12, department.getId());
}
public static class Department {
private int id;
Reported by PMD.
Line: 19
Assert.assertEquals(12, department.getId());
}
public static class Department {
private int id;
private String name;
private List<Employee> members = new ArrayList<Employee>();
Reported by PMD.
Line: 52
}
public static class Employee {
private int id;
private String name;
private Department department;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_zhaoyao.java
4 issues
Line: 21
map.put("a", 1);
map.put("b", 2);
String text = JSON.toJSONString(map, SerializerFeature.WriteClassName);
System.out.println(text);
FieldMap map2 = (FieldMap) JSON.parse(text);
Assert.assertTrue(map.equals(map2));
}
Reported by PMD.
Line: 12
import com.alibaba.fastjson.serializer.SerializerFeature;
public class Bug_for_zhaoyao extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_zhaoyao.");
}
public void test_FieldMap() throws Exception {
FieldMap map = new FieldMap();
Reported by PMD.
Line: 13
public class Bug_for_zhaoyao extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_zhaoyao.");
}
public void test_FieldMap() throws Exception {
FieldMap map = new FieldMap();
map.put("a", 1);
Reported by PMD.
Line: 16
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_zhaoyao.");
}
public void test_FieldMap() throws Exception {
FieldMap map = new FieldMap();
map.put("a", 1);
map.put("b", 2);
String text = JSON.toJSONString(map, SerializerFeature.WriteClassName);
System.out.println(text);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/OOMTest.java
4 issues
Line: 14
import junit.framework.TestCase;
public class OOMTest extends TestCase {
public void test_oom() throws Exception {
for (int i = 0; i < 1000 * 1000; ++i) {
String text = "{\"" + i + "\":0}";
JSON.parse(text);
}
Reported by PMD.
Line: 22
}
Field field = SymbolTable.class.getDeclaredField("symbols");
field.setAccessible(true);
Object[] symbols = (Object[]) field.get(ParserConfig.getGlobalInstance().symbolTable);
Assert.assertEquals(4096, symbols.length);
}
}
Reported by PMD.
Line: 23
Field field = SymbolTable.class.getDeclaredField("symbols");
field.setAccessible(true);
Object[] symbols = (Object[]) field.get(ParserConfig.getGlobalInstance().symbolTable);
Assert.assertEquals(4096, symbols.length);
}
}
Reported by PMD.
Line: 23
Field field = SymbolTable.class.getDeclaredField("symbols");
field.setAccessible(true);
Object[] symbols = (Object[]) field.get(ParserConfig.getGlobalInstance().symbolTable);
Assert.assertEquals(4096, symbols.length);
}
}
Reported by PMD.