The following issues were found
src/test/java/com/alibaba/json/bvt/typeRef/TypeReferenceTest2.java
3 issues
Line: 28
text = JSON.toJSONString(list);
}
System.out.println(text);
{
List<Bean> list = JSON.parseObject(text, new TypeReference<List<Bean>>() {}); // 注意这里
Assert.assertEquals(3, list.size());
Assert.assertEquals(123, ((Bean) list.get(0)).getId());
Reported by PMD.
Line: 16
public class TypeReferenceTest2 extends TestCase {
public void test_0() throws Exception {
String text;
{
List<Bean> list = new ArrayList<Bean>();
list.add(new Bean(123, "马加爵"));
Reported by PMD.
Line: 55
}
}
public static class Bean {
private int id;
private String name;
public Bean(){
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/IgoreGetterTest.java
3 issues
Line: 11
import java.io.Reader;
public class IgoreGetterTest extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
assertEquals("{}", JSON.toJSONString(vo));
}
public static class VO {
Reported by PMD.
Line: 13
public class IgoreGetterTest extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
assertEquals("{}", JSON.toJSONString(vo));
}
public static class VO {
public InputStream getInputStream() {
throw new UnsupportedOperationException();
Reported by PMD.
Line: 7
import junit.framework.TestCase;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
public class IgoreGetterTest extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/typeRef/TypeReferenceTest5.java
3 issues
Line: 13
public class TypeReferenceTest5 extends TestCase {
public void test_typeRef() throws Exception {
TypeReference<A<B>> typeRef = new TypeReference<A<B>>() {
};
A<B> a = JSON.parseObject("{\"body\":{\"id\":123}}", typeRef);
Reported by PMD.
Line: 19
A<B> a = JSON.parseObject("{\"body\":{\"id\":123}}", typeRef);
B b = a.getBody();
Assert.assertEquals(123, b.get("id"));
}
public static class A<T> {
Reported by PMD.
Line: 20
A<B> a = JSON.parseObject("{\"body\":{\"id\":123}}", typeRef);
B b = a.getBody();
Assert.assertEquals(123, b.get("id"));
}
public static class A<T> {
private T body;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/GenericTypeTest.java
3 issues
Line: 11
public class GenericTypeTest 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 GenericTypeTest 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: 19
public static class MyResultResult extends BaseResult<String> {
}
public static class BaseResult<T> implements Serializable {
public T data;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/GenericTypeNotMatchTest.java
3 issues
Line: 12
* Created by wenshao on 10/02/2017.
*/
public class GenericTypeNotMatchTest extends TestCase {
public void test_for_notMatch() throws Exception {
Model model = new Model();
Base base = model;
base.id = BigInteger.valueOf(3);
JSON.toJSONString(base);
}
Reported by PMD.
Line: 12
* Created by wenshao on 10/02/2017.
*/
public class GenericTypeNotMatchTest extends TestCase {
public void test_for_notMatch() throws Exception {
Model model = new Model();
Base base = model;
base.id = BigInteger.valueOf(3);
JSON.toJSONString(base);
}
Reported by PMD.
Line: 24
}
public static class Base<T> {
public T id;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_containsValue.java
3 issues
Line: 13
import junit.framework.TestCase;
public class JSONPath_containsValue extends TestCase {
public void test_root() throws Exception {
List list = new ArrayList();
list.add("kiki");
list.add("ljw2083");
list.add("wenshao");
Reported by PMD.
Line: 15
public class JSONPath_containsValue extends TestCase {
public void test_root() throws Exception {
List list = new ArrayList();
list.add("kiki");
list.add("ljw2083");
list.add("wenshao");
Assert.assertTrue(JSONPath.containsValue(list, "/0", "kiki"));
Assert.assertFalse(JSONPath.containsValue(list, "/0", "kiki_"));
Reported by PMD.
Line: 32
Assert.assertTrue(JSONPath.contains(list, "/2"));
Assert.assertFalse(JSONPath.contains(list, "/3"));
Assert.assertFalse(JSONPath.contains(null, "$"));
Assert.assertFalse(JSONPath.compile("$").contains(null));
Assert.assertFalse(JSONPath.containsValue(null, "$", "kiki"));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/AfterFilterTest2.java
3 issues
Line: 12
import com.alibaba.fastjson.serializer.BeforeFilter;
public class AfterFilterTest2 extends TestCase {
public void test_afterFilter() throws Exception {
AfterFilter filter = new AfterFilter() {
@Override
public void writeAfter(Object object) {
this.writeKeyValue("id", 123);
Reported by PMD.
Line: 23
Assert.assertEquals("{\"id\":123}",JSON.toJSONString( new VO(), filter));
}
public void test_afterFilter2() throws Exception {
AfterFilter filter = new AfterFilter() {
@Override
public void writeAfter(Object object) {
this.writeKeyValue("id", 123);
Reported by PMD.
Line: 9
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.AfterFilter;
import com.alibaba.fastjson.serializer.BeforeFilter;
public class AfterFilterTest2 extends TestCase {
public void test_afterFilter() throws Exception {
AfterFilter filter = new AfterFilter() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/FloatTest.java
3 issues
Line: 10
public class FloatTest extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals("null", JSON.toJSONString(Float.NaN));
Assert.assertEquals("null", JSON.toJSONString(Double.NaN));
Assert.assertEquals("null", JSON.toJSONString(Float.POSITIVE_INFINITY));
Assert.assertEquals("null", JSON.toJSONString(Float.NEGATIVE_INFINITY));
Assert.assertEquals("null", JSON.toJSONString(Double.NaN));
Reported by PMD.
Line: 11
public class FloatTest extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals("null", JSON.toJSONString(Float.NaN));
Assert.assertEquals("null", JSON.toJSONString(Double.NaN));
Assert.assertEquals("null", JSON.toJSONString(Float.POSITIVE_INFINITY));
Assert.assertEquals("null", JSON.toJSONString(Float.NEGATIVE_INFINITY));
Assert.assertEquals("null", JSON.toJSONString(Double.NaN));
Assert.assertEquals("null", JSON.toJSONString(Double.POSITIVE_INFINITY));
Reported by PMD.
Line: 34
Assert.assertEquals(null, JSON.parseObject(JSON.toJSONString(new Bean(Float.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY))).get("f2"));
}
public static class Bean {
private float f1 = Float.NaN;
private double f2 = Double.NaN;
public Bean() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/FloatFormatTest2.java
3 issues
Line: 11
* Created by wenshao on 09/01/2017.
*/
public class FloatFormatTest2 extends TestCase {
public void test_format() throws Exception {
Model model = new Model();
model.value = 123.45678F;
String str = JSON.toJSONString(model);
assertEquals("{\"value\":123.46}", str);
Reported by PMD.
Line: 16
model.value = 123.45678F;
String str = JSON.toJSONString(model);
assertEquals("{\"value\":123.46}", str);
}
public static class Model {
@JSONField(format = "0.00")
public Float value;
Reported by PMD.
Line: 21
public static class Model {
@JSONField(format = "0.00")
public Float value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/FloatFormatTest.java
3 issues
Line: 11
* Created by wenshao on 09/01/2017.
*/
public class FloatFormatTest extends TestCase {
public void test_format() throws Exception {
Model model = new Model();
model.value = 123.45678F;
String str = JSON.toJSONString(model);
assertEquals("{\"value\":123.46}", str);
Reported by PMD.
Line: 16
model.value = 123.45678F;
String str = JSON.toJSONString(model);
assertEquals("{\"value\":123.46}", str);
}
public static class Model {
@JSONField(format = "0.00")
public float value;
Reported by PMD.
Line: 21
public static class Model {
@JSONField(format = "0.00")
public float value;
}
}
Reported by PMD.