The following issues were found
src/test/java/com/alibaba/json/bvt/path/JSONPath_field_access_filter_notNull.java
5 issues
Line: 14
public class JSONPath_field_access_filter_notNull extends TestCase {
public void test_list_map() throws Exception {
JSONPath path = new JSONPath("$[?(@.name)]");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
Reported by PMD.
Line: 23
entities.add(new Entity(1003, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(2, result.size());
Assert.assertSame(entities.get(0), result.get(0));
Assert.assertSame(entities.get(1), result.get(1));
}
public static class Entity {
Reported by PMD.
Line: 24
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(2, result.size());
Assert.assertSame(entities.get(0), result.get(0));
Assert.assertSame(entities.get(1), result.get(1));
}
public static class Entity {
Reported by PMD.
Line: 25
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(2, result.size());
Assert.assertSame(entities.get(0), result.get(0));
Assert.assertSame(entities.get(1), result.get(1));
}
public static class Entity {
private Integer id;
Reported by PMD.
Line: 28
Assert.assertSame(entities.get(1), result.get(1));
}
public static class Entity {
private Integer id;
private String name;
public Entity(Integer id, String name){
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/deny/DenyTest.java
5 issues
Line: 14
public class DenyTest extends TestCase {
public void test_0() throws Exception {
String text = "{}";
ParserConfig config = new ParserConfig();
config.addDeny(null);
Reported by PMD.
Line: 33
JSON.parseObject(text, B.class, config, JSON.DEFAULT_PARSER_FEATURE);
}
public void test_1() throws Exception {
String text = "{}";
ParserConfig config = new ParserConfig();
config.addDeny(null);
Reported by PMD.
Line: 8
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.json.bvtVO.deny.A;
import junit.framework.TestCase;
public class DenyTest extends TestCase {
Reported by PMD.
Line: 22
config.addDeny(null);
config.addDeny("com.alibaba.json.bvtVO.deny");
Exception error = null;
try {
JSON.parseObject("{\"@type\":\"com.alibaba.json.bvtVO.deny$A\"}", Object.class, config, JSON.DEFAULT_PARSER_FEATURE);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
Line: 41
config.addDeny(null);
config.addDeny("com.alibaba.json.bvt.parser.deser.deny.DenyTest.B");
Exception error = null;
try {
JSON.parseObject("{\"@type\":\"LLLcom.alibaba.json.bvt.parser.deser.deny.DenyTest$B;;;\"}", Object.class, config, JSON.DEFAULT_PARSER_FEATURE);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/JavaBeanSerializerTest2.java
5 issues
Line: 12
public class JavaBeanSerializerTest2 extends TestCase {
public void test_0() throws Exception {
new JavaBeanSerializer(A.class, Collections.<String, String> emptyMap());
}
public static class A {
Reported by PMD.
Line: 12
public class JavaBeanSerializerTest2 extends TestCase {
public void test_0() throws Exception {
new JavaBeanSerializer(A.class, Collections.<String, String> emptyMap());
}
public static class A {
Reported by PMD.
Line: 16
new JavaBeanSerializer(A.class, Collections.<String, String> emptyMap());
}
public static class A {
@JSONField(name = "uid")
private int id;
private String name;
Reported by PMD.
Line: 31
private byte[] bytes;
public byte[] getBytes() {
return bytes;
}
public void setBytes(byte[] bytes) {
this.bytes = bytes;
}
Reported by PMD.
Line: 34
return bytes;
}
public void setBytes(byte[] bytes) {
this.bytes = bytes;
}
public boolean isB2() {
return b2;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/CollectionFieldTest.java
5 issues
Line: 12
public class CollectionFieldTest extends TestCase {
public void test_null() throws Exception {
Entity value = JSON.parseObject("{value:null}", Entity.class);
Assert.assertNull(value.getValue());
}
public void test_empty() throws Exception {
Reported by PMD.
Line: 14
public void test_null() throws Exception {
Entity value = JSON.parseObject("{value:null}", Entity.class);
Assert.assertNull(value.getValue());
}
public void test_empty() throws Exception {
Entity value = JSON.parseObject("{value:[]}", Entity.class);
Assert.assertEquals(0, value.getValue().size());
Reported by PMD.
Line: 17
Assert.assertNull(value.getValue());
}
public void test_empty() throws Exception {
Entity value = JSON.parseObject("{value:[]}", Entity.class);
Assert.assertEquals(0, value.getValue().size());
}
private static class Entity {
Reported by PMD.
Line: 19
public void test_empty() throws Exception {
Entity value = JSON.parseObject("{value:[]}", Entity.class);
Assert.assertEquals(0, value.getValue().size());
}
private static class Entity {
private Collection value;
Reported by PMD.
Line: 19
public void test_empty() throws Exception {
Entity value = JSON.parseObject("{value:[]}", Entity.class);
Assert.assertEquals(0, value.getValue().size());
}
private static class Entity {
private Collection value;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/JSONTypeIncludesTest.java
5 issues
Line: 15
model.name = "wenshao";
String text = JSON.toJSONString(model);
System.out.println(text);
}
@JSONType(includes="name")
public static class Model {
public int id;
Reported by PMD.
Line: 9
import junit.framework.TestCase;
public class JSONTypeIncludesTest extends TestCase {
public void test_includes() throws Exception {
Model model = new Model();
model.id = 1001;
model.name = "wenshao";
String text = JSON.toJSONString(model);
Reported by PMD.
Line: 9
import junit.framework.TestCase;
public class JSONTypeIncludesTest extends TestCase {
public void test_includes() throws Exception {
Model model = new Model();
model.id = 1001;
model.name = "wenshao";
String text = JSON.toJSONString(model);
Reported by PMD.
Line: 20
@JSONType(includes="name")
public static class Model {
public int id;
public String name;
}
}
Reported by PMD.
Line: 21
@JSONType(includes="name")
public static class Model {
public int id;
public String name;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest24.java
5 issues
Line: 18
*/
public class RefTest24
extends TestCase {
public void test_ref() throws Exception {
ByteCodeDO codeDO = new ByteCodeDO();
codeDO.id = 1001;
Map<String, Object> data = new LinkedHashMap();
Map<String, Object> m1 = new LinkedHashMap();
Reported by PMD.
Line: 33
Object o = JSON.parseObject(str, Feature.OrderedField);
assertEquals(str, JSON.toJSONString(o, SerializerFeature.WriteMapNullValue));
}
public static class ByteCodeDO {
public int id;
}
Reported by PMD.
Line: 37
}
public static class ByteCodeDO {
public int id;
}
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.ref;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import java.util.HashMap;
Reported by PMD.
Line: 9
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* Created by wenshao on 16/8/23.
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_7.java
5 issues
Line: 11
public class SerializeWriterTest_7 extends TestCase {
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.UseSingleQuotes, true);
out.writeFieldValue(',', "name", (Enum) null);
Assert.assertEquals(",'name':null", out.toString());
Reported by PMD.
Line: 19
Assert.assertEquals(",'name':null", out.toString());
}
public void test_1() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, true);
out.config(SerializerFeature.UseSingleQuotes, true);
out.writeFieldName("名称");
Assert.assertEquals("'名称':", out.toString());
Reported by PMD.
Line: 27
Assert.assertEquals("'名称':", out.toString());
}
public void test_2() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, false);
out.writeFieldName("名称");
Assert.assertEquals("名称:", out.toString());
}
Reported by PMD.
Line: 34
Assert.assertEquals("名称:", out.toString());
}
public void test_3() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, false);
out.writeFieldName("a\n\n\n\n");
Assert.assertEquals("\"a\\n\\n\\n\\n\":", out.toString());
}
Reported by PMD.
Line: 41
Assert.assertEquals("\"a\\n\\n\\n\\n\":", out.toString());
}
public void test_4() throws Exception {
SerializeWriter out = new SerializeWriter(1);
out.config(SerializerFeature.QuoteFieldNames, false);
out.config(SerializerFeature.UseSingleQuotes, true);
out.writeFieldName("a\n\n\n\n");
Assert.assertEquals("'a\\n\\n\\n\\n':", out.toString());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/TestSpecial3.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 TestSpecial3 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('\u000B');
Reported by PMD.
Line: 9
public class TestSpecial3 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('\u000B');
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('\u000B');
}
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('\u000B');
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/PatternDeserializerTest.java
5 issues
Line: 17
public class PatternDeserializerTest extends TestCase {
public void test_pattern() throws Exception {
Assert.assertEquals(Pattern.compile("abc").pattern(), JSON.parseObject("'abc'", Pattern.class).pattern());
Assert.assertEquals(null, JSON.parseObject("null", Pattern.class));
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
Reported by PMD.
Line: 18
public class PatternDeserializerTest extends TestCase {
public void test_pattern() throws Exception {
Assert.assertEquals(Pattern.compile("abc").pattern(), JSON.parseObject("'abc'", Pattern.class).pattern());
Assert.assertEquals(null, JSON.parseObject("null", Pattern.class));
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));
Reported by PMD.
Line: 18
public class PatternDeserializerTest extends TestCase {
public void test_pattern() throws Exception {
Assert.assertEquals(Pattern.compile("abc").pattern(), JSON.parseObject("'abc'", Pattern.class).pattern());
Assert.assertEquals(null, JSON.parseObject("null", Pattern.class));
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));
Reported by PMD.
Line: 23
Assert.assertEquals(null, JSON.parseObject("null", Pattern.class));
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));
Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
}
}
Reported by PMD.
Line: 24
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));
Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_deepScan_test.java
5 issues
Line: 16
public class JSONPath_deepScan_test extends TestCase {
@SuppressWarnings({ "rawtypes", "unchecked" })
public void test_0() throws Exception {
Map root = Collections.singletonMap("company", //
Collections.singletonMap("departs", //
Arrays.asList( //
Collections.singletonMap("id",
Reported by PMD.
Line: 30
));
List<Object> ids = (List<Object>) JSONPath.eval(root, "$..id");
Assert.assertEquals(3, ids.size());
Assert.assertEquals(1001, ids.get(0));
Assert.assertEquals(1002, ids.get(1));
Assert.assertEquals(1003, ids.get(2));
}
Reported by PMD.
Line: 31
List<Object> ids = (List<Object>) JSONPath.eval(root, "$..id");
Assert.assertEquals(3, ids.size());
Assert.assertEquals(1001, ids.get(0));
Assert.assertEquals(1002, ids.get(1));
Assert.assertEquals(1003, ids.get(2));
}
public static class Root {
Reported by PMD.
Line: 32
List<Object> ids = (List<Object>) JSONPath.eval(root, "$..id");
Assert.assertEquals(3, ids.size());
Assert.assertEquals(1001, ids.get(0));
Assert.assertEquals(1002, ids.get(1));
Assert.assertEquals(1003, ids.get(2));
}
public static class Root {
Reported by PMD.
Line: 33
Assert.assertEquals(3, ids.size());
Assert.assertEquals(1001, ids.get(0));
Assert.assertEquals(1002, ids.get(1));
Assert.assertEquals(1003, ids.get(2));
}
public static class Root {
}
Reported by PMD.