The following issues were found
src/test/java/com/alibaba/json/bvt/IncomingDataPointTest.java
10 issues
Line: 30
IncomingDataPoint[] array = new IncomingDataPoint[] {point};
String json = JSON.toJSONString(array);
System.out.println(json);
JSON.parseArray(json, IncomingDataPoint.class);
IncomingDataPoint p2 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"}]", IncomingDataPoint.class);
IncomingDataPoint p3 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"},null]", IncomingDataPoint.class);
Reported by PMD.
Line: 36
IncomingDataPoint p2 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"}]", IncomingDataPoint.class);
IncomingDataPoint p3 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"},null]", IncomingDataPoint.class);
System.out.println(JSON.toJSONString(p2));
// JSON.parseObject(json, IncomingDataPoint[].class);
}
public void test_for_IncomingDataPoint() throws Exception {
// "metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"
String text = "[[\"DataAdaptor.LbMultiGroupPersonalityDataAdaptor.stddev.aggregate_sum\",\"1501812639932\",\"95.52667633256902\",{\"appName\":\"aladdin\",\"hostIdc\":\"et2\",\"hostunit\":\"CENTER\",\"nodegroup\":\"aladdin_prehost\",\"idc\":\"ET2\",\"agg_version\":\"100\",\"group\":\"DEFAULT\"},\"\",\"\",\"\"]]";
Reported by PMD.
Line: 42
public void test_for_IncomingDataPoint() throws Exception {
// "metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"
String text = "[[\"DataAdaptor.LbMultiGroupPersonalityDataAdaptor.stddev.aggregate_sum\",\"1501812639932\",\"95.52667633256902\",{\"appName\":\"aladdin\",\"hostIdc\":\"et2\",\"hostunit\":\"CENTER\",\"nodegroup\":\"aladdin_prehost\",\"idc\":\"ET2\",\"agg_version\":\"100\",\"group\":\"DEFAULT\"},\"\",\"\",\"\"]]";
System.out.println(text);
JSON.parseArray(text, IncomingDataPoint.class);
}
}
Reported by PMD.
Line: 14
* Created by wenshao on 03/08/2017.
*/
public class IncomingDataPointTest extends TestCase {
public void test_0() throws Exception {
Map<String, String> tags = new LinkedHashMap<String, String>();
tags.put("site", "et2");
tags.put("appname", "histore");
tags.put("ip", "1.1.1.1");
Reported by PMD.
Line: 14
* Created by wenshao on 03/08/2017.
*/
public class IncomingDataPointTest extends TestCase {
public void test_0() throws Exception {
Map<String, String> tags = new LinkedHashMap<String, String>();
tags.put("site", "et2");
tags.put("appname", "histore");
tags.put("ip", "1.1.1.1");
Reported by PMD.
Line: 18
Map<String, String> tags = new LinkedHashMap<String, String>();
tags.put("site", "et2");
tags.put("appname", "histore");
tags.put("ip", "1.1.1.1");
IncomingDataPoint point = new IncomingDataPoint();
point.setMetric("mem.usage.GB");
point.setTimestamp(1501760861298L);
point.setTags(tags);
Reported by PMD.
Line: 35
JSON.parseArray(json, IncomingDataPoint.class);
IncomingDataPoint p2 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"}]", IncomingDataPoint.class);
IncomingDataPoint p3 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"},null]", IncomingDataPoint.class);
System.out.println(JSON.toJSONString(p2));
// JSON.parseObject(json, IncomingDataPoint[].class);
}
public void test_for_IncomingDataPoint() throws Exception {
// "metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"
Reported by PMD.
Line: 39
System.out.println(JSON.toJSONString(p2));
// JSON.parseObject(json, IncomingDataPoint[].class);
}
public void test_for_IncomingDataPoint() throws Exception {
// "metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"
String text = "[[\"DataAdaptor.LbMultiGroupPersonalityDataAdaptor.stddev.aggregate_sum\",\"1501812639932\",\"95.52667633256902\",{\"appName\":\"aladdin\",\"hostIdc\":\"et2\",\"hostunit\":\"CENTER\",\"nodegroup\":\"aladdin_prehost\",\"idc\":\"ET2\",\"agg_version\":\"100\",\"group\":\"DEFAULT\"},\"\",\"\",\"\"]]";
System.out.println(text);
JSON.parseArray(text, IncomingDataPoint.class);
}
Reported by PMD.
Line: 39
System.out.println(JSON.toJSONString(p2));
// JSON.parseObject(json, IncomingDataPoint[].class);
}
public void test_for_IncomingDataPoint() throws Exception {
// "metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"
String text = "[[\"DataAdaptor.LbMultiGroupPersonalityDataAdaptor.stddev.aggregate_sum\",\"1501812639932\",\"95.52667633256902\",{\"appName\":\"aladdin\",\"hostIdc\":\"et2\",\"hostunit\":\"CENTER\",\"nodegroup\":\"aladdin_prehost\",\"idc\":\"ET2\",\"agg_version\":\"100\",\"group\":\"DEFAULT\"},\"\",\"\",\"\"]]";
System.out.println(text);
JSON.parseArray(text, IncomingDataPoint.class);
}
Reported by PMD.
Line: 35
JSON.parseArray(json, IncomingDataPoint.class);
IncomingDataPoint p2 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"}]", IncomingDataPoint.class);
IncomingDataPoint p3 = JSON.parseObject("[\"mem.usage.GB\",1501833776283,\"58.41\",{\"site\":\"et2\",\"appname\":\"histore\",\"ip\":\"1.1.1.1\"},null]", IncomingDataPoint.class);
System.out.println(JSON.toJSONString(p2));
// JSON.parseObject(json, IncomingDataPoint[].class);
}
public void test_for_IncomingDataPoint() throws Exception {
// "metric", "timestamp", "value", "tags", "tsuid", "granularity", "aggregator"
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/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_1300/Issue1303.java
10 issues
Line: 16
* Created by kimmking on 02/07/2017.
*/
public class Issue1303 extends TestCase {
public void test_for_issue() {
String jsonString = "[{\"author\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"a876c49c18\"},\"createdAt\":\"2017-07-02 20:06:13\",\"imgurl\":\"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=11075891,34401011&fm=117&gp=0.jpg\",\"name\":\"衣架\",\"objectId\":\"029d5493cd\",\"prices\":\"1\",\"updatedAt\":\"2017-07-02 20:06:13\"}]";
JSONArray jsonArray = JSON.parseArray(jsonString);
//jsonArray = new JSONArray(jsonArray);//这一句打开也一样是正确的
double total = 0;
for (int i = 0; i <jsonArray.size() ; i++) {
Reported by PMD.
Line: 16
* Created by kimmking on 02/07/2017.
*/
public class Issue1303 extends TestCase {
public void test_for_issue() {
String jsonString = "[{\"author\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"a876c49c18\"},\"createdAt\":\"2017-07-02 20:06:13\",\"imgurl\":\"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=11075891,34401011&fm=117&gp=0.jpg\",\"name\":\"衣架\",\"objectId\":\"029d5493cd\",\"prices\":\"1\",\"updatedAt\":\"2017-07-02 20:06:13\"}]";
JSONArray jsonArray = JSON.parseArray(jsonString);
//jsonArray = new JSONArray(jsonArray);//这一句打开也一样是正确的
double total = 0;
for (int i = 0; i <jsonArray.size() ; i++) {
Reported by PMD.
Line: 23
double total = 0;
for (int i = 0; i <jsonArray.size() ; i++) {
JSONObject object=jsonArray.getJSONObject(i);
assertEquals("衣架",object.getString("name"));
total=total+ Double.valueOf(object.getString("prices"));
}
assertEquals(1.0d,total);
}
}
Reported by PMD.
Line: 23
double total = 0;
for (int i = 0; i <jsonArray.size() ; i++) {
JSONObject object=jsonArray.getJSONObject(i);
assertEquals("衣架",object.getString("name"));
total=total+ Double.valueOf(object.getString("prices"));
}
assertEquals(1.0d,total);
}
}
Reported by PMD.
Line: 24
for (int i = 0; i <jsonArray.size() ; i++) {
JSONObject object=jsonArray.getJSONObject(i);
assertEquals("衣架",object.getString("name"));
total=total+ Double.valueOf(object.getString("prices"));
}
assertEquals(1.0d,total);
}
}
Reported by PMD.
Line: 26
assertEquals("衣架",object.getString("name"));
total=total+ Double.valueOf(object.getString("prices"));
}
assertEquals(1.0d,total);
}
}
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import org.junit.Assert;
Reported by PMD.
Line: 7
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import org.junit.Assert;
/**
Reported by PMD.
Line: 8
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import org.junit.Assert;
/**
* Created by kimmking on 02/07/2017.
Reported by PMD.
Line: 10
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import junit.framework.TestCase;
import org.junit.Assert;
/**
* Created by kimmking on 02/07/2017.
*/
public class Issue1303 extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1271.java
10 issues
Line: 19
final AtomicInteger count = new AtomicInteger(0);
ExtraProcessor extraProcessor = new ExtraProcessor() {
public void processExtra(Object object, String key, Object value) {
System.out.println("setter not found, class " + object.getClass().getName() + ", property " + key);
count.incrementAndGet();
}
};
Reported by PMD.
Line: 12
* Created by kimmking on 15/06/2017.
*/
public class Issue1271 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"a\":1,\"b\":2}";
final AtomicInteger count = new AtomicInteger(0);
ExtraProcessor extraProcessor = new ExtraProcessor() {
Reported by PMD.
Line: 12
* Created by kimmking on 15/06/2017.
*/
public class Issue1271 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"a\":1,\"b\":2}";
final AtomicInteger count = new AtomicInteger(0);
ExtraProcessor extraProcessor = new ExtraProcessor() {
Reported by PMD.
Line: 19
final AtomicInteger count = new AtomicInteger(0);
ExtraProcessor extraProcessor = new ExtraProcessor() {
public void processExtra(Object object, String key, Object value) {
System.out.println("setter not found, class " + object.getClass().getName() + ", property " + key);
count.incrementAndGet();
}
};
Reported by PMD.
Line: 26
A a = JSON.parseObject(json,A.class,extraProcessor);
assertEquals(1,a.a);
assertEquals(1, count.intValue());
B b = JSON.parseObject(json,B.class,extraProcessor);
assertEquals(1,b.a);
assertEquals(2, count.intValue());
Reported by PMD.
Line: 27
A a = JSON.parseObject(json,A.class,extraProcessor);
assertEquals(1,a.a);
assertEquals(1, count.intValue());
B b = JSON.parseObject(json,B.class,extraProcessor);
assertEquals(1,b.a);
assertEquals(2, count.intValue());
Reported by PMD.
Line: 30
assertEquals(1, count.intValue());
B b = JSON.parseObject(json,B.class,extraProcessor);
assertEquals(1,b.a);
assertEquals(2, count.intValue());
}
public static class A {
Reported by PMD.
Line: 31
B b = JSON.parseObject(json,B.class,extraProcessor);
assertEquals(1,b.a);
assertEquals(2, count.intValue());
}
public static class A {
public int a;
Reported by PMD.
Line: 36
}
public static class A {
public int a;
}
public static class B {
private int a;
Reported by PMD.
Line: 36
}
public static class A {
public int a;
}
public static class B {
private int a;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_569_1.java
10 issues
Line: 16
* Created by wenshao on 16/8/11.
*/
public class Bug_for_issue_569_1 extends TestCase {
public void test_for_issue() throws Exception {
String str = "{\"bList\":[{\"data\":[0,1]},{\"data\":[1,2]},{\"data\":[2,3]},{\"data\":[3,4]},{\"data\":[4,5]},{\"data\":[5,6]},{\"data\":[6,7]},{\"data\":[7,8]},{\"data\":[8,9]},{\"data\":[9,10]}]}";
A<Integer> aInteger;
A<Long> aLong;
// aInteger = JSON.parseObject(str, new TypeReference<A<Integer>>() {
Reported by PMD.
Line: 18
public class Bug_for_issue_569_1 extends TestCase {
public void test_for_issue() throws Exception {
String str = "{\"bList\":[{\"data\":[0,1]},{\"data\":[1,2]},{\"data\":[2,3]},{\"data\":[3,4]},{\"data\":[4,5]},{\"data\":[5,6]},{\"data\":[6,7]},{\"data\":[7,8]},{\"data\":[8,9]},{\"data\":[9,10]}]}";
A<Integer> aInteger;
A<Long> aLong;
// aInteger = JSON.parseObject(str, new TypeReference<A<Integer>>() {
// });
// Assert.assertEquals(aInteger.getbList().get(0).getData().get(0).getClass().getName(), Integer.class.getName());
Reported by PMD.
Line: 27
//
aLong = JSON.parseObject(str, new TypeReference<A<Long>>() {
});
Assert.assertEquals(aLong.getbList().get(0).getData().get(0).getClass().getName(), Long.class.getName());
}
Reported by PMD.
Line: 27
//
aLong = JSON.parseObject(str, new TypeReference<A<Long>>() {
});
Assert.assertEquals(aLong.getbList().get(0).getData().get(0).getClass().getName(), Long.class.getName());
}
Reported by PMD.
Line: 27
//
aLong = JSON.parseObject(str, new TypeReference<A<Long>>() {
});
Assert.assertEquals(aLong.getbList().get(0).getData().get(0).getClass().getName(), Long.class.getName());
}
Reported by PMD.
Line: 27
//
aLong = JSON.parseObject(str, new TypeReference<A<Long>>() {
});
Assert.assertEquals(aLong.getbList().get(0).getData().get(0).getClass().getName(), Long.class.getName());
}
Reported by PMD.
Line: 27
//
aLong = JSON.parseObject(str, new TypeReference<A<Long>>() {
});
Assert.assertEquals(aLong.getbList().get(0).getData().get(0).getClass().getName(), Long.class.getName());
}
Reported by PMD.
Line: 34
public static class A<T> {
private List<B<T>> bList;
public List<B<T>> getbList() {
return bList;
}
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import junit.framework.TestCase;
import org.junit.Assert;
import java.util.List;
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import junit.framework.TestCase;
import org.junit.Assert;
import java.util.List;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_465.java
10 issues
Line: 13
import junit.framework.TestCase;
public class Bug_for_issue_465 extends TestCase {
public void test_for_issue() throws Exception {
String json = "[\"abc\",\"efg\",\"sss\",[1,2]]";
TestBean testBean = JSON.parseObject(json, TestBean.class);
Assert.assertEquals("abc", testBean.name);
Assert.assertEquals("efg", testBean.country);
Reported by PMD.
Line: 25
Assert.assertEquals(2, testBean.location[1]);
}
public void f_test_for_issue_private() throws Exception {
String json = "[\"abc\",\"efg\",\"sss\",[1,2]]";
TestBean1 testBean = JSON.parseObject(json, TestBean1.class);
Assert.assertEquals("abc", testBean.name);
Assert.assertEquals("efg", testBean.country);
Reported by PMD.
Line: 38
}
@JSONType(parseFeatures = Feature.SupportArrayToBean)
public static class TestBean {
private String name;
private String password;
private String country;
Reported by PMD.
Line: 75
}
public int[] getLocation() {
return location;
}
@JSONField(ordinal = 3)
public void setLocation(int[] location) {
this.location = location;
Reported by PMD.
Line: 79
}
@JSONField(ordinal = 3)
public void setLocation(int[] location) {
this.location = location;
}
}
@JSONType(parseFeatures = Feature.SupportArrayToBean)
Reported by PMD.
Line: 85
}
@JSONType(parseFeatures = Feature.SupportArrayToBean)
private static class TestBean1 {
private String name;
private String password;
private String country;
Reported by PMD.
Line: 122
}
public int[] getLocation() {
return location;
}
@JSONField(ordinal = 3)
public void setLocation(int[] location) {
this.location = location;
Reported by PMD.
Line: 126
}
@JSONField(ordinal = 3)
public void setLocation(int[] location) {
this.location = location;
}
}
}
Reported by PMD.
Line: 79
}
@JSONField(ordinal = 3)
public void setLocation(int[] location) {
this.location = location;
}
}
@JSONType(parseFeatures = Feature.SupportArrayToBean)
Reported by PMD.
Line: 126
}
@JSONField(ordinal = 3)
public void setLocation(int[] location) {
this.location = location;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2100/Issue2132.java
10 issues
Line: 10
import java.util.List;
public class Issue2132 extends TestCase {
public void test_for_issue() throws Exception {
Cpu cpu = new Cpu("intel", 3.3);
Screen screen = new Screen(16, 9, "samsung");
Student student = new Student();
Computer computer = student.assembling(cpu,screen);
cpu.setName("intell");
Reported by PMD.
Line: 27
list1.add(computer);
String s = JSON.toJSONString(list1);
assertEquals("[[{\"name\":\"intell\",\"speed\":3.3},{\"height\":9,\"name\":\"samsung\",\"width\":16},\"2\",\"3\"],{\"cpu\":{\"$ref\":\"$[0][0]\"},\"screen\":{\"$ref\":\"$[0][1]\"}}]", s);
}
public static class Cpu {
private String name;
private double speed;
Reported by PMD.
Line: 30
assertEquals("[[{\"name\":\"intell\",\"speed\":3.3},{\"height\":9,\"name\":\"samsung\",\"width\":16},\"2\",\"3\"],{\"cpu\":{\"$ref\":\"$[0][0]\"},\"screen\":{\"$ref\":\"$[0][1]\"}}]", s);
}
public static class Cpu {
private String name;
private double speed;
public Cpu(String name, double speed) {
this.name = name;
Reported by PMD.
Line: 56
}
}
public static class Screen {
private int width;
private int height;
private String name;
public Screen(int width, int height, String name) {
Reported by PMD.
Line: 92
}
}
public static class Computer {
Cpu cpu;
Screen screen;
public Computer(Cpu cpu, Screen screen) {
this.cpu = cpu;
Reported by PMD.
Line: 118
}
}
public static class Student {
private Cpu cpu;
private Screen screen;
public Computer assembling(Cpu cpu, Screen screen) {
this.cpu = cpu;
Reported by PMD.
Line: 17
Computer computer = student.assembling(cpu,screen);
cpu.setName("intell");
Object[] objectArray = new Object[4];
objectArray[0] = cpu;
objectArray[1] = screen;
objectArray[2] = "2";
objectArray[3] = "3";
List<Object> list1 = new ArrayList<Object>();
Reported by PMD.
Line: 18
cpu.setName("intell");
Object[] objectArray = new Object[4];
objectArray[0] = cpu;
objectArray[1] = screen;
objectArray[2] = "2";
objectArray[3] = "3";
List<Object> list1 = new ArrayList<Object>();
list1.add(objectArray);
Reported by PMD.
Line: 19
Object[] objectArray = new Object[4];
objectArray[0] = cpu;
objectArray[1] = screen;
objectArray[2] = "2";
objectArray[3] = "3";
List<Object> list1 = new ArrayList<Object>();
list1.add(objectArray);
list1.add(computer);
Reported by PMD.
Line: 20
Object[] objectArray = new Object[4];
objectArray[0] = cpu;
objectArray[1] = screen;
objectArray[2] = "2";
objectArray[3] = "3";
List<Object> list1 = new ArrayList<Object>();
list1.add(objectArray);
list1.add(computer);
String s = JSON.toJSONString(list1);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/CurrencyTest5.java
10 issues
Line: 21
jsonObject.put("value", Currency.getInstance("CNY"));
String text = JSON.toJSONString(jsonObject, config);
System.out.println(text);
String str1 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"symbol\":\"CNY\"}}";
String str2 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"symbol\":\"¥\"}}";
String str3 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"numericCodeAsString\":\"156\",\"symbol\":\"CN¥\"}}";
String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
assertTrue(text.equals(str1)
Reported by PMD.
Line: 12
public class CurrencyTest5 extends TestCase {
public void test_0() throws Exception {
SerializeConfig config = new SerializeConfig();
config.put(Currency.class
, config.createJavaBeanSerializer(Currency.class));
JSONObject jsonObject = new JSONObject();
Reported by PMD.
Line: 12
public class CurrencyTest5 extends TestCase {
public void test_0() throws Exception {
SerializeConfig config = new SerializeConfig();
config.put(Currency.class
, config.createJavaBeanSerializer(Currency.class));
JSONObject jsonObject = new JSONObject();
Reported by PMD.
Line: 26
String str2 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"symbol\":\"¥\"}}";
String str3 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"numericCodeAsString\":\"156\",\"symbol\":\"CN¥\"}}";
String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
assertTrue(text.equals(str1)
|| text.equals(str2)
|| text.equals(str3)
|| text.equals(str4));
Currency currency = JSON.parseObject(text, VO.class).value;
Reported by PMD.
Line: 26
String str2 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"symbol\":\"¥\"}}";
String str3 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"numericCodeAsString\":\"156\",\"symbol\":\"CN¥\"}}";
String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
assertTrue(text.equals(str1)
|| text.equals(str2)
|| text.equals(str3)
|| text.equals(str4));
Currency currency = JSON.parseObject(text, VO.class).value;
Reported by PMD.
Line: 27
String str3 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"Chinese Yuan\",\"numericCodeAsString\":\"156\",\"symbol\":\"CN¥\"}}";
String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
assertTrue(text.equals(str1)
|| text.equals(str2)
|| text.equals(str3)
|| text.equals(str4));
Currency currency = JSON.parseObject(text, VO.class).value;
Reported by PMD.
Line: 28
String str4 = "{\"value\":{\"currencyCode\":\"CNY\",\"displayName\":\"人民币\",\"numericCodeAsString\":\"156\",\"symbol\":\"¥\"}}";
assertTrue(text.equals(str1)
|| text.equals(str2)
|| text.equals(str3)
|| text.equals(str4));
Currency currency = JSON.parseObject(text, VO.class).value;
assertSame(Currency.getInstance("CNY"), currency);
Reported by PMD.
Line: 29
assertTrue(text.equals(str1)
|| text.equals(str2)
|| text.equals(str3)
|| text.equals(str4));
Currency currency = JSON.parseObject(text, VO.class).value;
assertSame(Currency.getInstance("CNY"), currency);
}
Reported by PMD.
Line: 31
|| text.equals(str3)
|| text.equals(str4));
Currency currency = JSON.parseObject(text, VO.class).value;
assertSame(Currency.getInstance("CNY"), currency);
}
public static class VO {
Reported by PMD.
Line: 33
Currency currency = JSON.parseObject(text, VO.class).value;
assertSame(Currency.getInstance("CNY"), currency);
}
public static class VO {
public Currency value;
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.