The following issues were found
src/test/java/com/alibaba/json/bvt/jdk8/OffsetDateTimeTest.java
3 issues
Line: 18
vo.setDate(OffsetDateTime.now());
String text = JSON.toJSONString(vo);
System.out.println(text);
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getDate(), vo1.getDate());
}
Reported by PMD.
Line: 13
public class OffsetDateTimeTest extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.setDate(OffsetDateTime.now());
String text = JSON.toJSONString(vo);
System.out.println(text);
Reported by PMD.
Line: 22
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getDate(), vo1.getDate());
}
public static class VO {
private OffsetDateTime date;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jdk8/OffseTimeTest.java
3 issues
Line: 18
vo.setDate(OffsetTime.now());
String text = JSON.toJSONString(vo);
System.out.println(text);
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getDate(), vo1.getDate());
}
Reported by PMD.
Line: 13
public class OffseTimeTest extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.setDate(OffsetTime.now());
String text = JSON.toJSONString(vo);
System.out.println(text);
Reported by PMD.
Line: 22
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getDate(), vo1.getDate());
}
public static class VO {
private OffsetTime date;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1300/Issue1368.java
3 issues
Line: 15
public void test_for_issue() throws Exception {
ExtendedServletRequestDataBinder binder = new ExtendedServletRequestDataBinder(new Object());
String json = JSON.toJSONString(binder);
System.out.println(json);
Assert.assertTrue(json.indexOf("$ref")>=0);
}
}
Reported by PMD.
Line: 12
* Created by kimmking on 03/08/2017.
*/
public class Issue1368 extends TestCase {
public void test_for_issue() throws Exception {
ExtendedServletRequestDataBinder binder = new ExtendedServletRequestDataBinder(new Object());
String json = JSON.toJSONString(binder);
System.out.println(json);
Assert.assertTrue(json.indexOf("$ref")>=0);
}
Reported by PMD.
Line: 16
ExtendedServletRequestDataBinder binder = new ExtendedServletRequestDataBinder(new Object());
String json = JSON.toJSONString(binder);
System.out.println(json);
Assert.assertTrue(json.indexOf("$ref")>=0);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/CreateInstanceErrorTest.java
3 issues
Line: 11
public class CreateInstanceErrorTest extends TestCase {
public void test_ordered_field() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":1001}", Model.class);
} catch (Exception ex) {
error = ex;
Reported by PMD.
Line: 15
Exception error = null;
try {
JSON.parseObject("{\"id\":1001}", Model.class);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 12
public class CreateInstanceErrorTest extends TestCase {
public void test_ordered_field() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":1001}", Model.class);
} catch (Exception ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1600/Issue1644.java
3 issues
Line: 9
import java.sql.Time;
public class Issue1644 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("time", 1324138987429L);
Time time = jsonObject.getObject("time", java.sql.Time.class);
assertEquals(1324138987429L, time.getTime());
Reported by PMD.
Line: 14
jsonObject.put("time", 1324138987429L);
Time time = jsonObject.getObject("time", java.sql.Time.class);
assertEquals(1324138987429L, time.getTime());
}
}
Reported by PMD.
Line: 14
jsonObject.put("time", 1324138987429L);
Time time = jsonObject.getObject("time", java.sql.Time.class);
assertEquals(1324138987429L, time.getTime());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_default_long.java
3 issues
Line: 11
public class JSONCreatorTest_default_long extends TestCase {
public void test_create() throws Exception {
Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class);
Assert.assertEquals(0, model.id);
Assert.assertEquals("wenshao", model.name);
}
Reported by PMD.
Line: 20
public static class Model {
private final long id;
private final String name;
@JSONCreator
public Model(@JSONField(name="id") long id, @JSONField(name="name") String name) {
this.id = id;
Reported by PMD.
Line: 21
public static class Model {
private final long id;
private final String name;
@JSONCreator
public Model(@JSONField(name="id") long id, @JSONField(name="name") String name) {
this.id = id;
this.name = name;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1600/Issue1645.java
3 issues
Line: 10
import java.time.LocalDateTime;
public class Issue1645 extends TestCase {
public void test_for_issue() throws Exception {
String test = "{\"name\":\"test\",\"testDateTime\":\"2017-12-08 14:55:16\"}";
JSON.toJSONString(JSON.parseObject(test).toJavaObject(TestDateClass.class), SerializerFeature.PrettyFormat);
}
public static class TestDateClass{
Reported by PMD.
Line: 10
import java.time.LocalDateTime;
public class Issue1645 extends TestCase {
public void test_for_issue() throws Exception {
String test = "{\"name\":\"test\",\"testDateTime\":\"2017-12-08 14:55:16\"}";
JSON.toJSONString(JSON.parseObject(test).toJavaObject(TestDateClass.class), SerializerFeature.PrettyFormat);
}
public static class TestDateClass{
Reported by PMD.
Line: 12
public class Issue1645 extends TestCase {
public void test_for_issue() throws Exception {
String test = "{\"name\":\"test\",\"testDateTime\":\"2017-12-08 14:55:16\"}";
JSON.toJSONString(JSON.parseObject(test).toJavaObject(TestDateClass.class), SerializerFeature.PrettyFormat);
}
public static class TestDateClass{
public String name;
public LocalDateTime testDateTime;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1300/Issue1320.java
3 issues
Line: 11
* Created by wenshao on 23/07/2017.
*/
public class Issue1320 extends TestCase {
public void test_for_issue() throws Exception {
SSOToken token = new SSOToken();
JSON.toJSONString(token);
}
@SuppressWarnings("serial")
Reported by PMD.
Line: 11
* Created by wenshao on 23/07/2017.
*/
public class Issue1320 extends TestCase {
public void test_for_issue() throws Exception {
SSOToken token = new SSOToken();
JSON.toJSONString(token);
}
@SuppressWarnings("serial")
Reported by PMD.
Line: 17
}
@SuppressWarnings("serial")
public static class SSOToken extends Token {
/* 登录类型 */
private Integer type;
/* 预留 */
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1600/Issue1647.java
3 issues
Line: 18
.setWithFields(true);
String json = JSON.toJSONString(params);
System.out.println(json);
params = JSON.parseObject(json, Params.class);
assertEquals("{\"verification_ids\":[\"a\",\"b\"],\"with_fields\":true}", JSON.toJSONString(params));
}
@JSONType(naming = PropertyNamingStrategy.SnakeCase)
Reported by PMD.
Line: 12
import java.util.List;
public class Issue1647 extends TestCase {
public void test_for_issue() throws Exception {
Params params = new Params()
.setVerificationIds(Arrays.asList(new String[]{"a", "b"}))
.setWithFields(true);
String json = JSON.toJSONString(params);
Reported by PMD.
Line: 20
String json = JSON.toJSONString(params);
System.out.println(json);
params = JSON.parseObject(json, Params.class);
assertEquals("{\"verification_ids\":[\"a\",\"b\"],\"with_fields\":true}", JSON.toJSONString(params));
}
@JSONType(naming = PropertyNamingStrategy.SnakeCase)
public static class Params {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1300/Issue1307.java
3 issues
Line: 21
* Created by kimmking on 02/07/2017.
*/
public class Issue1307 extends TestCase {
ContextValueFilter contextValueFilter = new ContextValueFilter() {
public Object process(BeanContext beanContext, Object obj, String name, Object value) {
return "mark-"+value;
}
};
ValueFilter valueFilter = new ValueFilter() {
Reported by PMD.
Line: 26
return "mark-"+value;
}
};
ValueFilter valueFilter = new ValueFilter() {
public Object process(Object object, String name, Object value) {
return value;
}
};
Reported by PMD.
Line: 10
import com.alibaba.fastjson.serializer.SerializeFilter;
import com.alibaba.fastjson.serializer.ValueFilter;
import junit.framework.TestCase;
import org.junit.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Reported by PMD.