The following issues were found
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_default_double.java
3 issues
Line: 11
public class JSONCreatorTest_default_double extends TestCase {
public void test_create() throws Exception {
Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class);
Assert.assertTrue(model.id == 0);
Assert.assertEquals("wenshao", model.name);
}
Reported by PMD.
Line: 20
public static class Model {
private final double id;
private final String name;
@JSONCreator
public Model(@JSONField(name="id") double id, @JSONField(name="name") String name) {
this.id = id;
Reported by PMD.
Line: 21
public static class Model {
private final double id;
private final String name;
@JSONCreator
public Model(@JSONField(name="id") double id, @JSONField(name="name") String name) {
this.id = id;
this.name = name;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_default_float.java
3 issues
Line: 11
public class JSONCreatorTest_default_float extends TestCase {
public void test_create() throws Exception {
Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class);
Assert.assertTrue(model.id == 0);
Assert.assertEquals("wenshao", model.name);
}
Reported by PMD.
Line: 20
public static class Model {
private final float id;
private final String name;
@JSONCreator
public Model(@JSONField(name="id") float id, @JSONField(name="name") String name) {
this.id = id;
Reported by PMD.
Line: 21
public static class Model {
private final float id;
private final String name;
@JSONCreator
public Model(@JSONField(name="id") float id, @JSONField(name="name") String name) {
this.id = id;
this.name = name;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1100/Issue1144.java
3 issues
Line: 14
public void test_issue_1144() throws Exception {
Model model = new Model();
String json = JSON.toJSONString(model);
System.out.println(json);
}
@JSONType(alphabetic = false)
public static class Model {
public int f2;
Reported by PMD.
Line: 11
* Created by wenshao on 13/04/2017.
*/
public class Issue1144 extends TestCase {
public void test_issue_1144() throws Exception {
Model model = new Model();
String json = JSON.toJSONString(model);
System.out.println(json);
}
Reported by PMD.
Line: 11
* Created by wenshao on 13/04/2017.
*/
public class Issue1144 extends TestCase {
public void test_issue_1144() throws Exception {
Model model = new Model();
String json = JSON.toJSONString(model);
System.out.println(json);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1700/Issue1769.java
3 issues
Line: 13
import java.util.TimeZone;
public class Issue1769 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
Reported by PMD.
Line: 18
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
byte[] newby = "{\"beginTime\":\"420180319160440\"}".getBytes();
QueryTaskResultReq rsp3 = JSON.parseObject(newby, QueryTaskResultReq.class);
assertEquals("{\"beginTime\":\"152841225111920\"}", new String(JSON.toJSONBytes(rsp3)));
}
Reported by PMD.
Line: 21
public void test_for_issue() throws Exception {
byte[] newby = "{\"beginTime\":\"420180319160440\"}".getBytes();
QueryTaskResultReq rsp3 = JSON.parseObject(newby, QueryTaskResultReq.class);
assertEquals("{\"beginTime\":\"152841225111920\"}", new String(JSON.toJSONBytes(rsp3)));
}
@JSONType(orders = {"beginTime"})
public static class QueryTaskResultReq
{
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1700/Issue1780_JSONObject.java
3 issues
Line: 10
public class Issue1780_JSONObject extends TestCase {
public void test_for_issue() {
org.json.JSONObject req = new org.json.JSONObject();
req.put("id", 1111);
req.put("name", "name11");
String text = JSON.toJSONString(req, SerializerFeature.SortField);
assertTrue("{\"id\":1111,\"name\":\"name11\"}".equals(text)
Reported by PMD.
Line: 15
req.put("id", 1111);
req.put("name", "name11");
String text = JSON.toJSONString(req, SerializerFeature.SortField);
assertTrue("{\"id\":1111,\"name\":\"name11\"}".equals(text)
|| "{\"name\":\"name11\",\"id\":1111}".equals(text)
);
}
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.issue_1700;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
public class Issue1780_JSONObject extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2200/issue2224/KeyedCollection.java
3 issues
Line: 8
import java.util.LinkedHashMap;
import java.util.Map;
public abstract class KeyedCollection<TKey, TItem> implements CollectionEx<TItem>, Cloneable {
private transient Map<TKey, TItem> items = new LinkedHashMap<TKey, TItem>();
protected abstract TKey getKeyForItem(TItem item);
public TItem get(TKey key) {
Reported by PMD.
Line: 9
import java.util.Map;
public abstract class KeyedCollection<TKey, TItem> implements CollectionEx<TItem>, Cloneable {
private transient Map<TKey, TItem> items = new LinkedHashMap<TKey, TItem>();
protected abstract TKey getKeyForItem(TItem item);
public TItem get(TKey key) {
return this.items.get(key);
Reported by PMD.
Line: 39
return this.items.values().toArray();
}
public <T> T[] toArray(T[] a) {
return this.items.values().toArray(a);
}
public boolean add(TItem item) {
if (item == null)
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1000/Issue1089_private.java
3 issues
Line: 10
* Created by wenshao on 20/03/2017.
*/
public class Issue1089_private extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"ab\":123,\"a_b\":456}";
TestBean tb = JSON.parseObject(json, TestBean.class);
assertEquals(123, tb.getAb());
}
Reported by PMD.
Line: 13
public void test_for_issue() throws Exception {
String json = "{\"ab\":123,\"a_b\":456}";
TestBean tb = JSON.parseObject(json, TestBean.class);
assertEquals(123, tb.getAb());
}
private static class TestBean {
private int ab;
Reported by PMD.
Line: 13
public void test_for_issue() throws Exception {
String json = "{\"ab\":123,\"a_b\":456}";
TestBean tb = JSON.parseObject(json, TestBean.class);
assertEquals(123, tb.getAb());
}
private static class TestBean {
private int ab;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1000/Issue1089.java
3 issues
Line: 10
* Created by wenshao on 20/03/2017.
*/
public class Issue1089 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"ab\":123,\"a_b\":456}";
TestBean tb = JSON.parseObject(json, TestBean.class);
assertEquals(123, tb.getAb());
}
Reported by PMD.
Line: 13
public void test_for_issue() throws Exception {
String json = "{\"ab\":123,\"a_b\":456}";
TestBean tb = JSON.parseObject(json, TestBean.class);
assertEquals(123, tb.getAb());
}
public static class TestBean {
private int ab;
Reported by PMD.
Line: 13
public void test_for_issue() throws Exception {
String json = "{\"ab\":123,\"a_b\":456}";
TestBean tb = JSON.parseObject(json, TestBean.class);
assertEquals(123, tb.getAb());
}
public static class TestBean {
private int ab;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1000/Issue1086.java
3 issues
Line: 10
* Created by wenshao on 20/03/2017.
*/
public class Issue1086 extends TestCase {
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"flag\":1}", Model.class);
assertTrue(model.flag);
}
public static class Model {
Reported by PMD.
Line: 12
public class Issue1086 extends TestCase {
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"flag\":1}", Model.class);
assertTrue(model.flag);
}
public static class Model {
public boolean flag;
}
Reported by PMD.
Line: 16
}
public static class Model {
public boolean flag;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1000/Issue1082.java
3 issues
Line: 11
* Created by wenshao on 17/03/2017.
*/
public class Issue1082 extends TestCase {
public void test_for_issue() throws Exception {
Throwable error = null;
try {
JSON.parseObject("{}", Model_1082.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 18
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
}
public class Model_1082 {
}
Reported by PMD.
Line: 12
*/
public class Issue1082 extends TestCase {
public void test_for_issue() throws Exception {
Throwable error = null;
try {
JSON.parseObject("{}", Model_1082.class);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.