The following issues were found
src/test/java/com/alibaba/json/bvt/util/TypeUtilsCastLinkedHashMap.java
4 issues
Line: 11
import java.util.LinkedHashMap;
public class TypeUtilsCastLinkedHashMap extends TestCase {
public void test_for_cast() throws Exception {
JSONObject obj = JSON.parseObject("{\"id\":1001,\"name\":\"xxx\"}", Feature.OrderedField);
obj.toJavaObject(LinkedHashMap.class);
}
}
Reported by PMD.
Line: 11
import java.util.LinkedHashMap;
public class TypeUtilsCastLinkedHashMap extends TestCase {
public void test_for_cast() throws Exception {
JSONObject obj = JSON.parseObject("{\"id\":1001,\"name\":\"xxx\"}", Feature.OrderedField);
obj.toJavaObject(LinkedHashMap.class);
}
}
Reported by PMD.
Line: 13
public class TypeUtilsCastLinkedHashMap extends TestCase {
public void test_for_cast() throws Exception {
JSONObject obj = JSON.parseObject("{\"id\":1001,\"name\":\"xxx\"}", Feature.OrderedField);
obj.toJavaObject(LinkedHashMap.class);
}
}
Reported by PMD.
Line: 13
public class TypeUtilsCastLinkedHashMap extends TestCase {
public void test_for_cast() throws Exception {
JSONObject obj = JSON.parseObject("{\"id\":1001,\"name\":\"xxx\"}", Feature.OrderedField);
obj.toJavaObject(LinkedHashMap.class);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/DefaultObjectDeserializerTest3.java
4 issues
Line: 14
@SuppressWarnings("rawtypes")
public class DefaultObjectDeserializerTest3 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest2");
}
public void test_0() throws Exception {
HashMap o = (HashMap) JSON.parse("{\"@type\":\"java.lang.Cloneable\"}");
Reported by PMD.
Line: 15
@SuppressWarnings("rawtypes")
public class DefaultObjectDeserializerTest3 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest2");
}
public void test_0() throws Exception {
HashMap o = (HashMap) JSON.parse("{\"@type\":\"java.lang.Cloneable\"}");
Assert.assertEquals(0, o.size());
Reported by PMD.
Line: 18
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest2");
}
public void test_0() throws Exception {
HashMap o = (HashMap) JSON.parse("{\"@type\":\"java.lang.Cloneable\"}");
Assert.assertEquals(0, o.size());
}
}
Reported by PMD.
Line: 20
public void test_0() throws Exception {
HashMap o = (HashMap) JSON.parse("{\"@type\":\"java.lang.Cloneable\"}");
Assert.assertEquals(0, o.size());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/DefaultObjectDeserializerTest4.java
4 issues
Line: 12
public class DefaultObjectDeserializerTest4 extends TestCase {
public void test_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{\"id\":3, \"name\":\"xx\"}", ParserConfig.getGlobalInstance());
Entity entity = new Entity();
parser.parseObject(entity);
}
Reported by PMD.
Line: 12
public class DefaultObjectDeserializerTest4 extends TestCase {
public void test_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{\"id\":3, \"name\":\"xx\"}", ParserConfig.getGlobalInstance());
Entity entity = new Entity();
parser.parseObject(entity);
}
Reported by PMD.
Line: 19
parser.parseObject(entity);
}
public void test_1() throws Exception {
JSON.parseObject("{\"id\":3, \"name\":\"xx\"}", Entity.class, 0, Feature.IgnoreNotMatch);
}
public static class Entity {
Reported by PMD.
Line: 19
parser.parseObject(entity);
}
public void test_1() throws Exception {
JSON.parseObject("{\"id\":3, \"name\":\"xx\"}", Entity.class, 0, Feature.IgnoreNotMatch);
}
public static class Entity {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/DefaultObjectDeserializerTest8.java
4 issues
Line: 14
public class DefaultObjectDeserializerTest8 extends TestCase {
public <T> void test_1() throws Exception {
VO<T> vo = JSON.parseObject("{\"value\":[{\"id\":123}]}", new TypeReference<VO<T>>() {
});
Assert.assertNotNull(vo.getValue()[0]);
Assert.assertTrue(vo.getValue()[0] instanceof Map);
}
Reported by PMD.
Line: 26
private T[] value;
public T[] getValue() {
return value;
}
public void setValue(T[] value) {
this.value = value;
}
Reported by PMD.
Line: 29
return value;
}
public void setValue(T[] value) {
this.value = value;
}
}
Reported by PMD.
Line: 29
return value;
}
public void setValue(T[] value) {
this.value = value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/support/spring/data/PageToJSONTest.java
4 issues
Line: 16
import junit.framework.TestCase;
public class PageToJSONTest extends TestCase {
public void test_page() throws Exception {
List<Post> postList = new ArrayList<Post>();
{
postList.add(new Post(1001));
}
Reported by PMD.
Line: 26
JSONObject obj = (JSONObject) JSON.toJSON(page);
Assert.assertNotNull(obj);
Assert.assertEquals(1, obj.getJSONArray("content").size());
}
public static class Post{
public int id;
Reported by PMD.
Line: 26
JSONObject obj = (JSONObject) JSON.toJSON(page);
Assert.assertNotNull(obj);
Assert.assertEquals(1, obj.getJSONArray("content").size());
}
public static class Post{
public int id;
Reported by PMD.
Line: 30
}
public static class Post{
public int id;
public Post() {
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/TimeZoneTest.java
4 issues
Line: 12
public class TimeZoneTest extends TestCase {
public void test_timezone() throws Exception {
TimeZone tz1 = TimeZone.getDefault();
String text = JSON.toJSONString(tz1);
Assert.assertEquals(JSON.toJSONString(tz1.getID()), text);
Reported by PMD.
Line: 16
TimeZone tz1 = TimeZone.getDefault();
String text = JSON.toJSONString(tz1);
Assert.assertEquals(JSON.toJSONString(tz1.getID()), text);
TimeZone tz2 = JSON.parseObject(text, TimeZone.class);
Assert.assertEquals(tz1.getID(), tz2.getID());
}
}
Reported by PMD.
Line: 19
Assert.assertEquals(JSON.toJSONString(tz1.getID()), text);
TimeZone tz2 = JSON.parseObject(text, TimeZone.class);
Assert.assertEquals(tz1.getID(), tz2.getID());
}
}
Reported by PMD.
Line: 19
Assert.assertEquals(JSON.toJSONString(tz1.getID()), text);
TimeZone tz2 = JSON.parseObject(text, TimeZone.class);
Assert.assertEquals(tz1.getID(), tz2.getID());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/support/spring/FastJsonRedisSerializerTest.java
4 issues
Line: 18
public class FastJsonRedisSerializerTest {
private FastJsonRedisSerializer<User> serializer;
@Before
public void setUp() {
this.serializer = new FastJsonRedisSerializer<User>(User.class);
}
Reported by PMD.
Line: 70
fastJsonConfig.setSerializerFeatures(serializerFeatures);
ParserConfig parserConfig = ParserConfig.getGlobalInstance();
parserConfig.setAutoTypeSupport(true);
fastJsonConfig.setParserConfig(parserConfig);
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
Assert.assertNotNull(fastJsonRedisSerializer.getFastJsonConfig());
fastJsonRedisSerializer.setFastJsonConfig(fastJsonConfig);
Reported by PMD.
Line: 82
byte[] serializedValue = fastJsonRedisSerializer.serialize(userSer);
User userDes = (User) fastJsonRedisSerializer.deserialize(serializedValue);
Assert.assertEquals(userDes.getName(), "土豆");
}
static class User {
private Integer id;
private String name;
Reported by PMD.
Line: 85
Assert.assertEquals(userDes.getName(), "土豆");
}
static class User {
private Integer id;
private String name;
private Integer age;
public User() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/URITest.java
4 issues
Line: 12
public class URITest extends TestCase {
public void test_file() throws Exception {
URI uri = URI.create("http://www.alibaba.com/");
String text = JSON.toJSONString(uri);
Assert.assertEquals(JSON.toJSONString(uri.toString()), text);
Reported by PMD.
Line: 17
String text = JSON.toJSONString(uri);
Assert.assertEquals(JSON.toJSONString(uri.toString()), text);
URI uri2 = JSON.parseObject(text, URI.class);
Assert.assertEquals(uri.toString(), uri2.toString());
}
}
Reported by PMD.
Line: 20
Assert.assertEquals(JSON.toJSONString(uri.toString()), text);
URI uri2 = JSON.parseObject(text, URI.class);
Assert.assertEquals(uri.toString(), uri2.toString());
}
}
Reported by PMD.
Line: 20
Assert.assertEquals(JSON.toJSONString(uri.toString()), text);
URI uri2 = JSON.parseObject(text, URI.class);
Assert.assertEquals(uri.toString(), uri2.toString());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/WriteClassNameTest.java
4 issues
Line: 20
SerializeConfig config = new SerializeConfig();
config.setAsmEnable(false);
String text = JSON.toJSONString(object, config, SerializerFeature.WriteClassName);
System.out.println(text);
}
public static class Entity {
private int id;
Reported by PMD.
Line: 11
public class WriteClassNameTest extends TestCase {
public void test_writeClassName() throws Exception {
Entity object = new Entity();
object.setId(123);
object.setName("jobs");
object.setAverage(3.21F);
Reported by PMD.
Line: 11
public class WriteClassNameTest extends TestCase {
public void test_writeClassName() throws Exception {
Entity object = new Entity();
object.setId(123);
object.setName("jobs");
object.setAverage(3.21F);
Reported by PMD.
Line: 23
System.out.println(text);
}
public static class Entity {
private int id;
private String name;
private float average;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/SmartMatchTest2.java
4 issues
Line: 12
public class SmartMatchTest2 extends TestCase {
public void f_test_0 () throws Exception {
String text = "{\"_id\":1001}";
VO vo = JSON.parseObject(text, VO.class);
Assert.assertEquals(1001, vo.getId());
}
Reported by PMD.
Line: 16
String text = "{\"_id\":1001}";
VO vo = JSON.parseObject(text, VO.class);
Assert.assertEquals(1001, vo.getId());
}
public void test_vo2 () throws Exception {
String text = "{\"_id\":1001}";
Reported by PMD.
Line: 19
Assert.assertEquals(1001, vo.getId());
}
public void test_vo2 () throws Exception {
String text = "{\"_id\":1001}";
VO2 vo = JSON.parseObject(text, VO2.class);
Assert.assertEquals(1001, vo.getId());
}
Reported by PMD.
Line: 23
String text = "{\"_id\":1001}";
VO2 vo = JSON.parseObject(text, VO2.class);
Assert.assertEquals(1001, vo.getId());
}
private static class VO {
private int id;
Reported by PMD.