The following issues were found
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest6.java
2 issues
Line: 14
public class JSONCreatorTest6 extends TestCase {
public void test_create_error() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":1001,\"name\":\"wenshao\",\"obj\":{\"$ref\":\"$\"}}", Entity.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 15
public class JSONCreatorTest6 extends TestCase {
public void test_create_error() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":1001,\"name\":\"wenshao\",\"obj\":{\"$ref\":\"$\"}}", Entity.class);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/DateTest.java
2 issues
Line: 12
public class DateTest extends TestCase {
public void test_0() throws Exception {
Assert.assertNull(JSON.parseObject("", java.sql.Date.class));
Assert.assertNull(JSON.parseObject(null, java.sql.Date.class));
Assert.assertNull(JSON.parseObject("null", java.sql.Date.class));
Assert.assertNull(JSON.parseObject("\"\"", java.sql.Date.class));
Reported by PMD.
Line: 28
Assert.assertNull(JSON.parseObject("null", java.sql.Timestamp.class));
Assert.assertNull(JSON.parseObject("\"\"", java.sql.Timestamp.class));
Assert.assertNull(JSON.parseObject("{date:\"\"}", Entity.class).getDate());
}
public static class Entity {
private Date date;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jdk8/OptionalTest_empty.java
2 issues
Line: 13
public class OptionalTest_empty extends TestCase {
public void test_optional() throws Exception {
Model model = new Model();
model.value = Optional.empty();
String text = JSON.toJSONString(model);
Reported by PMD.
Line: 28
public static class Model {
public Optional<Value> value;
}
public static class Value {
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONLexerTest_3.java
2 issues
Line: 9
public class JSONLexerTest_3 extends TestCase {
public void test_matchField() throws Exception {
JSON.parseObject("{\"val\":{}}", VO.class);
}
public static class VO {
Reported by PMD.
Line: 9
public class JSONLexerTest_3 extends TestCase {
public void test_matchField() throws Exception {
JSON.parseObject("{\"val\":{}}", VO.class);
}
public static class VO {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONLexerTest_4.java
2 issues
Line: 11
public class JSONLexerTest_4 extends TestCase {
public void test_scanFieldString() throws Exception {
VO vo = JSON.parseObject("{\"value\":\"abc\"}", VO.class);
Assert.assertEquals("abc", vo.getValue());
}
public static class VO {
Reported by PMD.
Line: 13
public void test_scanFieldString() throws Exception {
VO vo = JSON.parseObject("{\"value\":\"abc\"}", VO.class);
Assert.assertEquals("abc", vo.getValue());
}
public static class VO {
private String value;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/ReadOnlyMapTest2.java
2 issues
Line: 13
public class ReadOnlyMapTest2 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);
}
Reported by PMD.
Line: 22
public static class Entity {
private Map<String, A> values;
public Map<String, A> getValues() {
return values;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1400/Issue1450.java
2 issues
Line: 9
import java.time.LocalDateTime;
public class Issue1450 extends TestCase {
public void test_for_issue() throws Exception {
LocalDateTime localDateTime = LocalDateTime.of(2018, 8, 31, 15, 26, 37, 1);
String json = JSON.toJSONStringWithDateFormat(localDateTime, "yyyy-MM-dd HH:mm:ss");//2018-08-31T15:26:37.000000001
assertEquals("\"2018-08-31 15:26:37\"", json);
}
}
Reported by PMD.
Line: 12
public void test_for_issue() throws Exception {
LocalDateTime localDateTime = LocalDateTime.of(2018, 8, 31, 15, 26, 37, 1);
String json = JSON.toJSONStringWithDateFormat(localDateTime, "yyyy-MM-dd HH:mm:ss");//2018-08-31T15:26:37.000000001
assertEquals("\"2018-08-31 15:26:37\"", json);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2300/Issue2344.java
2 issues
Line: 9
import junit.framework.TestCase;
public class Issue2344 extends TestCase {
public void test_for_issue() throws Exception {
LongPrimitiveEntity vo = new LongPrimitiveEntity(9007199254741992L);
assertEquals("{\"value\":\"9007199254741992\"}"
, JSON.toJSONString(vo, SerializerFeature.BrowserCompatible));
}
Reported by PMD.
Line: 12
public void test_for_issue() throws Exception {
LongPrimitiveEntity vo = new LongPrimitiveEntity(9007199254741992L);
assertEquals("{\"value\":\"9007199254741992\"}"
, JSON.toJSONString(vo, SerializerFeature.BrowserCompatible));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2400/Issue2429.java
2 issues
Line: 7
import junit.framework.TestCase;
public class Issue2429 extends TestCase {
public void testForIssue() {
String str = "{\"schema\":{$ref:\"111\"},\"name\":\"ft\",\"age\":12,\"address\":\"杭州\"}";
JSON.parseObject(str);
}
}
Reported by PMD.
Line: 7
import junit.framework.TestCase;
public class Issue2429 extends TestCase {
public void testForIssue() {
String str = "{\"schema\":{$ref:\"111\"},\"name\":\"ft\",\"age\":12,\"address\":\"杭州\"}";
JSON.parseObject(str);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/fullSer/LongTest.java
2 issues
Line: 17
vo.setValue(33L);
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.fullSer.LongTest$VO\",\"value\":33}", text);
}
public static class VO {
Reported by PMD.
Line: 11
public class LongTest extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.setValue(33L);
String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
Reported by PMD.