The following issues were found
src/test/java/com/alibaba/json/demo/JSONFeidDemo.java
3 issues
Line: 34
String text = JSON.toJSONString(user);
Assert.assertEquals("{\"name\":\"毛头\",\"uid\":123}", text);
System.out.println(text);
}
}
Reported by PMD.
Line: 11
public class JSONFeidDemo extends TestCase {
public static class User {
private int id;
private String name;
@JSONField(name = "uid")
Reported by PMD.
Line: 27
public void setName(String name) { this.name = name; }
}
public void test_0() throws Exception {
User user = new User();
user.setId(123);
user.setName("毛头");
String text = JSON.toJSONString(user);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/basicType/BigDecimal_BrowserCompatible.java
3 issues
Line: 13
import java.util.Map;
public class BigDecimal_BrowserCompatible extends TestCase {
public void test_for_issue() throws Exception {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("id1", new BigDecimal("-9223370018640066466"));
map.put("id2", new BigDecimal("9223370018640066466"));
map.put("id3", new BigDecimal("100"));
assertEquals("{\"id1\":\"-9223370018640066466\",\"id2\":\"9223370018640066466\",\"id3\":100}",
Reported by PMD.
Line: 18
map.put("id1", new BigDecimal("-9223370018640066466"));
map.put("id2", new BigDecimal("9223370018640066466"));
map.put("id3", new BigDecimal("100"));
assertEquals("{\"id1\":\"-9223370018640066466\",\"id2\":\"9223370018640066466\",\"id3\":100}",
JSON.toJSONString(map, SerializerFeature.BrowserCompatible)
);
}
}
Reported by PMD.
Line: 8
import junit.framework.TestCase;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.LinkedHashMap;
import java.util.Map;
public class BigDecimal_BrowserCompatible extends TestCase {
public void test_for_issue() throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/JSONTypeTest_orders_arrayMapping_2.java
3 issues
Line: 10
import junit.framework.TestCase;
public class JSONTypeTest_orders_arrayMapping_2 extends TestCase {
public void test_1() throws Exception {
Model vo = new Model();
vo.setId(1001);
vo.setName("xx");
vo.setAge(33);
vo.setDvalue(0.1D);
Reported by PMD.
Line: 18
vo.setDvalue(0.1D);
String json = JSON.toJSONString(vo);
assertEquals("[1001,\"xx\",33,0.0,0.1]", json);
JSON.parseObject(json, Model.class);
Model[] array = new Model[] {vo};
String json2 = JSON.toJSONString(array);
Reported by PMD.
Line: 34
, serialzeFeatures = SerializerFeature.BeanToArray
, parseFeatures = Feature.SupportArrayToBean
)
public static class Model {
private int id;
private String name;
private int age;
private float value;
private double dvalue;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ByteArrayFieldTest_5_base64.java
3 issues
Line: 10
public class ByteArrayFieldTest_5_base64 extends TestCase {
public void test_0() throws Exception {
Model model = new Model();
model.value = "ABCDEG".getBytes();
String json = JSON.toJSONString(model);
Reported by PMD.
Line: 17
String json = JSON.toJSONString(model);
assertEquals("{\"value\":\"QUJDREVH\"}", json);
Model model1 = JSON.parseObject(json, Model.class);
Assert.assertArrayEquals(model.value, model1.value);
}
Reported by PMD.
Line: 26
private static class Model {
@JSONField(format = "base64")
public byte[] value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/JSON_toJSONStringTest.java
3 issues
Line: 29
public class JSON_toJSONStringTest extends TestCase {
public void test_0() throws Exception {
User user = new User();
user.setId(123);
user.setName("毛头");
SerializeConfig mapping = new SerializeConfig();
Reported by PMD.
Line: 44
Assert.assertEquals("{\"id\":123}", jsonString);
}
public void test_1() throws Exception {
User user = new User();
user.setId(123);
user.setName("毛头");
SerializeConfig mapping = new SerializeConfig();
Reported by PMD.
Line: 59
Assert.assertEquals("{\"uid\":123}", jsonString);
}
public static class User {
private int id;
private String name;
public int getId() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/BigIntegerFieldTest.java
3 issues
Line: 14
public class BigIntegerFieldTest extends TestCase {
public void test_codec_null() throws Exception {
V0 v = new V0();
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 25
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: 28
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.
src/test/java/com/alibaba/json/bvt/LongFieldTest_3.java
3 issues
Line: 13
public class LongFieldTest_3 extends TestCase {
public void test_min() throws Exception {
Random random = new Random();
Model[] array = new Model[2048];
for (int i = 0; i < array.length; ++i) {
array[i] = new Model();
array[i].value = random.nextLong();
Reported by PMD.
Line: 34
public static class Model {
public long value;
}
}
Reported by PMD.
Line: 14
public class LongFieldTest_3 extends TestCase {
public void test_min() throws Exception {
Random random = new Random();
Model[] array = new Model[2048];
for (int i = 0; i < array.length; ++i) {
array[i] = new Model();
array[i].value = random.nextLong();
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/LongFieldTest_3_private.java
3 issues
Line: 13
public class LongFieldTest_3_private extends TestCase {
public void test_min() throws Exception {
Random random = new Random();
Model[] array = new Model[8192];
for (int i = 0; i < array.length; ++i) {
array[i] = new Model();
array[i].value = random.nextLong();
Reported by PMD.
Line: 34
private static class Model {
public long value;
}
}
Reported by PMD.
Line: 14
public class LongFieldTest_3_private extends TestCase {
public void test_min() throws Exception {
Random random = new Random();
Model[] array = new Model[8192];
for (int i = 0; i < array.length; ++i) {
array[i] = new Model();
array[i].value = random.nextLong();
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/LongFieldTest_3_stream.java
3 issues
Line: 15
public class LongFieldTest_3_stream extends TestCase {
public void test_min() throws Exception {
Random random = new Random();
Model[] array = new Model[8192];
for (int i = 0; i < array.length; ++i) {
array[i] = new Model();
array[i].value = random.nextLong();
Reported by PMD.
Line: 38
public static class Model {
public long value;
}
}
Reported by PMD.
Line: 16
public class LongFieldTest_3_stream extends TestCase {
public void test_min() throws Exception {
Random random = new Random();
Model[] array = new Model[8192];
for (int i = 0; i < array.length; ++i) {
array[i] = new Model();
array[i].value = random.nextLong();
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/LongFieldTest_4.java
3 issues
Line: 16
public class LongFieldTest_4 extends TestCase {
public void test_min() throws Exception {
Random random = new Random();
Model[] array = new Model[2048];
for (int i = 0; i < array.length; ++i) {
array[i] = new Model();
array[i].value = random.nextLong();
Reported by PMD.
Line: 37
@JSONType(serialzeFeatures = SerializerFeature.BeanToArray, parseFeatures = Feature.SupportArrayToBean)
public static class Model {
public long value;
}
}
Reported by PMD.
Line: 17
public class LongFieldTest_4 extends TestCase {
public void test_min() throws Exception {
Random random = new Random();
Model[] array = new Model[2048];
for (int i = 0; i < array.length; ++i) {
array[i] = new Model();
array[i].value = random.nextLong();
}
Reported by PMD.