The following issues were found
src/test/java/com/alibaba/json/bvt/parser/ReadOnlyCollectionTest_final_field_null.java
3 issues
Line: 14
public class ReadOnlyCollectionTest_final_field_null extends TestCase {
public void test_readOnlyNullList() throws Exception {
String text = "{\"list\":[1,2,3]}";
Entity entity = JSON.parseObject(text, Entity.class);
Assert.assertNotNull(entity);
Assert.assertEquals(3, entity.list.size());
}
Reported by PMD.
Line: 18
String text = "{\"list\":[1,2,3]}";
Entity entity = JSON.parseObject(text, Entity.class);
Assert.assertNotNull(entity);
Assert.assertEquals(3, entity.list.size());
}
public static class Entity {
public final List<Object> list = new ArrayList<Object>();
Reported by PMD.
Line: 23
public static class Entity {
public final List<Object> list = new ArrayList<Object>();
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/ReadOnlyMapTest.java
3 issues
Line: 14
public class ReadOnlyMapTest extends TestCase {
public void test_readOnlyNullList() throws Exception {
String text = "{\"values\":{\"a\":{}}}";
Entity entity = JSON.parseObject(text, Entity.class);
Assert.assertNotNull(entity);
Assert.assertNotNull(entity.values.get("a"));
Assert.assertTrue(entity.values.get("a") instanceof A);
Reported by PMD.
Line: 18
String text = "{\"values\":{\"a\":{}}}";
Entity entity = JSON.parseObject(text, Entity.class);
Assert.assertNotNull(entity);
Assert.assertNotNull(entity.values.get("a"));
Assert.assertTrue(entity.values.get("a") instanceof A);
}
public static class Entity {
Reported by PMD.
Line: 19
Entity entity = JSON.parseObject(text, Entity.class);
Assert.assertNotNull(entity);
Assert.assertNotNull(entity.values.get("a"));
Assert.assertTrue(entity.values.get("a") instanceof A);
}
public static class Entity {
private final Map<String, A> values = new HashMap<String, A>();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/ReadOnlyMapTest2_final_field.java
3 issues
Line: 13
public class ReadOnlyMapTest2_final_field extends TestCase {
public void test_readOnlyNullList() throws Exception {
String text = "{\"values\":{\"a\":{}}}";
Entity entity = JSON.parseObject(text, Entity.class);
Assert.assertNotNull(entity);
Assert.assertNull(entity.values);
}
Reported by PMD.
Line: 22
public static class Entity {
public final Map<String, A> values = null;
}
public static class A {
Reported by PMD.
Line: 22
public static class Entity {
public final Map<String, A> values = null;
}
public static class A {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1900/Issue1944.java
3 issues
Line: 7
import junit.framework.TestCase;
public class Issue1944 extends TestCase {
public void test_for_issue() throws Exception {
assertEquals(90.82195113f, JSON.parseObject("{\"value\":90.82195113}", Model.class).value);
}
public static class Model {
public float value;
Reported by PMD.
Line: 8
public class Issue1944 extends TestCase {
public void test_for_issue() throws Exception {
assertEquals(90.82195113f, JSON.parseObject("{\"value\":90.82195113}", Model.class).value);
}
public static class Model {
public float value;
}
Reported by PMD.
Line: 8
public class Issue1944 extends TestCase {
public void test_for_issue() throws Exception {
assertEquals(90.82195113f, JSON.parseObject("{\"value\":90.82195113}", Model.class).value);
}
public static class Model {
public float value;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1900/Issue1955.java
3 issues
Line: 12
import java.util.TimeZone;
public class Issue1955 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 strVal = "0100-01-27 11:22:00.000";
Date date = JSON.parseObject('"' + strVal + '"', Date.class);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.CHINA);
df.setTimeZone(JSON.defaultTimeZone);
Reported by PMD.
Line: 24
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.CHINA);
df.setTimeZone(JSON.defaultTimeZone);
assertEquals(df.parse(strVal), date);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/feature/WriteNullStringAsEmptyTest2.java
3 issues
Line: 13
* Created by wenshao on 14/03/2017.
*/
public class WriteNullStringAsEmptyTest2 extends TestCase {
public void test_features() throws Exception {
Model model = new Model();
String json = JSON.toJSONString(model);
assertEquals("{\"id\":\"\"}", json);
}
Reported by PMD.
Line: 16
public void test_features() throws Exception {
Model model = new Model();
String json = JSON.toJSONString(model);
assertEquals("{\"id\":\"\"}", json);
}
public static class Model {
@JSONField(serialzeFeatures = SerializerFeature.WriteNullStringAsEmpty)
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.PropertyFilter;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
/**
* Created by wenshao on 14/03/2017.
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1900/Issue1977.java
3 issues
Line: 11
import java.util.TimeZone;
public class Issue1977 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: 16
JSON.defaultLocale = Locale.CHINA;
}
public void test_for_issue() throws Exception {
java.sql.Date date = new java.sql.Date(1533265119604L);
String json = JSON.toJSONString(date, SerializerFeature.UseISO8601DateFormat);
assertEquals("\"2018-08-03T10:58:39.604+08:00\"", json);
// new java.sql.Date();
}
Reported by PMD.
Line: 19
public void test_for_issue() throws Exception {
java.sql.Date date = new java.sql.Date(1533265119604L);
String json = JSON.toJSONString(date, SerializerFeature.UseISO8601DateFormat);
assertEquals("\"2018-08-03T10:58:39.604+08:00\"", json);
// new java.sql.Date();
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/feature/InitStringFieldAsEmptyTest.java
3 issues
Line: 11
import junit.framework.TestCase;
public class InitStringFieldAsEmptyTest extends TestCase {
public void test_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{}");
parser.config(Feature.InitStringFieldAsEmpty, true);
Model model = parser.parseObject(Model.class);
Assert.assertEquals("", model.value);
parser.close();
Reported by PMD.
Line: 19
parser.close();
}
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{}");
parser.config(Feature.InitStringFieldAsEmpty, false);
Model model = parser.parseObject(Model.class);
Assert.assertNull(null, model.value);
parser.close();
Reported by PMD.
Line: 31
public Model() {
}
public String value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/feature/FeaturesTest6.java
3 issues
Line: 15
public class FeaturesTest6 extends TestCase {
public void test_0() throws Exception {
SerializeConfig config = new SerializeConfig();
config.setAsmEnable(false);
String text = JSON.toJSONString(new Entity(), config);
Assert.assertEquals("{\"value\":[]}", text);
Reported by PMD.
Line: 23
Assert.assertEquals("{\"value\":[]}", text);
}
public void test_1() throws Exception {
SerializeConfig config = new SerializeConfig();
config.setAsmEnable(true);
String text = JSON.toJSONString(new Entity(), config);
Assert.assertEquals("{\"value\":[]}", text);
Reported by PMD.
Line: 33
public static class Entity {
private List value;
@JSONField(serialzeFeatures = { SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty })
public List getValue() {
return value;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/feature/FeaturesTest5_1.java
3 issues
Line: 12
public class FeaturesTest5_1 extends TestCase {
public void test_0() throws Exception {
SerializeConfig config = new SerializeConfig();
config.setAsmEnable(false);
String text = JSON.toJSONString(new Entity(), config);
Assert.assertEquals("{\"value\":false}", text);
Reported by PMD.
Line: 20
Assert.assertEquals("{\"value\":false}", text);
}
public void test_1() throws Exception {
SerializeConfig config = new SerializeConfig();
config.setAsmEnable(true);
String text = JSON.toJSONString(new Entity(), config);
Assert.assertEquals("{\"value\":false}", text);
Reported by PMD.
Line: 30
public static class Entity {
private Boolean value;
@JSONField(serialzeFeatures = { SerializerFeature.WriteNullBooleanAsFalse })
public Boolean getValue() {
return value;
}
Reported by PMD.