The following issues were found
src/test/java/com/alibaba/json/bvt/path/JSONPath_12.java
10 issues
Line: 44
assertTrue(JSONPath.contains(schemaResult, jsonPath + "['" + attributeName + "']"));
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
System.out.println(schemaResult);
System.out.println(JSONPath.read(schemaResult.toJSONString(), jsonPath + "['" + attributeName + "']"));
assertTrue(newAttribute.containsKey("Brand. Name"));
}
}
Reported by PMD.
Line: 45
assertTrue(JSONPath.contains(schemaResult, jsonPath + "['" + attributeName + "']"));
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
System.out.println(schemaResult);
System.out.println(JSONPath.read(schemaResult.toJSONString(), jsonPath + "['" + attributeName + "']"));
assertTrue(newAttribute.containsKey("Brand. Name"));
}
}
Reported by PMD.
Line: 12
public class JSONPath_12
extends TestCase {
public void test(){
JSONObject schemaResult = JSON.parseObject("{\n" +
" \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n" +
" \"title\": \"AE product schema\",\n" +
" \"description\": \"AE product schema\",\n" +
" \"type\": \"object\",\n" +
Reported by PMD.
Line: 12
public class JSONPath_12
extends TestCase {
public void test(){
JSONObject schemaResult = JSON.parseObject("{\n" +
" \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n" +
" \"title\": \"AE product schema\",\n" +
" \"description\": \"AE product schema\",\n" +
" \"type\": \"object\",\n" +
Reported by PMD.
Line: 38
" \"title\": \"Brand Name\",\n" +
" \"type\": \"String\"\n" +
"}");
assertTrue(
JSONPath.set(schemaResult, jsonPath + "['" + attributeName + "']" , attributeValue)
);
assertTrue(JSONPath.contains(schemaResult, jsonPath + "['" + attributeName + "']"));
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
Reported by PMD.
Line: 42
JSONPath.set(schemaResult, jsonPath + "['" + attributeName + "']" , attributeValue)
);
assertTrue(JSONPath.contains(schemaResult, jsonPath + "['" + attributeName + "']"));
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
System.out.println(schemaResult);
System.out.println(JSONPath.read(schemaResult.toJSONString(), jsonPath + "['" + attributeName + "']"));
assertTrue(newAttribute.containsKey("Brand. Name"));
}
Reported by PMD.
Line: 45
assertTrue(JSONPath.contains(schemaResult, jsonPath + "['" + attributeName + "']"));
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
System.out.println(schemaResult);
System.out.println(JSONPath.read(schemaResult.toJSONString(), jsonPath + "['" + attributeName + "']"));
assertTrue(newAttribute.containsKey("Brand. Name"));
}
}
Reported by PMD.
Line: 46
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
System.out.println(schemaResult);
System.out.println(JSONPath.read(schemaResult.toJSONString(), jsonPath + "['" + attributeName + "']"));
assertTrue(newAttribute.containsKey("Brand. Name"));
}
}
Reported by PMD.
Line: 46
JSONObject newAttribute = (JSONObject)JSONPath.eval(schemaResult, jsonPath);
System.out.println(schemaResult);
System.out.println(JSONPath.read(schemaResult.toJSONString(), jsonPath + "['" + attributeName + "']"));
assertTrue(newAttribute.containsKey("Brand. Name"));
}
}
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 junit.framework.TestCase;
public class JSONPath_12
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/JSONLibDataFormatSerializer.java
10 issues
Line: 17
@SuppressWarnings("deprecation")
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
if (object == null) {
serializer.out.writeNull();
return;
}
Date date = (Date) object;
Reported by PMD.
Line: 24
Date date = (Date) object;
JSONObject json = new JSONObject();
json.put("date", date.getDate());
json.put("day", date.getDay());
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
Reported by PMD.
Line: 25
JSONObject json = new JSONObject();
json.put("date", date.getDate());
json.put("day", date.getDay());
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
Reported by PMD.
Line: 26
JSONObject json = new JSONObject();
json.put("date", date.getDate());
json.put("day", date.getDay());
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
Reported by PMD.
Line: 27
json.put("date", date.getDate());
json.put("day", date.getDay());
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
Reported by PMD.
Line: 28
json.put("day", date.getDay());
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
Reported by PMD.
Line: 29
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
serializer.write(json);
Reported by PMD.
Line: 30
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
serializer.write(json);
}
Reported by PMD.
Line: 31
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
serializer.write(json);
}
}
Reported by PMD.
Line: 32
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
serializer.write(json);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_14.java
10 issues
Line: 32
// 初始配置中,新增的字段添加的库中
Map<String, Object> paths = JSONPath.paths(sourceJson);
System.out.println(JSON.toJSONString(paths));
assertEquals(10, paths.size());
JSONObject destJson = JSON.parseObject("{\n" +
"\t\"boolean1\":true,\n" +
"\t\"boolean2\":false,\n" +
Reported by PMD.
Line: 47
}
if (!JSONPath.contains(destJson, stringObjectEntry.getKey())) {
JSONPath.set(destJson, stringObjectEntry.getKey(), stringObjectEntry.getValue());
System.out.println("key=" + stringObjectEntry.getKey() + " ,value=" + stringObjectEntry.getValue());
}
}
System.out.println(destJson.toJSONString());
}
Reported by PMD.
Line: 51
}
}
System.out.println(destJson.toJSONString());
}
}
Reported by PMD.
Line: 16
public class JSONPath_14
extends TestCase {
public void test_0() {
JSONObject sourceJson = JSON.parseObject("{\n" +
"\t\"boolean1\":true,\n" +
"\t\"boolean2\":false,\n" +
"\t\"boolean3\":true,\n" +
"\t\"boolean4\":true,\n" +
Reported by PMD.
Line: 26
"\t\"name1\":\"str\"\n" +
"}");
sourceJson.put("enum1", TimeUnit.SECONDS);
sourceJson.put("character1", 'A');
sourceJson.put("uuid1", UUID.randomUUID());
// 初始配置中,新增的字段添加的库中
Map<String, Object> paths = JSONPath.paths(sourceJson);
Reported by PMD.
Line: 27
"}");
sourceJson.put("enum1", TimeUnit.SECONDS);
sourceJson.put("character1", 'A');
sourceJson.put("uuid1", UUID.randomUUID());
// 初始配置中,新增的字段添加的库中
Map<String, Object> paths = JSONPath.paths(sourceJson);
System.out.println(JSON.toJSONString(paths));
Reported by PMD.
Line: 28
sourceJson.put("enum1", TimeUnit.SECONDS);
sourceJson.put("character1", 'A');
sourceJson.put("uuid1", UUID.randomUUID());
// 初始配置中,新增的字段添加的库中
Map<String, Object> paths = JSONPath.paths(sourceJson);
System.out.println(JSON.toJSONString(paths));
assertEquals(10, paths.size());
Reported by PMD.
Line: 33
// 初始配置中,新增的字段添加的库中
Map<String, Object> paths = JSONPath.paths(sourceJson);
System.out.println(JSON.toJSONString(paths));
assertEquals(10, paths.size());
JSONObject destJson = JSON.parseObject("{\n" +
"\t\"boolean1\":true,\n" +
"\t\"boolean2\":false,\n" +
"\t\"name\":\"str\"\n" +
Reported by PMD.
Line: 33
// 初始配置中,新增的字段添加的库中
Map<String, Object> paths = JSONPath.paths(sourceJson);
System.out.println(JSON.toJSONString(paths));
assertEquals(10, paths.size());
JSONObject destJson = JSON.parseObject("{\n" +
"\t\"boolean1\":true,\n" +
"\t\"boolean2\":false,\n" +
"\t\"name\":\"str\"\n" +
Reported by PMD.
Line: 51
}
}
System.out.println(destJson.toJSONString());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_256.java
10 issues
Line: 42
if (aList != null && aList.size() > 0) {
for (int i = 0; i < aList.size(); i++) {
System.out.println(aList.get(i).getId());
}
}
}
public static class AisleDeployInfo {
Reported by PMD.
Line: 17
public class Bug_for_issue_256 extends TestCase {
public void test_for_issue() throws Exception {
List<AisleDeployInfo> list3 = new ArrayList<AisleDeployInfo>();
AisleDeployInfo aisleDeployInfo = new AisleDeployInfo();
aisleDeployInfo.setId(1L);
aisleDeployInfo.setProvinceArea("3,4,5");
list3.add(aisleDeployInfo);
Reported by PMD.
Line: 17
public class Bug_for_issue_256 extends TestCase {
public void test_for_issue() throws Exception {
List<AisleDeployInfo> list3 = new ArrayList<AisleDeployInfo>();
AisleDeployInfo aisleDeployInfo = new AisleDeployInfo();
aisleDeployInfo.setId(1L);
aisleDeployInfo.setProvinceArea("3,4,5");
list3.add(aisleDeployInfo);
Reported by PMD.
Line: 40
Map<String, List<AisleDeployInfo>> map1 = JSON.parseObject(str, new TypeReference<Map<String, List<AisleDeployInfo>>>(){});
List<AisleDeployInfo> aList = map1.get("1");
if (aList != null && aList.size() > 0) {
for (int i = 0; i < aList.size(); i++) {
System.out.println(aList.get(i).getId());
}
}
}
Reported by PMD.
Line: 40
Map<String, List<AisleDeployInfo>> map1 = JSON.parseObject(str, new TypeReference<Map<String, List<AisleDeployInfo>>>(){});
List<AisleDeployInfo> aList = map1.get("1");
if (aList != null && aList.size() > 0) {
for (int i = 0; i < aList.size(); i++) {
System.out.println(aList.get(i).getId());
}
}
}
Reported by PMD.
Line: 41
List<AisleDeployInfo> aList = map1.get("1");
if (aList != null && aList.size() > 0) {
for (int i = 0; i < aList.size(); i++) {
System.out.println(aList.get(i).getId());
}
}
}
Reported by PMD.
Line: 42
if (aList != null && aList.size() > 0) {
for (int i = 0; i < aList.size(); i++) {
System.out.println(aList.get(i).getId());
}
}
}
public static class AisleDeployInfo {
Reported by PMD.
Line: 47
}
}
public static class AisleDeployInfo {
private long id;
private String provinceArea;
public long getId() {
return id;
Reported by PMD.
Line: 75
}
public static class Model extends HashMap {
}
}
Reported by PMD.
Line: 8
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import junit.framework.TestCase;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue1017.java
10 issues
Line: 13
* Created by wenshao on 11/02/2017.
*/
public class Issue1017 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"pictureList\":[\"http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000\",\"http://common.cnblogs.com/images/icon_weibo_24.png\"]}";
User user = JSON.parseObject(json, User.class);
assertNotNull(user.pictureList);
assertEquals(2, user.pictureList.size());
Reported by PMD.
Line: 13
* Created by wenshao on 11/02/2017.
*/
public class Issue1017 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"pictureList\":[\"http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000\",\"http://common.cnblogs.com/images/icon_weibo_24.png\"]}";
User user = JSON.parseObject(json, User.class);
assertNotNull(user.pictureList);
assertEquals(2, user.pictureList.size());
Reported by PMD.
Line: 17
String json = "{\"pictureList\":[\"http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000\",\"http://common.cnblogs.com/images/icon_weibo_24.png\"]}";
User user = JSON.parseObject(json, User.class);
assertNotNull(user.pictureList);
assertEquals(2, user.pictureList.size());
assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
}
Reported by PMD.
Line: 18
User user = JSON.parseObject(json, User.class);
assertNotNull(user.pictureList);
assertEquals(2, user.pictureList.size());
assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
}
public static class User implements Serializable {
Reported by PMD.
Line: 18
User user = JSON.parseObject(json, User.class);
assertNotNull(user.pictureList);
assertEquals(2, user.pictureList.size());
assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
}
public static class User implements Serializable {
Reported by PMD.
Line: 19
User user = JSON.parseObject(json, User.class);
assertNotNull(user.pictureList);
assertEquals(2, user.pictureList.size());
assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
}
public static class User implements Serializable {
private List<String> pictureList;
Reported by PMD.
Line: 19
User user = JSON.parseObject(json, User.class);
assertNotNull(user.pictureList);
assertEquals(2, user.pictureList.size());
assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
}
public static class User implements Serializable {
private List<String> pictureList;
Reported by PMD.
Line: 20
assertNotNull(user.pictureList);
assertEquals(2, user.pictureList.size());
assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
}
public static class User implements Serializable {
private List<String> pictureList;
public List<String> getPictureList() {
Reported by PMD.
Line: 20
assertNotNull(user.pictureList);
assertEquals(2, user.pictureList.size());
assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
}
public static class User implements Serializable {
private List<String> pictureList;
public List<String> getPictureList() {
Reported by PMD.
Line: 23
assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
}
public static class User implements Serializable {
private List<String> pictureList;
public List<String> getPictureList() {
return pictureList;
}
public User setPictureList(List<String> pictureList) {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1300/Issue1300.java
10 issues
Line: 14
* Created by wenshao on 01/07/2017.
*/
public class Issue1300 extends TestCase {
public void testFullJSON() {
JSONObject data = new JSONObject();
data.put("name", "string");
data.put("code", 1);
data.put("pinyin", "pinyin");
City object = TypeUtils.castToJavaBean(data, City.class);
Reported by PMD.
Line: 14
* Created by wenshao on 01/07/2017.
*/
public class Issue1300 extends TestCase {
public void testFullJSON() {
JSONObject data = new JSONObject();
data.put("name", "string");
data.put("code", 1);
data.put("pinyin", "pinyin");
City object = TypeUtils.castToJavaBean(data, City.class);
Reported by PMD.
Line: 18
JSONObject data = new JSONObject();
data.put("name", "string");
data.put("code", 1);
data.put("pinyin", "pinyin");
City object = TypeUtils.castToJavaBean(data, City.class);
assertEquals("string", object.name);
assertEquals(1, object.code);
assertEquals("pinyin", object.pinyin);
}
Reported by PMD.
Line: 20
data.put("code", 1);
data.put("pinyin", "pinyin");
City object = TypeUtils.castToJavaBean(data, City.class);
assertEquals("string", object.name);
assertEquals(1, object.code);
assertEquals("pinyin", object.pinyin);
}
public void testEmptyJSON() {
Reported by PMD.
Line: 21
data.put("pinyin", "pinyin");
City object = TypeUtils.castToJavaBean(data, City.class);
assertEquals("string", object.name);
assertEquals(1, object.code);
assertEquals("pinyin", object.pinyin);
}
public void testEmptyJSON() {
City object = TypeUtils.castToJavaBean(new JSONObject(), City.class);
Reported by PMD.
Line: 22
City object = TypeUtils.castToJavaBean(data, City.class);
assertEquals("string", object.name);
assertEquals(1, object.code);
assertEquals("pinyin", object.pinyin);
}
public void testEmptyJSON() {
City object = TypeUtils.castToJavaBean(new JSONObject(), City.class);
Assert.assertEquals(null, object.name);
Reported by PMD.
Line: 25
assertEquals("pinyin", object.pinyin);
}
public void testEmptyJSON() {
City object = TypeUtils.castToJavaBean(new JSONObject(), City.class);
Assert.assertEquals(null, object.name);
Assert.assertEquals(0, object.code);
}
Reported by PMD.
Line: 33
public static class City implements Parcelable {
public final int code;
public final String name;
public final String pinyin;
@JSONCreator
public City(@JSONField(name = "code") int code,
Reported by PMD.
Line: 34
public static class City implements Parcelable {
public final int code;
public final String name;
public final String pinyin;
@JSONCreator
public City(@JSONField(name = "code") int code,
@JSONField(name = "name") String name,
Reported by PMD.
Line: 35
public static class City implements Parcelable {
public final int code;
public final String name;
public final String pinyin;
@JSONCreator
public City(@JSONField(name = "code") int code,
@JSONField(name = "name") String name,
@JSONField(name = "pinyin") String pinyin) {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_Set2.java
10 issues
Line: 26
set.add(new B1());
a.setList(set);
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
// Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set2$A\",\"list\":[{},{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set2$B1\"}]}",
// text);
ParserConfig parserConfig = new ParserConfig();
parserConfig.addAccept("com.alibaba.json.bvt");
Reported by PMD.
Line: 15
import com.alibaba.fastjson.serializer.SerializerFeature;
public class WriteClassNameTest_Set2 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set2");
}
public void test_list() throws Exception {
A a = new A();
Reported by PMD.
Line: 16
public class WriteClassNameTest_Set2 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set2");
}
public void test_list() throws Exception {
A a = new A();
Set<B> set = new LinkedHashSet<B>();
Reported by PMD.
Line: 19
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set2");
}
public void test_list() throws Exception {
A a = new A();
Set<B> set = new LinkedHashSet<B>();
set.add(new B());
set.add(new B1());
a.setList(set);
Reported by PMD.
Line: 34
parserConfig.addAccept("com.alibaba.json.bvt");
A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
Reported by PMD.
Line: 34
parserConfig.addAccept("com.alibaba.json.bvt");
A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
Reported by PMD.
Line: 35
A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
Reported by PMD.
Line: 35
A a1 = (A) JSON.parseObject(text, Object.class, parserConfig);
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
Reported by PMD.
Line: 36
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
private Set<B> list;
Reported by PMD.
Line: 36
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue("B", new ArrayList<B>(a1.getList()).get(0) instanceof B || new ArrayList<B>(a1.getList()).get(0) instanceof B1);
Assert.assertTrue("B1", new ArrayList<B>(a1.getList()).get(1) instanceof B || new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
private Set<B> list;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/InetAddressDeserializerTest.java
10 issues
Line: 15
public class InetAddressDeserializerTest extends TestCase {
public void test_null() throws Exception {
String input = "null";
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
MiscCodec deser = new MiscCodec();
Reported by PMD.
Line: 24
Assert.assertNull(deser.deserialze(parser, null, null));
}
public void test_string_null() throws Exception {
String input = "null";
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
StringCodec deser = new StringCodec();
Reported by PMD.
Line: 33
Assert.assertNull(deser.deserialze(parser, null, null));
}
public void test_error_0() throws Exception {
String input = "'[&中国-^]'";
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
MiscCodec deser = new MiscCodec();
Reported by PMD.
Line: 41
Throwable error = null;
Object value = null;
try {
value = deser.deserialze(parser, null, null);
} catch (Throwable ex) {
error = ex;
}
Reported by PMD.
Line: 41
Throwable error = null;
Object value = null;
try {
value = deser.deserialze(parser, null, null);
} catch (Throwable ex) {
error = ex;
}
Reported by PMD.
Line: 43
Object value = null;
try {
value = deser.deserialze(parser, null, null);
} catch (Throwable ex) {
error = ex;
}
Assert.assertNotNull(error);
Reported by PMD.
Line: 44
Object value = null;
try {
value = deser.deserialze(parser, null, null);
} catch (Throwable ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 39
MiscCodec deser = new MiscCodec();
Throwable error = null;
Object value = null;
try {
value = deser.deserialze(parser, null, null);
} catch (Throwable ex) {
Reported by PMD.
Line: 41
Throwable error = null;
Object value = null;
try {
value = deser.deserialze(parser, null, null);
} catch (Throwable ex) {
error = ex;
}
Reported by PMD.
Line: 43
Object value = null;
try {
value = deser.deserialze(parser, null, null);
} catch (Throwable ex) {
error = ex;
}
Assert.assertNotNull(error);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SpecialTest.java
10 issues
Line: 16
count++;
}
}
System.out.println(count);
}
final static long flags;
static {
long val = 0L;
Reported by PMD.
Line: 5
import com.alibaba.fastjson.serializer.SerializerFeature;
public class SpecialTest {
public static void main(String[] args) throws Exception {
int count = 0;
for (int i = 0; i < 1000; ++i) {
Reported by PMD.
Line: 7
public class SpecialTest {
public static void main(String[] args) throws Exception {
int count = 0;
for (int i = 0; i < 1000; ++i) {
char ch = (char) i;
if(isSpecial(ch)) {
Reported by PMD.
Line: 28
}
static boolean isSpecial(char ch) {
if (ch <= 31) {
return true;
}
if (ch > '\\') { // 92
return false;
Reported by PMD.
Line: 32
return true;
}
if (ch > '\\') { // 92
return false;
}
return ((1L << (ch - 31)) & flags) != 0;
}
Reported by PMD.
Line: 44
// return false;
// }
if (ch == ' ') { // 32
return false;
}
if (ch == '/') { // 47
return SerializerFeature.isEnabled(features, SerializerFeature.WriteSlashAsSpecial);
Reported by PMD.
Line: 48
return false;
}
if (ch == '/') { // 47
return SerializerFeature.isEnabled(features, SerializerFeature.WriteSlashAsSpecial);
}
if (ch > '#' // 35
&& ch != '\\' // 92
Reported by PMD.
Line: 58
return false;
}
if (ch <= 0x1F // 31
|| ch == '\\' // 92
|| ch == '"' // 34
) {
return true;
}
Reported by PMD.
Line: 9
public static void main(String[] args) throws Exception {
int count = 0;
for (int i = 0; i < 1000; ++i) {
char ch = (char) i;
if(isSpecial(ch)) {
count++;
}
Reported by PMD.
Line: 13
for (int i = 0; i < 1000; ++i) {
char ch = (char) i;
if(isSpecial(ch)) {
count++;
}
}
System.out.println(count);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2300/Issue2343.java
10 issues
Line: 9
import junit.framework.TestCase;
public class Issue2343 extends TestCase {
public void test_for_issue() throws Exception {
A a = new A();
a.f1 = 101;
a.f2 = 102;
a.f3 = 103;
Reported by PMD.
Line: 9
import junit.framework.TestCase;
public class Issue2343 extends TestCase {
public void test_for_issue() throws Exception {
A a = new A();
a.f1 = 101;
a.f2 = 102;
a.f3 = 103;
Reported by PMD.
Line: 16
a.f3 = 103;
String str = JSON.toJSONString(a);
assertEquals("{\"f2\":102,\"f1\":101,\"f3\":103}", str);
JSONObject object = JSON.parseObject(str);
A a1 = object.toJavaObject(A.class);
assertEquals(a.f1, a1.f1);
assertEquals(a.f2, a1.f2);
Reported by PMD.
Line: 19
assertEquals("{\"f2\":102,\"f1\":101,\"f3\":103}", str);
JSONObject object = JSON.parseObject(str);
A a1 = object.toJavaObject(A.class);
assertEquals(a.f1, a1.f1);
assertEquals(a.f2, a1.f2);
assertEquals(a.f3, a1.f3);
}
Reported by PMD.
Line: 20
JSONObject object = JSON.parseObject(str);
A a1 = object.toJavaObject(A.class);
assertEquals(a.f1, a1.f1);
assertEquals(a.f2, a1.f2);
assertEquals(a.f3, a1.f3);
}
public static class A {
Reported by PMD.
Line: 21
JSONObject object = JSON.parseObject(str);
A a1 = object.toJavaObject(A.class);
assertEquals(a.f1, a1.f1);
assertEquals(a.f2, a1.f2);
assertEquals(a.f3, a1.f3);
}
public static class A {
@JSONField(ordinal = 1)
Reported by PMD.
Line: 22
A a1 = object.toJavaObject(A.class);
assertEquals(a.f1, a1.f1);
assertEquals(a.f2, a1.f2);
assertEquals(a.f3, a1.f3);
}
public static class A {
@JSONField(ordinal = 1)
public int f1;
Reported by PMD.
Line: 27
public static class A {
@JSONField(ordinal = 1)
public int f1;
@JSONField(ordinal = 0)
public int f2;
@JSONField(ordinal = 2)
Reported by PMD.
Line: 30
public int f1;
@JSONField(ordinal = 0)
public int f2;
@JSONField(ordinal = 2)
public int f3;
}
}
Reported by PMD.
Line: 33
public int f2;
@JSONField(ordinal = 2)
public int f3;
}
}
Reported by PMD.