The following issues were found
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_error.java
4 issues
Line: 14
public class JSONCreatorTest_error extends TestCase {
public void test_create() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":123,\"name\":\"abc\"}", Entity.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 30
private final String name;
@JSONCreator
public Entity(@JSONField(name = "id") int id, @JSONField(name = "name") String name){
throw new UnsupportedOperationException();
}
public int getId() {
return id;
Reported by PMD.
Line: 30
private final String name;
@JSONCreator
public Entity(@JSONField(name = "id") int id, @JSONField(name = "name") String name){
throw new UnsupportedOperationException();
}
public int getId() {
return id;
Reported by PMD.
Line: 15
public class JSONCreatorTest_error extends TestCase {
public void test_create() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":123,\"name\":\"abc\"}", Entity.class);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/date/DateParseTest11.java
4 issues
Line: 11
public class DateParseTest11 extends TestCase {
public void test() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2012-04-01T12:04:05.555\"}", VO.class);
}
public static class VO {
Reported by PMD.
Line: 11
public class DateParseTest11 extends TestCase {
public void test() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2012-04-01T12:04:05.555\"}", VO.class);
}
public static class VO {
Reported by PMD.
Line: 12
public class DateParseTest11 extends TestCase {
public void test() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2012-04-01T12:04:05.555\"}", VO.class);
}
public static class VO {
private Date date;
Reported by PMD.
Line: 12
public class DateParseTest11 extends TestCase {
public void test() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2012-04-01T12:04:05.555\"}", VO.class);
}
public static class VO {
private Date date;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_list_size.java
4 issues
Line: 13
import com.alibaba.fastjson.JSONPath;
public class JSONPath_list_size extends TestCase {
public void test_list_size() throws Exception {
List list = new ArrayList();
list.add(new Object());
list.add(new Object());
list.add(new Object());
JSONPath path = new JSONPath("$.size()");
Reported by PMD.
Line: 20
list.add(new Object());
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(list);
Assert.assertEquals(list.size(), result.intValue());
}
public void test_list_size2() throws Exception {
List list = new ArrayList();
list.add(new Object());
Reported by PMD.
Line: 23
Assert.assertEquals(list.size(), result.intValue());
}
public void test_list_size2() throws Exception {
List list = new ArrayList();
list.add(new Object());
list.add(new Object());
list.add(new Object());
JSONPath path = new JSONPath("$.size");
Reported by PMD.
Line: 30
list.add(new Object());
JSONPath path = new JSONPath("$.size");
Integer result = (Integer) path.eval(list);
Assert.assertEquals(list.size(), result.intValue());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_list_size_1.java
4 issues
Line: 10
import junit.framework.TestCase;
public class JSONPath_list_size_1 extends TestCase {
public void test_obj_array() throws Exception {
Object[] array = new Object[] {1, 2, 3};
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(array);
Assert.assertEquals(array.length, result.intValue());
}
Reported by PMD.
Line: 14
Object[] array = new Object[] {1, 2, 3};
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(array);
Assert.assertEquals(array.length, result.intValue());
}
public void test_int_array() throws Exception {
int[] array = new int[] {1, 2, 3};
JSONPath path = new JSONPath("$.size()");
Reported by PMD.
Line: 17
Assert.assertEquals(array.length, result.intValue());
}
public void test_int_array() throws Exception {
int[] array = new int[] {1, 2, 3};
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(array);
Assert.assertEquals(array.length, result.intValue());
}
Reported by PMD.
Line: 21
int[] array = new int[] {1, 2, 3};
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(array);
Assert.assertEquals(array.length, result.intValue());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_list_size_2.java
4 issues
Line: 13
import junit.framework.TestCase;
public class JSONPath_list_size_2 extends TestCase {
public void test_map() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("1001", 1001);
map.put("1002", 1002);
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(map);
Reported by PMD.
Line: 19
map.put("1002", 1002);
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(map);
Assert.assertEquals(map.size(), result.intValue());
}
public void test_map_null() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("1001", 1001);
Reported by PMD.
Line: 22
Assert.assertEquals(map.size(), result.intValue());
}
public void test_map_null() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("1001", 1001);
map.put("1002", 1002);
map.put("1003", null);
JSONPath path = new JSONPath("$.size()");
Reported by PMD.
Line: 29
map.put("1003", null);
JSONPath path = new JSONPath("$.size()");
Integer result = (Integer) path.eval(map);
Assert.assertEquals(2, result.intValue());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/date/DateParseTest10.java
4 issues
Line: 14
import com.alibaba.fastjson.JSON;
public class DateParseTest10 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_date() throws Exception {
Reported by PMD.
Line: 19
JSON.defaultLocale = Locale.CHINA;
}
public void test_date() throws Exception {
String text = "{\"value\":\"1979-07-14\"}";
VO vo = JSON.parseObject(text, VO.class);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", JSON.defaultLocale);
dateFormat.setTimeZone(JSON.defaultTimeZone);
Reported by PMD.
Line: 25
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", JSON.defaultLocale);
dateFormat.setTimeZone(JSON.defaultTimeZone);
Assert.assertEquals(vo.getValue(), dateFormat.parse("1979-07-14").getTime());
}
public static class VO {
private long value;
Reported by PMD.
Line: 25
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", JSON.defaultLocale);
dateFormat.setTimeZone(JSON.defaultTimeZone);
Assert.assertEquals(vo.getValue(), dateFormat.parse("1979-07-14").getTime());
}
public static class VO {
private long value;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_none_root.java
4 issues
Line: 16
public class JSONPath_none_root extends TestCase {
public void test_root() throws Exception {
List<Object> list = new ArrayList<Object>();
list.add(new Object());
Assert.assertSame(list.get(0), new JSONPath("[0]").eval(list));
}
Reported by PMD.
Line: 22
Assert.assertSame(list.get(0), new JSONPath("[0]").eval(list));
}
public void test_null() throws Exception {
Assert.assertNull(new JSONPath("name").eval(null));
}
public void test_map() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Reported by PMD.
Line: 26
Assert.assertNull(new JSONPath("name").eval(null));
}
public void test_map() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("val", new Object());
Assert.assertSame(map.get("val"), new JSONPath("val").eval(map));
}
Reported by PMD.
Line: 32
Assert.assertSame(map.get("val"), new JSONPath("val").eval(map));
}
public void test_entity() throws Exception {
Entity entity = new Entity();
entity.setValue(new Object());
Assert.assertSame(entity.getValue(), new JSONPath("value").eval(entity));
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_set_test2.java
4 issues
Line: 22
for (int i = 0; i < array.size(); ++i) {
Assert.assertEquals("123", array.getJSONObject(i).get("key"));
}
System.out.println(rootObject);
}
}
Reported by PMD.
Line: 14
public class JSONPath_set_test2 extends TestCase {
public void test_jsonpath() throws Exception {
JSONObject rootObject = JSON.parseObject("{\"array\":[{},{},{},{}]}");
JSONPath.set(rootObject, "$.array[0:].key", "123");
JSONArray array = rootObject.getJSONArray("array");
for (int i = 0; i < array.size(); ++i) {
Reported by PMD.
Line: 18
JSONObject rootObject = JSON.parseObject("{\"array\":[{},{},{},{}]}");
JSONPath.set(rootObject, "$.array[0:].key", "123");
JSONArray array = rootObject.getJSONArray("array");
for (int i = 0; i < array.size(); ++i) {
Assert.assertEquals("123", array.getJSONObject(i).get("key"));
}
System.out.println(rootObject);
}
Reported by PMD.
Line: 20
JSONArray array = rootObject.getJSONArray("array");
for (int i = 0; i < array.size(); ++i) {
Assert.assertEquals("123", array.getJSONObject(i).get("key"));
}
System.out.println(rootObject);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/number/NumberValueTest2.java
4 issues
Line: 12
public class NumberValueTest2 extends TestCase {
public void test_0() throws Exception {
String text = "{\"value\":3F}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertTrue(3F == ((Float)obj.get("value")).floatValue());
}
Reported by PMD.
Line: 15
public void test_0() throws Exception {
String text = "{\"value\":3F}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertTrue(3F == ((Float)obj.get("value")).floatValue());
}
public void test_1() throws Exception {
String text = "{\"value\":3.e3F}";
Reported by PMD.
Line: 19
}
public void test_1() throws Exception {
String text = "{\"value\":3.e3F}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertTrue(3.e3F == ((Float)obj.get("value")).floatValue());
}
Reported by PMD.
Line: 22
public void test_1() throws Exception {
String text = "{\"value\":3.e3F}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertTrue(3.e3F == ((Float)obj.get("value")).floatValue());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/asm/TestASM_object.java
4 issues
Line: 10
public class TestASM_object extends TestCase {
public void test_asm() throws Exception {
V0 v = new V0();
String text = JSON.toJSONString(v);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v.getValue().getValue(), v1.getValue().getValue());
Reported by PMD.
Line: 15
String text = JSON.toJSONString(v);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v.getValue().getValue(), v1.getValue().getValue());
}
public static class V0 {
private V1 value = new V1();
Reported by PMD.
Line: 15
String text = JSON.toJSONString(v);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v.getValue().getValue(), v1.getValue().getValue());
}
public static class V0 {
private V1 value = new V1();
Reported by PMD.
Line: 15
String text = JSON.toJSONString(v);
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v.getValue().getValue(), v1.getValue().getValue());
}
public static class V0 {
private V1 value = new V1();
Reported by PMD.