The following issues were found
src/test/java/com/alibaba/json/bvt/jdk8/ZonedDateTimeTest2.java
6 issues
Line: 18
vo.date = ZonedDateTime.now();
String text = JSON.toJSONString(vo);
System.out.println(text);
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.date.getSecond(), vo1.date.getSecond());
}
Reported by PMD.
Line: 13
public class ZonedDateTimeTest2 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.date = ZonedDateTime.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.date.getSecond(), vo1.date.getSecond());
}
public static class VO {
@JSONField(format="yyyy-MM-dd HH:mm:ss")
public ZonedDateTime date;
Reported by PMD.
Line: 22
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.date.getSecond(), vo1.date.getSecond());
}
public static class VO {
@JSONField(format="yyyy-MM-dd HH:mm:ss")
public ZonedDateTime date;
Reported by PMD.
Line: 27
public static class VO {
@JSONField(format="yyyy-MM-dd HH:mm:ss")
public ZonedDateTime date;
}
}
Reported by PMD.
Line: 9
import org.junit.Assert;
import java.time.ZonedDateTime;
import java.time.temporal.TemporalField;
public class ZonedDateTimeTest2 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1400/Issue1494.java
6 issues
Line: 11
import junit.framework.TestCase;
public class Issue1494 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"id\":1001,\"name\":\"wenshao\"}";
B b = JSON.parseObject(json, B.class);
assertEquals("{\"id\":1001,\"name\":\"wenshao\"}", JSON.toJSONString(b));
}
Reported by PMD.
Line: 14
public void test_for_issue() throws Exception {
String json = "{\"id\":1001,\"name\":\"wenshao\"}";
B b = JSON.parseObject(json, B.class);
assertEquals("{\"id\":1001,\"name\":\"wenshao\"}", JSON.toJSONString(b));
}
public static class A {
private int id;
Reported by PMD.
Line: 18
}
public static class A {
private int id;
public int getId() {
return id;
}
}
Reported by PMD.
Line: 27
@JSONType(parseFeatures = Feature.SupportNonPublicField)
public static class B extends A {
private String name;
public String getName() {
return name;
}
}
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializeConfig;
import junit.framework.TestCase;
public class Issue1494 extends TestCase {
public void test_for_issue() throws Exception {
Reported by PMD.
Line: 7
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializeConfig;
import junit.framework.TestCase;
public class Issue1494 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"id\":1001,\"name\":\"wenshao\"}";
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1600/Issue1603_map_getter.java
6 issues
Line: 11
import java.util.Map;
public class Issue1603_map_getter extends TestCase {
public void test_emptyMap() throws Exception {
Model_1 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_1.class);
assertEquals(0, m.values.size());
}
public void test_unmodifiableMap() throws Exception {
Reported by PMD.
Line: 13
public class Issue1603_map_getter extends TestCase {
public void test_emptyMap() throws Exception {
Model_1 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_1.class);
assertEquals(0, m.values.size());
}
public void test_unmodifiableMap() throws Exception {
Model_2 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_2.class);
assertEquals(0, m.values.size());
Reported by PMD.
Line: 13
public class Issue1603_map_getter extends TestCase {
public void test_emptyMap() throws Exception {
Model_1 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_1.class);
assertEquals(0, m.values.size());
}
public void test_unmodifiableMap() throws Exception {
Model_2 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_2.class);
assertEquals(0, m.values.size());
Reported by PMD.
Line: 16
assertEquals(0, m.values.size());
}
public void test_unmodifiableMap() throws Exception {
Model_2 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_2.class);
assertEquals(0, m.values.size());
}
public static class Model_1 {
Reported by PMD.
Line: 18
public void test_unmodifiableMap() throws Exception {
Model_2 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_2.class);
assertEquals(0, m.values.size());
}
public static class Model_1 {
private final Map<String, Object> values = Collections.emptyMap();
Reported by PMD.
Line: 18
public void test_unmodifiableMap() throws Exception {
Model_2 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_2.class);
assertEquals(0, m.values.size());
}
public static class Model_1 {
private final Map<String, Object> values = Collections.emptyMap();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2300/Issue2346.java
6 issues
Line: 11
import lombok.Getter;
public class Issue2346 extends TestCase {
public void test_for_issue() throws Exception {
String jsonStr = "{\"age\":1,\"name\":\"aa\"}";
TestEntity testEntity = JSON.parseObject(jsonStr, TestEntity.class);
assertEquals(jsonStr, JSON.toJSONString(testEntity));
}
Reported by PMD.
Line: 14
public void test_for_issue() throws Exception {
String jsonStr = "{\"age\":1,\"name\":\"aa\"}";
TestEntity testEntity = JSON.parseObject(jsonStr, TestEntity.class);
assertEquals(jsonStr, JSON.toJSONString(testEntity));
}
@Builder(builderClassName = "TestEntityBuilder")
@Getter
@JSONType(builder = TestEntity.TestEntityBuilder.class)
Reported by PMD.
Line: 40
@JSONPOJOBuilder(withPrefix = "www")
public static class TestEntity2Builder{
private TestEntity2 testEntity2 = new TestEntity2();
public TestEntity2 build(){
return testEntity2;
}
Reported by PMD.
Line: 40
@JSONPOJOBuilder(withPrefix = "www")
public static class TestEntity2Builder{
private TestEntity2 testEntity2 = new TestEntity2();
public TestEntity2 build(){
return testEntity2;
}
Reported by PMD.
Line: 66
private int age;
public static class TestEntity3Builder{
private TestEntity3 testEntity3 = new TestEntity3();
public TestEntity3 build(){
return testEntity3;
}
Reported by PMD.
Line: 66
private int age;
public static class TestEntity3Builder{
private TestEntity3 testEntity3 = new TestEntity3();
public TestEntity3 build(){
return testEntity3;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/joda/JodaTest_6_Duration.java
6 issues
Line: 9
import org.joda.time.Period;
public class JodaTest_6_Duration extends TestCase {
public void test_for_joda_0() throws Exception {
Model m = new Model();
m.duration = new Duration(24L*60L*60L*1000L);
String json = JSON.toJSONString(m);
Reported by PMD.
Line: 9
import org.joda.time.Period;
public class JodaTest_6_Duration extends TestCase {
public void test_for_joda_0() throws Exception {
Model m = new Model();
m.duration = new Duration(24L*60L*60L*1000L);
String json = JSON.toJSONString(m);
Reported by PMD.
Line: 16
String json = JSON.toJSONString(m);
assertEquals("{\"duration\":\"PT86400S\"}", json);
Model m1 = JSON.parseObject(json, Model.class);
assertEquals(m.duration, m1.duration);
}
Reported by PMD.
Line: 19
assertEquals("{\"duration\":\"PT86400S\"}", json);
Model m1 = JSON.parseObject(json, Model.class);
assertEquals(m.duration, m1.duration);
}
public static class Model {
public Duration duration;
}
Reported by PMD.
Line: 23
}
public static class Model {
public Duration duration;
}
}
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import org.joda.time.Duration;
import org.joda.time.Period;
public class JodaTest_6_Duration extends TestCase {
public void test_for_joda_0() throws Exception {
Model m = new Model();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/builder/BuilderTest_error_private.java
6 issues
Line: 13
public class BuilderTest_error_private extends TestCase {
public void test_0() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 26
@JSONType(builder = VOBuilder.class)
public static class VO {
private int id;
private String name;
public int getId() {
return id;
}
Reported by PMD.
Line: 27
public static class VO {
private int id;
private String name;
public int getId() {
return id;
}
Reported by PMD.
Line: 40
private static class VOBuilder {
private VO vo = new VO();
public VO build() {
throw new IllegalStateException();
}
Reported by PMD.
Line: 40
private static class VOBuilder {
private VO vo = new VO();
public VO build() {
throw new IllegalStateException();
}
Reported by PMD.
Line: 14
public class BuilderTest_error_private extends TestCase {
public void test_0() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/kotlin/Zoujing.java
6 issues
Line: 18
String json = "{\"benefitNoticeState\":1}";
Object obj = JSON.parseObject(json, clazz);
String result = JSON.toJSONString(obj);
System.out.println(result);
assertEquals("{\"benefitNoticeState\":1,\"outId\":\"\"}", result);
}
private static class ExtClassLoader extends ClassLoader {
Reported by PMD.
Line: 11
import java.io.InputStream;
public class Zoujing extends TestCase {
public void test_user() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class clazz = classLoader.loadClass("com.alidme.xrecharge.platform.common.data.NoticeData");
String json = "{\"benefitNoticeState\":1}";
Object obj = JSON.parseObject(json, clazz);
Reported by PMD.
Line: 19
Object obj = JSON.parseObject(json, clazz);
String result = JSON.toJSONString(obj);
System.out.println(result);
assertEquals("{\"benefitNoticeState\":1,\"outId\":\"\"}", result);
}
private static class ExtClassLoader extends ClassLoader {
public ExtClassLoader() throws IOException {
Reported by PMD.
Line: 29
{
byte[] bytes;
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/zuojing/NoticeData.clazz");
bytes = IOUtils.toByteArray(is);
is.close();
super.defineClass("com.alidme.xrecharge.platform.common.data.NoticeData", bytes, 0, bytes.length);
}
Reported by PMD.
Line: 38
{
byte[] bytes;
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/zuojing/NoticeDataKt.clazz");
bytes = IOUtils.toByteArray(is);
is.close();
super.defineClass("com.alidme.xrecharge.platform.common.data.NoticeDataKt", bytes, 0, bytes.length);
}
Reported by PMD.
Line: 47
{
byte[] bytes;
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/zuojing/NoticeData_Companion.clazz");
bytes = IOUtils.toByteArray(is);
is.close();
super.defineClass("com.alidme.xrecharge.platform.common.data.NoticeData$Companion", bytes, 0, bytes.length);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/date/DateTest_tz.java
6 issues
Line: 17
import junit.framework.TestCase;
public class DateTest_tz extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_codec() throws Exception {
Reported by PMD.
Line: 18
public class DateTest_tz extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_codec() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"value\":\"2016-04-29\"}"));
Reported by PMD.
Line: 22
JSON.defaultLocale = Locale.CHINA;
}
public void test_codec() throws Exception {
JSONReader reader = new JSONReader(new StringReader("{\"value\":\"2016-04-29\"}"));
reader.setLocale(Locale.CHINA);
reader.setTimzeZone(TimeZone.getTimeZone("Asia/Shanghai"));
Model model = reader.readObject(Model.class);
Reported by PMD.
Line: 33
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
format.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
Date date = format.parse("2016-04-29");
Assert.assertEquals(date.getTime(), model.value.getTime());
Assert.assertEquals(TimeZone.getTimeZone("Asia/Shanghai"), reader.getTimzeZone());
Assert.assertEquals(Locale.CHINA, reader.getLocal());
reader.close();
Reported by PMD.
Line: 33
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
format.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
Date date = format.parse("2016-04-29");
Assert.assertEquals(date.getTime(), model.value.getTime());
Assert.assertEquals(TimeZone.getTimeZone("Asia/Shanghai"), reader.getTimzeZone());
Assert.assertEquals(Locale.CHINA, reader.getLocal());
reader.close();
Reported by PMD.
Line: 42
}
public static class Model {
public Date value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1400/Issue1498.java
6 issues
Line: 7
import junit.framework.TestCase;
public class Issue1498 extends TestCase {
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"flag\":\"QUALITY_GRADUATE\"}", Model.class);
assertNull(model.flag);
}
public void test_for_issue_match() throws Exception {
Reported by PMD.
Line: 9
public class Issue1498 extends TestCase {
public void test_for_issue() throws Exception {
Model model = JSON.parseObject("{\"flag\":\"QUALITY_GRADUATE\"}", Model.class);
assertNull(model.flag);
}
public void test_for_issue_match() throws Exception {
Model model = JSON.parseObject("{\"flag\":\"IS_NEED_CHECK_IDENTITY\"}", Model.class);
assertSame(BuFlag.IS_NEED_CHECK_IDENTITY, model.flag);
Reported by PMD.
Line: 12
assertNull(model.flag);
}
public void test_for_issue_match() throws Exception {
Model model = JSON.parseObject("{\"flag\":\"IS_NEED_CHECK_IDENTITY\"}", Model.class);
assertSame(BuFlag.IS_NEED_CHECK_IDENTITY, model.flag);
}
public static class Model {
Reported by PMD.
Line: 14
public void test_for_issue_match() throws Exception {
Model model = JSON.parseObject("{\"flag\":\"IS_NEED_CHECK_IDENTITY\"}", Model.class);
assertSame(BuFlag.IS_NEED_CHECK_IDENTITY, model.flag);
}
public static class Model {
public BuFlag flag;
}
Reported by PMD.
Line: 18
}
public static class Model {
public BuFlag flag;
}
public enum BuFlag
{
IS_NEED_CHECK_IDENTITY(1L, "a"), HAS_CHECK_IDENTITY(2L, "b");
Reported by PMD.
Line: 26
IS_NEED_CHECK_IDENTITY(1L, "a"), HAS_CHECK_IDENTITY(2L, "b");
private long bit;
private String desc;
private BuFlag(long bit, String desc)
{
this.bit = bit;
this.desc = desc;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/kotlin/Issue1543.java
6 issues
Line: 14
import java.util.Map;
public class Issue1543 extends TestCase {
public void test_user() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class clazzUser = classLoader.loadClass("User1");
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 1);
Reported by PMD.
Line: 14
import java.util.Map;
public class Issue1543 extends TestCase {
public void test_user() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class clazzUser = classLoader.loadClass("User1");
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 1);
Reported by PMD.
Line: 25
JSON.parseObject(JSON.toJSONString(map), clazzUser);
}
public void test_cluster() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class clazzCluster = classLoader.loadClass("Cluster");
Object cluster = JSON.parseObject(JSON.toJSONString(Collections.singletonMap("cluster_enabled", 1)), clazzCluster);
assertEquals("{\"cluster_enabled\":1}", JSON.toJSONString(cluster));
Reported by PMD.
Line: 30
Class clazzCluster = classLoader.loadClass("Cluster");
Object cluster = JSON.parseObject(JSON.toJSONString(Collections.singletonMap("cluster_enabled", 1)), clazzCluster);
assertEquals("{\"cluster_enabled\":1}", JSON.toJSONString(cluster));
}
public static class ExtClassLoader extends ClassLoader {
public ExtClassLoader() throws IOException {
Reported by PMD.
Line: 40
{
byte[] bytes;
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/issue1543/User1.clazz");
bytes = IOUtils.toByteArray(is);
is.close();
super.defineClass("User1", bytes, 0, bytes.length);
}
Reported by PMD.
Line: 49
{
byte[] bytes;
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/issue1543/Cluster.clazz");
bytes = IOUtils.toByteArray(is);
is.close();
super.defineClass("Cluster", bytes, 0, bytes.length);
}
Reported by PMD.