The following issues were found
src/test/java/com/alibaba/json/bvt/proxy/TestProxy.java
6 issues
Line: 18
String text = JSON.toJSONString(vo);
System.out.println(text);
}
public static interface I {
}
Reported by PMD.
Line: 13
public class TestProxy extends TestCase {
public void test_0() throws Exception {
Object vo = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {I.class}, new VO());
String text = JSON.toJSONString(vo);
System.out.println(text);
Reported by PMD.
Line: 13
public class TestProxy extends TestCase {
public void test_0() throws Exception {
Object vo = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {I.class}, new VO());
String text = JSON.toJSONString(vo);
System.out.println(text);
Reported by PMD.
Line: 14
public class TestProxy extends TestCase {
public void test_0() throws Exception {
Object vo = Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {I.class}, new VO());
String text = JSON.toJSONString(vo);
System.out.println(text);
}
Reported by PMD.
Line: 26
}
public static class VO implements InvocationHandler {
private int id;
private String name;
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Reported by PMD.
Line: 31
private int id;
private String name;
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return null;
}
public int getId() {
return id;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/WriteNullListAsEmptyTest.java
6 issues
Line: 13
public class WriteNullListAsEmptyTest extends TestCase {
public void test_nullList() {
SerializerFeature[] features = { SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty };
Assert.assertEquals("{\"names\":[]}", JSON.toJSONString(new VO1(), features));
Assert.assertEquals("{\"names\":[]}", JSON.toJSONString(new VO2(), features));
Assert.assertEquals("{\"names\":[]}", JSON.toJSONString(new VO3(), features));
Assert.assertEquals("{\"names\":[]}", JSON.toJSONString(new VO4(), features));
Reported by PMD.
Line: 15
public void test_nullList() {
SerializerFeature[] features = { SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty };
Assert.assertEquals("{\"names\":[]}", JSON.toJSONString(new VO1(), features));
Assert.assertEquals("{\"names\":[]}", JSON.toJSONString(new VO2(), features));
Assert.assertEquals("{\"names\":[]}", JSON.toJSONString(new VO3(), features));
Assert.assertEquals("{\"names\":[]}", JSON.toJSONString(new VO4(), features));
}
Reported by PMD.
Line: 23
public static class VO1 {
private List<Object> names = null;
public List<Object> getNames() {
return names;
}
Reported by PMD.
Line: 36
public static class VO2 {
private List<String> names = null;
public List<String> getNames() {
return names;
}
Reported by PMD.
Line: 49
public static class VO3 {
private List<Integer> names = null;
public List<Integer> getNames() {
return names;
}
Reported by PMD.
Line: 62
public static class VO4 {
private List<Long> names = null;
public List<Long> getNames() {
return names;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest12.java
6 issues
Line: 18
entity.getChild().setParent(entity);
String text = JSON.toJSONString(entity);
System.out.println(text);
ParserConfig config = new ParserConfig();
config.setAsmEnable(false);
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Reported by PMD.
Line: 26
Assert.assertEquals(entity2, entity2.getChild().getParent());
System.out.println(JSON.toJSONString(entity2));
}
public static class Entity {
private final int id;
Reported by PMD.
Line: 13
public class RefTest12 extends TestCase {
public void test_0() throws Exception {
Entity entity = new Entity(123, new Child());
entity.getChild().setParent(entity);
String text = JSON.toJSONString(entity);
System.out.println(text);
Reported by PMD.
Line: 15
public void test_0() throws Exception {
Entity entity = new Entity(123, new Child());
entity.getChild().setParent(entity);
String text = JSON.toJSONString(entity);
System.out.println(text);
ParserConfig config = new ParserConfig();
Reported by PMD.
Line: 24
config.setAsmEnable(false);
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertEquals(entity2, entity2.getChild().getParent());
System.out.println(JSON.toJSONString(entity2));
}
public static class Entity {
Reported by PMD.
Line: 24
config.setAsmEnable(false);
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertEquals(entity2, entity2.getChild().getParent());
System.out.println(JSON.toJSONString(entity2));
}
public static class Entity {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest16.java
6 issues
Line: 28
Family[] familyArray = new Family[] { fA, fB };
String text = JSON.toJSONString(familyArray);
System.out.println(text);
Family[] result = JSON.parseObject(text, Family[].class);
Assert.assertSame(result[0].getMaster(), result[0].getMembers()[0]);
Assert.assertSame(result[1].getMaster(), result[1].getMembers()[0]);
Reported by PMD.
Line: 10
public class RefTest16 extends TestCase {
public void test_0() throws Exception {
Person pA = new Person("a");
Person pB = new Person("b");
Family fA = new Family();
Reported by PMD.
Line: 37
}
public static class Family {
private Person master;
private Person[] members;
public Person getMaster() {
Reported by PMD.
Line: 51
}
public Person[] getMembers() {
return members;
}
public void setMembers(Person[] members) {
this.members = members;
}
Reported by PMD.
Line: 54
return members;
}
public void setMembers(Person[] members) {
this.members = members;
}
}
Reported by PMD.
Line: 54
return members;
}
public void setMembers(Person[] members) {
this.members = members;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest22.java
6 issues
Line: 12
* Created by wenshao on 16/8/23.
*/
public class RefTest22 extends TestCase {
public void test_ref() throws Exception {
String json = "{\"name\":\"123\",\"assetSize\":{},\"items\":[{\"id\":123}],\"refItems\":{\"$ref\":\"$.items[0]\"}}";
JSONObject root = JSON.parseObject(json);
assertSame(root.getJSONArray("items").get(0), root.getJSONObject("refItems"));
}
}
Reported by PMD.
Line: 15
public void test_ref() throws Exception {
String json = "{\"name\":\"123\",\"assetSize\":{},\"items\":[{\"id\":123}],\"refItems\":{\"$ref\":\"$.items[0]\"}}";
JSONObject root = JSON.parseObject(json);
assertSame(root.getJSONArray("items").get(0), root.getJSONObject("refItems"));
}
}
Reported by PMD.
Line: 15
public void test_ref() throws Exception {
String json = "{\"name\":\"123\",\"assetSize\":{},\"items\":[{\"id\":123}],\"refItems\":{\"$ref\":\"$.items[0]\"}}";
JSONObject root = JSON.parseObject(json);
assertSame(root.getJSONArray("items").get(0), root.getJSONObject("refItems"));
}
}
Reported by PMD.
Line: 15
public void test_ref() throws Exception {
String json = "{\"name\":\"123\",\"assetSize\":{},\"items\":[{\"id\":123}],\"refItems\":{\"$ref\":\"$.items[0]\"}}";
JSONObject root = JSON.parseObject(json);
assertSame(root.getJSONArray("items").get(0), root.getJSONObject("refItems"));
}
}
Reported by PMD.
Line: 15
public void test_ref() throws Exception {
String json = "{\"name\":\"123\",\"assetSize\":{},\"items\":[{\"id\":123}],\"refItems\":{\"$ref\":\"$.items[0]\"}}";
JSONObject root = JSON.parseObject(json);
assertSame(root.getJSONArray("items").get(0), root.getJSONObject("refItems"));
}
}
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import junit.framework.TestCase;
/**
* Created by wenshao on 16/8/23.
*/
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest4.java
6 issues
Line: 13
public class RefTest4 extends TestCase {
public void test_str() throws Exception {
Object[] array = new Object[2];
array[0] = "abc";
array[1] = array[0];
Assert.assertEquals("[\"abc\",\"abc\"]", JSON.toJSONString(array));
}
Reported by PMD.
Line: 20
Assert.assertEquals("[\"abc\",\"abc\"]", JSON.toJSONString(array));
}
public void test_decimal() throws Exception {
Object[] array = new Object[2];
array[0] = new BigDecimal("123");
array[1] = array[0];
Assert.assertEquals("[123,123]", JSON.toJSONString(array));
}
Reported by PMD.
Line: 27
Assert.assertEquals("[123,123]", JSON.toJSONString(array));
}
public void test_integer() throws Exception {
Object[] array = new Object[2];
array[0] = Integer.valueOf(123);
array[1] = array[0];
Assert.assertEquals("[123,123]", JSON.toJSONString(array));
}
Reported by PMD.
Line: 14
public class RefTest4 extends TestCase {
public void test_str() throws Exception {
Object[] array = new Object[2];
array[0] = "abc";
array[1] = array[0];
Assert.assertEquals("[\"abc\",\"abc\"]", JSON.toJSONString(array));
}
Reported by PMD.
Line: 21
}
public void test_decimal() throws Exception {
Object[] array = new Object[2];
array[0] = new BigDecimal("123");
array[1] = array[0];
Assert.assertEquals("[123,123]", JSON.toJSONString(array));
}
Reported by PMD.
Line: 28
}
public void test_integer() throws Exception {
Object[] array = new Object[2];
array[0] = Integer.valueOf(123);
array[1] = array[0];
Assert.assertEquals("[123,123]", JSON.toJSONString(array));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_5.java
6 issues
Line: 13
public class SerializeWriterTest_5 extends TestCase {
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.writeFieldValue(',', "name", (Enum) null);
Assert.assertEquals(",\"name\":null", out.toString());
}
Reported by PMD.
Line: 16
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.writeFieldValue(',', "name", (Enum) null);
Assert.assertEquals(",\"name\":null", out.toString());
}
public void test_1() throws Exception {
SerializeWriter out = new SerializeWriter(1);
Reported by PMD.
Line: 20
Assert.assertEquals(",\"name\":null", out.toString());
}
public void test_1() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.writeFieldValue(',', "name", (BigDecimal) null);
Assert.assertEquals(",\"name\":null", out.toString());
}
Reported by PMD.
Line: 27
Assert.assertEquals(",\"name\":null", out.toString());
}
public void test_2() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.writeFieldValue(',', "name", (String) null);
Assert.assertEquals(",\"name\":null", out.toString());
}
Reported by PMD.
Line: 34
Assert.assertEquals(",\"name\":null", out.toString());
}
public void test_3() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.UseSingleQuotes, true);
out.writeFieldValue(',', "name", (String) null);
Assert.assertEquals(",'name':null", out.toString());
Reported by PMD.
Line: 42
Assert.assertEquals(",'name':null", out.toString());
}
public void test_4() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.UseSingleQuotes, true);
out.writeFieldValue(',', "name", (String) null);
Assert.assertEquals(",'name':null", out.toString());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_4.java
6 issues
Line: 13
@SuppressWarnings("deprecation")
public class SerializeWriterTest_4 extends TestCase {
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.WriteTabAsSpecial, true);
out.writeFieldValue(',', "name", "\t");
Assert.assertEquals(",\"name\":\"\\t\"", out.toString());
Reported by PMD.
Line: 17
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.WriteTabAsSpecial, true);
out.writeFieldValue(',', "name", "\t");
Assert.assertEquals(",\"name\":\"\\t\"", out.toString());
out.close();
}
public void test_1() throws Exception {
Reported by PMD.
Line: 22
out.close();
}
public void test_1() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.WriteTabAsSpecial, true);
out.writeFieldValue(',', "name", "\t\n");
Assert.assertEquals(",\"name\":\"\\t\\n\"", out.toString());
Reported by PMD.
Line: 31
out.close();
}
public void test_3() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.WriteTabAsSpecial, true);
out.writeFieldValue(',', "name", "\t\n \b\n\r\f\\ \"");
Assert.assertEquals(",\"name\":\"\\t\\n \\b\\n\\r\\f\\\\ \\\"\"", out.toString());
Reported by PMD.
Line: 40
out.close();
}
public void test_4() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.WriteTabAsSpecial, false);
out.writeFieldValue(',', "name", "\t\n \b\n\r\f\\ \"");
Assert.assertEquals(",\"name\":\"\\t\\n \\b\\n\\r\\f\\\\ \\\"\"", out.toString());
Reported by PMD.
Line: 49
out.close();
}
public void test_5() throws Exception {
SerializeWriter out = new SerializeWriter(1000);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.WriteTabAsSpecial, true);
out.writeString("\t\n \b\n\r\f\\ \"");
Assert.assertEquals("\"\\t\\n \\b\\n\\r\\f\\\\ \\\"\"", out.toString());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_float.java
6 issues
Line: 13
public class JSONCreatorTest_float extends TestCase {
public void test_create() throws Exception {
Entity entity = new Entity(123.45F, "菜姐");
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId() == entity2.getId());
Reported by PMD.
Line: 18
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId() == entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45F, "菜姐");
Reported by PMD.
Line: 19
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId() == entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45F, "菜姐");
String text = JSON.toJSONString(entity);
Reported by PMD.
Line: 22
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45F, "菜姐");
String text = JSON.toJSONString(entity);
ParserConfig config = new ParserConfig();
Reported by PMD.
Line: 29
ParserConfig config = new ParserConfig();
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertTrue(entity.getId() == entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public static class Entity {
Reported by PMD.
Line: 30
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertTrue(entity.getId() == entity2.getId());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public static class Entity {
private final float id;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/BooleanFieldTest3.java
6 issues
Line: 12
*/
public class BooleanFieldTest3 extends TestCase {
public void test_model() throws Exception {
Model model = new Model();
String text = JSON.toJSONString(model);
Assert.assertEquals("{\"ok\":true,\"ok2\":true,\"ok3\":true}", text);
}
Reported by PMD.
Line: 19
Assert.assertEquals("{\"ok\":true,\"ok2\":true,\"ok3\":true}", text);
}
public static class Model {
private Long fail;
private boolean ok;
Reported by PMD.
Line: 21
public static class Model {
private Long fail;
private boolean ok;
private Boolean ok2;
Reported by PMD.
Line: 23
private Long fail;
private boolean ok;
private Boolean ok2;
private boolean ok3;
Reported by PMD.
Line: 25
private boolean ok;
private Boolean ok2;
private boolean ok3;
public Long isFail() {
return 1L;
Reported by PMD.
Line: 27
private Boolean ok2;
private boolean ok3;
public Long isFail() {
return 1L;
}
Reported by PMD.