The following issues were found
src/test/java/com/alibaba/json/bvt/path/JSONPath_paths_test4.java
7 issues
Line: 15
import junit.framework.TestCase;
public class JSONPath_paths_test4 extends TestCase {
public void test_map() throws Exception {
List<Object> list = new ArrayList<Object>();
list.add(1001);
list.add("wenshao");
list.add(Collections.singletonMap("type", "emp"));
Reported by PMD.
Line: 24
Map<String, Object> paths = JSONPath.paths(list);
Assert.assertEquals(5, paths.size());
Assert.assertSame(list, paths.get("/"));
Assert.assertEquals(1001, paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
Assert.assertSame(list.get(2), paths.get("/2"));
Assert.assertSame(((Map)list.get(2)).get("type"), paths.get("/2/type"));
Reported by PMD.
Line: 25
Map<String, Object> paths = JSONPath.paths(list);
Assert.assertEquals(5, paths.size());
Assert.assertSame(list, paths.get("/"));
Assert.assertEquals(1001, paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
Assert.assertSame(list.get(2), paths.get("/2"));
Assert.assertSame(((Map)list.get(2)).get("type"), paths.get("/2/type"));
}
Reported by PMD.
Line: 26
Assert.assertEquals(5, paths.size());
Assert.assertSame(list, paths.get("/"));
Assert.assertEquals(1001, paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
Assert.assertSame(list.get(2), paths.get("/2"));
Assert.assertSame(((Map)list.get(2)).get("type"), paths.get("/2/type"));
}
}
Reported by PMD.
Line: 27
Assert.assertEquals(5, paths.size());
Assert.assertSame(list, paths.get("/"));
Assert.assertEquals(1001, paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
Assert.assertSame(list.get(2), paths.get("/2"));
Assert.assertSame(((Map)list.get(2)).get("type"), paths.get("/2/type"));
}
}
Reported by PMD.
Line: 28
Assert.assertSame(list, paths.get("/"));
Assert.assertEquals(1001, paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
Assert.assertSame(list.get(2), paths.get("/2"));
Assert.assertSame(((Map)list.get(2)).get("type"), paths.get("/2/type"));
}
}
Reported by PMD.
Line: 29
Assert.assertEquals(1001, paths.get("/0"));
Assert.assertEquals("wenshao", paths.get("/1"));
Assert.assertSame(list.get(2), paths.get("/2"));
Assert.assertSame(((Map)list.get(2)).get("type"), paths.get("/2/type"));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest10.java
7 issues
Line: 15
public class RefTest10 extends TestCase {
public void test_bug_for_wanglin() throws Exception {
String text = "{ \"schedulerCluster\": \"xyQuestionImport\", \"log\": { \"abilityServiceId\": \"-1\", \"abilityServiceVersionId\": \"-1\", \"createTime\": 1456832040060, \"ip\": \"192.168.1.71\", \"jobDataMap\": { \"com.fjhb.context.v1.Context\": { \"domain\": \"dev.medical.com\", \"gUID\": \"25c5e12ec19946e8a6850237cd8182de\", \"ip\": \"127.0.0.1\", \"organizationId\": \"-1\", \"platformId\": \"2c9180e5520a5e70015214fb2849000a\", \"platformVersionId\": \"2c9180e5520a6063015214fc062d0006\", \"projectId\": \"2c9180e5520a60630152150b0b4a000e\", \"recordChain\": true, \"requestUrl\": \"http://dev.medical.com:9009/gateway/web/admin/questionIE/questionImport\", \"subProjectId\": \"2c9180e5520a606301521596e7070018\", \"test\": false, \"unitId\": \"2c9180e54e7580cd014e801793720010\", \"userId\": \"4028823c4e850e60014e853115dc00sa\" }, \"questionImportDto\": { \"filePath\": \"/work/A4Mode2.xls\", \"organizationId\": \"-1\", \"platformId\": \"2c9180e5520a5e70015214fb2849000a\", \"platformVersionId\": \"2c9180e5520a6063015214fc062d0006\", \"projectId\": \"2c9180e5520a60630152150b0b4a000e\", \"subProjectId\": \"2c9180e5520a606301521596e7070018\", \"unitId\": \"-1\" }, \"questionExcelModeType\": 2, \"user.job.current.execute.key\": \"402881c75331cc62015331e732ce0002\" }, \"jobGroup\": \"xyQuestionImport\", \"jobName\": \"questionImport\", \"key\": \"402881c75331cc62015331e732ce0002\", \"organizationId\": \"-1\", \"platformId\": \"-1\", \"platformVersionId\": \"-1\", \"projectId\": \"-1\", \"remark\": \"\\\"xyQuestionImport\\\"集群中名为:\\\"402881c75331cc62015331ccecbc0000\\\"的调度器开始运行此任务\", \"status\": \"toExecuted\", \"subProjectId\": \"-1\", \"unitId\": \"-1\", \"userId\": \"4028823c4e850e60014e853115dc00sa\" }, \"context\": { \"$ref\": \"$.log.jobDataMap.com.fjhb.context.v1.Context\" }, \"schedulerName\": \"402881c75331cc62015331ccecbc0000\" }";;
JSONObject jsonObj = JSON.parseObject(text);
Assert.assertSame(jsonObj.getJSONObject("log").getJSONObject("jobDataMap").get("com.fjhb.context.v1.Context"), jsonObj.get("context"));
}
Reported by PMD.
Line: 16
public class RefTest10 extends TestCase {
public void test_bug_for_wanglin() throws Exception {
String text = "{ \"schedulerCluster\": \"xyQuestionImport\", \"log\": { \"abilityServiceId\": \"-1\", \"abilityServiceVersionId\": \"-1\", \"createTime\": 1456832040060, \"ip\": \"192.168.1.71\", \"jobDataMap\": { \"com.fjhb.context.v1.Context\": { \"domain\": \"dev.medical.com\", \"gUID\": \"25c5e12ec19946e8a6850237cd8182de\", \"ip\": \"127.0.0.1\", \"organizationId\": \"-1\", \"platformId\": \"2c9180e5520a5e70015214fb2849000a\", \"platformVersionId\": \"2c9180e5520a6063015214fc062d0006\", \"projectId\": \"2c9180e5520a60630152150b0b4a000e\", \"recordChain\": true, \"requestUrl\": \"http://dev.medical.com:9009/gateway/web/admin/questionIE/questionImport\", \"subProjectId\": \"2c9180e5520a606301521596e7070018\", \"test\": false, \"unitId\": \"2c9180e54e7580cd014e801793720010\", \"userId\": \"4028823c4e850e60014e853115dc00sa\" }, \"questionImportDto\": { \"filePath\": \"/work/A4Mode2.xls\", \"organizationId\": \"-1\", \"platformId\": \"2c9180e5520a5e70015214fb2849000a\", \"platformVersionId\": \"2c9180e5520a6063015214fc062d0006\", \"projectId\": \"2c9180e5520a60630152150b0b4a000e\", \"subProjectId\": \"2c9180e5520a606301521596e7070018\", \"unitId\": \"-1\" }, \"questionExcelModeType\": 2, \"user.job.current.execute.key\": \"402881c75331cc62015331e732ce0002\" }, \"jobGroup\": \"xyQuestionImport\", \"jobName\": \"questionImport\", \"key\": \"402881c75331cc62015331e732ce0002\", \"organizationId\": \"-1\", \"platformId\": \"-1\", \"platformVersionId\": \"-1\", \"projectId\": \"-1\", \"remark\": \"\\\"xyQuestionImport\\\"集群中名为:\\\"402881c75331cc62015331ccecbc0000\\\"的调度器开始运行此任务\", \"status\": \"toExecuted\", \"subProjectId\": \"-1\", \"unitId\": \"-1\", \"userId\": \"4028823c4e850e60014e853115dc00sa\" }, \"context\": { \"$ref\": \"$.log.jobDataMap.com.fjhb.context.v1.Context\" }, \"schedulerName\": \"402881c75331cc62015331ccecbc0000\" }";;
JSONObject jsonObj = JSON.parseObject(text);
Assert.assertSame(jsonObj.getJSONObject("log").getJSONObject("jobDataMap").get("com.fjhb.context.v1.Context"), jsonObj.get("context"));
}
Reported by PMD.
Line: 19
String text = "{ \"schedulerCluster\": \"xyQuestionImport\", \"log\": { \"abilityServiceId\": \"-1\", \"abilityServiceVersionId\": \"-1\", \"createTime\": 1456832040060, \"ip\": \"192.168.1.71\", \"jobDataMap\": { \"com.fjhb.context.v1.Context\": { \"domain\": \"dev.medical.com\", \"gUID\": \"25c5e12ec19946e8a6850237cd8182de\", \"ip\": \"127.0.0.1\", \"organizationId\": \"-1\", \"platformId\": \"2c9180e5520a5e70015214fb2849000a\", \"platformVersionId\": \"2c9180e5520a6063015214fc062d0006\", \"projectId\": \"2c9180e5520a60630152150b0b4a000e\", \"recordChain\": true, \"requestUrl\": \"http://dev.medical.com:9009/gateway/web/admin/questionIE/questionImport\", \"subProjectId\": \"2c9180e5520a606301521596e7070018\", \"test\": false, \"unitId\": \"2c9180e54e7580cd014e801793720010\", \"userId\": \"4028823c4e850e60014e853115dc00sa\" }, \"questionImportDto\": { \"filePath\": \"/work/A4Mode2.xls\", \"organizationId\": \"-1\", \"platformId\": \"2c9180e5520a5e70015214fb2849000a\", \"platformVersionId\": \"2c9180e5520a6063015214fc062d0006\", \"projectId\": \"2c9180e5520a60630152150b0b4a000e\", \"subProjectId\": \"2c9180e5520a606301521596e7070018\", \"unitId\": \"-1\" }, \"questionExcelModeType\": 2, \"user.job.current.execute.key\": \"402881c75331cc62015331e732ce0002\" }, \"jobGroup\": \"xyQuestionImport\", \"jobName\": \"questionImport\", \"key\": \"402881c75331cc62015331e732ce0002\", \"organizationId\": \"-1\", \"platformId\": \"-1\", \"platformVersionId\": \"-1\", \"projectId\": \"-1\", \"remark\": \"\\\"xyQuestionImport\\\"集群中名为:\\\"402881c75331cc62015331ccecbc0000\\\"的调度器开始运行此任务\", \"status\": \"toExecuted\", \"subProjectId\": \"-1\", \"unitId\": \"-1\", \"userId\": \"4028823c4e850e60014e853115dc00sa\" }, \"context\": { \"$ref\": \"$.log.jobDataMap.com.fjhb.context.v1.Context\" }, \"schedulerName\": \"402881c75331cc62015331ccecbc0000\" }";;
JSONObject jsonObj = JSON.parseObject(text);
Assert.assertSame(jsonObj.getJSONObject("log").getJSONObject("jobDataMap").get("com.fjhb.context.v1.Context"), jsonObj.get("context"));
}
public static class VO {
private A a;
Reported by PMD.
Line: 19
String text = "{ \"schedulerCluster\": \"xyQuestionImport\", \"log\": { \"abilityServiceId\": \"-1\", \"abilityServiceVersionId\": \"-1\", \"createTime\": 1456832040060, \"ip\": \"192.168.1.71\", \"jobDataMap\": { \"com.fjhb.context.v1.Context\": { \"domain\": \"dev.medical.com\", \"gUID\": \"25c5e12ec19946e8a6850237cd8182de\", \"ip\": \"127.0.0.1\", \"organizationId\": \"-1\", \"platformId\": \"2c9180e5520a5e70015214fb2849000a\", \"platformVersionId\": \"2c9180e5520a6063015214fc062d0006\", \"projectId\": \"2c9180e5520a60630152150b0b4a000e\", \"recordChain\": true, \"requestUrl\": \"http://dev.medical.com:9009/gateway/web/admin/questionIE/questionImport\", \"subProjectId\": \"2c9180e5520a606301521596e7070018\", \"test\": false, \"unitId\": \"2c9180e54e7580cd014e801793720010\", \"userId\": \"4028823c4e850e60014e853115dc00sa\" }, \"questionImportDto\": { \"filePath\": \"/work/A4Mode2.xls\", \"organizationId\": \"-1\", \"platformId\": \"2c9180e5520a5e70015214fb2849000a\", \"platformVersionId\": \"2c9180e5520a6063015214fc062d0006\", \"projectId\": \"2c9180e5520a60630152150b0b4a000e\", \"subProjectId\": \"2c9180e5520a606301521596e7070018\", \"unitId\": \"-1\" }, \"questionExcelModeType\": 2, \"user.job.current.execute.key\": \"402881c75331cc62015331e732ce0002\" }, \"jobGroup\": \"xyQuestionImport\", \"jobName\": \"questionImport\", \"key\": \"402881c75331cc62015331e732ce0002\", \"organizationId\": \"-1\", \"platformId\": \"-1\", \"platformVersionId\": \"-1\", \"projectId\": \"-1\", \"remark\": \"\\\"xyQuestionImport\\\"集群中名为:\\\"402881c75331cc62015331ccecbc0000\\\"的调度器开始运行此任务\", \"status\": \"toExecuted\", \"subProjectId\": \"-1\", \"unitId\": \"-1\", \"userId\": \"4028823c4e850e60014e853115dc00sa\" }, \"context\": { \"$ref\": \"$.log.jobDataMap.com.fjhb.context.v1.Context\" }, \"schedulerName\": \"402881c75331cc62015331ccecbc0000\" }";;
JSONObject jsonObj = JSON.parseObject(text);
Assert.assertSame(jsonObj.getJSONObject("log").getJSONObject("jobDataMap").get("com.fjhb.context.v1.Context"), jsonObj.get("context"));
}
public static class VO {
private A a;
Reported by PMD.
Line: 19
String text = "{ \"schedulerCluster\": \"xyQuestionImport\", \"log\": { \"abilityServiceId\": \"-1\", \"abilityServiceVersionId\": \"-1\", \"createTime\": 1456832040060, \"ip\": \"192.168.1.71\", \"jobDataMap\": { \"com.fjhb.context.v1.Context\": { \"domain\": \"dev.medical.com\", \"gUID\": \"25c5e12ec19946e8a6850237cd8182de\", \"ip\": \"127.0.0.1\", \"organizationId\": \"-1\", \"platformId\": \"2c9180e5520a5e70015214fb2849000a\", \"platformVersionId\": \"2c9180e5520a6063015214fc062d0006\", \"projectId\": \"2c9180e5520a60630152150b0b4a000e\", \"recordChain\": true, \"requestUrl\": \"http://dev.medical.com:9009/gateway/web/admin/questionIE/questionImport\", \"subProjectId\": \"2c9180e5520a606301521596e7070018\", \"test\": false, \"unitId\": \"2c9180e54e7580cd014e801793720010\", \"userId\": \"4028823c4e850e60014e853115dc00sa\" }, \"questionImportDto\": { \"filePath\": \"/work/A4Mode2.xls\", \"organizationId\": \"-1\", \"platformId\": \"2c9180e5520a5e70015214fb2849000a\", \"platformVersionId\": \"2c9180e5520a6063015214fc062d0006\", \"projectId\": \"2c9180e5520a60630152150b0b4a000e\", \"subProjectId\": \"2c9180e5520a606301521596e7070018\", \"unitId\": \"-1\" }, \"questionExcelModeType\": 2, \"user.job.current.execute.key\": \"402881c75331cc62015331e732ce0002\" }, \"jobGroup\": \"xyQuestionImport\", \"jobName\": \"questionImport\", \"key\": \"402881c75331cc62015331e732ce0002\", \"organizationId\": \"-1\", \"platformId\": \"-1\", \"platformVersionId\": \"-1\", \"projectId\": \"-1\", \"remark\": \"\\\"xyQuestionImport\\\"集群中名为:\\\"402881c75331cc62015331ccecbc0000\\\"的调度器开始运行此任务\", \"status\": \"toExecuted\", \"subProjectId\": \"-1\", \"unitId\": \"-1\", \"userId\": \"4028823c4e850e60014e853115dc00sa\" }, \"context\": { \"$ref\": \"$.log.jobDataMap.com.fjhb.context.v1.Context\" }, \"schedulerName\": \"402881c75331cc62015331ccecbc0000\" }";;
JSONObject jsonObj = JSON.parseObject(text);
Assert.assertSame(jsonObj.getJSONObject("log").getJSONObject("jobDataMap").get("com.fjhb.context.v1.Context"), jsonObj.get("context"));
}
public static class VO {
private A a;
Reported by PMD.
Line: 19
String text = "{ \"schedulerCluster\": \"xyQuestionImport\", \"log\": { \"abilityServiceId\": \"-1\", \"abilityServiceVersionId\": \"-1\", \"createTime\": 1456832040060, \"ip\": \"192.168.1.71\", \"jobDataMap\": { \"com.fjhb.context.v1.Context\": { \"domain\": \"dev.medical.com\", \"gUID\": \"25c5e12ec19946e8a6850237cd8182de\", \"ip\": \"127.0.0.1\", \"organizationId\": \"-1\", \"platformId\": \"2c9180e5520a5e70015214fb2849000a\", \"platformVersionId\": \"2c9180e5520a6063015214fc062d0006\", \"projectId\": \"2c9180e5520a60630152150b0b4a000e\", \"recordChain\": true, \"requestUrl\": \"http://dev.medical.com:9009/gateway/web/admin/questionIE/questionImport\", \"subProjectId\": \"2c9180e5520a606301521596e7070018\", \"test\": false, \"unitId\": \"2c9180e54e7580cd014e801793720010\", \"userId\": \"4028823c4e850e60014e853115dc00sa\" }, \"questionImportDto\": { \"filePath\": \"/work/A4Mode2.xls\", \"organizationId\": \"-1\", \"platformId\": \"2c9180e5520a5e70015214fb2849000a\", \"platformVersionId\": \"2c9180e5520a6063015214fc062d0006\", \"projectId\": \"2c9180e5520a60630152150b0b4a000e\", \"subProjectId\": \"2c9180e5520a606301521596e7070018\", \"unitId\": \"-1\" }, \"questionExcelModeType\": 2, \"user.job.current.execute.key\": \"402881c75331cc62015331e732ce0002\" }, \"jobGroup\": \"xyQuestionImport\", \"jobName\": \"questionImport\", \"key\": \"402881c75331cc62015331e732ce0002\", \"organizationId\": \"-1\", \"platformId\": \"-1\", \"platformVersionId\": \"-1\", \"projectId\": \"-1\", \"remark\": \"\\\"xyQuestionImport\\\"集群中名为:\\\"402881c75331cc62015331ccecbc0000\\\"的调度器开始运行此任务\", \"status\": \"toExecuted\", \"subProjectId\": \"-1\", \"unitId\": \"-1\", \"userId\": \"4028823c4e850e60014e853115dc00sa\" }, \"context\": { \"$ref\": \"$.log.jobDataMap.com.fjhb.context.v1.Context\" }, \"schedulerName\": \"402881c75331cc62015331ccecbc0000\" }";;
JSONObject jsonObj = JSON.parseObject(text);
Assert.assertSame(jsonObj.getJSONObject("log").getJSONObject("jobDataMap").get("com.fjhb.context.v1.Context"), jsonObj.get("context"));
}
public static class VO {
private A a;
Reported by PMD.
Line: 22
Assert.assertSame(jsonObj.getJSONObject("log").getJSONObject("jobDataMap").get("com.fjhb.context.v1.Context"), jsonObj.get("context"));
}
public static class VO {
private A a;
private Set<A> values = new HashSet<A>();
public A getA() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/generic/GenericMap.java
7 issues
Line: 13
* Created by wenshao on 20/01/2017.
*/
public class GenericMap extends TestCase {
public void test_generic() throws Exception {
Model<User> model = JSON.parseObject("{\"values\":{\"1001\":{\"id\":1001}}}", new TypeReference<Model<User>>() {});
User user = model.values.get("1001");
assertNotNull(user);
assertEquals(1001, user.id);
}
Reported by PMD.
Line: 13
* Created by wenshao on 20/01/2017.
*/
public class GenericMap extends TestCase {
public void test_generic() throws Exception {
Model<User> model = JSON.parseObject("{\"values\":{\"1001\":{\"id\":1001}}}", new TypeReference<Model<User>>() {});
User user = model.values.get("1001");
assertNotNull(user);
assertEquals(1001, user.id);
}
Reported by PMD.
Line: 15
public class GenericMap extends TestCase {
public void test_generic() throws Exception {
Model<User> model = JSON.parseObject("{\"values\":{\"1001\":{\"id\":1001}}}", new TypeReference<Model<User>>() {});
User user = model.values.get("1001");
assertNotNull(user);
assertEquals(1001, user.id);
}
public static class Model<T> {
Reported by PMD.
Line: 16
public void test_generic() throws Exception {
Model<User> model = JSON.parseObject("{\"values\":{\"1001\":{\"id\":1001}}}", new TypeReference<Model<User>>() {});
User user = model.values.get("1001");
assertNotNull(user);
assertEquals(1001, user.id);
}
public static class Model<T> {
public Map<String, T> values;
Reported by PMD.
Line: 17
Model<User> model = JSON.parseObject("{\"values\":{\"1001\":{\"id\":1001}}}", new TypeReference<Model<User>>() {});
User user = model.values.get("1001");
assertNotNull(user);
assertEquals(1001, user.id);
}
public static class Model<T> {
public Map<String, T> values;
}
Reported by PMD.
Line: 21
}
public static class Model<T> {
public Map<String, T> values;
}
public static class User {
public int id;
}
Reported by PMD.
Line: 25
}
public static class User {
public int id;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/AbstractTest.java
7 issues
Line: 18
public class AbstractTest extends TestCase {
public void test_0() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, new ADeserializer());
VO vo = JSON.parseObject("{\"a\":{\"num\":1,\"name\":\"bb\"}}", VO.class);
Assert.assertTrue(vo.getA() instanceof B);
}
Reported by PMD.
Line: 21
public void test_0() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, new ADeserializer());
VO vo = JSON.parseObject("{\"a\":{\"num\":1,\"name\":\"bb\"}}", VO.class);
Assert.assertTrue(vo.getA() instanceof B);
}
public void test_1() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, new ADeserializer());
VO vo = JSON.parseObject("{\"a\":{\"num\":2,\"name\":\"bb\"}}", VO.class);
Reported by PMD.
Line: 24
Assert.assertTrue(vo.getA() instanceof B);
}
public void test_1() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, new ADeserializer());
VO vo = JSON.parseObject("{\"a\":{\"num\":2,\"name\":\"bb\"}}", VO.class);
Assert.assertTrue(vo.getA() instanceof C);
}
Reported by PMD.
Line: 27
public void test_1() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, new ADeserializer());
VO vo = JSON.parseObject("{\"a\":{\"num\":2,\"name\":\"bb\"}}", VO.class);
Assert.assertTrue(vo.getA() instanceof C);
}
public static class ADeserializer implements ObjectDeserializer {
Reported by PMD.
Line: 36
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONObject json = parser.parseObject();
int num = json.getInteger("num");
if (num == 1) {
return (T) JSON.toJavaObject(json, B.class);
} else if (num == 2) {
return (T) JSON.toJavaObject(json, C.class);
} else {
Reported by PMD.
Line: 37
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONObject json = parser.parseObject();
int num = json.getInteger("num");
if (num == 1) {
return (T) JSON.toJavaObject(json, B.class);
} else if (num == 2) {
return (T) JSON.toJavaObject(json, C.class);
} else {
return (T) JSON.toJavaObject(json, A.class);
Reported by PMD.
Line: 39
int num = json.getInteger("num");
if (num == 1) {
return (T) JSON.toJavaObject(json, B.class);
} else if (num == 2) {
return (T) JSON.toJavaObject(json, C.class);
} else {
return (T) JSON.toJavaObject(json, A.class);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest_for_huanxige.java
7 issues
Line: 12
* Created by wenshao on 08/02/2017.
*/
public class RefTest_for_huanxige extends TestCase {
public void test_for_ref() throws Exception {
//字符串通过其它对象序列化而来,当中涉及循环引用,因此存在$ref
String jsonStr="{\"displayName\":\"灰度发布\",\"id\":221," +
"\"name\":\"灰度\",\"processInsId\":48,\"processInstance\":{\"$ref\":\"$" +
".lastSubProcessInstence.parentProcess\"},\"status\":1,\"success\":true," +
"\"tail\":true,\"type\":\"gray\"}";
Reported by PMD.
Line: 12
* Created by wenshao on 08/02/2017.
*/
public class RefTest_for_huanxige extends TestCase {
public void test_for_ref() throws Exception {
//字符串通过其它对象序列化而来,当中涉及循环引用,因此存在$ref
String jsonStr="{\"displayName\":\"灰度发布\",\"id\":221," +
"\"name\":\"灰度\",\"processInsId\":48,\"processInstance\":{\"$ref\":\"$" +
".lastSubProcessInstence.parentProcess\"},\"status\":1,\"success\":true," +
"\"tail\":true,\"type\":\"gray\"}";
Reported by PMD.
Line: 19
".lastSubProcessInstence.parentProcess\"},\"status\":1,\"success\":true," +
"\"tail\":true,\"type\":\"gray\"}";
ProcessNodeInstanceDto a = JSON.parseObject(jsonStr, ProcessNodeInstanceDto.class);//status为空!!!
assertNotNull(a.status);
assertEquals(1, a.status.intValue());
}
public static class ProcessNodeInstanceDto implements Serializable {
private Long id;
Reported by PMD.
Line: 20
"\"tail\":true,\"type\":\"gray\"}";
ProcessNodeInstanceDto a = JSON.parseObject(jsonStr, ProcessNodeInstanceDto.class);//status为空!!!
assertNotNull(a.status);
assertEquals(1, a.status.intValue());
}
public static class ProcessNodeInstanceDto implements Serializable {
private Long id;
private Long processInsId;
Reported by PMD.
Line: 20
"\"tail\":true,\"type\":\"gray\"}";
ProcessNodeInstanceDto a = JSON.parseObject(jsonStr, ProcessNodeInstanceDto.class);//status为空!!!
assertNotNull(a.status);
assertEquals(1, a.status.intValue());
}
public static class ProcessNodeInstanceDto implements Serializable {
private Long id;
private Long processInsId;
Reported by PMD.
Line: 23
assertEquals(1, a.status.intValue());
}
public static class ProcessNodeInstanceDto implements Serializable {
private Long id;
private Long processInsId;
private String name;
private String displayName;
private Integer status;
Reported by PMD.
Line: 23
assertEquals(1, a.status.intValue());
}
public static class ProcessNodeInstanceDto implements Serializable {
private Long id;
private Long processInsId;
private String name;
private String displayName;
private Integer status;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerilaizeFilterTest.java
7 issues
Line: 14
public void test_for_jsonField() throws Exception {
Model m = new Model();
String json = JSON.toJSONString(m);
System.out.println(json);
}
public static class MyValueFilter implements ValueFilter {
public Object process(Object object, String name, Object value) {
Reported by PMD.
Line: 11
import junit.framework.TestCase;
public class SerilaizeFilterTest extends TestCase {
public void test_for_jsonField() throws Exception {
Model m = new Model();
String json = JSON.toJSONString(m);
System.out.println(json);
}
Reported by PMD.
Line: 11
import junit.framework.TestCase;
public class SerilaizeFilterTest extends TestCase {
public void test_for_jsonField() throws Exception {
Model m = new Model();
String json = JSON.toJSONString(m);
System.out.println(json);
}
Reported by PMD.
Line: 20
public static class MyValueFilter implements ValueFilter {
public Object process(Object object, String name, Object value) {
if (name.equals("id")) {
return 123;
}
return null;
}
Reported by PMD.
Line: 20
public static class MyValueFilter implements ValueFilter {
public Object process(Object object, String name, Object value) {
if (name.equals("id")) {
return 123;
}
return null;
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.serializer;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.serializer.PropertyFilter;
import com.alibaba.fastjson.serializer.ValueFilter;
import junit.framework.TestCase;
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.serializer.PropertyFilter;
import com.alibaba.fastjson.serializer.ValueFilter;
import junit.framework.TestCase;
public class SerilaizeFilterTest extends TestCase {
public void test_for_jsonField() throws Exception {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_Eishay_Media.java
7 issues
Line: 25
media.setPersons(Arrays.<String>asList("a",null));
String text = JSON.toJSONString(media, SerializerFeature.BeanToArray);
System.out.println(text);
Media media2 = JSON.parseObject(text, Media.class, Feature.SupportArrayToBean);
Assert.assertEquals(media.getHeight(), media2.getHeight());
Assert.assertEquals(media.getWidth(), media2.getWidth());
Assert.assertEquals(media.getSize(), media2.getSize());
Reported by PMD.
Line: 17
import data.media.Media.Player;
public class WriteAsArray_Eishay_Media extends TestCase {
public void test_0 () throws Exception {
Media media = new Media();
media.setHeight(123);
media.setPlayer(Player.FLASH);
media.setTitle("xx");
media.setPersons(Arrays.<String>asList("a",null));
Reported by PMD.
Line: 28
System.out.println(text);
Media media2 = JSON.parseObject(text, Media.class, Feature.SupportArrayToBean);
Assert.assertEquals(media.getHeight(), media2.getHeight());
Assert.assertEquals(media.getWidth(), media2.getWidth());
Assert.assertEquals(media.getSize(), media2.getSize());
Assert.assertEquals(media.getTitle(), media2.getTitle());
Assert.assertEquals(media.getUri(), media2.getUri());
}
Reported by PMD.
Line: 29
Media media2 = JSON.parseObject(text, Media.class, Feature.SupportArrayToBean);
Assert.assertEquals(media.getHeight(), media2.getHeight());
Assert.assertEquals(media.getWidth(), media2.getWidth());
Assert.assertEquals(media.getSize(), media2.getSize());
Assert.assertEquals(media.getTitle(), media2.getTitle());
Assert.assertEquals(media.getUri(), media2.getUri());
}
Reported by PMD.
Line: 30
Media media2 = JSON.parseObject(text, Media.class, Feature.SupportArrayToBean);
Assert.assertEquals(media.getHeight(), media2.getHeight());
Assert.assertEquals(media.getWidth(), media2.getWidth());
Assert.assertEquals(media.getSize(), media2.getSize());
Assert.assertEquals(media.getTitle(), media2.getTitle());
Assert.assertEquals(media.getUri(), media2.getUri());
}
}
Reported by PMD.
Line: 31
Assert.assertEquals(media.getHeight(), media2.getHeight());
Assert.assertEquals(media.getWidth(), media2.getWidth());
Assert.assertEquals(media.getSize(), media2.getSize());
Assert.assertEquals(media.getTitle(), media2.getTitle());
Assert.assertEquals(media.getUri(), media2.getUri());
}
}
Reported by PMD.
Line: 32
Assert.assertEquals(media.getWidth(), media2.getWidth());
Assert.assertEquals(media.getSize(), media2.getSize());
Assert.assertEquals(media.getTitle(), media2.getTitle());
Assert.assertEquals(media.getUri(), media2.getUri());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/BugTest1.java
7 issues
Line: 16
public class BugTest1 extends TestCase {
public void test_0() throws Exception {
AtomicBoolean v = new AtomicBoolean();
Assert.assertEquals("false", JSON.toJSONString(v));
}
public void test_1() throws Exception {
Reported by PMD.
Line: 21
Assert.assertEquals("false", JSON.toJSONString(v));
}
public void test_1() throws Exception {
AtomicBoolean v = new AtomicBoolean(true);
Assert.assertEquals("true", JSON.toJSONString(v));
}
public void test_2() throws Exception {
Reported by PMD.
Line: 26
Assert.assertEquals("true", JSON.toJSONString(v));
}
public void test_2() throws Exception {
AtomicInteger v = new AtomicInteger();
Assert.assertEquals("0", JSON.toJSONString(v));
}
public void test_3() throws Exception {
Reported by PMD.
Line: 31
Assert.assertEquals("0", JSON.toJSONString(v));
}
public void test_3() throws Exception {
AtomicLong v = new AtomicLong();
Assert.assertEquals("0", JSON.toJSONString(v));
}
public void test_4() throws Exception {
Reported by PMD.
Line: 36
Assert.assertEquals("0", JSON.toJSONString(v));
}
public void test_4() throws Exception {
AtomicReference<Integer> v = new AtomicReference<Integer>(3);
Assert.assertEquals("3", JSON.toJSONString(v));
}
public void test_5() throws Exception {
Reported by PMD.
Line: 41
Assert.assertEquals("3", JSON.toJSONString(v));
}
public void test_5() throws Exception {
Assert.assertEquals("\"java.util.concurrent.atomic.AtomicReference\"", JSON.toJSONString(AtomicReference.class));
}
public void test_7() throws Exception {
Assert.assertEquals("'java.util.concurrent.atomic.AtomicReference'", JSON.toJSONString(AtomicReference.class, SerializerFeature.UseSingleQuotes));
Reported by PMD.
Line: 45
Assert.assertEquals("\"java.util.concurrent.atomic.AtomicReference\"", JSON.toJSONString(AtomicReference.class));
}
public void test_7() throws Exception {
Assert.assertEquals("'java.util.concurrent.atomic.AtomicReference'", JSON.toJSONString(AtomicReference.class, SerializerFeature.UseSingleQuotes));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/asm/TestASMEishay.java
7 issues
Line: 14
public class TestASMEishay extends TestCase {
public void test_asm() throws Exception {
String text = JSON.toJSONString(EishayEncode.mediaContent, SerializerFeature.WriteEnumUsingToString);
System.out.println(text);
System.out.println(text.getBytes().length);
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
System.out.println(text2);
}
Reported by PMD.
Line: 15
public void test_asm() throws Exception {
String text = JSON.toJSONString(EishayEncode.mediaContent, SerializerFeature.WriteEnumUsingToString);
System.out.println(text);
System.out.println(text.getBytes().length);
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
System.out.println(text2);
}
}
Reported by PMD.
Line: 18
System.out.println(text.getBytes().length);
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
System.out.println(text2);
}
}
Reported by PMD.
Line: 12
import data.media.MediaContent;
public class TestASMEishay extends TestCase {
public void test_asm() throws Exception {
String text = JSON.toJSONString(EishayEncode.mediaContent, SerializerFeature.WriteEnumUsingToString);
System.out.println(text);
System.out.println(text.getBytes().length);
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
Reported by PMD.
Line: 12
import data.media.MediaContent;
public class TestASMEishay extends TestCase {
public void test_asm() throws Exception {
String text = JSON.toJSONString(EishayEncode.mediaContent, SerializerFeature.WriteEnumUsingToString);
System.out.println(text);
System.out.println(text.getBytes().length);
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
Reported by PMD.
Line: 15
public void test_asm() throws Exception {
String text = JSON.toJSONString(EishayEncode.mediaContent, SerializerFeature.WriteEnumUsingToString);
System.out.println(text);
System.out.println(text.getBytes().length);
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
System.out.println(text2);
}
}
Reported by PMD.
Line: 15
public void test_asm() throws Exception {
String text = JSON.toJSONString(EishayEncode.mediaContent, SerializerFeature.WriteEnumUsingToString);
System.out.println(text);
System.out.println(text.getBytes().length);
MediaContent object = JSON.parseObject(text, MediaContent.class);
String text2 = JSON.toJSONString(object, SerializerFeature.WriteEnumUsingToString);
System.out.println(text2);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_BrowserSecure_6_name_script.java
7 issues
Line: 13
public class SerializeWriterTest_BrowserSecure_6_name_script extends TestCase {
public void test_0() throws Exception {
JSONObject object = new JSONObject();
object.put("<script>alert(1);</script>", "value");
String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\":\"value\"}", text);
Reported by PMD.
Line: 13
public class SerializeWriterTest_BrowserSecure_6_name_script extends TestCase {
public void test_0() throws Exception {
JSONObject object = new JSONObject();
object.put("<script>alert(1);</script>", "value");
String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\":\"value\"}", text);
Reported by PMD.
Line: 18
object.put("<script>alert(1);</script>", "value");
String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\":\"value\"}", text);
JSONObject object1 = JSON.parseObject(text);
assertEquals(object.get("<script>alert(1);</script>"), object1.get("<script>alert(1);</script>"));
}
//
// public void test_1() throws Exception {
Reported by PMD.
Line: 20
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\":\"value\"}", text);
JSONObject object1 = JSON.parseObject(text);
assertEquals(object.get("<script>alert(1);</script>"), object1.get("<script>alert(1);</script>"));
}
//
// public void test_1() throws Exception {
// String text = JSON.toJSONString("<", SerializerFeature.BrowserSecure);
// assertEquals("\"\\u003C\"", text);
Reported by PMD.
Line: 20
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\":\"value\"}", text);
JSONObject object1 = JSON.parseObject(text);
assertEquals(object.get("<script>alert(1);</script>"), object1.get("<script>alert(1);</script>"));
}
//
// public void test_1() throws Exception {
// String text = JSON.toJSONString("<", SerializerFeature.BrowserSecure);
// assertEquals("\"\\u003C\"", text);
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONWriter;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import java.io.StringWriter;
Reported by PMD.
Line: 9
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import java.io.StringWriter;
public class SerializeWriterTest_BrowserSecure_6_name_script extends TestCase {
public void test_0() throws Exception {
JSONObject object = new JSONObject();
Reported by PMD.