The following issues were found
src/test/java/com/alibaba/json/bvt/jdk8/InstantTest.java
3 issues
Line: 18
vo.setDate(Instant.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 InstantTest extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.setDate(Instant.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 Instant date;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1281.java
3 issues
Line: 14
* Created by wenshao on 24/06/2017.
*/
public class Issue1281 extends TestCase {
public void test_for_issue() throws Exception {
Type type1 = new TypeReference<Result<Map<String, Object>>>() {}.getType();
Type type2 = new TypeReference<Result<Map<String, Object>>>() {}.getType();
assertSame(type1, type2);
}
Reported by PMD.
Line: 17
public void test_for_issue() throws Exception {
Type type1 = new TypeReference<Result<Map<String, Object>>>() {}.getType();
Type type2 = new TypeReference<Result<Map<String, Object>>>() {}.getType();
assertSame(type1, type2);
}
public static class Result<T> {
public T value;
}
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.issue_1200;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import junit.framework.TestCase;
import java.lang.reflect.Type;
import java.util.Map;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jdk8/DurationTest.java
3 issues
Line: 18
vo.setDate(Duration.ofHours(3));
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 DurationTest extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.setDate(Duration.ofHours(3));
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 Duration date;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/DefaultJSONParserTest_comma.java
3 issues
Line: 12
public class DefaultJSONParserTest_comma extends TestCase {
public void test_getInput() {
String text = "{,,}";
char[] chars = text.toCharArray();
DefaultJSONParser parser = new DefaultJSONParser(chars, chars.length, ParserConfig.getGlobalInstance(), 0);
JSONException error = null;
Reported by PMD.
Line: 14
public void test_getInput() {
String text = "{,,}";
char[] chars = text.toCharArray();
DefaultJSONParser parser = new DefaultJSONParser(chars, chars.length, ParserConfig.getGlobalInstance(), 0);
JSONException error = null;
try {
parser.parseObject();
Reported by PMD.
Line: 17
char[] chars = text.toCharArray();
DefaultJSONParser parser = new DefaultJSONParser(chars, chars.length, ParserConfig.getGlobalInstance(), 0);
JSONException error = null;
try {
parser.parseObject();
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/date/DateTest_dotnet.java
3 issues
Line: 12
import junit.framework.TestCase;
public class DateTest_dotnet extends TestCase {
public void test_date() throws Exception {
String text = "{\"date\":\"/Date(1461081600000)/\"}";
Model model = JSON.parseObject(text, Model.class);
Assert.assertEquals(1461081600000L, model.date.getTime());
}
Reported by PMD.
Line: 16
String text = "{\"date\":\"/Date(1461081600000)/\"}";
Model model = JSON.parseObject(text, Model.class);
Assert.assertEquals(1461081600000L, model.date.getTime());
}
public static class Model {
public Date date;
}
Reported by PMD.
Line: 20
}
public static class Model {
public Date date;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jdk8/DoubleAdderTest.java
3 issues
Line: 13
* Created by wenshao on 14/03/2017.
*/
public class DoubleAdderTest extends TestCase {
public void test_long_add() throws Exception {
DoubleAdder adder = new DoubleAdder();
adder.add(3);
String json = JSON.toJSONString(adder);
assertEquals("{\"value\":3.0}", json);
Reported by PMD.
Line: 18
adder.add(3);
String json = JSON.toJSONString(adder);
assertEquals("{\"value\":3.0}", json);
}
}
Reported by PMD.
Line: 7
import junit.framework.TestCase;
import java.util.concurrent.atomic.DoubleAdder;
import java.util.concurrent.atomic.LongAdder;
/**
* Created by wenshao on 14/03/2017.
*/
public class DoubleAdderTest extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3600/Issue3682.java
3 issues
Line: 11
public class Issue3682 extends TestCase {
public void test_for_issue() throws Exception {
Cid cid = JSON.parseObject(SOURCE, Cid.class);
System.out.println(cid);
}
@Data
static public class Cid {
Reported by PMD.
Line: 9
import lombok.Data;
public class Issue3682 extends TestCase {
public void test_for_issue() throws Exception {
Cid cid = JSON.parseObject(SOURCE, Cid.class);
System.out.println(cid);
}
@Data
Reported by PMD.
Line: 9
import lombok.Data;
public class Issue3682 extends TestCase {
public void test_for_issue() throws Exception {
Cid cid = JSON.parseObject(SOURCE, Cid.class);
System.out.println(cid);
}
@Data
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_default_boolean.java
3 issues
Line: 11
public class JSONCreatorTest_default_boolean extends TestCase {
public void test_create() throws Exception {
Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class);
Assert.assertFalse(model.id);
Assert.assertEquals("wenshao", model.name);
}
Reported by PMD.
Line: 20
public static class Model {
private final boolean id;
private final String name;
@JSONCreator
public Model(@JSONField(name="id") boolean id, @JSONField(name="name") String name) {
this.id = id;
Reported by PMD.
Line: 21
public static class Model {
private final boolean id;
private final String name;
@JSONCreator
public Model(@JSONField(name="id") boolean id, @JSONField(name="name") String name) {
this.id = id;
this.name = name;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/FeatureCountTest.java
3 issues
Line: 9
public class FeatureCountTest extends TestCase {
public void testZ_0() throws Exception {
Feature[] features = Feature.class.getEnumConstants();
System.out.println(features.length);
assertTrue(features.length < 32);
}
}
Reported by PMD.
Line: 7
import junit.framework.TestCase;
public class FeatureCountTest extends TestCase {
public void testZ_0() throws Exception {
Feature[] features = Feature.class.getEnumConstants();
System.out.println(features.length);
assertTrue(features.length < 32);
}
}
Reported by PMD.
Line: 10
public void testZ_0() throws Exception {
Feature[] features = Feature.class.getEnumConstants();
System.out.println(features.length);
assertTrue(features.length < 32);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1222_1.java
3 issues
Line: 12
* Created by wenshao on 01/06/2017.
*/
public class Issue1222_1 extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
model.type = Type.A;
String text = JSON.toJSONString(model, SerializerFeature.WriteEnumUsingToString);
assertEquals("{\"type\":\"TypeA\"}", text);
}
Reported by PMD.
Line: 16
Model model = new Model();
model.type = Type.A;
String text = JSON.toJSONString(model, SerializerFeature.WriteEnumUsingToString);
assertEquals("{\"type\":\"TypeA\"}", text);
}
private static class Model {
public Type type;
}
Reported by PMD.
Line: 20
}
private static class Model {
public Type type;
}
private static enum Type implements JSONAware {
A, B;
Reported by PMD.