The following issues were found
src/test/java/com/alibaba/json/bvt/parser/number/NumberValueTest_error_7.java
4 issues
Line: 12
public class NumberValueTest_error_7 extends TestCase {
public void test_0() throws Exception {
Exception error = null;
try {
String text = "{\"value\":-";
JSON.parse(text);
} catch (Exception e) {
Reported by PMD.
Line: 17
try {
String text = "{\"value\":-";
JSON.parse(text);
} catch (Exception e) {
error = e;
}
Assert.assertNotNull(error);
}
}
Reported by PMD.
Line: 6
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import junit.framework.TestCase;
public class NumberValueTest_error_7 extends TestCase {
Reported by PMD.
Line: 13
public class NumberValueTest_error_7 extends TestCase {
public void test_0() throws Exception {
Exception error = null;
try {
String text = "{\"value\":-";
JSON.parse(text);
} catch (Exception e) {
error = e;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/number/NumberValueTest.java
4 issues
Line: 12
public class NumberValueTest extends TestCase {
public void test_0() throws Exception {
String text = "{\"value\":3D}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertTrue(3D == ((Double)obj.get("value")).doubleValue());
}
Reported by PMD.
Line: 15
public void test_0() throws Exception {
String text = "{\"value\":3D}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertTrue(3D == ((Double)obj.get("value")).doubleValue());
}
public void test_1() throws Exception {
String text = "{\"value\":3.e3D}";
Reported by PMD.
Line: 19
}
public void test_1() throws Exception {
String text = "{\"value\":3.e3D}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertTrue(3.e3D == ((Double)obj.get("value")).doubleValue());
}
Reported by PMD.
Line: 22
public void test_1() throws Exception {
String text = "{\"value\":3.e3D}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertTrue(3.e3D == ((Double)obj.get("value")).doubleValue());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/DupSetterTest6.java
4 issues
Line: 21
public class DupSetterTest6 extends TestCase {
public void testDupSetter() {
VO vo = new VO();
vo.status = 3;
String json = JSONObject.toJSONString(vo);
VO vo2 = JSONObject.parseObject(json, VO.class);
Assert.assertEquals(3, vo2.status3);
Reported by PMD.
Line: 29
Assert.assertEquals(3, vo2.status3);
}
public static class VO {
public int status;
private int status2;
private int status3;
Reported by PMD.
Line: 32
public static class VO {
public int status;
private int status2;
private int status3;
public Integer getStatus() {
return status;
}
Reported by PMD.
Line: 33
public int status;
private int status2;
private int status3;
public Integer getStatus() {
return status;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/FloatArraySerializerTest.java
4 issues
Line: 12
public class FloatArraySerializerTest extends TestCase {
public void test_0() {
Assert.assertEquals("[]", JSON.toJSONString(new float[0]));
Assert.assertEquals("{\"value\":null}", JSON.toJSONString(new Entity(), SerializerFeature.WriteMapNullValue));
Assert.assertEquals("{\"value\":[]}", JSON.toJSONString(new Entity(), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
Assert.assertEquals("[1.0,2.0]", JSON.toJSONString(new float[] { 1, 2 }));
Assert.assertEquals("[1.0,2.0,3.0]", JSON.toJSONString(new float[] { 1, 2, 3 }));
Reported by PMD.
Line: 26
private float[] value;
public float[] getValue() {
return value;
}
public void setValue(float[] value) {
this.value = value;
}
Reported by PMD.
Line: 29
return value;
}
public void setValue(float[] value) {
this.value = value;
}
}
}
Reported by PMD.
Line: 29
return value;
}
public void setValue(float[] value) {
this.value = value;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/GenericTypeNotMatchTest2.java
4 issues
Line: 12
* Created by wenshao on 10/02/2017.
*/
public class GenericTypeNotMatchTest2 extends TestCase {
public void test_for_notMatch() throws Exception {
Model model = new Model();
Base base = model;
base.setId(BigInteger.valueOf(3));
Reported by PMD.
Line: 12
* Created by wenshao on 10/02/2017.
*/
public class GenericTypeNotMatchTest2 extends TestCase {
public void test_for_notMatch() throws Exception {
Model model = new Model();
Base base = model;
base.setId(BigInteger.valueOf(3));
Reported by PMD.
Line: 16
Model model = new Model();
Base base = model;
base.setId(BigInteger.valueOf(3));
JSON.toJSONString(base);
}
Reported by PMD.
Line: 27
}
public static class Base<T> {
private T xid;
public void setId(T id) {
this.xid = id;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/GenericTypeTest2.java
4 issues
Line: 11
public class GenericTypeTest2 extends TestCase {
public void test_gerneric() throws Exception {
MyResultResult result = new MyResultResult();
JSON.toJSONString(result);
}
public static class MyResultResult extends BaseResult<String> {
Reported by PMD.
Line: 11
public class GenericTypeTest2 extends TestCase {
public void test_gerneric() throws Exception {
MyResultResult result = new MyResultResult();
JSON.toJSONString(result);
}
public static class MyResultResult extends BaseResult<String> {
Reported by PMD.
Line: 20
}
public static class BaseResult<T> {
private T data;
public T getData() {
return data;
}
}
}
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.serializer;
import java.io.Serializable;
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
public class GenericTypeTest2 extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/IgnoreGetMethodTest.java
4 issues
Line: 25
public static class PayDO {
public Integer getCurrentSubPayOrder() {
throw new RuntimeException("non getter getXXX method should not be called");
}
}
}
Reported by PMD.
Line: 19
public void test() {
PayDO result = new PayDO();
String json = JSON.toJSONString(result, SerializerFeature.IgnoreNonFieldGetter);
System.out.println(json);
}
public static class PayDO {
public Integer getCurrentSubPayOrder() {
Reported by PMD.
Line: 16
// System.out.println(json);
// }
public void test() {
PayDO result = new PayDO();
String json = JSON.toJSONString(result, SerializerFeature.IgnoreNonFieldGetter);
System.out.println(json);
}
Reported by PMD.
Line: 16
// System.out.println(json);
// }
public void test() {
PayDO result = new PayDO();
String json = JSON.toJSONString(result, SerializerFeature.IgnoreNonFieldGetter);
System.out.println(json);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/typeRef/TypeReferenceTest4.java
4 issues
Line: 13
public class TypeReferenceTest4 extends TestCase {
public void test_typeRef() throws Exception {
TypeReference<VO<List<A>>> typeRef = new TypeReference<VO<List<A>>>() {
};
VO<List<A>> vo = JSON.parseObject("{\"list\":[{\"id\":123}]}", typeRef);
Reported by PMD.
Line: 19
VO<List<A>> vo = JSON.parseObject("{\"list\":[{\"id\":123}]}", typeRef);
Assert.assertEquals(123, vo.getList().get(0).getId());
}
public static class VO<T> {
private T list;
Reported by PMD.
Line: 19
VO<List<A>> vo = JSON.parseObject("{\"list\":[{\"id\":123}]}", typeRef);
Assert.assertEquals(123, vo.getList().get(0).getId());
}
public static class VO<T> {
private T list;
Reported by PMD.
Line: 19
VO<List<A>> vo = JSON.parseObject("{\"list\":[{\"id\":123}]}", typeRef);
Assert.assertEquals(123, vo.getList().get(0).getId());
}
public static class VO<T> {
private T list;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/IntArrayEncodeTest.java
4 issues
Line: 11
public class IntArrayEncodeTest extends TestCase {
public void test_0_s() throws Exception {
SerializeWriter out = new SerializeWriter(1);
JSONSerializer serializer = new JSONSerializer(out);
serializer.write(new int[] { 0, 1 });
Reported by PMD.
Line: 20
Assert.assertEquals("[0,1]", out.toString());
}
public void test_1_s() throws Exception {
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.write(new int[] {});
Reported by PMD.
Line: 29
Assert.assertEquals("[]", out.toString());
}
public void test_2_s() throws Exception {
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.write(new int[] { -2147483648 });
Reported by PMD.
Line: 38
Assert.assertEquals("[-2147483648]", out.toString());
}
public void test_3_s() throws Exception {
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
StringBuilder sb = new StringBuilder();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest3.java
4 issues
Line: 10
import com.alibaba.fastjson.annotation.JSONField;
public class JSONFieldTest3 extends TestCase {
public void test_jsonField() throws Exception {
VO vo = new VO();
vo.setId(123);
vo.setFlag(true);
Reported by PMD.
Line: 20
Assert.assertEquals("{\"id\":123}", text);
}
public static class VO {
private int id;
@JSONField(serialize = false)
private boolean _flag;
Reported by PMD.
Line: 24
private int id;
@JSONField(serialize = false)
private boolean _flag;
@JSONField(serialize = false)
private int _id2;
public int getId() {
Reported by PMD.
Line: 27
private boolean _flag;
@JSONField(serialize = false)
private int _id2;
public int getId() {
return id;
}
Reported by PMD.