The following issues were found
src/test/java/com/alibaba/json/bvt/TestFlase.java
3 issues
Line: 11
public void test_0() throws Exception {
Object obj = JSON.parseObject("[{\"data\":{\"@type\":\"java.util.TreeMap\",false:21L},\"dataType\":2,\"dis\":0,\"length\":24,\"maxNum\":100,\"size\":3600000,\"version\":0}]", VO[].class);
System.out.println(JSON.toJSONString(obj));
}
public static class VO {
private Object data;
Reported by PMD.
Line: 9
public class TestFlase extends TestCase {
public void test_0() throws Exception {
Object obj = JSON.parseObject("[{\"data\":{\"@type\":\"java.util.TreeMap\",false:21L},\"dataType\":2,\"dis\":0,\"length\":24,\"maxNum\":100,\"size\":3600000,\"version\":0}]", VO[].class);
System.out.println(JSON.toJSONString(obj));
}
public static class VO {
Reported by PMD.
Line: 9
public class TestFlase extends TestCase {
public void test_0() throws Exception {
Object obj = JSON.parseObject("[{\"data\":{\"@type\":\"java.util.TreeMap\",false:21L},\"dataType\":2,\"dis\":0,\"length\":24,\"maxNum\":100,\"size\":3600000,\"version\":0}]", VO[].class);
System.out.println(JSON.toJSONString(obj));
}
public static class VO {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/TestNullKeyMap.java
3 issues
Line: 12
public class TestNullKeyMap extends TestCase {
public void test_0 () throws Exception {
HashMap map = new HashMap();
map.put(null, 123);
String text = JSON.toJSONString(map);
Reported by PMD.
Line: 20
Assert.assertEquals("{null:123}", text);
HashMap map2 = JSON.parseObject(text, HashMap.class);
Assert.assertEquals(map.get(null), map2.get(null));
}
}
Reported by PMD.
Line: 21
Assert.assertEquals("{null:123}", text);
HashMap map2 = JSON.parseObject(text, HashMap.class);
Assert.assertEquals(map.get(null), map2.get(null));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/TestSerializable.java
3 issues
Line: 11
import com.alibaba.fastjson.JSON;
public class TestSerializable extends TestCase {
public void test_codec() throws Exception {
VO vo = new VO();
vo.setValue(new ArrayList());
JSON.toJSONString(vo);
}
Reported by PMD.
Line: 11
import com.alibaba.fastjson.JSON;
public class TestSerializable extends TestCase {
public void test_codec() throws Exception {
VO vo = new VO();
vo.setValue(new ArrayList());
JSON.toJSONString(vo);
}
Reported by PMD.
Line: 18
JSON.toJSONString(vo);
}
public static class VO {
private long id;
private Serializable value;
public long getId() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/UnQuoteFieldNamesTest.java
3 issues
Line: 17
* Created by wenshao on 11/01/2017.
*/
public class UnQuoteFieldNamesTest extends TestCase {
public void test_for_issue() throws Exception {
Map map = Collections.singletonMap("value", 123);
String json = JSON.toJSONString(map
, SerializeConfig.globalInstance
, new SerializeFilter[0]
Reported by PMD.
Line: 26
, null
, JSON.DEFAULT_GENERATE_FEATURE & ~SerializerFeature.QuoteFieldNames.mask
);
assertEquals("{value:123}", json);
}
}
Reported by PMD.
Line: 8
import com.alibaba.fastjson.serializer.SerializeFilter;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import org.junit.Assert;
import java.util.Collections;
import java.util.Map;
/**
Reported by PMD.
src/test/java/com/alibaba/json/bvt/XX01.java
3 issues
Line: 11
* Created by wenshao on 14/08/2017.
*/
public class XX01 extends TestCase {
public void test_for_xx() throws Exception {
String text = "{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}";
JSONObject test = JSON.parseObject(text);
String text2 = test.toJSONString();
assertEquals("{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}", text2);
Reported by PMD.
Line: 15
String text = "{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}";
JSONObject test = JSON.parseObject(text);
String text2 = test.toJSONString();
assertEquals("{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}", text2);
}
}
Reported by PMD.
Line: 16
JSONObject test = JSON.parseObject(text);
String text2 = test.toJSONString();
assertEquals("{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}:1}", text2);
}
}
Reported by PMD.
src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectX.java
3 issues
Line: 9
import java.util.List;
public class ObjectX {
private long a = 0;
private int b;
Reported by PMD.
Line: 12
public class ObjectX {
private long a = 0;
private int b;
private List<Integer> c;
Reported by PMD.
Line: 20
private List<Integer> c;
private int d = 0;
private int e;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/annotation/JSONTypeAutoTypeCheckHandlerTest.java
3 issues
Line: 9
import junit.framework.TestCase;
public class JSONTypeAutoTypeCheckHandlerTest extends TestCase {
public void test_for_checkAutoType() throws Exception {
Cat cat = (Cat) JSON.parseObject("{\"@type\":\"Cat\",\"catId\":123}", Animal.class);
assertEquals(123, cat.catId);
}
@JSONType(autoTypeCheckHandler = MyAutoTypeCheckHandler.class)
Reported by PMD.
Line: 11
public class JSONTypeAutoTypeCheckHandlerTest extends TestCase {
public void test_for_checkAutoType() throws Exception {
Cat cat = (Cat) JSON.parseObject("{\"@type\":\"Cat\",\"catId\":123}", Animal.class);
assertEquals(123, cat.catId);
}
@JSONType(autoTypeCheckHandler = MyAutoTypeCheckHandler.class)
public static class Animal {
Reported by PMD.
Line: 20
}
public static class Cat extends Animal {
public int catId;
}
public static class Mouse extends Animal {
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/annotation/SerializeUsingWhenString.java
3 issues
Line: 17
* @author by laugh on 16/9/28 12:08.
*/
public class SerializeUsingWhenString extends TestCase {
public void test_annotation() throws Exception {
Model model = new Model();
model.value = "100";
Assert.assertEquals("{\"value\":\"100元\"}", JSON.toJSONString(model));
ModelWithOutJsonField modelWithOutJsonField = new ModelWithOutJsonField();
Reported by PMD.
Line: 30
public static class Model {
@JSONField(serializeUsing = ModelValueSerializer.class)
public String value;
}
public static class ModelWithOutJsonField {
public String value;
Reported by PMD.
Line: 35
public static class ModelWithOutJsonField {
public String value;
}
public static class ModelValueSerializer implements ObjectSerializer {
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType,
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue993.java
3 issues
Line: 12
* Created by wenshao on 15/01/2017.
*/
public class Issue993 extends TestCase {
public void test_for_issue() throws Exception {
Student student = new Student();
student.name = "小刚";
String json = JSON.toJSONString(student, SerializerFeature.WriteMapNullValue);
assertEquals("{\"student_name\":\"小刚\",\"student_age\":0,\"student_grade\":null}", json);
Reported by PMD.
Line: 17
student.name = "小刚";
String json = JSON.toJSONString(student, SerializerFeature.WriteMapNullValue);
assertEquals("{\"student_name\":\"小刚\",\"student_age\":0,\"student_grade\":null}", json);
}
public static class Student {
@JSONField(name="student_name",ordinal = 0)
public String name;
Reported by PMD.
Line: 22
public static class Student {
@JSONField(name="student_name",ordinal = 0)
public String name;
@JSONField(name="student_age",ordinal = 1)
public int age;
@JSONField(name="student_grade",ordinal = 2)
Reported by PMD.
src/test/java/com/alibaba/json/bvt/asm/TestNonASM.java
3 issues
Line: 10
public class TestNonASM extends TestCase {
public void test_no_asm() throws Exception {
ParserConfig mapping = new ParserConfig();
mapping.setAsmEnable(false);
Assert.assertEquals(false, mapping.isAsmEnable());
Reported by PMD.
Line: 20
Assert.assertEquals(true, mapping.isAsmEnable());
}
public void test_error() throws Exception {
}
}
Reported by PMD.
Line: 20
Assert.assertEquals(true, mapping.isAsmEnable());
}
public void test_error() throws Exception {
}
}
Reported by PMD.