The following issues were found
src/test/java/com/alibaba/json/bvt/parser/stream/JSONReaderTest.java
4 issues
Line: 15
import com.alibaba.fastjson.JSONReader;
public class JSONReaderTest extends TestCase {
public void test_read() throws Exception {
String resource = "2.json";
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
JSONReader reader = new JSONReader(new InputStreamReader(is, "UTF-8"));
Reported by PMD.
Line: 17
public class JSONReaderTest extends TestCase {
public void test_read() throws Exception {
String resource = "2.json";
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
JSONReader reader = new JSONReader(new InputStreamReader(is, "UTF-8"));
reader.startObject();
Reported by PMD.
Line: 17
public class JSONReaderTest extends TestCase {
public void test_read() throws Exception {
String resource = "2.json";
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
JSONReader reader = new JSONReader(new InputStreamReader(is, "UTF-8"));
reader.startObject();
Reported by PMD.
Line: 17
public class JSONReaderTest extends TestCase {
public void test_read() throws Exception {
String resource = "2.json";
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
JSONReader reader = new JSONReader(new InputStreamReader(is, "UTF-8"));
reader.startObject();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_0_private.java
4 issues
Line: 12
import com.alibaba.fastjson.serializer.SerializerFeature;
public class WriteAsArray_0_private extends TestCase {
public void test_0 () throws Exception {
VO vo = new VO();
vo.setId(123);
vo.setName("wenshao");
String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);
Reported by PMD.
Line: 20
String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);
Assert.assertEquals("[123,\"wenshao\"]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
}
private static class VO {
private int id;
Reported by PMD.
Line: 21
Assert.assertEquals("[123,\"wenshao\"]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
}
private static class VO {
private int id;
private String name;
Reported by PMD.
Line: 24
Assert.assertEquals(vo.getName(), vo2.getName());
}
private static class VO {
private int id;
private String name;
public int getId() {
return id;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/TestSpecial_4.java
4 issues
Line: 12
public class TestSpecial_4 extends TestCase {
public void test_special() throws Exception {
String json = "{\"大小\":123}";
JSONObject object = JSON.parseObject(json);
Object obj = JSONPath.eval(object, "$.大小");
assertEquals(123, obj);
}
Reported by PMD.
Line: 16
String json = "{\"大小\":123}";
JSONObject object = JSON.parseObject(json);
Object obj = JSONPath.eval(object, "$.大小");
assertEquals(123, obj);
}
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.path;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import com.alibaba.fastjson.parser.Feature;
import junit.framework.TestCase;
Reported by PMD.
Line: 7
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import com.alibaba.fastjson.parser.Feature;
import junit.framework.TestCase;
public class TestSpecial_4 extends TestCase {
public void test_special() throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest.java
4 issues
Line: 13
public class RefTest extends TestCase {
public void test_ref() throws Exception {
JSONSerializer ser = new JSONSerializer();
Assert.assertFalse(ser.containsReference(null));
}
public void test_array_ref() throws Exception {
Reported by PMD.
Line: 18
Assert.assertFalse(ser.containsReference(null));
}
public void test_array_ref() throws Exception {
JSON.toJSONString(new A[] {new A()}, SerializerFeature.DisableCircularReferenceDetect);
}
public class A {
Reported by PMD.
Line: 18
Assert.assertFalse(ser.containsReference(null));
}
public void test_array_ref() throws Exception {
JSON.toJSONString(new A[] {new A()}, SerializerFeature.DisableCircularReferenceDetect);
}
public class A {
Reported by PMD.
Line: 24
public class A {
private A a;
public A getA() {
return a;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/stream/JSONReaderTest_4.java
4 issues
Line: 13
public class JSONReaderTest_4 extends TestCase {
public void test_read_Long() throws Exception {
String text = "1001";
JSONReader reader = new JSONReader(new MyReader(text));
}
Reported by PMD.
Line: 13
public class JSONReaderTest_4 extends TestCase {
public void test_read_Long() throws Exception {
String text = "1001";
JSONReader reader = new JSONReader(new MyReader(text));
}
Reported by PMD.
Line: 15
public void test_read_Long() throws Exception {
String text = "1001";
JSONReader reader = new JSONReader(new MyReader(text));
}
public static class MyReader extends BufferedReader {
Reported by PMD.
Line: 15
public void test_read_Long() throws Exception {
String text = "1001";
JSONReader reader = new JSONReader(new MyReader(text));
}
public static class MyReader extends BufferedReader {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/generic/GenericTest3.java
4 issues
Line: 12
public class GenericTest3 extends TestCase {
public static class A<T> {
public B<T> b;
}
public static class B<T> {
public T value;
}
Reported by PMD.
Line: 16
}
public static class B<T> {
public T value;
}
public static class ValueObject {
public String property1;
public int property2;
Reported by PMD.
Line: 24
public int property2;
}
public void test_generic() throws Exception {
A<ValueObject> object = JSON.parseObject(
"{b:{value:{property1:'string',property2:123}}}",
new TypeReference<A<ValueObject>>() {
});
Reported by PMD.
Line: 30
new TypeReference<A<ValueObject>>() {
});
Assert.assertEquals(ValueObject.class, object.b.value.getClass());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest18.java
4 issues
Line: 12
import junit.framework.TestCase;
public class RefTest18 extends TestCase {
public void test_array() throws Exception {
String text = "{\"b\":{},\"a\":[{\"$ref\":\"$.b\"}]}";
JSONObject obj = JSON.parseObject(text);
JSONArray array = obj.getJSONArray("a");
Assert.assertEquals(1, array.size());
Reported by PMD.
Line: 16
String text = "{\"b\":{},\"a\":[{\"$ref\":\"$.b\"}]}";
JSONObject obj = JSON.parseObject(text);
JSONArray array = obj.getJSONArray("a");
Assert.assertEquals(1, array.size());
Assert.assertNotNull(array.get(0));
}
}
Reported by PMD.
Line: 17
JSONObject obj = JSON.parseObject(text);
JSONArray array = obj.getJSONArray("a");
Assert.assertEquals(1, array.size());
Assert.assertNotNull(array.get(0));
}
}
Reported by PMD.
Line: 18
JSONObject obj = JSON.parseObject(text);
JSONArray array = obj.getJSONArray("a");
Assert.assertEquals(1, array.size());
Assert.assertNotNull(array.get(0));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest21.java
4 issues
Line: 15
public void test_ref() throws Exception {
String jsonTest = "{\"details\":{\"type\":{\"items\":{\"allOf\":[{\"$ref\":\"title\",\"required\":[\"iconImg\"]}]}}}}";
JSONObject object = JSON.parseObject(jsonTest, Feature.DisableSpecialKeyDetect);
System.out.println( object.get( "details"));
}
}
Reported by PMD.
Line: 12
* Created by wenshao on 16/8/23.
*/
public class RefTest21 extends TestCase {
public void test_ref() throws Exception {
String jsonTest = "{\"details\":{\"type\":{\"items\":{\"allOf\":[{\"$ref\":\"title\",\"required\":[\"iconImg\"]}]}}}}";
JSONObject object = JSON.parseObject(jsonTest, Feature.DisableSpecialKeyDetect);
System.out.println( object.get( "details"));
}
}
Reported by PMD.
Line: 12
* Created by wenshao on 16/8/23.
*/
public class RefTest21 extends TestCase {
public void test_ref() throws Exception {
String jsonTest = "{\"details\":{\"type\":{\"items\":{\"allOf\":[{\"$ref\":\"title\",\"required\":[\"iconImg\"]}]}}}}";
JSONObject object = JSON.parseObject(jsonTest, Feature.DisableSpecialKeyDetect);
System.out.println( object.get( "details"));
}
}
Reported by PMD.
Line: 15
public void test_ref() throws Exception {
String jsonTest = "{\"details\":{\"type\":{\"items\":{\"allOf\":[{\"$ref\":\"title\",\"required\":[\"iconImg\"]}]}}}}";
JSONObject object = JSON.parseObject(jsonTest, Feature.DisableSpecialKeyDetect);
System.out.println( object.get( "details"));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest6.java
4 issues
Line: 29
jsonObject.put("c", c);
String text = JSON.toJSONString(jsonObject, SerializerFeature.PrettyFormat);
System.out.println(text);
}
private class A {
private B b;
Reported by PMD.
Line: 16
*
* @throws Exception
*/
public void test_0() throws Exception {
A a = new A();
B b = new B();
C c = new C();
a.setB(b);
b.setC(c);
Reported by PMD.
Line: 16
*
* @throws Exception
*/
public void test_0() throws Exception {
A a = new A();
B b = new B();
C c = new C();
a.setB(b);
b.setC(c);
Reported by PMD.
Line: 45
}
}
private class B {
private C c;
private A a;
public C getC() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/error/ParseErrorTest_date.java
4 issues
Line: 14
public class ParseErrorTest_date extends TestCase {
public void test_for_error() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"value\":\"2011-01-09M\"}", Model.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 24
Assert.assertNotNull(error);
}
public void test_for_error_1() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"value\":\"2011-01-09", Model.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 15
public class ParseErrorTest_date extends TestCase {
public void test_for_error() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"value\":\"2011-01-09M\"}", Model.class);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
Line: 25
}
public void test_for_error_1() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"value\":\"2011-01-09", Model.class);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.