The following issues were found
src/test/java/com/alibaba/json/bvt/LongArrayFieldTest_primitive.java
6 issues
Line: 12
public class LongArrayFieldTest_primitive extends TestCase {
public void test_codec_null() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 23
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue(), v.getValue());
}
public void test_codec_null_1() throws Exception {
V0 v = new V0();
Reported by PMD.
Line: 26
Assert.assertEquals(v1.getValue(), v.getValue());
}
public void test_codec_null_1() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 41
private long[] value;
public long[] getValue() {
return value;
}
public void setValue(long[] value) {
this.value = value;
}
Reported by PMD.
Line: 44
return value;
}
public void setValue(long[] value) {
this.value = value;
}
}
}
Reported by PMD.
Line: 44
return value;
}
public void setValue(long[] value) {
this.value = value;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ObjectArrayFieldTest.java
6 issues
Line: 12
public class ObjectArrayFieldTest extends TestCase {
public void test_codec_null() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 23
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue(), v.getValue());
}
public void test_codec_null_1() throws Exception {
V0 v = new V0();
Reported by PMD.
Line: 26
Assert.assertEquals(v1.getValue(), v.getValue());
}
public void test_codec_null_1() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 41
private Object[] value;
public Object[] getValue() {
return value;
}
public void setValue(Object[] value) {
this.value = value;
}
Reported by PMD.
Line: 44
return value;
}
public void setValue(Object[] value) {
this.value = value;
}
}
}
Reported by PMD.
Line: 44
return value;
}
public void setValue(Object[] value) {
this.value = value;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/PatternFieldTest.java
6 issues
Line: 14
public class PatternFieldTest extends TestCase {
public void test_codec() throws Exception {
User user = new User();
user.setValue(Pattern.compile("."));
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 24
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue().pattern(), user.getValue().pattern());
}
public void test_codec_null() throws Exception {
User user = new User();
user.setValue(null);
Reported by PMD.
Line: 24
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue().pattern(), user.getValue().pattern());
}
public void test_codec_null() throws Exception {
User user = new User();
user.setValue(null);
Reported by PMD.
Line: 24
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue().pattern(), user.getValue().pattern());
}
public void test_codec_null() throws Exception {
User user = new User();
user.setValue(null);
Reported by PMD.
Line: 27
Assert.assertEquals(user1.getValue().pattern(), user.getValue().pattern());
}
public void test_codec_null() throws Exception {
User user = new User();
user.setValue(null);
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 37
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
public static class User {
private Pattern value;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/SpecialKeyTest2.java
6 issues
Line: 12
import junit.framework.TestCase;
public class SpecialKeyTest2 extends TestCase {
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"items\":{\"1\":{},\"1001\":{}},\"items1\":{\"$ref\":\"$.items\"}}", Model.class);
Assert.assertEquals(2, model.items.size());
Assert.assertNotNull(model.items.get(1L));
Assert.assertNotNull(model.items.get(1001L));
Assert.assertSame(model.items, model.items1);
Reported by PMD.
Line: 14
public class SpecialKeyTest2 extends TestCase {
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"items\":{\"1\":{},\"1001\":{}},\"items1\":{\"$ref\":\"$.items\"}}", Model.class);
Assert.assertEquals(2, model.items.size());
Assert.assertNotNull(model.items.get(1L));
Assert.assertNotNull(model.items.get(1001L));
Assert.assertSame(model.items, model.items1);
}
Reported by PMD.
Line: 15
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"items\":{\"1\":{},\"1001\":{}},\"items1\":{\"$ref\":\"$.items\"}}", Model.class);
Assert.assertEquals(2, model.items.size());
Assert.assertNotNull(model.items.get(1L));
Assert.assertNotNull(model.items.get(1001L));
Assert.assertSame(model.items, model.items1);
}
public static class Model {
Reported by PMD.
Line: 16
Model model = JSON.parseObject("{\"items\":{\"1\":{},\"1001\":{}},\"items1\":{\"$ref\":\"$.items\"}}", Model.class);
Assert.assertEquals(2, model.items.size());
Assert.assertNotNull(model.items.get(1L));
Assert.assertNotNull(model.items.get(1001L));
Assert.assertSame(model.items, model.items1);
}
public static class Model {
public Map<Long, Item> items;
Reported by PMD.
Line: 21
}
public static class Model {
public Map<Long, Item> items;
public Map<Long, Item> items1;
}
public static class Item {
}
Reported by PMD.
Line: 22
public static class Model {
public Map<Long, Item> items;
public Map<Long, Item> items1;
}
public static class Item {
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/StringFieldTest_special_1.java
6 issues
Line: 11
import junit.framework.TestCase;
public class StringFieldTest_special_1 extends TestCase {
public void test_special() throws Exception {
Model model = new Model();
StringBuilder buf = new StringBuilder();
for (int i = Character.MIN_VALUE; i < Character.MAX_VALUE; ++i) {
buf.append((char) i);
}
Reported by PMD.
Line: 25
Assert.assertEquals(model.name, model2.name);
}
public void test_special_browsecue() throws Exception {
Model model = new Model();
StringBuilder buf = new StringBuilder();
for (int i = Character.MIN_VALUE; i < Character.MAX_VALUE; ++i) {
buf.append((char) i);
}
Reported by PMD.
Line: 34
model.name = buf.toString();
String text = JSON.toJSONString(model, SerializerFeature.BrowserSecure);
text = text.replaceAll("<", "<");
text = text.replaceAll(">", ">");
Model model2 = JSON.parseObject(text, Model.class);
Assert.assertEquals(model.name, model2.name);
}
Reported by PMD.
Line: 35
String text = JSON.toJSONString(model, SerializerFeature.BrowserSecure);
text = text.replaceAll("<", "<");
text = text.replaceAll(">", ">");
Model model2 = JSON.parseObject(text, Model.class);
Assert.assertEquals(model.name, model2.name);
}
public void test_special_browsecompatible() throws Exception {
Reported by PMD.
Line: 40
Assert.assertEquals(model.name, model2.name);
}
public void test_special_browsecompatible() throws Exception {
Model model = new Model();
StringBuilder buf = new StringBuilder();
for (int i = Character.MIN_VALUE; i < Character.MAX_VALUE; ++i) {
buf.append((char) i);
}
Reported by PMD.
Line: 56
public static class Model {
public String name;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/asm/Case_Eishay.java
6 issues
Line: 22
public void test_0() throws Exception {
//JavaBeanMapping.getGlobalInstance().setAsmEnable(false);
System.out.println(text);
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
System.out.println(text2);
System.out.println(JSON.toJSONString(JSON.parseObject(text2), true));
}
Reported by PMD.
Line: 25
System.out.println(text);
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
System.out.println(text2);
System.out.println(JSON.toJSONString(JSON.parseObject(text2), true));
}
}
Reported by PMD.
Line: 26
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
System.out.println(text2);
System.out.println(JSON.toJSONString(JSON.parseObject(text2), true));
}
}
Reported by PMD.
Line: 13
public class Case_Eishay extends TestCase {
private final String text;
public Case_Eishay(){
super();
this.text = EishayDecodeBytes.instance.getText();
}
Reported by PMD.
Line: 20
this.text = EishayDecodeBytes.instance.getText();
}
public void test_0() throws Exception {
//JavaBeanMapping.getGlobalInstance().setAsmEnable(false);
System.out.println(text);
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
System.out.println(text2);
Reported by PMD.
Line: 20
this.text = EishayDecodeBytes.instance.getText();
}
public void test_0() throws Exception {
//JavaBeanMapping.getGlobalInstance().setAsmEnable(false);
System.out.println(text);
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
System.out.println(text2);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/asm/SortFieldTest.java
6 issues
Line: 31
V1 entity = new V1();
String text = JSON.toJSONString(entity, SerializerFeature.SortField);
System.out.println(text);
// 按字段顺序输出
// {"f1":0,"f2":0,"f3":0,"f4":0,"f5":0}
Assert.assertEquals("{\"f1\":0,\"f2\":0,\"f3\":0,\"f4\":0,\"f5\":0}", text);
Reported by PMD.
Line: 14
public class SortFieldTest extends TestCase {
public void test_0() throws Exception {
V0 entity = new V0();
String text = JSON.toJSONString(entity, SerializerFeature.UseSingleQuotes, SerializerFeature.SortField);
Assert.assertEquals("{'f0':0,'f1':0,'f10':0,'f11':0,'f12':0,'f13':0,'f14':0,'f2':0,'f3':0,'f4':0,'f5':0,'f6':0,'f7':0,'f8':0,'f9':0}", text);
Reported by PMD.
Line: 21
Assert.assertEquals("{'f0':0,'f1':0,'f10':0,'f11':0,'f12':0,'f13':0,'f14':0,'f2':0,'f3':0,'f4':0,'f5':0,'f6':0,'f7':0,'f8':0,'f9':0}", text);
LinkedHashMap object = JSON.parseObject(text, LinkedHashMap.class);
text = JSON.toJSONString(object, SerializerFeature.UseSingleQuotes, SerializerFeature.SortField);
Assert.assertEquals("{'f0':0,'f1':0,'f10':0,'f11':0,'f12':0,'f13':0,'f14':0,'f2':0,'f3':0,'f4':0,'f5':0,'f6':0,'f7':0,'f8':0,'f9':0}", text);
}
Reported by PMD.
Line: 27
}
public void test_1() throws Exception {
V1 entity = new V1();
String text = JSON.toJSONString(entity, SerializerFeature.SortField);
System.out.println(text);
Reported by PMD.
Line: 43
}
public static class V1 {
private int f2;
private int f1;
private int f4;
private int f3;
Reported by PMD.
Line: 63
public void setF5(int f5) {this.f5 = f5;}
}
public static class V0 {
private int f5;
private int f4;
private int f3;
private int f2;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/basicType/LongTest_browserCompatible.java
6 issues
Line: 17
import junit.framework.TestCase;
public class LongTest_browserCompatible extends TestCase {
public void test_array() throws Exception {
long[] values = new long[] {Long.MIN_VALUE, -1, 0, 1, Long.MAX_VALUE};
String text = JSON.toJSONString(values, SerializerFeature.BrowserCompatible);
long[] values_2 = JSON.parseObject(text, long[].class);
Assert.assertEquals(values_2.length, values.length);
for (int i = 0; i < values.length; ++i) {
Reported by PMD.
Line: 27
}
}
public void test_array_writer() throws Exception {
long[] values = new long[] {Long.MIN_VALUE, -1, 0, 1, Long.MAX_VALUE};
StringWriter writer = new StringWriter();
JSON.writeJSONString(writer, values, SerializerFeature.BrowserCompatible);
String text = writer.toString();
Reported by PMD.
Line: 40
}
}
public void test_array_writer_2() throws Exception {
Random random = new Random();
long[] values = new long[2048];
for (int i = 0; i < values.length; ++i) {
values[i] = random.nextLong();
}
Reported by PMD.
Line: 57
}
}
public void test_map() throws Exception {
long[] values = new long[] {Long.MIN_VALUE, -1, 0, 1, Long.MAX_VALUE};
Map<String, Object> map = new HashMap<String, Object>();
for (int i = 0; i < values.length; ++i) {
map.put(Long.toString(i), values[i]);
}
Reported by PMD.
Line: 41
}
public void test_array_writer_2() throws Exception {
Random random = new Random();
long[] values = new long[2048];
for (int i = 0; i < values.length; ++i) {
values[i] = random.nextLong();
}
Reported by PMD.
Line: 65
}
String text = JSON.toJSONString(map, SerializerFeature.BrowserCompatible);
JSONObject obj = JSON.parseObject(text);
for (int i = 0; i < values.length; ++i) {
Assert.assertEquals(values[i], ((Number) obj.getLong(Long.toString(i))).longValue());
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_SpitFire_4.java
6 issues
Line: 22
Assert.assertNotNull(o.getPayload());
}
public static abstract class AbstractDTO {
}
public static class Header {
}
Reported by PMD.
Line: 17
q.setHeader(new Header());
q.setPayload(new Payload());
String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
System.out.println(text);
Generic<Payload> o = (Generic<Payload>) JSON.parseObject(text, q.getClass());
Assert.assertNotNull(o.getPayload());
}
public static abstract class AbstractDTO {
Reported by PMD.
Line: 12
public class Bug_for_SpitFire_4 extends TestCase {
public void test_for_SpitFire() {
Generic<Payload> q = new Generic<Payload>();
q.setHeader(new Header());
q.setPayload(new Payload());
String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
System.out.println(text);
Reported by PMD.
Line: 19
String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
System.out.println(text);
Generic<Payload> o = (Generic<Payload>) JSON.parseObject(text, q.getClass());
Assert.assertNotNull(o.getPayload());
}
public static abstract class AbstractDTO {
}
Reported by PMD.
Line: 22
Assert.assertNotNull(o.getPayload());
}
public static abstract class AbstractDTO {
}
public static class Header {
}
Reported by PMD.
Line: 33
}
public static class Generic<T extends AbstractDTO> extends AbstractDTO {
Header header;
T payload;
public Header getHeader() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_SpitFire_5.java
6 issues
Line: 22
Assert.assertNotNull(o.getPayload());
}
public static abstract class AbstractDTO {
}
public static class Header {
}
Reported by PMD.
Line: 17
q.setHeader(new Header());
q.setPayload(new Payload());
String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
System.out.println(text);
Generic<Payload> o = (Generic<Payload>) JSON.parseObject(text, q.getClass());
Assert.assertNotNull(o.getPayload());
}
public static abstract class AbstractDTO {
Reported by PMD.
Line: 12
public class Bug_for_SpitFire_5 extends TestCase {
public void test_for_SpitFire() {
Generic<Payload> q = new Generic<Payload>();
q.setHeader(new Header());
q.setPayload(new Payload());
String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
System.out.println(text);
Reported by PMD.
Line: 19
String text = JSON.toJSONString(q, SerializerFeature.WriteClassName);
System.out.println(text);
Generic<Payload> o = (Generic<Payload>) JSON.parseObject(text, q.getClass());
Assert.assertNotNull(o.getPayload());
}
public static abstract class AbstractDTO {
}
Reported by PMD.
Line: 22
Assert.assertNotNull(o.getPayload());
}
public static abstract class AbstractDTO {
}
public static class Header {
}
Reported by PMD.
Line: 42
}
}
public static class Generic<T extends AbstractDTO> extends AbstractDTO {
Header header;
T payload;
public Header getHeader() {
Reported by PMD.