The following issues were found
src/test/java/com/alibaba/json/bvt/ChineseSpaceTest.java
7 issues
Line: 15
* Created by wenshao on 2016/10/14.
*/
public class ChineseSpaceTest extends TestCase {
public void test_for_chinese_space() throws Exception {
Map<String, String> map = Collections.singletonMap("v", " ");
String json = JSON.toJSONString(map);
assertEquals("{\"v\":\" \"}", json);
JSONObject jsonObject = JSON.parseObject(json);
Reported by PMD.
Line: 15
* Created by wenshao on 2016/10/14.
*/
public class ChineseSpaceTest extends TestCase {
public void test_for_chinese_space() throws Exception {
Map<String, String> map = Collections.singletonMap("v", " ");
String json = JSON.toJSONString(map);
assertEquals("{\"v\":\" \"}", json);
JSONObject jsonObject = JSON.parseObject(json);
Reported by PMD.
Line: 18
public void test_for_chinese_space() throws Exception {
Map<String, String> map = Collections.singletonMap("v", " ");
String json = JSON.toJSONString(map);
assertEquals("{\"v\":\" \"}", json);
JSONObject jsonObject = JSON.parseObject(json);
assertEquals(map.get("v"), jsonObject.get("v"));
}
}
Reported by PMD.
Line: 21
assertEquals("{\"v\":\" \"}", json);
JSONObject jsonObject = JSON.parseObject(json);
assertEquals(map.get("v"), jsonObject.get("v"));
}
}
Reported by PMD.
Line: 21
assertEquals("{\"v\":\" \"}", json);
JSONObject jsonObject = JSON.parseObject(json);
assertEquals(map.get("v"), jsonObject.get("v"));
}
}
Reported by PMD.
Line: 21
assertEquals("{\"v\":\" \"}", json);
JSONObject jsonObject = JSON.parseObject(json);
assertEquals(map.get("v"), jsonObject.get("v"));
}
}
Reported by PMD.
Line: 8
import junit.framework.TestCase;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* Created by wenshao on 2016/10/14.
*/
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_389.java
7 issues
Line: 14
public class Bug_for_issue_389 extends TestCase {
public void test_for_issue() throws Exception {
Def def = new Def();
def.add(new User());
String defStr = JSON.toJSONString(def);
Assert.assertEquals("[{}]", defStr);
Reported by PMD.
Line: 22
Assert.assertEquals("[{}]", defStr);
Def _def = JSON.parseObject(defStr, Def.class);
Assert.assertEquals(User.class, _def.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
Def def = new Def();
def.add(new User());
Reported by PMD.
Line: 22
Assert.assertEquals("[{}]", defStr);
Def _def = JSON.parseObject(defStr, Def.class);
Assert.assertEquals(User.class, _def.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
Def def = new Def();
def.add(new User());
Reported by PMD.
Line: 25
Assert.assertEquals(User.class, _def.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
Def def = new Def();
def.add(new User());
String defStr = JSON.toJSONString(def);
Assert.assertEquals("[{}]", defStr);
Reported by PMD.
Line: 33
Assert.assertEquals("[{}]", defStr);
Def _def = JSON.parseObject(defStr, new TypeReference<Def>() {});
Assert.assertEquals(User.class, _def.get(0).getClass());
}
public static class User {
String name;
Reported by PMD.
Line: 36
Assert.assertEquals(User.class, _def.get(0).getClass());
}
public static class User {
String name;
String value;
public String getName() {
Reported by PMD.
Line: 59
}
public static class Def extends ArrayList<User> {
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue983.java
7 issues
Line: 13
* Created by wenshao on 10/01/2017.
*/
public class Issue983 extends TestCase {
public void test_for_issue() throws Exception {
Map.Entry entry = JSON.parseObject("{\"name\":\"foo\"}", Map.Entry.class);
assertEquals("name", entry.getKey());
assertEquals("foo", entry.getValue());
}
}
Reported by PMD.
Line: 13
* Created by wenshao on 10/01/2017.
*/
public class Issue983 extends TestCase {
public void test_for_issue() throws Exception {
Map.Entry entry = JSON.parseObject("{\"name\":\"foo\"}", Map.Entry.class);
assertEquals("name", entry.getKey());
assertEquals("foo", entry.getValue());
}
}
Reported by PMD.
Line: 15
public class Issue983 extends TestCase {
public void test_for_issue() throws Exception {
Map.Entry entry = JSON.parseObject("{\"name\":\"foo\"}", Map.Entry.class);
assertEquals("name", entry.getKey());
assertEquals("foo", entry.getValue());
}
}
Reported by PMD.
Line: 15
public class Issue983 extends TestCase {
public void test_for_issue() throws Exception {
Map.Entry entry = JSON.parseObject("{\"name\":\"foo\"}", Map.Entry.class);
assertEquals("name", entry.getKey());
assertEquals("foo", entry.getValue());
}
}
Reported by PMD.
Line: 16
public void test_for_issue() throws Exception {
Map.Entry entry = JSON.parseObject("{\"name\":\"foo\"}", Map.Entry.class);
assertEquals("name", entry.getKey());
assertEquals("foo", entry.getValue());
}
}
Reported by PMD.
Line: 16
public void test_for_issue() throws Exception {
Map.Entry entry = JSON.parseObject("{\"name\":\"foo\"}", Map.Entry.class);
assertEquals("name", entry.getKey());
assertEquals("foo", entry.getValue());
}
}
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import java.util.AbstractMap;
import java.util.Map;
/**
* Created by wenshao on 10/01/2017.
*/
Reported by PMD.
src/test/java/com/alibaba/json/bvt/asm/Huge_200_ClassTest.java
7 issues
Line: 1
package com.alibaba.json.bvt.asm;
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
public class Huge_200_ClassTest extends TestCase {
public void test_huge() {
JSON.parseObject("{}", VO.class);
Reported by PMD.
Line: 7
import junit.framework.TestCase;
public class Huge_200_ClassTest extends TestCase {
public void test_huge() {
JSON.parseObject("{}", VO.class);
}
public static class VO {
Reported by PMD.
Line: 8
import junit.framework.TestCase;
public class Huge_200_ClassTest extends TestCase {
public void test_huge() {
JSON.parseObject("{}", VO.class);
}
public static class VO {
Reported by PMD.
Line: 8
import junit.framework.TestCase;
public class Huge_200_ClassTest extends TestCase {
public void test_huge() {
JSON.parseObject("{}", VO.class);
}
public static class VO {
Reported by PMD.
Line: 12
JSON.parseObject("{}", VO.class);
}
public static class VO {
private Integer f000;
private Integer f001;
private Integer f002;
private Integer f003;
Reported by PMD.
Line: 12
JSON.parseObject("{}", VO.class);
}
public static class VO {
private Integer f000;
private Integer f001;
private Integer f002;
private Integer f003;
Reported by PMD.
Line: 12
JSON.parseObject("{}", VO.class);
}
public static class VO {
private Integer f000;
private Integer f001;
private Integer f002;
private Integer f003;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_457.java
7 issues
Line: 17
public class Bug_for_issue_457 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig.global.putDeserializer(MyEnum.class, new MyEnumDeser());
VO entity = JSON.parseObject("{\"myEnum\":\"AA\"}", VO.class);
Assert.assertEquals(MyEnum.A, entity.myEnum);
}
Reported by PMD.
Line: 28
@Override
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
String text = (String) parser.parse();
if (text.equals("AA")) {
return (T) MyEnum.A;
}
if (text.equals("BB")) {
return (T) MyEnum.B;
Reported by PMD.
Line: 28
@Override
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
String text = (String) parser.parse();
if (text.equals("AA")) {
return (T) MyEnum.A;
}
if (text.equals("BB")) {
return (T) MyEnum.B;
Reported by PMD.
Line: 28
@Override
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
String text = (String) parser.parse();
if (text.equals("AA")) {
return (T) MyEnum.A;
}
if (text.equals("BB")) {
return (T) MyEnum.B;
Reported by PMD.
Line: 32
return (T) MyEnum.A;
}
if (text.equals("BB")) {
return (T) MyEnum.B;
}
return null;
}
Reported by PMD.
Line: 32
return (T) MyEnum.A;
}
if (text.equals("BB")) {
return (T) MyEnum.B;
}
return null;
}
Reported by PMD.
Line: 32
return (T) MyEnum.A;
}
if (text.equals("BB")) {
return (T) MyEnum.B;
}
return null;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/annotation/JsonSeeAlsoTest.java
7 issues
Line: 13
public class JsonSeeAlsoTest extends TestCase {
public void test_seeAlso_dog() throws Exception {
Dog dog = new Dog();
dog.dogName = "dog1001";
String text = JSON.toJSONString(dog, SerializerFeature.WriteClassName);
Assert.assertEquals("{\"@type\":\"dog\",\"dogName\":\"dog1001\"}", text);
Reported by PMD.
Line: 25
Assert.assertEquals(dog.dogName, dog2.dogName);
}
public void test_seeAlso_cat() throws Exception {
Cat cat = new Cat();
cat.catName = "cat2001";
String text = JSON.toJSONString(cat, SerializerFeature.WriteClassName);
Assert.assertEquals("{\"@type\":\"cat\",\"catName\":\"cat2001\"}", text);
Reported by PMD.
Line: 37
Assert.assertEquals(cat.catName, cat2.catName);
}
public void test_seeAlso_tidy() throws Exception {
Tidy tidy = new Tidy();
tidy.dogName = "dog2001";
tidy.tidySpecific = "tidy1001";
String text = JSON.toJSONString(tidy, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 56
@JSONType(typeName = "dog", seeAlso={Tidy.class, Labrador.class})
public static class Dog extends Animal {
public String dogName;
}
@JSONType(typeName = "cat")
public static class Cat extends Animal {
public String catName;
Reported by PMD.
Line: 61
@JSONType(typeName = "cat")
public static class Cat extends Animal {
public String catName;
}
@JSONType(typeName = "tidy")
public static class Tidy extends Dog {
public String tidySpecific;
Reported by PMD.
Line: 66
@JSONType(typeName = "tidy")
public static class Tidy extends Dog {
public String tidySpecific;
}
@JSONType(typeName = "labrador")
public static class Labrador extends Dog {
public String tidySpecific;
Reported by PMD.
Line: 71
@JSONType(typeName = "labrador")
public static class Labrador extends Dog {
public String tidySpecific;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue989.java
7 issues
Line: 23
*/
public class Issue989 extends TestCase {
public void test_for_issue() throws Exception {
assertEquals(
JSON.toJSONString(getMyObject(new HashMap<String, Name>())),
JSON.toJSONString(getMyObject(new TreeMap<String, Name>()))
);
}
Reported by PMD.
Line: 24
public class Issue989 extends TestCase {
public void test_for_issue() throws Exception {
assertEquals(
JSON.toJSONString(getMyObject(new HashMap<String, Name>())),
JSON.toJSONString(getMyObject(new TreeMap<String, Name>()))
);
}
Reported by PMD.
Line: 47
for(Map.Entry<String, Name> entry :
((Map<String, Name>)object).entrySet()) {
Name name = entry.getValue();
names.put(entry.getKey(), name.getFirst() + ":" + name.getSecond());
}
MapSerializer.instance.write(serializer, names, fieldName, JSONObject.class, features);
}
}
Reported by PMD.
Line: 47
for(Map.Entry<String, Name> entry :
((Map<String, Name>)object).entrySet()) {
Name name = entry.getValue();
names.put(entry.getKey(), name.getFirst() + ":" + name.getSecond());
}
MapSerializer.instance.write(serializer, names, fieldName, JSONObject.class, features);
}
}
Reported by PMD.
Line: 49
Name name = entry.getValue();
names.put(entry.getKey(), name.getFirst() + ":" + name.getSecond());
}
MapSerializer.instance.write(serializer, names, fieldName, JSONObject.class, features);
}
}
public static class MyObject {
Reported by PMD.
Line: 69
}
private static class Name {
private String first;
private String second;
Reported by PMD.
Line: 10
import com.alibaba.fastjson.serializer.MapSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import junit.framework.TestCase;
import org.junit.Assert;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/annotation/CustomSerializerTest_enum.java
7 issues
Line: 17
public class CustomSerializerTest_enum extends TestCase {
public void test_0() throws Exception {
Model model = new Model();
model.id = 1001;
model.orderType = OrderType.PayOrder;
String text = JSON.toJSONString(model);
// Assert.assertEquals("{\"id\":1001,\"orderType\":{\"remark\":\"支付订单\",\"value\":1}}", text);
Reported by PMD.
Line: 17
public class CustomSerializerTest_enum extends TestCase {
public void test_0() throws Exception {
Model model = new Model();
model.id = 1001;
model.orderType = OrderType.PayOrder;
String text = JSON.toJSONString(model);
// Assert.assertEquals("{\"id\":1001,\"orderType\":{\"remark\":\"支付订单\",\"value\":1}}", text);
Reported by PMD.
Line: 21
Model model = new Model();
model.id = 1001;
model.orderType = OrderType.PayOrder;
String text = JSON.toJSONString(model);
// Assert.assertEquals("{\"id\":1001,\"orderType\":{\"remark\":\"支付订单\",\"value\":1}}", text);
}
public static class Model {
public int id;
Reported by PMD.
Line: 26
}
public static class Model {
public int id;
public OrderType orderType;
}
public static enum OrderType implements JSONSerializable {
PayOrder(1, "支付订单"), //
Reported by PMD.
Line: 27
public static class Model {
public int id;
public OrderType orderType;
}
public static enum OrderType implements JSONSerializable {
PayOrder(1, "支付订单"), //
SettleBill(2, "结算单");
Reported by PMD.
Line: 6
import java.io.IOException;
import java.lang.reflect.Type;
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.JSONSerializable;
import com.alibaba.fastjson.serializer.JSONSerializer;
Reported by PMD.
Line: 21
Model model = new Model();
model.id = 1001;
model.orderType = OrderType.PayOrder;
String text = JSON.toJSONString(model);
// Assert.assertEquals("{\"id\":1001,\"orderType\":{\"remark\":\"支付订单\",\"value\":1}}", text);
}
public static class Model {
public int id;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/builder/BuilderTest1_private.java
7 issues
Line: 12
public class BuilderTest1_private extends TestCase {
public void test_create() throws Exception {
VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
Assert.assertEquals(12304, vo.getId());
Assert.assertEquals("ljw", vo.getName());
}
Reported by PMD.
Line: 15
public void test_create() throws Exception {
VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
Assert.assertEquals(12304, vo.getId());
Assert.assertEquals("ljw", vo.getName());
}
@JSONType(builder=VOBuilder.class)
public static class VO {
Reported by PMD.
Line: 16
VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
Assert.assertEquals(12304, vo.getId());
Assert.assertEquals("ljw", vo.getName());
}
@JSONType(builder=VOBuilder.class)
public static class VO {
private int id;
Reported by PMD.
Line: 21
@JSONType(builder=VOBuilder.class)
public static class VO {
private int id;
private String name;
public int getId() {
return id;
}
Reported by PMD.
Line: 22
@JSONType(builder=VOBuilder.class)
public static class VO {
private int id;
private String name;
public int getId() {
return id;
}
Reported by PMD.
Line: 35
private static class VOBuilder {
private VO vo = new VO();
public VO create() {
return vo;
}
Reported by PMD.
Line: 35
private static class VOBuilder {
private VO vo = new VO();
public VO create() {
return vo;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/builder/BuilderTest0_private.java
7 issues
Line: 12
public class BuilderTest0_private extends TestCase {
public void test_0() throws Exception {
VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
Assert.assertEquals(12304, vo.getId());
Assert.assertEquals("ljw", vo.getName());
}
Reported by PMD.
Line: 15
public void test_0() throws Exception {
VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
Assert.assertEquals(12304, vo.getId());
Assert.assertEquals("ljw", vo.getName());
}
@JSONType(builder=VOBuilder.class)
public static class VO {
Reported by PMD.
Line: 16
VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
Assert.assertEquals(12304, vo.getId());
Assert.assertEquals("ljw", vo.getName());
}
@JSONType(builder=VOBuilder.class)
public static class VO {
private int id;
Reported by PMD.
Line: 21
@JSONType(builder=VOBuilder.class)
public static class VO {
private int id;
private String name;
public int getId() {
return id;
}
Reported by PMD.
Line: 22
@JSONType(builder=VOBuilder.class)
public static class VO {
private int id;
private String name;
public int getId() {
return id;
}
Reported by PMD.
Line: 35
private static class VOBuilder {
private VO vo = new VO();
public VO build() {
return vo;
}
Reported by PMD.
Line: 35
private static class VOBuilder {
private VO vo = new VO();
public VO build() {
return vo;
}
Reported by PMD.