The following issues were found
src/test/java/com/alibaba/json/bvt/issue_3600/Issue3689.java
6 issues
Line: 87
public void test_for_issue() {
JSONArray.parseArray("[\"////dfdfdf\"]"); //不会抛异常
JSONArray objects = JSONArray.parseArray("[\"dfdfdf\"]");//不会抛异常
System.out.println(JSONArray.parseArray("[\"////dfdfdf\"]"));
System.out.println(JSONArray.parseArray("[\"dfdfdf\"]"));
}
}
Reported by PMD.
Line: 88
JSONArray.parseArray("[\"////dfdfdf\"]"); //不会抛异常
JSONArray objects = JSONArray.parseArray("[\"dfdfdf\"]");//不会抛异常
System.out.println(JSONArray.parseArray("[\"////dfdfdf\"]"));
System.out.println(JSONArray.parseArray("[\"dfdfdf\"]"));
}
}
Reported by PMD.
Line: 7
import com.alibaba.fastjson.JSONException;
import org.junit.Test;
public class Issue3689 {
@Test(expected = JSONException.class)
public void test_without_type_0_meaningles_char() {
JSONArray.parseArray("dfdfdf");
}
Reported by PMD.
Line: 84
}
@Test
public void test_for_issue() {
JSONArray.parseArray("[\"////dfdfdf\"]"); //不会抛异常
JSONArray objects = JSONArray.parseArray("[\"dfdfdf\"]");//不会抛异常
System.out.println(JSONArray.parseArray("[\"////dfdfdf\"]"));
System.out.println(JSONArray.parseArray("[\"dfdfdf\"]"));
}
Reported by PMD.
Line: 86
@Test
public void test_for_issue() {
JSONArray.parseArray("[\"////dfdfdf\"]"); //不会抛异常
JSONArray objects = JSONArray.parseArray("[\"dfdfdf\"]");//不会抛异常
System.out.println(JSONArray.parseArray("[\"////dfdfdf\"]"));
System.out.println(JSONArray.parseArray("[\"dfdfdf\"]"));
}
}
Reported by PMD.
Line: 86
@Test
public void test_for_issue() {
JSONArray.parseArray("[\"////dfdfdf\"]"); //不会抛异常
JSONArray objects = JSONArray.parseArray("[\"dfdfdf\"]");//不会抛异常
System.out.println(JSONArray.parseArray("[\"////dfdfdf\"]"));
System.out.println(JSONArray.parseArray("[\"dfdfdf\"]"));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2700/Issue2743.java
6 issues
Line: 14
public class Issue2743 extends TestCase {
// 场景:验证字符串数组,楼主提供的用例
public void test_0() throws Exception {
String json = "{\"info\":{\"com.xxx.service.xxxServiceForOrder@queryGoodsV2(Long,Long,Long)\":[{\"method\":\"queryPrepayGoodsV2\"}]}}";
Object obj = JSONPath.extract(json,
"$['info']['com.xxx.service.xxxServiceForOrder@queryGoodsV2(Long,Long,Long)']");
assertEquals("[{\"method\":\"queryPrepayGoodsV2\"}]", obj.toString());
}
Reported by PMD.
Line: 18
String json = "{\"info\":{\"com.xxx.service.xxxServiceForOrder@queryGoodsV2(Long,Long,Long)\":[{\"method\":\"queryPrepayGoodsV2\"}]}}";
Object obj = JSONPath.extract(json,
"$['info']['com.xxx.service.xxxServiceForOrder@queryGoodsV2(Long,Long,Long)']");
assertEquals("[{\"method\":\"queryPrepayGoodsV2\"}]", obj.toString());
}
// 场景:验证数字数组
public void test_1() throws Exception {
String json = "[10,11,12,13,14,15,16,17,18,19,20]";
Reported by PMD.
Line: 18
String json = "{\"info\":{\"com.xxx.service.xxxServiceForOrder@queryGoodsV2(Long,Long,Long)\":[{\"method\":\"queryPrepayGoodsV2\"}]}}";
Object obj = JSONPath.extract(json,
"$['info']['com.xxx.service.xxxServiceForOrder@queryGoodsV2(Long,Long,Long)']");
assertEquals("[{\"method\":\"queryPrepayGoodsV2\"}]", obj.toString());
}
// 场景:验证数字数组
public void test_1() throws Exception {
String json = "[10,11,12,13,14,15,16,17,18,19,20]";
Reported by PMD.
Line: 22
}
// 场景:验证数字数组
public void test_1() throws Exception {
String json = "[10,11,12,13,14,15,16,17,18,19,20]";
Object obj = JSONPath.extract(json, "$[3,4]");
assertEquals("[13,14]", obj.toString());
}
//
Reported by PMD.
Line: 25
public void test_1() throws Exception {
String json = "[10,11,12,13,14,15,16,17,18,19,20]";
Object obj = JSONPath.extract(json, "$[3,4]");
assertEquals("[13,14]", obj.toString());
}
//
// // 场景:验证修复bug用的正则表达式
// public void test_2() throws Exception {
// String strArrayRegex = "\'\\s*,\\s*\'";
Reported by PMD.
Line: 25
public void test_1() throws Exception {
String json = "[10,11,12,13,14,15,16,17,18,19,20]";
Object obj = JSONPath.extract(json, "$[3,4]");
assertEquals("[13,14]", obj.toString());
}
//
// // 场景:验证修复bug用的正则表达式
// public void test_2() throws Exception {
// String strArrayRegex = "\'\\s*,\\s*\'";
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jdk7/PathTest.java
6 issues
Line: 18
model.path = Paths.get("/root/fastjson");
String text = JSON.toJSONString(model);
System.out.println(text);
//windows下,输出为
//Assert.assertEquals("{\"path\":\"\\root\\fastjson\"}", text);
//linux ,mac
//Assert.assertEquals("{\"path\":\"/root/fastjson\"}", text);
Reported by PMD.
Line: 13
import com.alibaba.fastjson.JSON;
public class PathTest extends TestCase {
public void test_for_path() throws Exception {
Model model = new Model();
model.path = Paths.get("/root/fastjson");
String text = JSON.toJSONString(model);
System.out.println(text);
Reported by PMD.
Line: 26
//Assert.assertEquals("{\"path\":\"/root/fastjson\"}", text);
Model model2 = JSON.parseObject(text, Model.class);
Assert.assertEquals(model.path.toString(), model2.path.toString());
}
public void test_for_null() throws Exception {
String text = "{\"path\":null}";
Reported by PMD.
Line: 26
//Assert.assertEquals("{\"path\":\"/root/fastjson\"}", text);
Model model2 = JSON.parseObject(text, Model.class);
Assert.assertEquals(model.path.toString(), model2.path.toString());
}
public void test_for_null() throws Exception {
String text = "{\"path\":null}";
Reported by PMD.
Line: 29
Assert.assertEquals(model.path.toString(), model2.path.toString());
}
public void test_for_null() throws Exception {
String text = "{\"path\":null}";
Model model2 = JSON.parseObject(text, Model.class);
Assert.assertNull(model2.path);
}
Reported by PMD.
Line: 37
}
public static class Model {
public Path path;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1256.java
6 issues
Line: 14
* Created by kimmking on 12/06/2017.
*/
public class Issue1256 extends TestCase {
public void test_for_issue() throws Exception {
// params ={"key_obj":{"age":39,"name":"Mike"},"key_string":"Hello","key_random":-1193959466,"key_int":10000}
A a = new A();
Reported by PMD.
Line: 30
map.put("key_int",10000);
String jsonString = JSON.toJSONString(map);
assertTrue(jsonString.contains("Mike"));
}
public static class A {
public String name;
public int age;
Reported by PMD.
Line: 30
map.put("key_int",10000);
String jsonString = JSON.toJSONString(map);
assertTrue(jsonString.contains("Mike"));
}
public static class A {
public String name;
public int age;
Reported by PMD.
Line: 34
}
public static class A {
public String name;
public int age;
}
}
Reported by PMD.
Line: 35
public static class A {
public String name;
public int age;
}
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.issue_1200;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import junit.framework.TestCase;
import java.util.HashMap;
import java.util.Map;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1276.java
6 issues
Line: 13
public void test_for_issue() throws Exception {
MyException myException = new MyException(100,"error msg");
String str = JSON.toJSONString(myException);
System.out.println(str);
MyException myException1 = JSON.parseObject(str, MyException.class);
assertEquals(myException.getCode(), myException1.getCode());
String str1 = JSON.toJSONString(myException1);
Reported by PMD.
Line: 10
* Created by wenshao on 18/06/2017.
*/
public class Issue1276 extends TestCase {
public void test_for_issue() throws Exception {
MyException myException = new MyException(100,"error msg");
String str = JSON.toJSONString(myException);
System.out.println(str);
MyException myException1 = JSON.parseObject(str, MyException.class);
Reported by PMD.
Line: 10
* Created by wenshao on 18/06/2017.
*/
public class Issue1276 extends TestCase {
public void test_for_issue() throws Exception {
MyException myException = new MyException(100,"error msg");
String str = JSON.toJSONString(myException);
System.out.println(str);
MyException myException1 = JSON.parseObject(str, MyException.class);
Reported by PMD.
Line: 16
System.out.println(str);
MyException myException1 = JSON.parseObject(str, MyException.class);
assertEquals(myException.getCode(), myException1.getCode());
String str1 = JSON.toJSONString(myException1);
assertEquals(str, str1);
}
Reported by PMD.
Line: 16
System.out.println(str);
MyException myException1 = JSON.parseObject(str, MyException.class);
assertEquals(myException.getCode(), myException1.getCode());
String str1 = JSON.toJSONString(myException1);
assertEquals(str, str1);
}
Reported by PMD.
Line: 19
assertEquals(myException.getCode(), myException1.getCode());
String str1 = JSON.toJSONString(myException1);
assertEquals(str, str1);
}
public static class MyException extends RuntimeException{
private static final long serialVersionUID = 7815426752583648734L;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest9.java
6 issues
Line: 9
import junit.framework.TestCase;
public class JSONCreatorTest9 extends TestCase {
public void test_for_yk() throws Exception {
String text = "{\"videoid\":\"XNzBxOCU0NjYxCg==\",\"videoName\":\"xxx\"}";
YoukuVideoDTO dto = JSON.parseObject(text, YoukuVideoDTO.class);
assertEquals("XNzBxOCU0NjYxCg==", dto.videoId);
assertEquals("xxx", dto.videoName);
Reported by PMD.
Line: 9
import junit.framework.TestCase;
public class JSONCreatorTest9 extends TestCase {
public void test_for_yk() throws Exception {
String text = "{\"videoid\":\"XNzBxOCU0NjYxCg==\",\"videoName\":\"xxx\"}";
YoukuVideoDTO dto = JSON.parseObject(text, YoukuVideoDTO.class);
assertEquals("XNzBxOCU0NjYxCg==", dto.videoId);
assertEquals("xxx", dto.videoName);
Reported by PMD.
Line: 13
String text = "{\"videoid\":\"XNzBxOCU0NjYxCg==\",\"videoName\":\"xxx\"}";
YoukuVideoDTO dto = JSON.parseObject(text, YoukuVideoDTO.class);
assertEquals("XNzBxOCU0NjYxCg==", dto.videoId);
assertEquals("xxx", dto.videoName);
}
public static class YoukuVideoDTO {
Reported by PMD.
Line: 14
YoukuVideoDTO dto = JSON.parseObject(text, YoukuVideoDTO.class);
assertEquals("XNzBxOCU0NjYxCg==", dto.videoId);
assertEquals("xxx", dto.videoName);
}
public static class YoukuVideoDTO {
private String videoId;
Reported by PMD.
Line: 19
}
public static class YoukuVideoDTO {
private String videoId;
private String videoName;
@JSONCreator
public YoukuVideoDTO(@JSONField(name = "videoid") String videoId) {
Reported by PMD.
Line: 19
}
public static class YoukuVideoDTO {
private String videoId;
private String videoName;
@JSONCreator
public YoukuVideoDTO(@JSONField(name = "videoid") String videoId) {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jdk8/LocalDateTest2.java
6 issues
Line: 13
public class LocalDateTest2 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2016-05-06T20:24:28.484\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Reported by PMD.
Line: 16
public void test_for_issue() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2016-05-06T20:24:28.484\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
Reported by PMD.
Line: 17
VO vo = JSON.parseObject("{\"date\":\"2016-05-06T20:24:28.484\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public static class VO {
Reported by PMD.
Line: 18
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public static class VO {
public LocalDate date;
Reported by PMD.
Line: 19
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public static class VO {
public LocalDate date;
Reported by PMD.
Line: 23
}
public static class VO {
public LocalDate date;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1298.java
6 issues
Line: 16
* Created by wenshao on 30/06/2017.
*/
public class Issue1298 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.US;
}
public void test_for_issue() throws Exception {
Reported by PMD.
Line: 21
JSON.defaultLocale = Locale.US;
}
public void test_for_issue() throws Exception {
JSONObject object = new JSONObject();
object.put("date", "2017-06-29T08:06:30.000+05:30");
Date date = object.getObject("date", java.util.Date.class);
Reported by PMD.
Line: 24
public void test_for_issue() throws Exception {
JSONObject object = new JSONObject();
object.put("date", "2017-06-29T08:06:30.000+05:30");
Date date = object.getObject("date", java.util.Date.class);
assertEquals("\"2017-06-29T10:36:30+08:00\"", JSON.toJSONString(date, SerializerFeature.UseISO8601DateFormat));
}
Reported by PMD.
Line: 28
Date date = object.getObject("date", java.util.Date.class);
assertEquals("\"2017-06-29T10:36:30+08:00\"", JSON.toJSONString(date, SerializerFeature.UseISO8601DateFormat));
}
public void test_for_issue_1() throws Exception {
JSONObject object = new JSONObject();
Reported by PMD.
Line: 31
assertEquals("\"2017-06-29T10:36:30+08:00\"", JSON.toJSONString(date, SerializerFeature.UseISO8601DateFormat));
}
public void test_for_issue_1() throws Exception {
JSONObject object = new JSONObject();
object.put("date", "2017-08-15 20:00:00.000");
Date date = object.getObject("date", java.util.Date.class);
Reported by PMD.
Line: 38
Date date = object.getObject("date", java.util.Date.class);
assertEquals("\"2017-08-15T20:00:00+08:00\"", JSON.toJSONString(date, SerializerFeature.UseISO8601DateFormat));
JSON.parseObject("\"2017-08-15 20:00:00.000\"", java.util.Date.class);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/DefaultExtJSONParserTest_1.java
6 issues
Line: 49
a.setF18(12.345D);
String text = JSON.toJSONString(a);
System.out.println(text);
TestEntity b = new TestEntity();
{
DefaultJSONParser parser = new DefaultJSONParser(text);
parser.parseObject(b);
Reported by PMD.
Line: 15
public class DefaultExtJSONParserTest_1 extends TestCase {
public void test_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{\"f1\":true}");
TestEntity entity = parser.parseObject(TestEntity.class);
Assert.assertEquals(true, entity.isF1());
}
Reported by PMD.
Line: 18
public void test_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{\"f1\":true}");
TestEntity entity = parser.parseObject(TestEntity.class);
Assert.assertEquals(true, entity.isF1());
}
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{\"f2\":true}");
TestEntity entity = parser.parseObject(TestEntity.class);
Reported by PMD.
Line: 21
Assert.assertEquals(true, entity.isF1());
}
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{\"f2\":true}");
TestEntity entity = parser.parseObject(TestEntity.class);
Assert.assertEquals(Boolean.TRUE, entity.getF2());
}
Reported by PMD.
Line: 24
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{\"f2\":true}");
TestEntity entity = parser.parseObject(TestEntity.class);
Assert.assertEquals(Boolean.TRUE, entity.getF2());
}
public void f_test_2() throws Exception {
TestEntity a = new TestEntity();
a.setF1(true);
Reported by PMD.
Line: 27
Assert.assertEquals(Boolean.TRUE, entity.getF2());
}
public void f_test_2() throws Exception {
TestEntity a = new TestEntity();
a.setF1(true);
a.setF2(Boolean.TRUE);
a.setF3((byte) 123);
a.setF4((byte) 123);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/DateParserTest_sql_timestamp.java
6 issues
Line: 17
@SuppressWarnings("deprecation")
public class DateParserTest_sql_timestamp extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void f_test_date_0() throws Exception {
Reported by PMD.
Line: 22
JSON.defaultLocale = Locale.CHINA;
}
public void f_test_date_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("1294552193254");
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
Assert.assertEquals(new java.sql.Timestamp(1294552193254L), date);
Reported by PMD.
Line: 31
parser.close();
}
public void test_date_1() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
Reported by PMD.
Line: 42
parser.close();
}
public void test_date_2() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
Reported by PMD.
Line: 52
parser.close();
}
public void test_date_3() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53\"", ParserConfig.getGlobalInstance(), features);
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
Reported by PMD.
Line: 63
parser.close();
}
public void test_date_4() throws Exception {
int features = JSON.DEFAULT_PARSER_FEATURE;
features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);
java.sql.Timestamp date = parser.parseObject(java.sql.Timestamp.class);
Reported by PMD.