The following issues were found
src/test/java/com/alibaba/json/bvt/serializer/BooleanArraySerializerTest.java
4 issues
Line: 12
public class BooleanArraySerializerTest extends TestCase {
public void test_0() {
Assert.assertEquals("{\"value\":null}", JSON.toJSONString(new Entity(), SerializerFeature.WriteMapNullValue));
Assert.assertEquals("{\"value\":[]}", JSON.toJSONString(new Entity(), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
}
public static class Entity {
Reported by PMD.
Line: 22
private boolean[] value;
public boolean[] getValue() {
return value;
}
public void setValue(boolean[] value) {
this.value = value;
}
Reported by PMD.
Line: 25
return value;
}
public void setValue(boolean[] value) {
this.value = value;
}
}
}
Reported by PMD.
Line: 25
return value;
}
public void setValue(boolean[] value) {
this.value = value;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/asm/TestASM_List.java
4 issues
Line: 19
v.getList().add(new V1());
v.getList().add(new V1());
String text = JSON.toJSONString(v, SerializerFeature.UseSingleQuotes, SerializerFeature.WriteMapNullValue);
System.out.println(text);
// Assert.assertEquals("{'list':[{},{}]}", text);
}
public static class V0 {
Reported by PMD.
Line: 14
public class TestASM_List extends TestCase {
public void test_decimal_3() throws Exception {
V0 v = new V0();
v.getList().add(new V1());
v.getList().add(new V1());
String text = JSON.toJSONString(v, SerializerFeature.UseSingleQuotes, SerializerFeature.WriteMapNullValue);
System.out.println(text);
Reported by PMD.
Line: 14
public class TestASM_List extends TestCase {
public void test_decimal_3() throws Exception {
V0 v = new V0();
v.getList().add(new V1());
v.getList().add(new V1());
String text = JSON.toJSONString(v, SerializerFeature.UseSingleQuotes, SerializerFeature.WriteMapNullValue);
System.out.println(text);
Reported by PMD.
Line: 38
}
public static class V1 {
private int id;
private TimeUnit unit = TimeUnit.SECONDS;
private String name;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/stream/JSONReader_obj_2.java
4 issues
Line: 13
public class JSONReader_obj_2 extends TestCase {
public void test_array() throws Exception {
JSONReader reader = new JSONReader(new StringReader("[{\"id\":123}]"));
reader.startArray();
VO vo = reader.readObject(VO.class);
Reported by PMD.
Line: 20
VO vo = reader.readObject(VO.class);
Assert.assertEquals(123, vo.getId());
reader.endArray();
reader.close();
}
Reported by PMD.
Line: 27
reader.close();
}
public void test_obj() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"id\":123}"));
VO vo = reader.readObject(VO.class);
Assert.assertEquals(123, vo.getId());
Reported by PMD.
Line: 32
VO vo = reader.readObject(VO.class);
Assert.assertEquals(123, vo.getId());
reader.close();
}
public static class VO {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/ByteArrayFieldSerializerTest.java
4 issues
Line: 11
public class ByteArrayFieldSerializerTest extends TestCase {
public void test_0() throws Exception {
A a1 = new A();
a1.setBytes(new byte[] { 1, 2 });
Assert.assertEquals("{\"bytes\":\"AQI=\"}", JSON.toJSONString(a1));
}
Reported by PMD.
Line: 18
Assert.assertEquals("{\"bytes\":\"AQI=\"}", JSON.toJSONString(a1));
}
public void test_1() throws Exception {
A a1 = new A();
Assert.assertEquals("{\"bytes\":null}", JSON.toJSONString(a1, SerializerFeature.WriteMapNullValue));
}
Reported by PMD.
Line: 29
private byte[] bytes;
public byte[] getBytes() {
return bytes;
}
public void setBytes(byte[] bytes) {
this.bytes = bytes;
}
Reported by PMD.
Line: 32
return bytes;
}
public void setBytes(byte[] bytes) {
this.bytes = bytes;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/ByteArrayTest.java
4 issues
Line: 12
public class ByteArrayTest extends TestCase {
public void test_bytes() throws Exception {
VO vo = new VO();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
SerializerFeature[] features = { SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty };
Reported by PMD.
Line: 26
Assert.assertEquals("{\"value\":[]}", text2);
}
public void test_bytes_1() throws Exception {
VO vo = new VO();
vo.setValue(new byte[] {1, 2, 3});
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 46
private byte[] value;
public byte[] getValue() {
return value;
}
public void setValue(byte[] value) {
this.value = value;
}
Reported by PMD.
Line: 49
return value;
}
public void setValue(byte[] value) {
this.value = value;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/CharArraySerializerTest.java
4 issues
Line: 11
public class CharArraySerializerTest extends TestCase {
public void test_null() throws Exception {
VO vo = new VO();
Assert.assertEquals("{\"value\":[]}", JSON.toJSONString(vo, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
Assert.assertEquals("{\"value\":null}", JSON.toJSONString(vo, SerializerFeature.WriteMapNullValue));
}
Reported by PMD.
Line: 23
private char[] value;
public char[] getValue() {
return value;
}
public void setValue(char[] value) {
this.value = value;
}
Reported by PMD.
Line: 26
return value;
}
public void setValue(char[] value) {
this.value = value;
}
}
}
Reported by PMD.
Line: 26
return value;
}
public void setValue(char[] value) {
this.value = value;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/BooleanFieldDeserializerTest.java
4 issues
Line: 10
public class BooleanFieldDeserializerTest extends TestCase {
public void test_0() throws Exception {
Entity a = JSON.parseObject("{f1:null, f2:null}", Entity.class);
Assert.assertEquals(true, a.isF1());
Assert.assertEquals(null, a.getF2());
}
Reported by PMD.
Line: 12
public void test_0() throws Exception {
Entity a = JSON.parseObject("{f1:null, f2:null}", Entity.class);
Assert.assertEquals(true, a.isF1());
Assert.assertEquals(null, a.getF2());
}
public static class Entity {
Reported by PMD.
Line: 13
public void test_0() throws Exception {
Entity a = JSON.parseObject("{f1:null, f2:null}", Entity.class);
Assert.assertEquals(true, a.isF1());
Assert.assertEquals(null, a.getF2());
}
public static class Entity {
private boolean f1 = true;
Reported by PMD.
Line: 16
Assert.assertEquals(null, a.getF2());
}
public static class Entity {
private boolean f1 = true;
private Boolean f2 = Boolean.TRUE;
public boolean isF1() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/CharsetTest.java
4 issues
Line: 12
public class CharsetTest extends TestCase {
public void test_file() throws Exception {
Charset c = Charset.defaultCharset();
String text = JSON.toJSONString(c);
Assert.assertEquals(JSON.toJSONString(c.toString()), text);
Reported by PMD.
Line: 17
String text = JSON.toJSONString(c);
Assert.assertEquals(JSON.toJSONString(c.toString()), text);
Charset c1 = JSON.parseObject(text, Charset.class);
Assert.assertEquals(c.toString(), c1.toString());
}
}
Reported by PMD.
Line: 20
Assert.assertEquals(JSON.toJSONString(c.toString()), text);
Charset c1 = JSON.parseObject(text, Charset.class);
Assert.assertEquals(c.toString(), c1.toString());
}
}
Reported by PMD.
Line: 20
Assert.assertEquals(JSON.toJSONString(c.toString()), text);
Charset c1 = JSON.parseObject(text, Charset.class);
Assert.assertEquals(c.toString(), c1.toString());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/arraymapping/ArrayMapping_bool.java
4 issues
Line: 11
import junit.framework.TestCase;
public class ArrayMapping_bool extends TestCase {
public void test_for_true() throws Exception {
Model model = JSON.parseObject("[true,\"wenshao\"]", Model.class, Feature.SupportArrayToBean);
Assert.assertEquals(true, model.id);
Assert.assertEquals("wenshao", model.name);
}
Reported by PMD.
Line: 17
Assert.assertEquals("wenshao", model.name);
}
public void test_for_false() throws Exception {
Model model = JSON.parseObject("[false,\"wenshao\"]", Model.class, Feature.SupportArrayToBean);
Assert.assertEquals(false, model.id);
Assert.assertEquals("wenshao", model.name);
}
Reported by PMD.
Line: 24
}
public static class Model {
public boolean id;
public String name;
}
}
Reported by PMD.
Line: 25
public static class Model {
public boolean id;
public String name;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/ClassTest.java
4 issues
Line: 10
public class ClassTest extends TestCase {
public void test_null() throws Exception {
Assert.assertNull(JSON.parseObject("null", Class.class));
Assert.assertNull(JSON.parseObject("null", Class[].class));
Assert.assertNull(JSON.parseArray("null", Class.class));
Assert.assertNull(JSON.parseObject("{value:null}", VO.class).getValue());
}
Reported by PMD.
Line: 14
Assert.assertNull(JSON.parseObject("null", Class.class));
Assert.assertNull(JSON.parseObject("null", Class[].class));
Assert.assertNull(JSON.parseArray("null", Class.class));
Assert.assertNull(JSON.parseObject("{value:null}", VO.class).getValue());
}
public void test_primitive() throws Exception {
Assert.assertEquals(byte.class, JSON.parseObject("\"byte\"", Class.class));
Assert.assertEquals(short.class, JSON.parseObject("\"short\"", Class.class));
Reported by PMD.
Line: 17
Assert.assertNull(JSON.parseObject("{value:null}", VO.class).getValue());
}
public void test_primitive() throws Exception {
Assert.assertEquals(byte.class, JSON.parseObject("\"byte\"", Class.class));
Assert.assertEquals(short.class, JSON.parseObject("\"short\"", Class.class));
Assert.assertEquals(int.class, JSON.parseObject("\"int\"", Class.class));
Assert.assertEquals(long.class, JSON.parseObject("\"long\"", Class.class));
Assert.assertEquals(float.class, JSON.parseObject("\"float\"", Class.class));
Reported by PMD.
Line: 28
Assert.assertEquals(boolean.class, JSON.parseObject("\"boolean\"", Class.class));
}
public void test_array() throws Exception {
Assert.assertEquals(int[].class, JSON.parseObject("\"[int\"", Class.class));
Assert.assertEquals(int[][].class, JSON.parseObject("\"[[int\"", Class.class));
Assert.assertEquals(int[][][][].class, JSON.parseObject("\"[[[[int\"", Class.class));
}
Reported by PMD.