The following issues were found
src/test/java/com/alibaba/json/bvt/issue_1100/Issue1150.java
6 issues
Line: 12
* Created by wenshao on 24/04/2017.
*/
public class Issue1150 extends TestCase {
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"values\":\"\"}", Model.class);
assertNull(model.values);
}
public void test_for_issue_array() throws Exception {
Reported by PMD.
Line: 14
public class Issue1150 extends TestCase {
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"values\":\"\"}", Model.class);
assertNull(model.values);
}
public void test_for_issue_array() throws Exception {
Model2 model = JSON.parseObject("{\"values\":\"\"}", Model2.class);
assertNull(model.values);
Reported by PMD.
Line: 17
assertNull(model.values);
}
public void test_for_issue_array() throws Exception {
Model2 model = JSON.parseObject("{\"values\":\"\"}", Model2.class);
assertNull(model.values);
}
public static class Model {
Reported by PMD.
Line: 19
public void test_for_issue_array() throws Exception {
Model2 model = JSON.parseObject("{\"values\":\"\"}", Model2.class);
assertNull(model.values);
}
public static class Model {
public List values;
}
Reported by PMD.
Line: 23
}
public static class Model {
public List values;
}
public static class Model2 {
public Item[] values;
}
Reported by PMD.
Line: 27
}
public static class Model2 {
public Item[] values;
}
public static class Item {
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2600/Issue2678.java
6 issues
Line: 9
import com.alibaba.fastjson.serializer.SerializerFeature;
public class Issue2678 extends TestCase {
public void test_field() throws Exception {
Person person = new Person();
person.setName("Ariston");
person.setAge(23);
String json = JSON.toJSONString(person);
assertEquals("{\"age\":23,'name':'Ariston'}", json);
Reported by PMD.
Line: 14
person.setName("Ariston");
person.setAge(23);
String json = JSON.toJSONString(person);
assertEquals("{\"age\":23,'name':'Ariston'}", json);
}
public void test_getter() throws Exception {
Person2 person = new Person2();
person.setName("Ariston");
Reported by PMD.
Line: 17
assertEquals("{\"age\":23,'name':'Ariston'}", json);
}
public void test_getter() throws Exception {
Person2 person = new Person2();
person.setName("Ariston");
person.setAge(23);
String json = JSON.toJSONString(person);
assertEquals("{\"age\":23,'name':'Ariston'}", json);
Reported by PMD.
Line: 22
person.setName("Ariston");
person.setAge(23);
String json = JSON.toJSONString(person);
assertEquals("{\"age\":23,'name':'Ariston'}", json);
}
static class Person {
@JSONField(serialzeFeatures = SerializerFeature.UseSingleQuotes)
Reported by PMD.
Line: 25
assertEquals("{\"age\":23,'name':'Ariston'}", json);
}
static class Person {
@JSONField(serialzeFeatures = SerializerFeature.UseSingleQuotes)
private String name;
private int age;
Reported by PMD.
Line: 53
}
}
static class Person2 {
private String name;
private int age;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONReaderScannerTest__entity_boolean.java
6 issues
Line: 16
public class JSONReaderScannerTest__entity_boolean extends TestCase {
public void test_scanInt() throws Exception {
StringBuffer buf = new StringBuffer();
buf.append('[');
for (int i = 0; i < 10; ++i) {
if (i != 0) {
buf.append(',');
Reported by PMD.
Line: 17
public class JSONReaderScannerTest__entity_boolean extends TestCase {
public void test_scanInt() throws Exception {
StringBuffer buf = new StringBuffer();
buf.append('[');
for (int i = 0; i < 10; ++i) {
if (i != 0) {
buf.append(',');
}
Reported by PMD.
Line: 34
}
buf.append(']');
Reader reader = new StringReader(buf.toString());
JSONReaderScanner scanner = new JSONReaderScanner(reader);
DefaultJSONParser parser = new DefaultJSONParser(scanner);
List<VO> array = parser.parseArray(VO.class);
Reported by PMD.
Line: 42
List<VO> array = parser.parseArray(VO.class);
for (int i = 0; i < array.size(); ++i) {
if (i % 2 == 0) {
Assert.assertEquals(true, array.get(i).getId());
} else {
Assert.assertEquals(false, array.get(i).getId());
}
}
}
Reported by PMD.
Line: 44
if (i % 2 == 0) {
Assert.assertEquals(true, array.get(i).getId());
} else {
Assert.assertEquals(false, array.get(i).getId());
}
}
}
public static class VO {
Reported by PMD.
Line: 10
import org.junit.Assert;
import junit.framework.TestCase;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.JSONReaderScanner;
public class JSONReaderScannerTest__entity_boolean extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1700/Issue1723.java
6 issues
Line: 8
import junit.framework.TestCase;
public class Issue1723 extends TestCase {
public void test_for_issue() throws Exception {
User user = JSON.parseObject("{\"age\":\"0.9390308260917664\"}", User.class);
assertEquals(0.9390308260917664F, user.age);
}
public void test_for_issue_1() throws Exception {
Reported by PMD.
Line: 10
public class Issue1723 extends TestCase {
public void test_for_issue() throws Exception {
User user = JSON.parseObject("{\"age\":\"0.9390308260917664\"}", User.class);
assertEquals(0.9390308260917664F, user.age);
}
public void test_for_issue_1() throws Exception {
User user = JSON.parseObject("{\"age\":\"8.200000000000001\"}", User.class);
assertEquals(8.200000000000001F, user.age);
Reported by PMD.
Line: 13
assertEquals(0.9390308260917664F, user.age);
}
public void test_for_issue_1() throws Exception {
User user = JSON.parseObject("{\"age\":\"8.200000000000001\"}", User.class);
assertEquals(8.200000000000001F, user.age);
}
public void test_for_issue_2() throws Exception {
Reported by PMD.
Line: 15
public void test_for_issue_1() throws Exception {
User user = JSON.parseObject("{\"age\":\"8.200000000000001\"}", User.class);
assertEquals(8.200000000000001F, user.age);
}
public void test_for_issue_2() throws Exception {
User user = JSON.parseObject("[\"8.200000000000001\"]", User.class, Feature.SupportArrayToBean);
assertEquals(8.200000000000001F, user.age);
Reported by PMD.
Line: 18
assertEquals(8.200000000000001F, user.age);
}
public void test_for_issue_2() throws Exception {
User user = JSON.parseObject("[\"8.200000000000001\"]", User.class, Feature.SupportArrayToBean);
assertEquals(8.200000000000001F, user.age);
}
public static class User {
Reported by PMD.
Line: 20
public void test_for_issue_2() throws Exception {
User user = JSON.parseObject("[\"8.200000000000001\"]", User.class, Feature.SupportArrayToBean);
assertEquals(8.200000000000001F, user.age);
}
public static class User {
private float age;
public float getAge() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONLexerTest_5.java
6 issues
Line: 13
public class JSONLexerTest_5 extends TestCase {
public void test_scanFieldString() throws Exception {
VO vo = JSON.parseObject("{\"values\":[\"abc\"]}", VO.class);
Assert.assertEquals("abc", vo.getValues().get(0));
}
public static class VO {
Reported by PMD.
Line: 15
public void test_scanFieldString() throws Exception {
VO vo = JSON.parseObject("{\"values\":[\"abc\"]}", VO.class);
Assert.assertEquals("abc", vo.getValues().get(0));
}
public static class VO {
public LinkedList<String> values;
Reported by PMD.
Line: 15
public void test_scanFieldString() throws Exception {
VO vo = JSON.parseObject("{\"values\":[\"abc\"]}", VO.class);
Assert.assertEquals("abc", vo.getValues().get(0));
}
public static class VO {
public LinkedList<String> values;
Reported by PMD.
Line: 20
public static class VO {
public LinkedList<String> values;
public LinkedList<String> getValues() {
return values;
}
Reported by PMD.
Line: 22
public LinkedList<String> values;
public LinkedList<String> getValues() {
return values;
}
public void setValues(LinkedList<String> values) {
this.values = values;
Reported by PMD.
Line: 26
return values;
}
public void setValues(LinkedList<String> values) {
this.values = values;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3500/Issue3516.java
6 issues
Line: 7
import junit.framework.TestCase;
public class Issue3516 extends TestCase {
public void test_for_issue() throws Exception {
JSONValidator validator = JSONValidator.from("{}");
assertEquals(JSONValidator.Type.Object, validator.getType());
assertTrue(validator.validate());
}
}
Reported by PMD.
Line: 7
import junit.framework.TestCase;
public class Issue3516 extends TestCase {
public void test_for_issue() throws Exception {
JSONValidator validator = JSONValidator.from("{}");
assertEquals(JSONValidator.Type.Object, validator.getType());
assertTrue(validator.validate());
}
}
Reported by PMD.
Line: 9
public class Issue3516 extends TestCase {
public void test_for_issue() throws Exception {
JSONValidator validator = JSONValidator.from("{}");
assertEquals(JSONValidator.Type.Object, validator.getType());
assertTrue(validator.validate());
}
}
Reported by PMD.
Line: 9
public class Issue3516 extends TestCase {
public void test_for_issue() throws Exception {
JSONValidator validator = JSONValidator.from("{}");
assertEquals(JSONValidator.Type.Object, validator.getType());
assertTrue(validator.validate());
}
}
Reported by PMD.
Line: 10
public void test_for_issue() throws Exception {
JSONValidator validator = JSONValidator.from("{}");
assertEquals(JSONValidator.Type.Object, validator.getType());
assertTrue(validator.validate());
}
}
Reported by PMD.
Line: 10
public void test_for_issue() throws Exception {
JSONValidator validator = JSONValidator.from("{}");
assertEquals(JSONValidator.Type.Object, validator.getType());
assertTrue(validator.validate());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2100/Issue2189.java
6 issues
Line: 7
import junit.framework.TestCase;
public class Issue2189 extends TestCase {
public void test_for_issue() throws Exception {
String str = "[{\"id\":\"1\",\"name\":\"a\"},{\"id\":\"2\",\"name\":\"b\"}]";
assertEquals("[\"1\",\"2\"]",
JSONPath.extract(str, "$.*.id")
.toString()
);
Reported by PMD.
Line: 9
public class Issue2189 extends TestCase {
public void test_for_issue() throws Exception {
String str = "[{\"id\":\"1\",\"name\":\"a\"},{\"id\":\"2\",\"name\":\"b\"}]";
assertEquals("[\"1\",\"2\"]",
JSONPath.extract(str, "$.*.id")
.toString()
);
}
Reported by PMD.
Line: 10
public void test_for_issue() throws Exception {
String str = "[{\"id\":\"1\",\"name\":\"a\"},{\"id\":\"2\",\"name\":\"b\"}]";
assertEquals("[\"1\",\"2\"]",
JSONPath.extract(str, "$.*.id")
.toString()
);
}
public void test_for_issue_1() throws Exception {
Reported by PMD.
Line: 15
);
}
public void test_for_issue_1() throws Exception {
String str = "[{\"id\":\"1\",\"name\":\"a\"},{\"id\":\"2\",\"name\":\"b\"}]";
assertEquals("[\"2\"]",
JSONPath.extract(str, "$.*[?(@.name=='b')].id")
.toString()
);
Reported by PMD.
Line: 17
public void test_for_issue_1() throws Exception {
String str = "[{\"id\":\"1\",\"name\":\"a\"},{\"id\":\"2\",\"name\":\"b\"}]";
assertEquals("[\"2\"]",
JSONPath.extract(str, "$.*[?(@.name=='b')].id")
.toString()
);
}
}
Reported by PMD.
Line: 18
public void test_for_issue_1() throws Exception {
String str = "[{\"id\":\"1\",\"name\":\"a\"},{\"id\":\"2\",\"name\":\"b\"}]";
assertEquals("[\"2\"]",
JSONPath.extract(str, "$.*[?(@.name=='b')].id")
.toString()
);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3500/Issue3579.java
6 issues
Line: 10
import java.math.BigDecimal;
public class Issue3579 extends TestCase {
public void test_for_issue() throws Exception {
assertEquals("1",
JSON.toJSONString(new BigDecimal("1"))
);
assertEquals("1.",
Reported by PMD.
Line: 10
import java.math.BigDecimal;
public class Issue3579 extends TestCase {
public void test_for_issue() throws Exception {
assertEquals("1",
JSON.toJSONString(new BigDecimal("1"))
);
assertEquals("1.",
Reported by PMD.
Line: 11
public class Issue3579 extends TestCase {
public void test_for_issue() throws Exception {
assertEquals("1",
JSON.toJSONString(new BigDecimal("1"))
);
assertEquals("1.",
JSON.toJSONString(new BigDecimal("1"), SerializerFeature.WriteClassName)
Reported by PMD.
Line: 12
public class Issue3579 extends TestCase {
public void test_for_issue() throws Exception {
assertEquals("1",
JSON.toJSONString(new BigDecimal("1"))
);
assertEquals("1.",
JSON.toJSONString(new BigDecimal("1"), SerializerFeature.WriteClassName)
);
Reported by PMD.
Line: 15
JSON.toJSONString(new BigDecimal("1"))
);
assertEquals("1.",
JSON.toJSONString(new BigDecimal("1"), SerializerFeature.WriteClassName)
);
}
}
Reported by PMD.
Line: 16
);
assertEquals("1.",
JSON.toJSONString(new BigDecimal("1"), SerializerFeature.WriteClassName)
);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1203.java
6 issues
Line: 11
* Created by wenshao on 16/05/2017.
*/
public class Issue1203 extends TestCase {
public void test_for_issue() throws Exception {
String[] strArr = new String[5];
strArr[0] = "a";
strArr[1] = "b";
strArr[3] = "d";
strArr[4] = "";
Reported by PMD.
Line: 19
strArr[4] = "";
String json = JSON.toJSONString(strArr, SerializerFeature.WriteNullStringAsEmpty);
assertEquals("[\"a\",\"b\",\"\",\"d\",\"\"]", json);
}
}
Reported by PMD.
Line: 12
*/
public class Issue1203 extends TestCase {
public void test_for_issue() throws Exception {
String[] strArr = new String[5];
strArr[0] = "a";
strArr[1] = "b";
strArr[3] = "d";
strArr[4] = "";
Reported by PMD.
Line: 13
public class Issue1203 extends TestCase {
public void test_for_issue() throws Exception {
String[] strArr = new String[5];
strArr[0] = "a";
strArr[1] = "b";
strArr[3] = "d";
strArr[4] = "";
String json = JSON.toJSONString(strArr, SerializerFeature.WriteNullStringAsEmpty);
Reported by PMD.
Line: 14
public void test_for_issue() throws Exception {
String[] strArr = new String[5];
strArr[0] = "a";
strArr[1] = "b";
strArr[3] = "d";
strArr[4] = "";
String json = JSON.toJSONString(strArr, SerializerFeature.WriteNullStringAsEmpty);
assertEquals("[\"a\",\"b\",\"\",\"d\",\"\"]", json);
Reported by PMD.
Line: 15
String[] strArr = new String[5];
strArr[0] = "a";
strArr[1] = "b";
strArr[3] = "d";
strArr[4] = "";
String json = JSON.toJSONString(strArr, SerializerFeature.WriteNullStringAsEmpty);
assertEquals("[\"a\",\"b\",\"\",\"d\",\"\"]", json);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1225.java
6 issues
Line: 25
// new TypeReference<ExtendGenericType<String>>(){}).data.get(1));
// }
public void test_parseObject_2() {
SimpleGenericObject object = JSON.parseObject("{\"data\":[\"1\",\"2\",\"3\"],\"a\":\"a\"}",
SimpleGenericObject.class);
assertEquals("2", object.data.get(1));
}
Reported by PMD.
Line: 29
SimpleGenericObject object = JSON.parseObject("{\"data\":[\"1\",\"2\",\"3\"],\"a\":\"a\"}",
SimpleGenericObject.class);
assertEquals("2", object.data.get(1));
}
// public void test_parseObject_2_jackson() throws Exception {
// ObjectMapper mapper = new ObjectMapper();
// SimpleGenericObject object = mapper.readValue("{\"data\":[\"1\",\"2\",\"3\"]}",
Reported by PMD.
Line: 29
SimpleGenericObject object = JSON.parseObject("{\"data\":[\"1\",\"2\",\"3\"],\"a\":\"a\"}",
SimpleGenericObject.class);
assertEquals("2", object.data.get(1));
}
// public void test_parseObject_2_jackson() throws Exception {
// ObjectMapper mapper = new ObjectMapper();
// SimpleGenericObject object = mapper.readValue("{\"data\":[\"1\",\"2\",\"3\"]}",
Reported by PMD.
Line: 42
// }
static class BaseGenericType<T> {
public T data;
}
static class ExtendGenericType<T> extends BaseGenericType<List<T>> {
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.issue_1200;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import junit.framework.TestCase;
import java.util.List;
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import junit.framework.TestCase;
import java.util.List;
/**
Reported by PMD.