The following issues were found
src/test/java/com/alibaba/json/bvt/path/JSONPath_11.java
5 issues
Line: 36
"]";
JSONArray array = JSON.parseArray(json);
System.out.println(JSONPath.eval(array, "$[0,1][CN='t1c1CN']"));
}
// public void test_path_2() throws Exception {
//// File file = new File("/Users/wenshao/Downloads/test");
//// String json = FileUtils.readFileToString(file);
Reported by PMD.
Line: 11
public class JSONPath_11 extends TestCase {
public void test(){
String json = "[\n" +
" [\n" +
" {\n" +
" \"CN\": \"t1c1CN\",\n" +
" \"FP\": \"t1c1FP\"\n" +
Reported by PMD.
Line: 11
public class JSONPath_11 extends TestCase {
public void test(){
String json = "[\n" +
" [\n" +
" {\n" +
" \"CN\": \"t1c1CN\",\n" +
" \"FP\": \"t1c1FP\"\n" +
Reported by PMD.
Line: 14
public void test(){
String json = "[\n" +
" [\n" +
" {\n" +
" \"CN\": \"t1c1CN\",\n" +
" \"FP\": \"t1c1FP\"\n" +
" },\n" +
" {\n" +
" \"CN\": \"t1c2CN\",\n" +
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import junit.framework.TestCase;
public class JSONPath_11 extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/str/StringTest_00.java
5 issues
Line: 14
public class StringTest_00 extends TestCase {
public void test_string() throws Exception {
char[] chars = new char[1024];
Arrays.fill(chars, '0');
StringBuilder buf = new StringBuilder();
buf.append("[\"");
for (int i = 0; i < 16; ++i) {
Reported by PMD.
Line: 21
buf.append("[\"");
for (int i = 0; i < 16; ++i) {
buf.append("\\\\");
buf.append(new String(chars));
}
buf.append("\"]");
String text = buf.toString();
JSONArray array = (JSONArray) JSON.parse(text);
Reported by PMD.
Line: 27
String text = buf.toString();
JSONArray array = (JSONArray) JSON.parse(text);
Assert.assertEquals(1, array.size());
String item = (String) array.get(0);
Assert.assertEquals(16 * 1024 + 16, item.length());
for (int i = 0; i < 16; ++i) {
Reported by PMD.
Line: 29
JSONArray array = (JSONArray) JSON.parse(text);
Assert.assertEquals(1, array.size());
String item = (String) array.get(0);
Assert.assertEquals(16 * 1024 + 16, item.length());
for (int i = 0; i < 16; ++i) {
Assert.assertTrue(item.charAt(i * 1025) == '\\');
for (int j = 0; j < 1024; ++j) {
Reported by PMD.
Line: 30
Assert.assertEquals(1, array.size());
String item = (String) array.get(0);
Assert.assertEquals(16 * 1024 + 16, item.length());
for (int i = 0; i < 16; ++i) {
Assert.assertTrue(item.charAt(i * 1025) == '\\');
for (int j = 0; j < 1024; ++j) {
Assert.assertTrue(item.charAt(i * 1025 + j + 1) == '0');
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest9.java
5 issues
Line: 14
public class RefTest9 extends TestCase {
public void test_bug_for_wanglin() throws Exception {
VO vo = new VO();
A a = new A();
vo.setA(a);
vo.getValues().add(a);
Reported by PMD.
Line: 18
VO vo = new VO();
A a = new A();
vo.setA(a);
vo.getValues().add(a);
String text = JSON.toJSONString(vo);
Assert.assertEquals("{\"a\":{},\"values\":[{\"$ref\":\"$.a\"}]}", text);
VO vo2 = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 23
String text = JSON.toJSONString(vo);
Assert.assertEquals("{\"a\":{},\"values\":[{\"$ref\":\"$.a\"}]}", text);
VO vo2 = JSON.parseObject(text, VO.class);
}
public static class VO {
private A a;
Reported by PMD.
Line: 26
VO vo2 = JSON.parseObject(text, VO.class);
}
public static class VO {
private A a;
private Set<A> values = new HashSet<A>();
public A getA() {
Reported by PMD.
Line: 23
String text = JSON.toJSONString(vo);
Assert.assertEquals("{\"a\":{},\"values\":[{\"$ref\":\"$.a\"}]}", text);
VO vo2 = JSON.parseObject(text, VO.class);
}
public static class VO {
private A a;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/MapDeserializerTest.java
5 issues
Line: 11
import com.alibaba.fastjson.JSON;
public class MapDeserializerTest extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.deser.MapDeserializerTest.");
}
public void test_0() throws Exception {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.MapDeserializerTest$MyMap\"}", Map.class);
Reported by PMD.
Line: 12
public class MapDeserializerTest extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.deser.MapDeserializerTest.");
}
public void test_0() throws Exception {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.MapDeserializerTest$MyMap\"}", Map.class);
}
Reported by PMD.
Line: 15
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.deser.MapDeserializerTest.");
}
public void test_0() throws Exception {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.MapDeserializerTest$MyMap\"}", Map.class);
}
public static class MyMap extends HashMap {
public MyMap () {
Reported by PMD.
Line: 15
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.deser.MapDeserializerTest.");
}
public void test_0() throws Exception {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.MapDeserializerTest$MyMap\"}", Map.class);
}
public static class MyMap extends HashMap {
public MyMap () {
Reported by PMD.
Line: 19
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.deser.MapDeserializerTest$MyMap\"}", Map.class);
}
public static class MyMap extends HashMap {
public MyMap () {
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/TestSpecial2.java
5 issues
Line: 20
VO vo = new VO();
vo.setValue(buf.toString());
System.out.println(JSON.toJSONString(vo));
}
public static class VO {
private String value;
Reported by PMD.
Line: 9
public class TestSpecial2 extends TestCase {
public void test_0() throws Exception {
StringBuilder buf = new StringBuilder();
buf.append('\r');
buf.append('\r');
for (int i = 0; i < 1000; ++i) {
buf.append((char) 160);
Reported by PMD.
Line: 9
public class TestSpecial2 extends TestCase {
public void test_0() throws Exception {
StringBuilder buf = new StringBuilder();
buf.append('\r');
buf.append('\r');
for (int i = 0; i < 1000; ++i) {
buf.append((char) 160);
Reported by PMD.
Line: 11
public void test_0() throws Exception {
StringBuilder buf = new StringBuilder();
buf.append('\r');
buf.append('\r');
for (int i = 0; i < 1000; ++i) {
buf.append((char) 160);
}
Reported by PMD.
Line: 11
public void test_0() throws Exception {
StringBuilder buf = new StringBuilder();
buf.append('\r');
buf.append('\r');
for (int i = 0; i < 1000; ++i) {
buf.append((char) 160);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_enum.java
5 issues
Line: 11
public class JSONPath_enum extends TestCase {
public void test_name() throws Exception {
Model model = new Model();
model.size = Size.Small;
Assert.assertEquals(Size.Small.name(), JSONPath.eval(model, "$.size.name"));
}
Reported by PMD.
Line: 15
Model model = new Model();
model.size = Size.Small;
Assert.assertEquals(Size.Small.name(), JSONPath.eval(model, "$.size.name"));
}
public void test_orginal() throws Exception {
Model model = new Model();
model.size = Size.Small;
Reported by PMD.
Line: 18
Assert.assertEquals(Size.Small.name(), JSONPath.eval(model, "$.size.name"));
}
public void test_orginal() throws Exception {
Model model = new Model();
model.size = Size.Small;
Assert.assertEquals(Size.Small.ordinal(), JSONPath.eval(model, "$.size.ordinal"));
}
Reported by PMD.
Line: 22
Model model = new Model();
model.size = Size.Small;
Assert.assertEquals(Size.Small.ordinal(), JSONPath.eval(model, "$.size.ordinal"));
}
public static class Model {
public Size size;
}
Reported by PMD.
Line: 26
}
public static class Model {
public Size size;
}
public static enum Size {
Big, Median, Small
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_3.java
5 issues
Line: 11
public class SerializeWriterTest_3 extends TestCase {
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.writeFieldValue(',', "name", "jobs");
Assert.assertEquals(",\"name\":\"jobs\"", out.toString());
}
Reported by PMD.
Line: 14
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.writeFieldValue(',', "name", "jobs");
Assert.assertEquals(",\"name\":\"jobs\"", out.toString());
}
public void test_1() throws Exception {
SerializeWriter out = new SerializeWriter(1);
Reported by PMD.
Line: 18
Assert.assertEquals(",\"name\":\"jobs\"", out.toString());
}
public void test_1() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, false);
out.writeFieldValue(',', "name", "jobs");
Assert.assertEquals(",name:\"jobs\"", out.toString());
}
Reported by PMD.
Line: 25
Assert.assertEquals(",name:\"jobs\"", out.toString());
}
public void test_null() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.writeFieldValue(',', "name", (String) null);
Assert.assertEquals(",\"name\":null", out.toString());
}
Reported by PMD.
Line: 32
Assert.assertEquals(",\"name\":null", out.toString());
}
public void test_null_1() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, false);
out.writeFieldValue(',', "name", (String) null);
Assert.assertEquals(",name:null", out.toString());
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/LongArraySerializerTest.java
5 issues
Line: 13
public class LongArraySerializerTest extends TestCase {
public void test_0() {
Assert.assertEquals("[]", JSON.toJSONString(new long[0]));
Assert.assertEquals("[1,2]", JSON.toJSONString(new long[] { 1, 2 }));
Assert.assertEquals("[1,2,3,-4]", JSON.toJSONString(new long[] { 1, 2, 3, -4 }));
Assert.assertEquals("{\"value\":null}", JSON.toJSONString(new Entity(), SerializerFeature.WriteMapNullValue));
Assert.assertEquals("{\"value\":[]}", JSON.toJSONString(new Entity(), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
Reported by PMD.
Line: 26
private long[] value;
public long[] getValue() {
return value;
}
public void setValue(long[] value) {
this.value = value;
}
Reported by PMD.
Line: 29
return value;
}
public void setValue(long[] value) {
this.value = value;
}
}
}
Reported by PMD.
Line: 8
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializeWriter;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class LongArraySerializerTest extends TestCase {
public void test_0() {
Reported by PMD.
Line: 29
return value;
}
public void setValue(long[] value) {
this.value = value;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/typeRef/TypeReferenceTest10.java
5 issues
Line: 13
* Created by wenshao on 2016/10/11.
*/
public class TypeReferenceTest10 extends TestCase {
public void test_same() throws Exception {
Type type1 = getType();
Type type2 = getType();
assertEquals(type1, type2);
assertSame(type1, type2);
Reported by PMD.
Line: 13
* Created by wenshao on 2016/10/11.
*/
public class TypeReferenceTest10 extends TestCase {
public void test_same() throws Exception {
Type type1 = getType();
Type type2 = getType();
assertEquals(type1, type2);
assertSame(type1, type2);
Reported by PMD.
Line: 17
Type type1 = getType();
Type type2 = getType();
assertEquals(type1, type2);
assertSame(type1, type2);
}
Type getType() {
return new TypeReference<Model<Integer>>() {}.getType();
Reported by PMD.
Line: 18
Type type2 = getType();
assertEquals(type1, type2);
assertSame(type1, type2);
}
Type getType() {
return new TypeReference<Model<Integer>>() {}.getType();
}
Reported by PMD.
Line: 5
import com.alibaba.fastjson.TypeReference;
import junit.framework.TestCase;
import org.junit.Assert;
import java.lang.reflect.Type;
/**
* Created by wenshao on 2016/10/11.
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/IntegerArrayFieldSerializerTest.java
5 issues
Line: 11
public class IntegerArrayFieldSerializerTest extends TestCase {
public void test_0() throws Exception {
A a1 = new A();
a1.setBytes(new int[] { 1, 2 });
Assert.assertEquals("{\"bytes\":[1,2]}", JSON.toJSONString(a1));
}
Reported by PMD.
Line: 18
Assert.assertEquals("{\"bytes\":[1,2]}", JSON.toJSONString(a1));
}
public void test_1() throws Exception {
A a1 = new A();
Assert.assertEquals("{\"bytes\":null}", JSON.toJSONString(a1, SerializerFeature.WriteMapNullValue));
}
Reported by PMD.
Line: 29
private int[] bytes;
public int[] getBytes() {
return bytes;
}
public void setBytes(int[] bytes) {
this.bytes = bytes;
}
Reported by PMD.
Line: 32
return bytes;
}
public void setBytes(int[] bytes) {
this.bytes = bytes;
}
}
}
Reported by PMD.
Line: 32
return bytes;
}
public void setBytes(int[] bytes) {
this.bytes = bytes;
}
}
}
Reported by PMD.