The following issues were found
src/test/java/com/alibaba/json/bvt/issue_1600/Issue1679.java
4 issues
Line: 12
import java.util.TimeZone;
public class Issue1679 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: 17
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
String json = "{\"create\":\"2018-01-10 08:30:00\"}";
User user = JSON.parseObject(json, User.class);
assertEquals("\"2018-01-10T08:30:00+08:00\"", JSON.toJSONString(user.create, SerializerFeature.UseISO8601DateFormat));
}
Reported by PMD.
Line: 20
public void test_for_issue() throws Exception {
String json = "{\"create\":\"2018-01-10 08:30:00\"}";
User user = JSON.parseObject(json, User.class);
assertEquals("\"2018-01-10T08:30:00+08:00\"", JSON.toJSONString(user.create, SerializerFeature.UseISO8601DateFormat));
}
public static class User{
public Date create;
}
Reported by PMD.
Line: 24
}
public static class User{
public Date create;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1600/Issue1662_1.java
4 issues
Line: 17
import java.lang.reflect.Type;
public class Issue1662_1 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"value\":123}";
Model model = JSON.parseObject(json, Model.class);
assertEquals("{\"value\":\"12300元\"}",JSON.toJSONString(model));
}
Reported by PMD.
Line: 20
public void test_for_issue() throws Exception {
String json = "{\"value\":123}";
Model model = JSON.parseObject(json, Model.class);
assertEquals("{\"value\":\"12300元\"}",JSON.toJSONString(model));
}
public static class Model {
@JSONField(serializeUsing = ModelValueSerializer.class, deserializeUsing = ModelValueDeserializer.class)
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.issue_1600;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import com.alibaba.fastjson.serializer.JSONSerializer;
Reported by PMD.
Line: 7
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import junit.framework.TestCase;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/cglib/TestCglib.java
4 issues
Line: 15
public class TestCglib extends TestCase {
public void test_cglib() throws Exception {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(Entity.class);
enhancer.setCallback(new Proxy());
Entity entity = (Entity) enhancer.create();
Reported by PMD.
Line: 21
enhancer.setCallback(new Proxy());
Entity entity = (Entity) enhancer.create();
entity.setId(3);
entity.setName("Jobs");
String text = JSON.toJSONString(entity);
Assert.assertEquals("{\"id\":3,\"name\":\"Jobs\"}", text);
Reported by PMD.
Line: 22
Entity entity = (Entity) enhancer.create();
entity.setId(3);
entity.setName("Jobs");
String text = JSON.toJSONString(entity);
Assert.assertEquals("{\"id\":3,\"name\":\"Jobs\"}", text);
}
Reported by PMD.
Line: 37
}
public static class Entity {
private int id;
private String name;
public Entity(){
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1600/Issue1657.java
4 issues
Line: 9
import java.util.HashMap;
public class Issue1657 extends TestCase {
public void test_for_issue() throws Exception {
HashMap map = JSON.parseObject("\"\"", HashMap.class);
assertEquals(0, map.size());
}
}
Reported by PMD.
Line: 10
public class Issue1657 extends TestCase {
public void test_for_issue() throws Exception {
HashMap map = JSON.parseObject("\"\"", HashMap.class);
assertEquals(0, map.size());
}
}
Reported by PMD.
Line: 11
public class Issue1657 extends TestCase {
public void test_for_issue() throws Exception {
HashMap map = JSON.parseObject("\"\"", HashMap.class);
assertEquals(0, map.size());
}
}
Reported by PMD.
Line: 11
public class Issue1657 extends TestCase {
public void test_for_issue() throws Exception {
HashMap map = JSON.parseObject("\"\"", HashMap.class);
assertEquals(0, map.size());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jdk8/OptionalTest2.java
4 issues
Line: 13
public class OptionalTest2 extends TestCase {
public void test_optional() throws Exception {
Entity entity = new Entity();
entity.setValue(Optional.of(123));
String text = JSON.toJSONString(entity);
Reported by PMD.
Line: 23
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(entity.getValue().get(), entity2.getValue().get());
}
public static class Entity {
private Optional<Integer> value;
Reported by PMD.
Line: 23
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(entity.getValue().get(), entity2.getValue().get());
}
public static class Entity {
private Optional<Integer> value;
Reported by PMD.
Line: 23
Entity entity2 = JSON.parseObject(text, Entity.class);
Assert.assertEquals(entity.getValue().get(), entity2.getValue().get());
}
public static class Entity {
private Optional<Integer> value;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/joda/JodaTest_5_DateTimeFormatter.java
4 issues
Line: 8
import org.joda.time.format.*;
public class JodaTest_5_DateTimeFormatter extends TestCase {
public void test_for_joda_0() throws Exception {
String json = "{\"formatter\":\"yyyyMMdd\"}";
Model m = JSON.parseObject(json, Model.class);
assertEquals(DateTimeFormat.forPattern("yyyyMMdd"), m.formatter);
Reported by PMD.
Line: 13
String json = "{\"formatter\":\"yyyyMMdd\"}";
Model m = JSON.parseObject(json, Model.class);
assertEquals(DateTimeFormat.forPattern("yyyyMMdd"), m.formatter);
}
public static class Model {
public DateTimeFormatter formatter;
}
Reported by PMD.
Line: 17
}
public static class Model {
public DateTimeFormatter formatter;
}
}
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import org.joda.time.format.*;
public class JodaTest_5_DateTimeFormatter extends TestCase {
public void test_for_joda_0() throws Exception {
String json = "{\"formatter\":\"yyyyMMdd\"}";
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1500/Issue1576.java
4 issues
Line: 10
import java.util.List;
public class Issue1576 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"code\":200,\"in_msg\":\"a\",\"out_msg\":\"a\",\"data\":[{\"title\":\"a\",\"url\":\"url\",\"content\":\"content\"}],\"client_id\":0,\"client_param\":0,\"userid\":0}";
NewsDetail newsDetail = JSON.parseObject(json, NewsDetail.class);
assertNotNull(newsDetail);
}
Reported by PMD.
Line: 13
public void test_for_issue() throws Exception {
String json = "{\"code\":200,\"in_msg\":\"a\",\"out_msg\":\"a\",\"data\":[{\"title\":\"a\",\"url\":\"url\",\"content\":\"content\"}],\"client_id\":0,\"client_param\":0,\"userid\":0}";
NewsDetail newsDetail = JSON.parseObject(json, NewsDetail.class);
assertNotNull(newsDetail);
}
public static class NewsDetail {
public int code;
Reported by PMD.
Line: 16
assertNotNull(newsDetail);
}
public static class NewsDetail {
public int code;
public String in_msg;
public String out_msg;
public String client_id;
Reported by PMD.
Line: 83
}
}
public static class DataBean {
/**
* title : 中午
* url : url
* content : content
*/
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1500/Issue1510.java
4 issues
Line: 12
import java.util.TimeZone;
public class Issue1510 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: 17
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"startTime\":\"2017-11-04\",\"endTime\":\"2017-11-14\"}", Model.class);
String text = JSON.toJSONString(model);
assertEquals("{\"endTime\":\"2017-11-14\",\"startTime\":\"2017-11-04\"}", text);
}
Reported by PMD.
Line: 20
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"startTime\":\"2017-11-04\",\"endTime\":\"2017-11-14\"}", Model.class);
String text = JSON.toJSONString(model);
assertEquals("{\"endTime\":\"2017-11-14\",\"startTime\":\"2017-11-04\"}", text);
}
public static class Model {
@JSONField(format = "yyyy-MM-dd")
private Date startTime;
Reported by PMD.
Line: 23
assertEquals("{\"endTime\":\"2017-11-14\",\"startTime\":\"2017-11-04\"}", text);
}
public static class Model {
@JSONField(format = "yyyy-MM-dd")
private Date startTime;
@JSONField(format = "yyyy-MM-dd")
private Date endTime;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1400/Issue1496.java
4 issues
Line: 12
import java.util.List;
public class Issue1496 extends TestCase {
public void test_for_issue() throws Exception {
String json = JSON.toJSONString(SetupStatus.FINAL_TRAIL);
assertEquals("{\"canRefuse\":true,\"code\":3,\"declaringClass\":\"com.alibaba.json.bvt.issue_1400.Issue1496$SetupStatus\",\"first\":false,\"last\":false,\"name\":\"FINAL_TRAIL\",\"nameCn\":\"公益委员会/理事会/理事长审核\"}", json);
}
public interface ISetupStatusInfo {
Reported by PMD.
Line: 14
public class Issue1496 extends TestCase {
public void test_for_issue() throws Exception {
String json = JSON.toJSONString(SetupStatus.FINAL_TRAIL);
assertEquals("{\"canRefuse\":true,\"code\":3,\"declaringClass\":\"com.alibaba.json.bvt.issue_1400.Issue1496$SetupStatus\",\"first\":false,\"last\":false,\"name\":\"FINAL_TRAIL\",\"nameCn\":\"公益委员会/理事会/理事长审核\"}", json);
}
public interface ISetupStatusInfo {
List<SetupStatus> nextList();
Reported by PMD.
Line: 172
return null;
}
for (SetupStatus status : values()) {
if (status.name.equals(name)) {
return status;
}
}
return null;
}
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.serializer.SerializeConfig;
import junit.framework.TestCase;
import java.util.Arrays;
import java.util.List;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/kotlin/Issue1547.java
4 issues
Line: 12
import java.lang.reflect.Constructor;
public class Issue1547 extends TestCase {
public void test_user() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class clazz = classLoader.loadClass("Head");
Object head = JSON.parseObject("{\"msg\":\"mmm\",\"code\":\"ccc\"}", clazz);
assertEquals("{\"code\":\"ccc\",\"msg\":\"mmm\"}", JSON.toJSONString(head));
Reported by PMD.
Line: 17
Class clazz = classLoader.loadClass("Head");
Object head = JSON.parseObject("{\"msg\":\"mmm\",\"code\":\"ccc\"}", clazz);
assertEquals("{\"code\":\"ccc\",\"msg\":\"mmm\"}", JSON.toJSONString(head));
}
public static class ExtClassLoader extends ClassLoader {
public ExtClassLoader() throws IOException {
Reported by PMD.
Line: 27
{
byte[] bytes;
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/issue1547/Head.clazz");
bytes = IOUtils.toByteArray(is);
is.close();
super.defineClass("Head", bytes, 0, bytes.length);
}
Reported by PMD.
Line: 9
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
public class Issue1547 extends TestCase {
public void test_user() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class clazz = classLoader.loadClass("Head");
Reported by PMD.