The following issues were found
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/parser/AtomicIntegerComptableAndroidTest.java
10 issues
Line: 13
* Created by wenshao on 20/03/2017.
*/
public class AtomicIntegerComptableAndroidTest extends TestCase {
public void test_for_compatible_zero() throws Exception {
String text = "{\"andIncrement\":-1,\"andDecrement\":0}";
assertEquals(0, JSON.parseObject(text, AtomicInteger.class).intValue());
}
Reported by PMD.
Line: 16
public void test_for_compatible_zero() throws Exception {
String text = "{\"andIncrement\":-1,\"andDecrement\":0}";
assertEquals(0, JSON.parseObject(text, AtomicInteger.class).intValue());
}
public void test_for_compatible_six() throws Exception {
String text = "{\"andIncrement\":5,\"andDecrement\":6}";
Reported by PMD.
Line: 16
public void test_for_compatible_zero() throws Exception {
String text = "{\"andIncrement\":-1,\"andDecrement\":0}";
assertEquals(0, JSON.parseObject(text, AtomicInteger.class).intValue());
}
public void test_for_compatible_six() throws Exception {
String text = "{\"andIncrement\":5,\"andDecrement\":6}";
Reported by PMD.
Line: 19
assertEquals(0, JSON.parseObject(text, AtomicInteger.class).intValue());
}
public void test_for_compatible_six() throws Exception {
String text = "{\"andIncrement\":5,\"andDecrement\":6}";
assertEquals(6, JSON.parseObject(text, AtomicInteger.class).intValue());
}
Reported by PMD.
Line: 22
public void test_for_compatible_six() throws Exception {
String text = "{\"andIncrement\":5,\"andDecrement\":6}";
assertEquals(6, JSON.parseObject(text, AtomicInteger.class).intValue());
}
public void test_for_compatible_five() throws Exception {
String text = "{\"andDecrement\":6,\"andIncrement\":5}";
Reported by PMD.
Line: 22
public void test_for_compatible_six() throws Exception {
String text = "{\"andIncrement\":5,\"andDecrement\":6}";
assertEquals(6, JSON.parseObject(text, AtomicInteger.class).intValue());
}
public void test_for_compatible_five() throws Exception {
String text = "{\"andDecrement\":6,\"andIncrement\":5}";
Reported by PMD.
Line: 25
assertEquals(6, JSON.parseObject(text, AtomicInteger.class).intValue());
}
public void test_for_compatible_five() throws Exception {
String text = "{\"andDecrement\":6,\"andIncrement\":5}";
assertEquals(5, JSON.parseObject(text, AtomicInteger.class).intValue());
}
}
Reported by PMD.
Line: 28
public void test_for_compatible_five() throws Exception {
String text = "{\"andDecrement\":6,\"andIncrement\":5}";
assertEquals(5, JSON.parseObject(text, AtomicInteger.class).intValue());
}
}
Reported by PMD.
Line: 28
public void test_for_compatible_five() throws Exception {
String text = "{\"andDecrement\":6,\"andIncrement\":5}";
assertEquals(5, JSON.parseObject(text, AtomicInteger.class).intValue());
}
}
Reported by PMD.
Line: 7
import junit.framework.TestCase;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
/**
* Created by wenshao on 20/03/2017.
*/
public class AtomicIntegerComptableAndroidTest extends TestCase {
Reported by PMD.
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/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest10.java
10 issues
Line: 10
import junit.framework.TestCase;
public class JSONCreatorTest10 extends TestCase {
public void test_for_yk() throws Exception {
String jsonString = "{\"link\":\"http://lqgzs.org/fsqhwlnf\",\"text\":\"乐动力专享\"}";
JSONObject headerJSON = JSONObject.parseObject(jsonString);
HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);
assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
Reported by PMD.
Line: 10
import junit.framework.TestCase;
public class JSONCreatorTest10 extends TestCase {
public void test_for_yk() throws Exception {
String jsonString = "{\"link\":\"http://lqgzs.org/fsqhwlnf\",\"text\":\"乐动力专享\"}";
JSONObject headerJSON = JSONObject.parseObject(jsonString);
HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);
assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
Reported by PMD.
Line: 13
public void test_for_yk() throws Exception {
String jsonString = "{\"link\":\"http://lqgzs.org/fsqhwlnf\",\"text\":\"乐动力专享\"}";
JSONObject headerJSON = JSONObject.parseObject(jsonString);
HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);
assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
assertEquals("乐动力专享", headerDTO.title);
}
Reported by PMD.
Line: 15
JSONObject headerJSON = JSONObject.parseObject(jsonString);
HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);
assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
assertEquals("乐动力专享", headerDTO.title);
}
public static class HeaderDTO {
private String title;
Reported by PMD.
Line: 16
HeaderDTO headerDTO = headerJSON.toJavaObject(HeaderDTO.class);
assertEquals("http://lqgzs.org/fsqhwlnf", headerDTO.link);
assertEquals("乐动力专享", headerDTO.title);
}
public static class HeaderDTO {
private String title;
private String link;
Reported by PMD.
Line: 20
}
public static class HeaderDTO {
private String title;
private String link;
@JSONCreator
public HeaderDTO(@JSONField(name = "text") String title,@JSONField(name = "link") String link) {
this.title = title;
Reported by PMD.
Line: 20
}
public static class HeaderDTO {
private String title;
private String link;
@JSONCreator
public HeaderDTO(@JSONField(name = "text") String title,@JSONField(name = "link") String link) {
this.title = title;
Reported by PMD.
Line: 21
public static class HeaderDTO {
private String title;
private String link;
@JSONCreator
public HeaderDTO(@JSONField(name = "text") String title,@JSONField(name = "link") String link) {
this.title = title;
this.link = link;
Reported by PMD.
Line: 21
public static class HeaderDTO {
private String title;
private String link;
@JSONCreator
public HeaderDTO(@JSONField(name = "text") String title,@JSONField(name = "link") String link) {
this.title = title;
this.link = link;
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.parser.creator;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import junit.framework.TestCase;
public class JSONCreatorTest10 extends TestCase {
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/parser/creator/JSONCreatorTest_float_obj.java
10 issues
Line: 14
public class JSONCreatorTest_float_obj extends TestCase {
public void test_create() throws Exception {
Entity entity = new Entity(123.45F, "菜姐");
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
Reported by PMD.
Line: 19
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45F, "菜姐");
Reported by PMD.
Line: 19
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45F, "菜姐");
Reported by PMD.
Line: 19
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45F, "菜姐");
Reported by PMD.
Line: 20
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45F, "菜姐");
String text = JSON.toJSONString(entity);
Reported by PMD.
Line: 23
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45F, "菜姐");
String text = JSON.toJSONString(entity);
ParserConfig config = new ParserConfig();
Reported by PMD.
Line: 30
ParserConfig config = new ParserConfig();
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public static class Entity {
Reported by PMD.
Line: 30
ParserConfig config = new ParserConfig();
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public static class Entity {
Reported by PMD.
Line: 30
ParserConfig config = new ParserConfig();
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public static class Entity {
Reported by PMD.
Line: 31
Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
Assert.assertTrue(entity.getId().floatValue() == entity2.getId().floatValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public static class Entity {
private final Float id;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_Collection.java
10 issues
Line: 22
A a = new A();
a.setList(Collections.singletonList(new B()));
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection$A\",\"list\":[{}]}",
text);
A a1 = (A) JSON.parse(text);
Reported by PMD.
Line: 14
import com.alibaba.fastjson.serializer.SerializerFeature;
public class WriteClassNameTest_Collection extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection");
}
public void test_list() throws Exception {
A a = new A();
Reported by PMD.
Line: 15
public class WriteClassNameTest_Collection extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection");
}
public void test_list() throws Exception {
A a = new A();
a.setList(Collections.singletonList(new B()));
Reported by PMD.
Line: 18
com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection");
}
public void test_list() throws Exception {
A a = new A();
a.setList(Collections.singletonList(new B()));
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection$A\",\"list\":[{}]}",
Reported by PMD.
Line: 28
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
private static class A {
Reported by PMD.
Line: 28
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
private static class A {
Reported by PMD.
Line: 29
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
private static class A {
private Collection<B> list;
Reported by PMD.
Line: 29
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
private static class A {
private Collection<B> list;
Reported by PMD.
Line: 29
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
private static class A {
private Collection<B> list;
Reported by PMD.
Line: 6
import java.util.Collection;
import java.util.Collections;
import com.alibaba.fastjson.parser.ParserConfig;
import org.junit.Assert;
import junit.framework.TestCase;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/MapTest.java
10 issues
Line: 25
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
System.out.println(text);
VO vo2 = (VO) JSON.parse(text);
Assert.assertEquals(vo.getValue(), vo2.getValue());
}
Reported by PMD.
Line: 39
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
System.out.println(text);
VO vo2 = (VO) JSON.parse(text);
Assert.assertEquals(vo.getValue(), vo2.getValue());
}
Reported by PMD.
Line: 15
import com.alibaba.fastjson.serializer.SerializerFeature;
public class MapTest extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.MapTest");
}
public void test_map() throws Exception {
VO vo = new VO();
Reported by PMD.
Line: 16
public class MapTest extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.MapTest");
}
public void test_map() throws Exception {
VO vo = new VO();
vo.getValue().put("1", "AA");
Reported by PMD.
Line: 19
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.MapTest");
}
public void test_map() throws Exception {
VO vo = new VO();
vo.getValue().put("1", "AA");
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 21
public void test_map() throws Exception {
VO vo = new VO();
vo.getValue().put("1", "AA");
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
System.out.println(text);
Reported by PMD.
Line: 29
VO vo2 = (VO) JSON.parse(text);
Assert.assertEquals(vo.getValue(), vo2.getValue());
}
public void test_map_2() throws Exception {
VO vo = new VO();
vo.setValue(new TreeMap<String, Object>());
Reported by PMD.
Line: 32
Assert.assertEquals(vo.getValue(), vo2.getValue());
}
public void test_map_2() throws Exception {
VO vo = new VO();
vo.setValue(new TreeMap<String, Object>());
vo.getValue().put("1", "AA");
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 35
public void test_map_2() throws Exception {
VO vo = new VO();
vo.setValue(new TreeMap<String, Object>());
vo.getValue().put("1", "AA");
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
System.out.println(text);
Reported by PMD.
Line: 43
VO vo2 = (VO) JSON.parse(text);
Assert.assertEquals(vo.getValue(), vo2.getValue());
}
private static class VO {
private Map<String, Object> value = new HashMap<String, Object>();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/ProxyTest2.java
10 issues
Line: 15
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
// System.out.println(model2.getClass());
assertEquals("{\"id\":1001}", JSON.toJSONString(model));
Reported by PMD.
Line: 12
* Created by wenshao on 07/08/2017.
*/
public class ProxyTest2 extends TestCase {
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
Reported by PMD.
Line: 12
* Created by wenshao on 07/08/2017.
*/
public class ProxyTest2 extends TestCase {
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
Reported by PMD.
Line: 13
*/
public class ProxyTest2 extends TestCase {
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
// System.out.println(model2.getClass());
Reported by PMD.
Line: 14
public class ProxyTest2 extends TestCase {
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
// System.out.println(model2.getClass());
Reported by PMD.
Line: 15
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
// System.out.println(model2.getClass());
assertEquals("{\"id\":1001}", JSON.toJSONString(model));
Reported by PMD.
Line: 20
// System.out.println(model.getClass());
// System.out.println(model2.getClass());
assertEquals("{\"id\":1001}", JSON.toJSONString(model));
assertEquals("{\"id\":1001}", JSON.toJSONString(model));
}
public static interface Model {
Reported by PMD.
Line: 21
// System.out.println(model2.getClass());
assertEquals("{\"id\":1001}", JSON.toJSONString(model));
assertEquals("{\"id\":1001}", JSON.toJSONString(model));
}
public static interface Model {
int getId();
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import java.lang.reflect.Proxy;
/**
* Created by wenshao on 07/08/2017.
*/
public class ProxyTest2 extends TestCase {
Reported by PMD.
Line: 14
public class ProxyTest2 extends TestCase {
public void test_0() throws Exception {
Model model = JSON.parseObject("{\"id\":1001}", Model.class);
Model model2 = JSON.parseObject("{\"id\":1001}", Model.class);
System.out.println(model.getId());
// System.out.println(model.getClass());
// System.out.println(model2.getClass());
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.