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/creator/JSONCreatorTest_double_obj.java
10 issues
Line: 14
public class JSONCreatorTest_double_obj extends TestCase {
public void test_create() throws Exception {
Entity entity = new Entity(123.45D, "菜姐");
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
Reported by PMD.
Line: 19
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45D, "菜姐");
Reported by PMD.
Line: 19
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45D, "菜姐");
Reported by PMD.
Line: 19
String text = JSON.toJSONString(entity);
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45D, "菜姐");
Reported by PMD.
Line: 20
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public void test_create_2() throws Exception {
Entity entity = new Entity(123.45D, "菜姐");
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.45D, "菜姐");
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().doubleValue() == entity2.getId().doubleValue());
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().doubleValue() == entity2.getId().doubleValue());
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().doubleValue() == entity2.getId().doubleValue());
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().doubleValue() == entity2.getId().doubleValue());
Assert.assertEquals(entity.getName(), entity2.getName());
}
public static class Entity {
private final Double id;
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/parser/AETest.java
10 issues
Line: 42
" ]\n" +
"}";
public void test_for_ae() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(Area.class, new ObjectDeserializer() {
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONObject jsonObject = (JSONObject) parser.parse();
String areaType;
Reported by PMD.
Line: 42
" ]\n" +
"}";
public void test_for_ae() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(Area.class, new ObjectDeserializer() {
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONObject jsonObject = (JSONObject) parser.parse();
String areaType;
Reported by PMD.
Line: 48
JSONObject jsonObject = (JSONObject) parser.parse();
String areaType;
if (jsonObject.get("type") instanceof String) {
areaType = (String) jsonObject.get("type");
} else {
return null;
}
if (Area.TYPE_FLOOR.equals(areaType)) {
Reported by PMD.
Line: 53
} else {
return null;
}
if (Area.TYPE_FLOOR.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, Floor.class);
} else if (Area.TYPE_ITEM.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, Item.class);
}
Reported by PMD.
Line: 55
}
if (Area.TYPE_FLOOR.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, Floor.class);
} else if (Area.TYPE_ITEM.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, Item.class);
}
return null;
}
Reported by PMD.
Line: 70
Data data = JSON.parseObject(jsonData, Data.class);
Item item = (Item) ((Floor)(data.areaList.get(0))).children.get(0);
}
}
Reported by PMD.
Line: 70
Data data = JSON.parseObject(jsonData, Data.class);
Item item = (Item) ((Floor)(data.areaList.get(0))).children.get(0);
}
}
Reported by PMD.
Line: 9
import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.json.bvtVO.ae.*;
import junit.framework.TestCase;
import java.lang.reflect.Type;
import java.util.Arrays;
Reported by PMD.
Line: 10
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.json.bvtVO.ae.*;
import junit.framework.TestCase;
import java.lang.reflect.Type;
import java.util.Arrays;
Reported by PMD.
Line: 14
import junit.framework.TestCase;
import java.lang.reflect.Type;
import java.util.Arrays;
/**
* Created by wenshao on 08/05/2017.
*/
public class AETest extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2300/Issue2358.java
10 issues
Line: 11
public class Issue2358 extends TestCase {
public void test_for_issue() throws Exception {
String str = "[{\n" +
" \"test1\":\"1\",\n" +
" \"test2\":\"2\"\n" +
"},\n" +
" {\n" +
Reported by PMD.
Line: 11
public class Issue2358 extends TestCase {
public void test_for_issue() throws Exception {
String str = "[{\n" +
" \"test1\":\"1\",\n" +
" \"test2\":\"2\"\n" +
"},\n" +
" {\n" +
Reported by PMD.
Line: 23
Exception error = null;
try {
List<TestJson2> testJsons = JSONObject.parseArray(str, TestJson2.class);
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
assertEquals("can't create non-static inner class instance.", error.getMessage());
Reported by PMD.
Line: 27
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
assertEquals("can't create non-static inner class instance.", error.getMessage());
}
class TestJson {
Reported by PMD.
Line: 28
error = ex;
}
assertNotNull(error);
assertEquals("can't create non-static inner class instance.", error.getMessage());
}
class TestJson {
private String test1;
Reported by PMD.
Line: 28
error = ex;
}
assertNotNull(error);
assertEquals("can't create non-static inner class instance.", error.getMessage());
}
class TestJson {
private String test1;
Reported by PMD.
Line: 31
assertEquals("can't create non-static inner class instance.", error.getMessage());
}
class TestJson {
private String test1;
private String test2;
public String getTest1() {
Reported by PMD.
Line: 55
}
class TestJson2 {
private String test1;
private String test2;
public String getTest1() {
return test1;
Reported by PMD.
Line: 21
" \"test2\":\"2\"\n" +
" }]";
Exception error = null;
try {
List<TestJson2> testJsons = JSONObject.parseArray(str, TestJson2.class);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
Line: 23
Exception error = null;
try {
List<TestJson2> testJsons = JSONObject.parseArray(str, TestJson2.class);
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
assertEquals("can't create non-static inner class instance.", error.getMessage());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/mixins/MixinSerForFieldsTest.java
10 issues
Line: 20
}
}
abstract class MixIn {
@JSONField(serialize = false)
public String a;
@JSONField(name = "banana")
public String b;
}
Reported by PMD.
Line: 11
public class MixinSerForFieldsTest extends TestCase {
static class BeanClass {
public String a;
public String b;
public BeanClass(String a, String b) {
this.a = a;
this.b = b;
Reported by PMD.
Line: 12
public class MixinSerForFieldsTest extends TestCase {
static class BeanClass {
public String a;
public String b;
public BeanClass(String a, String b) {
this.a = a;
this.b = b;
}
Reported by PMD.
Line: 20
}
}
abstract class MixIn {
@JSONField(serialize = false)
public String a;
@JSONField(name = "banana")
public String b;
}
Reported by PMD.
Line: 27
public String b;
}
public void test() throws Exception{
BeanClass bean = new BeanClass("1", "2");
JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
String jsonString = JSON.toJSONString(bean);
JSONObject result = JSON.parseObject(jsonString);
Reported by PMD.
Line: 27
public String b;
}
public void test() throws Exception{
BeanClass bean = new BeanClass("1", "2");
JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
String jsonString = JSON.toJSONString(bean);
JSONObject result = JSON.parseObject(jsonString);
Reported by PMD.
Line: 33
JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
String jsonString = JSON.toJSONString(bean);
JSONObject result = JSON.parseObject(jsonString);
assertEquals(1, result.size());
assertEquals("2", result.get("banana"));
JSON.removeMixInAnnotations(BeanClass.class);
}
}
Reported by PMD.
Line: 33
JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
String jsonString = JSON.toJSONString(bean);
JSONObject result = JSON.parseObject(jsonString);
assertEquals(1, result.size());
assertEquals("2", result.get("banana"));
JSON.removeMixInAnnotations(BeanClass.class);
}
}
Reported by PMD.
Line: 34
String jsonString = JSON.toJSONString(bean);
JSONObject result = JSON.parseObject(jsonString);
assertEquals(1, result.size());
assertEquals("2", result.get("banana"));
JSON.removeMixInAnnotations(BeanClass.class);
}
}
Reported by PMD.
Line: 34
String jsonString = JSON.toJSONString(bean);
JSONObject result = JSON.parseObject(jsonString);
assertEquals(1, result.size());
assertEquals("2", result.get("banana"));
JSON.removeMixInAnnotations(BeanClass.class);
}
}
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/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.
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.