The following issues were found
src/test/java/com/alibaba/json/bvt/jdk8/OptionalLong_Test.java
2 issues
Line: 13
public class OptionalLong_Test extends TestCase {
public void test_optional() throws Exception {
Model model = new Model();
model.value = OptionalLong.empty();
String text = JSON.toJSONString(model);
Reported by PMD.
Line: 28
public static class Model {
public OptionalLong value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/autoType/AutoTypeTest6.java
2 issues
Line: 7
import junit.framework.TestCase;
public class AutoTypeTest6 extends TestCase {
public void test_0() throws Exception {
JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.util.AntiCollisionHashMap\"}");
}
}
Reported by PMD.
Line: 7
import junit.framework.TestCase;
public class AutoTypeTest6 extends TestCase {
public void test_0() throws Exception {
JSON.parseObject("{\"@type\":\"com.alibaba.fastjson.util.AntiCollisionHashMap\"}");
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1100/Issue1177.java
2 issues
Line: 11
* Created by wenshao on 02/05/2017.
*/
public class Issue1177 extends TestCase {
public void test_for_issue() throws Exception {
String text = "{\"a\":{\"b\":\"c\",\"g\":{\"e\":\"f\"}},\"d\":{\"a\":\"f\",\"h\":[\"s1\"]}} ";
JSONObject jsonObject = JSONObject.parseObject(text);
Object eval = JSONPath.eval(jsonObject, "$..a");
assertNotNull(eval);
}
Reported by PMD.
Line: 15
String text = "{\"a\":{\"b\":\"c\",\"g\":{\"e\":\"f\"}},\"d\":{\"a\":\"f\",\"h\":[\"s1\"]}} ";
JSONObject jsonObject = JSONObject.parseObject(text);
Object eval = JSONPath.eval(jsonObject, "$..a");
assertNotNull(eval);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/feature/FeatureTest_8.java
2 issues
Line: 11
import junit.framework.TestCase;
public class FeatureTest_8 extends TestCase {
public void test_get_obj() throws Exception {
VO value = JSON.parseObject("{}", VO.class, Feature.InitStringFieldAsEmpty);
Assert.assertEquals("", value.id);
}
private static class VO {
Reported by PMD.
Line: 17
}
private static class VO {
public String id;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1700/Issue1727.java
2 issues
Line: 11
import java.util.Date;
public class Issue1727 extends TestCase {
public void test_for_issue() throws Exception {
String jsonString = "{\"gmtCreate\":\"20180131214157805-0800\"}";
JSONObject.parseObject(jsonString, Model.class); //正常解析
JSONObject.toJavaObject(JSON.parseObject(jsonString), Model.class);
}
Reported by PMD.
Line: 11
import java.util.Date;
public class Issue1727 extends TestCase {
public void test_for_issue() throws Exception {
String jsonString = "{\"gmtCreate\":\"20180131214157805-0800\"}";
JSONObject.parseObject(jsonString, Model.class); //正常解析
JSONObject.toJavaObject(JSON.parseObject(jsonString), Model.class);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1700/Issue1761.java
2 issues
Line: 7
import junit.framework.TestCase;
public class Issue1761 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("null","");
double d = jsonObject.getDoubleValue("null");
assertEquals(d, 0.0D);
}
Reported by PMD.
Line: 11
JSONObject jsonObject = new JSONObject();
jsonObject.put("null","");
double d = jsonObject.getDoubleValue("null");
assertEquals(d, 0.0D);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1900/Issue1972.java
2 issues
Line: 9
import junit.framework.TestCase;
public class Issue1972 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject jsonObject = new JSONObject();
final JSONObject a = new JSONObject();
final JSONObject b = new JSONObject();
a.put("b", b);
Reported by PMD.
Line: 23
jsonObject.put("a", a);
JSONPath.arrayAdd(jsonObject,"$.a.b[c = '2018-04'].d", obj);
assertEquals("{\"a\":{\"b\":{\"c\":\"2018-04\",\"d\":[123]}}}", jsonObject.toString());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2500/Issue2516.java
2 issues
Line: 13
public class Issue2516 extends TestCase
{
public void test_for_issue() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.toJavaObject(JSONObject.class);
jsonObject.toJavaObject(JSON.class);
new JSONArray().toJavaObject(JSON.class);
Reported by PMD.
Line: 13
public class Issue2516 extends TestCase
{
public void test_for_issue() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.toJavaObject(JSONObject.class);
jsonObject.toJavaObject(JSON.class);
new JSONArray().toJavaObject(JSON.class);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/date/DateTest_dotnet_3.java
2 issues
Line: 13
public class DateTest_dotnet_3 extends TestCase {
public void test_date() throws Exception {
String text = "{\"date\":\"/Date(1461081600321+0500)/\"}";
Model model = JSON.parseObject(text, Model.class);
Assert.assertEquals(1461081600321L, model.date.getTime());
}
Reported by PMD.
Line: 17
String text = "{\"date\":\"/Date(1461081600321+0500)/\"}";
Model model = JSON.parseObject(text, Model.class);
Assert.assertEquals(1461081600321L, model.date.getTime());
}
private static class Model {
private Date date;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/date/DateFieldTest7.java
2 issues
Line: 16
import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;
public class DateFieldTest7 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_0() throws Exception {
Reported by PMD.
Line: 21
JSON.defaultLocale = Locale.CHINA;
}
public void test_0() throws Exception {
SerializeConfig config = new SerializeConfig();
config.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));
config.setAsmEnable(false);
Entity object = new Entity();
Reported by PMD.