The following issues were found
src/test/java/data/media/ImageGenDecoder.java
59 issues
Line: 13
import com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
public class ImageGenDecoder extends JavaBeanDeserializer implements ObjectDeserializer {
private char[] size_gen_prefix__ = "\"size\":".toCharArray();
private char[] uri_gen_prefix__ = "\"uri\":".toCharArray();
private char[] title_gen_prefix__ = "\"title\":".toCharArray();
private char[] width_gen_prefix__ = "\"width\":".toCharArray();
private char[] height_gen_prefix__ = "\"height\":".toCharArray();
Reported by PMD.
Line: 13
import com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
public class ImageGenDecoder extends JavaBeanDeserializer implements ObjectDeserializer {
private char[] size_gen_prefix__ = "\"size\":".toCharArray();
private char[] uri_gen_prefix__ = "\"uri\":".toCharArray();
private char[] title_gen_prefix__ = "\"title\":".toCharArray();
private char[] width_gen_prefix__ = "\"width\":".toCharArray();
private char[] height_gen_prefix__ = "\"height\":".toCharArray();
Reported by PMD.
Line: 14
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
public class ImageGenDecoder extends JavaBeanDeserializer implements ObjectDeserializer {
private char[] size_gen_prefix__ = "\"size\":".toCharArray();
private char[] uri_gen_prefix__ = "\"uri\":".toCharArray();
private char[] title_gen_prefix__ = "\"title\":".toCharArray();
private char[] width_gen_prefix__ = "\"width\":".toCharArray();
private char[] height_gen_prefix__ = "\"height\":".toCharArray();
Reported by PMD.
Line: 14
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
public class ImageGenDecoder extends JavaBeanDeserializer implements ObjectDeserializer {
private char[] size_gen_prefix__ = "\"size\":".toCharArray();
private char[] uri_gen_prefix__ = "\"uri\":".toCharArray();
private char[] title_gen_prefix__ = "\"title\":".toCharArray();
private char[] width_gen_prefix__ = "\"width\":".toCharArray();
private char[] height_gen_prefix__ = "\"height\":".toCharArray();
Reported by PMD.
Line: 15
public class ImageGenDecoder extends JavaBeanDeserializer implements ObjectDeserializer {
private char[] size_gen_prefix__ = "\"size\":".toCharArray();
private char[] uri_gen_prefix__ = "\"uri\":".toCharArray();
private char[] title_gen_prefix__ = "\"title\":".toCharArray();
private char[] width_gen_prefix__ = "\"width\":".toCharArray();
private char[] height_gen_prefix__ = "\"height\":".toCharArray();
private ObjectDeserializer uri_gen_deser__;
Reported by PMD.
Line: 15
public class ImageGenDecoder extends JavaBeanDeserializer implements ObjectDeserializer {
private char[] size_gen_prefix__ = "\"size\":".toCharArray();
private char[] uri_gen_prefix__ = "\"uri\":".toCharArray();
private char[] title_gen_prefix__ = "\"title\":".toCharArray();
private char[] width_gen_prefix__ = "\"width\":".toCharArray();
private char[] height_gen_prefix__ = "\"height\":".toCharArray();
private ObjectDeserializer uri_gen_deser__;
Reported by PMD.
Line: 16
public class ImageGenDecoder extends JavaBeanDeserializer implements ObjectDeserializer {
private char[] size_gen_prefix__ = "\"size\":".toCharArray();
private char[] uri_gen_prefix__ = "\"uri\":".toCharArray();
private char[] title_gen_prefix__ = "\"title\":".toCharArray();
private char[] width_gen_prefix__ = "\"width\":".toCharArray();
private char[] height_gen_prefix__ = "\"height\":".toCharArray();
private ObjectDeserializer uri_gen_deser__;
private ObjectDeserializer title_gen_deser__;
Reported by PMD.
Line: 16
public class ImageGenDecoder extends JavaBeanDeserializer implements ObjectDeserializer {
private char[] size_gen_prefix__ = "\"size\":".toCharArray();
private char[] uri_gen_prefix__ = "\"uri\":".toCharArray();
private char[] title_gen_prefix__ = "\"title\":".toCharArray();
private char[] width_gen_prefix__ = "\"width\":".toCharArray();
private char[] height_gen_prefix__ = "\"height\":".toCharArray();
private ObjectDeserializer uri_gen_deser__;
private ObjectDeserializer title_gen_deser__;
Reported by PMD.
Line: 17
private char[] size_gen_prefix__ = "\"size\":".toCharArray();
private char[] uri_gen_prefix__ = "\"uri\":".toCharArray();
private char[] title_gen_prefix__ = "\"title\":".toCharArray();
private char[] width_gen_prefix__ = "\"width\":".toCharArray();
private char[] height_gen_prefix__ = "\"height\":".toCharArray();
private ObjectDeserializer uri_gen_deser__;
private ObjectDeserializer title_gen_deser__;
private ObjectDeserializer size_gen_deser__;
Reported by PMD.
Line: 17
private char[] size_gen_prefix__ = "\"size\":".toCharArray();
private char[] uri_gen_prefix__ = "\"uri\":".toCharArray();
private char[] title_gen_prefix__ = "\"title\":".toCharArray();
private char[] width_gen_prefix__ = "\"width\":".toCharArray();
private char[] height_gen_prefix__ = "\"height\":".toCharArray();
private ObjectDeserializer uri_gen_deser__;
private ObjectDeserializer title_gen_deser__;
private ObjectDeserializer size_gen_deser__;
Reported by PMD.
src/main/java/com/alibaba/fastjson/asm/Opcodes.java
59 issues
Line: 42
* @author Eugene Kuleshov
*/
public interface Opcodes {
int T_INT = 10;
// versions
// int V1_1 = 3 << 16 | 45;
// int V1_2 = 0 << 16 | 46;
Reported by PMD.
Line: 50
// int V1_2 = 0 << 16 | 46;
// int V1_3 = 0 << 16 | 47;
// int V1_4 = 0 << 16 | 48;
int V1_5 = 0 << 16 | 49;
// int V1_6 = 0 << 16 | 50;
// int V1_7 = 0 << 16 | 51;
// access flags
Reported by PMD.
Line: 56
// access flags
int ACC_PUBLIC = 0x0001; // class, field, method
int ACC_SUPER = 0x0020; // class
// opcodes // visit method (- = idem)
int ACONST_NULL = 1; // -
Reported by PMD.
Line: 57
// access flags
int ACC_PUBLIC = 0x0001; // class, field, method
int ACC_SUPER = 0x0020; // class
// opcodes // visit method (- = idem)
int ACONST_NULL = 1; // -
int ICONST_0 = 3; // -
Reported by PMD.
Line: 61
// opcodes // visit method (- = idem)
int ACONST_NULL = 1; // -
int ICONST_0 = 3; // -
int ICONST_1 = 4; // -
int LCONST_0 = 9; // -
int LCONST_1 = 10; // -
int FCONST_0 = 11; // -
Reported by PMD.
Line: 62
// opcodes // visit method (- = idem)
int ACONST_NULL = 1; // -
int ICONST_0 = 3; // -
int ICONST_1 = 4; // -
int LCONST_0 = 9; // -
int LCONST_1 = 10; // -
int FCONST_0 = 11; // -
int DCONST_0 = 14; // -
Reported by PMD.
Line: 63
int ACONST_NULL = 1; // -
int ICONST_0 = 3; // -
int ICONST_1 = 4; // -
int LCONST_0 = 9; // -
int LCONST_1 = 10; // -
int FCONST_0 = 11; // -
int DCONST_0 = 14; // -
int BIPUSH = 16; // visitIntInsn
Reported by PMD.
Line: 64
int ACONST_NULL = 1; // -
int ICONST_0 = 3; // -
int ICONST_1 = 4; // -
int LCONST_0 = 9; // -
int LCONST_1 = 10; // -
int FCONST_0 = 11; // -
int DCONST_0 = 14; // -
int BIPUSH = 16; // visitIntInsn
// int SIPUSH = 17; // -
Reported by PMD.
Line: 65
int ICONST_0 = 3; // -
int ICONST_1 = 4; // -
int LCONST_0 = 9; // -
int LCONST_1 = 10; // -
int FCONST_0 = 11; // -
int DCONST_0 = 14; // -
int BIPUSH = 16; // visitIntInsn
// int SIPUSH = 17; // -
// int LDC = 18; // visitLdcInsn
Reported by PMD.
Line: 66
int ICONST_1 = 4; // -
int LCONST_0 = 9; // -
int LCONST_1 = 10; // -
int FCONST_0 = 11; // -
int DCONST_0 = 14; // -
int BIPUSH = 16; // visitIntInsn
// int SIPUSH = 17; // -
// int LDC = 18; // visitLdcInsn
// int LDC_W = 19; // -
Reported by PMD.
src/main/java/com/alibaba/fastjson/parser/deserializer/ArrayListTypeFieldDeserializer.java
59 issues
Line: 176
if (lexer.isEnabled(Feature.AllowArbitraryCommas)) {
while (lexer.token() == JSONToken.COMMA) {
lexer.nextToken();
continue;
}
}
if (lexer.token() == JSONToken.RBRACKET) {
break;
Reported by PMD.
Line: 21
import com.alibaba.fastjson.util.FieldInfo;
import com.alibaba.fastjson.util.ParameterizedTypeImpl;
public class ArrayListTypeFieldDeserializer extends FieldDeserializer {
private final Type itemType;
private int itemFastMatchToken;
private ObjectDeserializer deserializer;
Reported by PMD.
Line: 21
import com.alibaba.fastjson.util.FieldInfo;
import com.alibaba.fastjson.util.ParameterizedTypeImpl;
public class ArrayListTypeFieldDeserializer extends FieldDeserializer {
private final Type itemType;
private int itemFastMatchToken;
private ObjectDeserializer deserializer;
Reported by PMD.
Line: 23
public class ArrayListTypeFieldDeserializer extends FieldDeserializer {
private final Type itemType;
private int itemFastMatchToken;
private ObjectDeserializer deserializer;
public ArrayListTypeFieldDeserializer(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo){
super(clazz, fieldInfo);
Reported by PMD.
Line: 24
public class ArrayListTypeFieldDeserializer extends FieldDeserializer {
private final Type itemType;
private int itemFastMatchToken;
private ObjectDeserializer deserializer;
public ArrayListTypeFieldDeserializer(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo){
super(clazz, fieldInfo);
Reported by PMD.
Line: 25
private final Type itemType;
private int itemFastMatchToken;
private ObjectDeserializer deserializer;
public ArrayListTypeFieldDeserializer(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo){
super(clazz, fieldInfo);
Type fieldType = fieldInfo.fieldType;
Reported by PMD.
Line: 27
private int itemFastMatchToken;
private ObjectDeserializer deserializer;
public ArrayListTypeFieldDeserializer(ParserConfig mapping, Class<?> clazz, FieldInfo fieldInfo){
super(clazz, fieldInfo);
Type fieldType = fieldInfo.fieldType;
if (fieldType instanceof ParameterizedType) {
Type argType = ((ParameterizedType) fieldInfo.fieldType).getActualTypeArguments()[0];
Reported by PMD.
Line: 36
if (argType instanceof WildcardType) {
WildcardType wildcardType = (WildcardType) argType;
Type[] upperBounds = wildcardType.getUpperBounds();
if (upperBounds.length == 1) {
argType = upperBounds[0];
}
}
this.itemType = argType;
} else {
Reported by PMD.
Line: 54
@Override
public void parseField(DefaultJSONParser parser, Object object, Type objectType, Map<String, Object> fieldValues) {
JSONLexer lexer = parser.lexer;
final int token = lexer.token();
if (token == JSONToken.NULL
|| (token == JSONToken.LITERAL_STRING && lexer.stringVal().length() == 0)) {
if (object == null) {
fieldValues.put(fieldInfo.name, null);
} else {
Reported by PMD.
Line: 56
JSONLexer lexer = parser.lexer;
final int token = lexer.token();
if (token == JSONToken.NULL
|| (token == JSONToken.LITERAL_STRING && lexer.stringVal().length() == 0)) {
if (object == null) {
fieldValues.put(fieldInfo.name, null);
} else {
setValue(object, null);
}
Reported by PMD.
src/test/java/com/alibaba/json/test/codec/FastjsonManualCodec.java
58 issues
Line: 179
}
@Override
public byte[] encodeToBytes(Object object) throws Exception {
// TODO Auto-generated method stub
return null;
}
@Override
Reported by PMD.
Line: 29
private SerializeConfig serializeConfig = new SerializeConfig();
public FastjsonManualCodec(){
System.out.println("fastjson-" + JSON.VERSION);
serializeConfig.put(MediaContent.class, new MediaContentSerializer());
}
public String getName() {
Reported by PMD.
Line: 25
public class FastjsonManualCodec implements Codec {
private ParserConfig config = new ParserConfig();
private SerializeConfig serializeConfig = new SerializeConfig();
public FastjsonManualCodec(){
System.out.println("fastjson-" + JSON.VERSION);
Reported by PMD.
Line: 25
public class FastjsonManualCodec implements Codec {
private ParserConfig config = new ParserConfig();
private SerializeConfig serializeConfig = new SerializeConfig();
public FastjsonManualCodec(){
System.out.println("fastjson-" + JSON.VERSION);
Reported by PMD.
Line: 26
public class FastjsonManualCodec implements Codec {
private ParserConfig config = new ParserConfig();
private SerializeConfig serializeConfig = new SerializeConfig();
public FastjsonManualCodec(){
System.out.println("fastjson-" + JSON.VERSION);
serializeConfig.put(MediaContent.class, new MediaContentSerializer());
Reported by PMD.
Line: 26
public class FastjsonManualCodec implements Codec {
private ParserConfig config = new ParserConfig();
private SerializeConfig serializeConfig = new SerializeConfig();
public FastjsonManualCodec(){
System.out.println("fastjson-" + JSON.VERSION);
serializeConfig.put(MediaContent.class, new MediaContentSerializer());
Reported by PMD.
Line: 44
return parser.parseObject(clazz);
}
public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(text, config);
parser.config(Feature.DisableCircularReferenceDetect, true);
return parser.parseArray(clazz);
}
Reported by PMD.
Line: 64
// private JavaBeanSerializer serializer = new JavaBeanSerializer(Long_100_Entity.class);
public String encode(Object object) throws Exception {
SerializeWriter out = new SerializeWriter();
out.config(SerializerFeature.DisableCircularReferenceDetect, true);
JSONSerializer serializer = new JSONSerializer(out, serializeConfig);
serializer.write(object);
Reported by PMD.
Line: 79
}
@SuppressWarnings("unchecked")
public <T> T decodeObject(byte[] input, Class<T> clazz) throws Exception {
return (T) JSON.parseObject(input, clazz, Feature.DisableCircularReferenceDetect);
}
public static class ImageSerializer implements ObjectSerializer {
Reported by PMD.
Line: 92
SerializeWriter out = serializer.out;
out.writeFieldValue('{', "height", image.getHeight());
out.writeFieldValueStringWithDoubleQuote(',', "size", image.getSize().name());
String tile = image.getTitle();
out.writeFieldValueStringWithDoubleQuoteCheck(',', "title", tile);
out.writeFieldValueStringWithDoubleQuoteCheck(',', "uri", image.getUri());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/AEHuangliang2Test.java
58 issues
Line: 391
NetResponse response = JSON.parseObject(mockResultJson, NetResponse.class);
String bodyJson = JSON.toJSONString(response.body);
System.out.println(bodyJson);
FloorPageData pageData = JSON.parseObject(bodyJson, FloorPageData.class);
assertNotNull(pageData.areas);
}
}
Reported by PMD.
Line: 21
static String jsonData = "{\n" +
" \"areas\": [\n" +
" {\n" +
" \"@type\": \"section\",\n" +
" \"templateId\": \"grid\",\n" +
" \"style\": {\n" +
" \"card\" : \"true\",\n" +
" \"column-count\":\"2\",\n" +
" \"aspect-ratio\":\"2\",\n" +
Reported by PMD.
Line: 22
" \"areas\": [\n" +
" {\n" +
" \"@type\": \"section\",\n" +
" \"templateId\": \"grid\",\n" +
" \"style\": {\n" +
" \"card\" : \"true\",\n" +
" \"column-count\":\"2\",\n" +
" \"aspect-ratio\":\"2\",\n" +
" \"margins\":\"16 0 16 16\",\n" +
Reported by PMD.
Line: 23
" {\n" +
" \"@type\": \"section\",\n" +
" \"templateId\": \"grid\",\n" +
" \"style\": {\n" +
" \"card\" : \"true\",\n" +
" \"column-count\":\"2\",\n" +
" \"aspect-ratio\":\"2\",\n" +
" \"margins\":\"16 0 16 16\",\n" +
" \"background-color\": \"#ffffff\",\n" +
Reported by PMD.
Line: 24
" \"@type\": \"section\",\n" +
" \"templateId\": \"grid\",\n" +
" \"style\": {\n" +
" \"card\" : \"true\",\n" +
" \"column-count\":\"2\",\n" +
" \"aspect-ratio\":\"2\",\n" +
" \"margins\":\"16 0 16 16\",\n" +
" \"background-color\": \"#ffffff\",\n" +
" \"column-gap\": \"10\"\n" +
Reported by PMD.
Line: 25
" \"templateId\": \"grid\",\n" +
" \"style\": {\n" +
" \"card\" : \"true\",\n" +
" \"column-count\":\"2\",\n" +
" \"aspect-ratio\":\"2\",\n" +
" \"margins\":\"16 0 16 16\",\n" +
" \"background-color\": \"#ffffff\",\n" +
" \"column-gap\": \"10\"\n" +
" },\n" +
Reported by PMD.
Line: 26
" \"style\": {\n" +
" \"card\" : \"true\",\n" +
" \"column-count\":\"2\",\n" +
" \"aspect-ratio\":\"2\",\n" +
" \"margins\":\"16 0 16 16\",\n" +
" \"background-color\": \"#ffffff\",\n" +
" \"column-gap\": \"10\"\n" +
" },\n" +
" \"children\": [\n" +
Reported by PMD.
Line: 27
" \"card\" : \"true\",\n" +
" \"column-count\":\"2\",\n" +
" \"aspect-ratio\":\"2\",\n" +
" \"margins\":\"16 0 16 16\",\n" +
" \"background-color\": \"#ffffff\",\n" +
" \"column-gap\": \"10\"\n" +
" },\n" +
" \"children\": [\n" +
" {\n" +
Reported by PMD.
Line: 28
" \"column-count\":\"2\",\n" +
" \"aspect-ratio\":\"2\",\n" +
" \"margins\":\"16 0 16 16\",\n" +
" \"background-color\": \"#ffffff\",\n" +
" \"column-gap\": \"10\"\n" +
" },\n" +
" \"children\": [\n" +
" {\n" +
" \"@type\": \"section\",\n" +
Reported by PMD.
Line: 29
" \"aspect-ratio\":\"2\",\n" +
" \"margins\":\"16 0 16 16\",\n" +
" \"background-color\": \"#ffffff\",\n" +
" \"column-gap\": \"10\"\n" +
" },\n" +
" \"children\": [\n" +
" {\n" +
" \"@type\": \"section\",\n" +
" \"templateId\": \"grid\",\n" +
Reported by PMD.
src/main/java/com/alibaba/fastjson/parser/deserializer/ThrowableDeserializer.java
57 issues
Line: 18
import com.alibaba.fastjson.util.FieldInfo;
import com.alibaba.fastjson.util.TypeUtils;
public class ThrowableDeserializer extends JavaBeanDeserializer {
public ThrowableDeserializer(ParserConfig mapping, Class<?> clazz){
super(mapping, clazz, clazz);
}
Reported by PMD.
Line: 18
import com.alibaba.fastjson.util.FieldInfo;
import com.alibaba.fastjson.util.TypeUtils;
public class ThrowableDeserializer extends JavaBeanDeserializer {
public ThrowableDeserializer(ParserConfig mapping, Class<?> clazz){
super(mapping, clazz, clazz);
}
Reported by PMD.
Line: 18
import com.alibaba.fastjson.util.FieldInfo;
import com.alibaba.fastjson.util.TypeUtils;
public class ThrowableDeserializer extends JavaBeanDeserializer {
public ThrowableDeserializer(ParserConfig mapping, Class<?> clazz){
super(mapping, clazz, clazz);
}
Reported by PMD.
Line: 25
}
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken();
return null;
Reported by PMD.
Line: 25
}
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken();
return null;
Reported by PMD.
Line: 25
}
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken();
return null;
Reported by PMD.
Line: 25
}
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken();
return null;
Reported by PMD.
Line: 25
}
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken();
return null;
Reported by PMD.
Line: 25
}
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken();
return null;
Reported by PMD.
Line: 28
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.NULL) {
lexer.nextToken();
return null;
}
if (parser.getResolveStatus() == DefaultJSONParser.TypeNameRedirect) {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/JSONSerializerTest.java
57 issues
Line: 19
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class JSONSerializerTest extends TestCase {
public void test_0() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(new C());
Reported by PMD.
Line: 21
public class JSONSerializerTest extends TestCase {
public void test_0() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(new C());
Assert.assertEquals("[]", serializer.getWriter().toString());
}
Reported by PMD.
Line: 25
JSONSerializer serializer = new JSONSerializer();
serializer.write(new C());
Assert.assertEquals("[]", serializer.getWriter().toString());
}
public void test_0_s() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(new C());
Reported by PMD.
Line: 28
Assert.assertEquals("[]", serializer.getWriter().toString());
}
public void test_0_s() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(new C());
Assert.assertEquals("[]", serializer.getWriter().toString());
}
Reported by PMD.
Line: 32
JSONSerializer serializer = new JSONSerializer();
serializer.write(new C());
Assert.assertEquals("[]", serializer.getWriter().toString());
}
public void test_1() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(Collections.singletonList(1));
Reported by PMD.
Line: 35
Assert.assertEquals("[]", serializer.getWriter().toString());
}
public void test_1() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(Collections.singletonList(1));
Assert.assertEquals("[1]", serializer.getWriter().toString());
}
Reported by PMD.
Line: 39
JSONSerializer serializer = new JSONSerializer();
serializer.write(Collections.singletonList(1));
Assert.assertEquals("[1]", serializer.getWriter().toString());
}
public void test_1_s() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(Collections.singletonList(1));
Reported by PMD.
Line: 42
Assert.assertEquals("[1]", serializer.getWriter().toString());
}
public void test_1_s() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(Collections.singletonList(1));
Assert.assertEquals("[1]", serializer.getWriter().toString());
}
Reported by PMD.
Line: 46
JSONSerializer serializer = new JSONSerializer();
serializer.write(Collections.singletonList(1));
Assert.assertEquals("[1]", serializer.getWriter().toString());
}
public void test_2() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(Collections.EMPTY_MAP);
Reported by PMD.
Line: 49
Assert.assertEquals("[1]", serializer.getWriter().toString());
}
public void test_2() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.write(Collections.EMPTY_MAP);
Assert.assertEquals("{}", serializer.getWriter().toString());
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/extract/JSONPath_extract_2_book.java
56 issues
Line: 10
import java.io.InputStream;
import java.io.InputStreamReader;
public class JSONPath_extract_2_book extends TestCase {
public void test_0() throws Exception {
assertEquals("[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
, JSONPath.extract(json, "$.store.book.author")
.toString());
Reported by PMD.
Line: 12
public class JSONPath_extract_2_book extends TestCase {
public void test_0() throws Exception {
assertEquals("[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
, JSONPath.extract(json, "$.store.book.author")
.toString());
}
Reported by PMD.
Line: 13
public class JSONPath_extract_2_book extends TestCase {
public void test_0() throws Exception {
assertEquals("[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
, JSONPath.extract(json, "$.store.book.author")
.toString());
}
public void test_1() throws Exception {
Reported by PMD.
Line: 14
public void test_0() throws Exception {
assertEquals("[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
, JSONPath.extract(json, "$.store.book.author")
.toString());
}
public void test_1() throws Exception {
assertEquals("[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
Reported by PMD.
Line: 18
.toString());
}
public void test_1() throws Exception {
assertEquals("[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
, JSONPath.extract(json, "$.store.book[*].author")
.toString());
}
Reported by PMD.
Line: 19
}
public void test_1() throws Exception {
assertEquals("[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
, JSONPath.extract(json, "$.store.book[*].author")
.toString());
}
public void test_2() throws Exception {
Reported by PMD.
Line: 20
public void test_1() throws Exception {
assertEquals("[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
, JSONPath.extract(json, "$.store.book[*].author")
.toString());
}
public void test_2() throws Exception {
assertNull(JSONPath.extract(json, "$.author"));
Reported by PMD.
Line: 24
.toString());
}
public void test_2() throws Exception {
assertNull(JSONPath.extract(json, "$.author"));
}
public void test_3() throws Exception {
assertEquals("[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
Reported by PMD.
Line: 25
}
public void test_2() throws Exception {
assertNull(JSONPath.extract(json, "$.author"));
}
public void test_3() throws Exception {
assertEquals("[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
, JSONPath.extract(json, "$..author")
Reported by PMD.
Line: 28
assertNull(JSONPath.extract(json, "$.author"));
}
public void test_3() throws Exception {
assertEquals("[\"Nigel Rees\",\"Evelyn Waugh\",\"Herman Melville\",\"J. R. R. Tolkien\"]"
, JSONPath.extract(json, "$..author")
.toString());
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest_scanFieldBoolean.java
55 issues
Line: 8
import com.alibaba.fastjson.JSON;
public class JSONScannerTest_scanFieldBoolean extends TestCase {
public void test_true() throws Exception {
String text = "{\"value\":true}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals(true, obj.getValue());
Reported by PMD.
Line: 10
public class JSONScannerTest_scanFieldBoolean extends TestCase {
public void test_true() throws Exception {
String text = "{\"value\":true}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals(true, obj.getValue());
}
Reported by PMD.
Line: 13
public void test_true() throws Exception {
String text = "{\"value\":true}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals(true, obj.getValue());
}
public void test_false() throws Exception {
String text = "{\"value\":false}";
VO obj = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 16
Assert.assertEquals(true, obj.getValue());
}
public void test_false() throws Exception {
String text = "{\"value\":false}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals(false, obj.getValue());
}
Reported by PMD.
Line: 19
public void test_false() throws Exception {
String text = "{\"value\":false}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals(false, obj.getValue());
}
public void test_1() throws Exception {
String text = "{\"value\":\"true\"}";
VO obj = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 22
Assert.assertEquals(false, obj.getValue());
}
public void test_1() throws Exception {
String text = "{\"value\":\"true\"}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals(true, obj.getValue());
}
Reported by PMD.
Line: 25
public void test_1() throws Exception {
String text = "{\"value\":\"true\"}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals(true, obj.getValue());
}
public void test_2() throws Exception {
String text = "{\"value\":\"false\"}";
VO obj = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 28
Assert.assertEquals(true, obj.getValue());
}
public void test_2() throws Exception {
String text = "{\"value\":\"false\"}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals(false, obj.getValue());
}
Reported by PMD.
Line: 31
public void test_2() throws Exception {
String text = "{\"value\":\"false\"}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals(false, obj.getValue());
}
public void test_3() throws Exception {
String text = "{\"value\":\"1\"}";
VO obj = JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 34
Assert.assertEquals(false, obj.getValue());
}
public void test_3() throws Exception {
String text = "{\"value\":\"1\"}";
VO obj = JSON.parseObject(text, VO.class);
Assert.assertEquals(true, obj.getValue());
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2600/Issue2617.java
55 issues
Line: 21
public class Issue2617 extends TestCase {
// 场景:通过@JSONField(deserializeUsing = MyDateDeserializer.class)来自定义解析
public void test_for_issue() throws Exception {
String str = "{ \"a\": { \"date\": 6, \"day\": 2, \"hours\": 18, \"minutes\": 37, \"month\": 7, \"seconds\": 1, \"time\": 1565087821607, \"timezoneOffset\": -480, \"year\": 119 } }";
Date date = JSON.parseObject(str, A.class).getA();
Date date2 = new Date(1565087821607L);
assertEquals(date2.getDate(), date.getDate());
Reported by PMD.
Line: 21
public class Issue2617 extends TestCase {
// 场景:通过@JSONField(deserializeUsing = MyDateDeserializer.class)来自定义解析
public void test_for_issue() throws Exception {
String str = "{ \"a\": { \"date\": 6, \"day\": 2, \"hours\": 18, \"minutes\": 37, \"month\": 7, \"seconds\": 1, \"time\": 1565087821607, \"timezoneOffset\": -480, \"year\": 119 } }";
Date date = JSON.parseObject(str, A.class).getA();
Date date2 = new Date(1565087821607L);
assertEquals(date2.getDate(), date.getDate());
Reported by PMD.
Line: 23
// 场景:通过@JSONField(deserializeUsing = MyDateDeserializer.class)来自定义解析
public void test_for_issue() throws Exception {
String str = "{ \"a\": { \"date\": 6, \"day\": 2, \"hours\": 18, \"minutes\": 37, \"month\": 7, \"seconds\": 1, \"time\": 1565087821607, \"timezoneOffset\": -480, \"year\": 119 } }";
Date date = JSON.parseObject(str, A.class).getA();
Date date2 = new Date(1565087821607L);
assertEquals(date2.getDate(), date.getDate());
assertEquals(date2.getDay(), date.getDay());
assertEquals(date2.getHours(), date.getHours());
Reported by PMD.
Line: 26
Date date = JSON.parseObject(str, A.class).getA();
Date date2 = new Date(1565087821607L);
assertEquals(date2.getDate(), date.getDate());
assertEquals(date2.getDay(), date.getDay());
assertEquals(date2.getHours(), date.getHours());
assertEquals(date2.getMinutes(), date.getMinutes());
assertEquals(date2.getMonth(), date.getMonth());
assertEquals(date2.getSeconds(), date.getSeconds());
Reported by PMD.
Line: 26
Date date = JSON.parseObject(str, A.class).getA();
Date date2 = new Date(1565087821607L);
assertEquals(date2.getDate(), date.getDate());
assertEquals(date2.getDay(), date.getDay());
assertEquals(date2.getHours(), date.getHours());
assertEquals(date2.getMinutes(), date.getMinutes());
assertEquals(date2.getMonth(), date.getMonth());
assertEquals(date2.getSeconds(), date.getSeconds());
Reported by PMD.
Line: 27
Date date2 = new Date(1565087821607L);
assertEquals(date2.getDate(), date.getDate());
assertEquals(date2.getDay(), date.getDay());
assertEquals(date2.getHours(), date.getHours());
assertEquals(date2.getMinutes(), date.getMinutes());
assertEquals(date2.getMonth(), date.getMonth());
assertEquals(date2.getSeconds(), date.getSeconds());
assertEquals(date2.getTime(), date.getTime());
Reported by PMD.
Line: 27
Date date2 = new Date(1565087821607L);
assertEquals(date2.getDate(), date.getDate());
assertEquals(date2.getDay(), date.getDay());
assertEquals(date2.getHours(), date.getHours());
assertEquals(date2.getMinutes(), date.getMinutes());
assertEquals(date2.getMonth(), date.getMonth());
assertEquals(date2.getSeconds(), date.getSeconds());
assertEquals(date2.getTime(), date.getTime());
Reported by PMD.
Line: 28
assertEquals(date2.getDate(), date.getDate());
assertEquals(date2.getDay(), date.getDay());
assertEquals(date2.getHours(), date.getHours());
assertEquals(date2.getMinutes(), date.getMinutes());
assertEquals(date2.getMonth(), date.getMonth());
assertEquals(date2.getSeconds(), date.getSeconds());
assertEquals(date2.getTime(), date.getTime());
assertEquals(date2.getTimezoneOffset(), date.getTimezoneOffset());
Reported by PMD.
Line: 28
assertEquals(date2.getDate(), date.getDate());
assertEquals(date2.getDay(), date.getDay());
assertEquals(date2.getHours(), date.getHours());
assertEquals(date2.getMinutes(), date.getMinutes());
assertEquals(date2.getMonth(), date.getMonth());
assertEquals(date2.getSeconds(), date.getSeconds());
assertEquals(date2.getTime(), date.getTime());
assertEquals(date2.getTimezoneOffset(), date.getTimezoneOffset());
Reported by PMD.
Line: 29
assertEquals(date2.getDate(), date.getDate());
assertEquals(date2.getDay(), date.getDay());
assertEquals(date2.getHours(), date.getHours());
assertEquals(date2.getMinutes(), date.getMinutes());
assertEquals(date2.getMonth(), date.getMonth());
assertEquals(date2.getSeconds(), date.getSeconds());
assertEquals(date2.getTime(), date.getTime());
assertEquals(date2.getTimezoneOffset(), date.getTimezoneOffset());
assertEquals(date2.getYear(), date.getYear());
Reported by PMD.