The following issues were found
src/test/java/com/alibaba/json/bvt/path/JSONPath_containsValue_double.java
3 issues
Line: 10
import junit.framework.TestCase;
public class JSONPath_containsValue_double extends TestCase {
public void test_root() throws Exception {
Model model = new Model();
model.value = 1001D;
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001));
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001L));
Reported by PMD.
Line: 14
Model model = new Model();
model.value = 1001D;
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001));
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001L));
Assert.assertTrue(JSONPath.containsValue(model, "/value", (short) 1001));
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001F));
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001D));
Reported by PMD.
Line: 28
}
public static class Model {
public double value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_containsValue_biginteger.java
3 issues
Line: 12
import junit.framework.TestCase;
public class JSONPath_containsValue_biginteger extends TestCase {
public void test_root() throws Exception {
Model model = new Model();
model.value = new BigInteger("1001");
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001));
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001L));
Reported by PMD.
Line: 16
Model model = new Model();
model.value = new BigInteger("1001");
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001));
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001L));
Assert.assertTrue(JSONPath.containsValue(model, "/value", (short) 1001));
Assert.assertFalse(JSONPath.containsValue(model, "/value", 1002));
Assert.assertFalse(JSONPath.containsValue(model, "/value", 1002L));
Reported by PMD.
Line: 26
}
public static class Model {
public BigInteger value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/BooleanDeserializerTest.java
3 issues
Line: 15
public class BooleanDeserializerTest extends TestCase {
public void test_boolean() throws Exception {
Assert.assertEquals(Boolean.TRUE, JSON.parseObject("true", Boolean.class));
Assert.assertEquals(Boolean.FALSE, JSON.parseObject("false", Boolean.class));
Assert.assertEquals(Boolean.TRUE, JSON.parseObject("'true'", Boolean.class));
Assert.assertEquals(Boolean.FALSE, JSON.parseObject("'false'", Boolean.class));
Reported by PMD.
Line: 30
{
DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(),
JSON.DEFAULT_PARSER_FEATURE);
Assert.assertEquals(null, BooleanCodec.instance.deserialze(parser, null, null));
parser.close();
}
Assert.assertEquals(JSONToken.TRUE, BooleanCodec.instance.getFastMatchToken());
}
}
Reported by PMD.
Line: 33
Assert.assertEquals(null, BooleanCodec.instance.deserialze(parser, null, null));
parser.close();
}
Assert.assertEquals(JSONToken.TRUE, BooleanCodec.instance.getFastMatchToken());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumTest3.java
3 issues
Line: 40
try {
JSON.parseObject(json, Pojo.class);
Assert.assertTrue(true);
} catch (Exception e) {
Assert.fail("枚举默认序列化name值,可以反序列化成功");
}
Map<String, Pojo> map = new HashMap<String, Pojo>();
map.put("a", pojo);
Reported by PMD.
Line: 71
try {
Pojo pojo1 = JSON.parseObject(json, Pojo.class);
Assert.assertNull(pojo1.getSex());
} catch (Exception e) {
Assert.assertTrue(true);
}
Map<String, Pojo> map = new HashMap<String, Pojo>();
Reported by PMD.
Line: 72
try {
Pojo pojo1 = JSON.parseObject(json, Pojo.class);
Assert.assertNull(pojo1.getSex());
} catch (Exception e) {
Assert.assertTrue(true);
}
Map<String, Pojo> map = new HashMap<String, Pojo>();
map.put("a", pojo);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/TransientTest.java
3 issues
Line: 28
parent.addChild(child);
String text = JSON.toJSONString(parent);
System.out.println(text);
Map</**fieldName*/String , Field> fieldCacheMap =new HashMap<String, Field>();
ParserConfig.parserAllFieldToCache(Category.class, fieldCacheMap);
Assert.assertNotNull(ParserConfig.getFieldFromCache("name", fieldCacheMap));
Assert.assertNull(ParserConfig.getFieldFromCache("abc",fieldCacheMap));
}
Reported by PMD.
Line: 18
public class TransientTest extends TestCase {
public void test_transient() throws Exception {
Category parent = new Category();
parent.setName("Parent");
Category child = new Category();
child.setName("child");
Reported by PMD.
Line: 35
Assert.assertNull(ParserConfig.getFieldFromCache("abc",fieldCacheMap));
}
public static class Category {
private String name;
private transient Category parent;
private List<Category> children = new ArrayList<Category>();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/features/JSONDirectTest_number.java
3 issues
Line: 9
import org.junit.Assert;
public class JSONDirectTest_number extends TestCase {
public void test_feature() throws Exception {
Model model = new Model();
model.id = 1001;
model.value = "12.34";
String json = JSON.toJSONString(model);
Reported by PMD.
Line: 20
}
public static class Model {
public int id;
@JSONField(jsonDirect=true)
public String value;
}
}
Reported by PMD.
Line: 22
public static class Model {
public int id;
@JSONField(jsonDirect=true)
public String value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_array_length.java
3 issues
Line: 11
import java.util.Collections;
public class JSONPath_array_length extends TestCase {
public void test_list_size() throws Exception {
Assert.assertEquals(0, JSONPath.eval(new JSONArray(), "$.length"));
}
public void test_list_size1() throws Exception {
Assert.assertEquals(0, JSONPath.eval(new Object[0], "$.length()"));
Reported by PMD.
Line: 15
Assert.assertEquals(0, JSONPath.eval(new JSONArray(), "$.length"));
}
public void test_list_size1() throws Exception {
Assert.assertEquals(0, JSONPath.eval(new Object[0], "$.length()"));
}
}
Reported by PMD.
Line: 8
import junit.framework.TestCase;
import org.junit.Assert;
import java.util.Collections;
public class JSONPath_array_length extends TestCase {
public void test_list_size() throws Exception {
Assert.assertEquals(0, JSONPath.eval(new JSONArray(), "$.length"));
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/ArraySerializerTest.java
3 issues
Line: 13
public class ArraySerializerTest extends TestCase {
public void test_0() throws Exception {
SerializeWriter out = new SerializeWriter(1);
JSONSerializer.write(out, new A[] { new A(), null, null });
Assert.assertEquals("[{},null,null]", out.toString());
Reported by PMD.
Line: 21
Assert.assertEquals("[{},null,null]", out.toString());
}
public void test_1() throws Exception {
SerializeWriter out = new SerializeWriter(1);
JSONSerializer.write(out, new A[] {});
Assert.assertEquals("[]", out.toString());
Reported by PMD.
Line: 31
new IOUtils();
}
public void test_2() throws Exception {
SerializeWriter out = new SerializeWriter(1);
JSONSerializer.write(out, new A[] { new A() });
Assert.assertEquals("[{}]", out.toString());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/UUIDTest.java
3 issues
Line: 17
String text = JSON.toJSONString(id);
System.out.println(text);
Assert.assertEquals(JSON.toJSONString(id.toString()), text);
UUID id2 = JSON.parseObject(text, UUID.class);
Assert.assertEquals(id, id2);
Reported by PMD.
Line: 12
public class UUIDTest extends TestCase {
public void test_timezone() throws Exception {
UUID id = UUID.randomUUID();
String text = JSON.toJSONString(id);
System.out.println(text);
Reported by PMD.
Line: 19
System.out.println(text);
Assert.assertEquals(JSON.toJSONString(id.toString()), text);
UUID id2 = JSON.parseObject(text, UUID.class);
Assert.assertEquals(id, id2);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/JSONSerializerTest3.java
3 issues
Line: 15
import junit.framework.TestCase;
public class JSONSerializerTest3 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_0() throws Exception {
Reported by PMD.
Line: 20
JSON.defaultLocale = Locale.CHINA;
}
public void test_0() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.setDateFormat("yyyy");
Assert.assertEquals("yyyy", ((SimpleDateFormat) serializer.getDateFormat()).toPattern());
Assert.assertEquals("yyyy", serializer.getDateFormatPattern());
Reported by PMD.
Line: 30
serializer.setDateFormat("yyyy-MM");
Assert.assertEquals("yyyy-MM", ((SimpleDateFormat) serializer.getDateFormat()).toPattern());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
format.setTimeZone(JSON.defaultTimeZone);
serializer.setDateFormat(format);
Assert.assertEquals("yyyy-MM-dd", serializer.getDateFormatPattern());
serializer.close();
Reported by PMD.