The following issues were found
src/test/java/com/alibaba/json/bvt/parser/CreateInstanceErrorTest2.java
6 issues
Line: 13
public class CreateInstanceErrorTest2 extends TestCase {
public void test_ordered_field() throws Exception {
Exception error = null;
try {
Model model = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.json.bvt.parser.CreateInstanceErrorTest2$MyMap\"}}", Model.class);
} catch (Exception ex) {
error = ex;
Reported by PMD.
Line: 16
public void test_ordered_field() throws Exception {
Exception error = null;
try {
Model model = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.json.bvt.parser.CreateInstanceErrorTest2$MyMap\"}}", Model.class);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 17
Exception error = null;
try {
Model model = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.json.bvt.parser.CreateInstanceErrorTest2$MyMap\"}}", Model.class);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 28
public Object value;
}
public static class MyMap extends HashMap {
public MyMap(){
throw new UnsupportedOperationException();
}
}
}
Reported by PMD.
Line: 14
public class CreateInstanceErrorTest2 extends TestCase {
public void test_ordered_field() throws Exception {
Exception error = null;
try {
Model model = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.json.bvt.parser.CreateInstanceErrorTest2$MyMap\"}}", Model.class);
} catch (Exception ex) {
error = ex;
}
Reported by PMD.
Line: 16
public void test_ordered_field() throws Exception {
Exception error = null;
try {
Model model = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.json.bvt.parser.CreateInstanceErrorTest2$MyMap\"}}", Model.class);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jdk8/LocalTimeTest3.java
6 issues
Line: 13
public class LocalTimeTest3 extends TestCase {
public void test_for_issue() throws Exception {
VO vo1 = JSON.parseObject("{\"date\":\"2016-05-05T20:24:28.484\"}", VO.class);
Assert.assertEquals(20, vo1.date.getHour());
Assert.assertEquals(24, vo1.date.getMinute());
Assert.assertEquals(28, vo1.date.getSecond());
Reported by PMD.
Line: 16
public void test_for_issue() throws Exception {
VO vo1 = JSON.parseObject("{\"date\":\"2016-05-05T20:24:28.484\"}", VO.class);
Assert.assertEquals(20, vo1.date.getHour());
Assert.assertEquals(24, vo1.date.getMinute());
Assert.assertEquals(28, vo1.date.getSecond());
Assert.assertEquals(484000000, vo1.date.getNano());
}
Reported by PMD.
Line: 17
VO vo1 = JSON.parseObject("{\"date\":\"2016-05-05T20:24:28.484\"}", VO.class);
Assert.assertEquals(20, vo1.date.getHour());
Assert.assertEquals(24, vo1.date.getMinute());
Assert.assertEquals(28, vo1.date.getSecond());
Assert.assertEquals(484000000, vo1.date.getNano());
}
public static class VO {
Reported by PMD.
Line: 18
Assert.assertEquals(20, vo1.date.getHour());
Assert.assertEquals(24, vo1.date.getMinute());
Assert.assertEquals(28, vo1.date.getSecond());
Assert.assertEquals(484000000, vo1.date.getNano());
}
public static class VO {
Reported by PMD.
Line: 19
Assert.assertEquals(20, vo1.date.getHour());
Assert.assertEquals(24, vo1.date.getMinute());
Assert.assertEquals(28, vo1.date.getSecond());
Assert.assertEquals(484000000, vo1.date.getNano());
}
public static class VO {
public LocalTime date;
Reported by PMD.
Line: 24
public static class VO {
public LocalTime date;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/builder/BuilderTest_error.java
6 issues
Line: 13
public class BuilderTest_error extends TestCase {
public void test_0() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 26
@JSONType(builder = VOBuilder.class)
public static class VO {
private int id;
private String name;
public int getId() {
return id;
}
Reported by PMD.
Line: 27
public static class VO {
private int id;
private String name;
public int getId() {
return id;
}
Reported by PMD.
Line: 40
public static class VOBuilder {
private VO vo = new VO();
public VO build() {
throw new IllegalStateException();
}
Reported by PMD.
Line: 40
public static class VOBuilder {
private VO vo = new VO();
public VO build() {
throw new IllegalStateException();
}
Reported by PMD.
Line: 14
public class BuilderTest_error extends TestCase {
public void test_0() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1400/Issue1445.java
6 issues
Line: 9
import junit.framework.TestCase;
public class Issue1445 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject obj = new JSONObject();
obj.put("data", new JSONObject());
obj.getJSONObject("data").put("data", new JSONObject());
obj.getJSONObject("data").getJSONObject("data").put("map", new JSONObject());
Reported by PMD.
Line: 12
public void test_for_issue() throws Exception {
JSONObject obj = new JSONObject();
obj.put("data", new JSONObject());
obj.getJSONObject("data").put("data", new JSONObject());
obj.getJSONObject("data").getJSONObject("data").put("map", new JSONObject());
obj.getJSONObject("data").getJSONObject("data").getJSONObject("map").put("21160001", "abc");
String json = JSON.toJSONString(obj);
Reported by PMD.
Line: 15
obj.put("data", new JSONObject());
obj.getJSONObject("data").put("data", new JSONObject());
obj.getJSONObject("data").getJSONObject("data").put("map", new JSONObject());
obj.getJSONObject("data").getJSONObject("data").getJSONObject("map").put("21160001", "abc");
String json = JSON.toJSONString(obj);
assertEquals("abc", JSONPath.read(json,"data.data.map.21160001"));
}
}
Reported by PMD.
Line: 15
obj.put("data", new JSONObject());
obj.getJSONObject("data").put("data", new JSONObject());
obj.getJSONObject("data").getJSONObject("data").put("map", new JSONObject());
obj.getJSONObject("data").getJSONObject("data").getJSONObject("map").put("21160001", "abc");
String json = JSON.toJSONString(obj);
assertEquals("abc", JSONPath.read(json,"data.data.map.21160001"));
}
}
Reported by PMD.
Line: 15
obj.put("data", new JSONObject());
obj.getJSONObject("data").put("data", new JSONObject());
obj.getJSONObject("data").getJSONObject("data").put("map", new JSONObject());
obj.getJSONObject("data").getJSONObject("data").getJSONObject("map").put("21160001", "abc");
String json = JSON.toJSONString(obj);
assertEquals("abc", JSONPath.read(json,"data.data.map.21160001"));
}
}
Reported by PMD.
Line: 18
obj.getJSONObject("data").getJSONObject("data").getJSONObject("map").put("21160001", "abc");
String json = JSON.toJSONString(obj);
assertEquals("abc", JSONPath.read(json,"data.data.map.21160001"));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/MapResetTest.java
5 issues
Line: 15
// book.setMetadata(new MetaData());
String text = JSON.toJSONString(book);
System.out.println(text);
Book book2 = JSON.parseObject(text, Book.class);
System.out.println(JSON.toJSONString(book2));
}
Reported by PMD.
Line: 18
System.out.println(text);
Book book2 = JSON.parseObject(text, Book.class);
System.out.println(JSON.toJSONString(book2));
}
public static class Book {
private int id;
Reported by PMD.
Line: 9
public class MapResetTest extends TestCase {
public void test_0() throws Exception {
Book book = new Book();
// book.setMetadata(new MetaData());
String text = JSON.toJSONString(book);
Reported by PMD.
Line: 9
public class MapResetTest extends TestCase {
public void test_0() throws Exception {
Book book = new Book();
// book.setMetadata(new MetaData());
String text = JSON.toJSONString(book);
Reported by PMD.
Line: 21
System.out.println(JSON.toJSONString(book2));
}
public static class Book {
private int id;
private int pageCountNum;
private MetaData metadata;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2700/Issue2703.java
5 issues
Line: 9
import junit.framework.TestCase;
public class Issue2703 extends TestCase {
public void test_for_issue() {
Object a = JSON.toJavaObject(new JSONObject(), JSON.class);
assertTrue(a instanceof JSONObject);
Object b = new JSONObject().toJavaObject(JSON.class);
assertTrue(b instanceof JSONObject);
Reported by PMD.
Line: 9
import junit.framework.TestCase;
public class Issue2703 extends TestCase {
public void test_for_issue() {
Object a = JSON.toJavaObject(new JSONObject(), JSON.class);
assertTrue(a instanceof JSONObject);
Object b = new JSONObject().toJavaObject(JSON.class);
assertTrue(b instanceof JSONObject);
Reported by PMD.
Line: 11
public class Issue2703 extends TestCase {
public void test_for_issue() {
Object a = JSON.toJavaObject(new JSONObject(), JSON.class);
assertTrue(a instanceof JSONObject);
Object b = new JSONObject().toJavaObject(JSON.class);
assertTrue(b instanceof JSONObject);
Object c = JSON.toJavaObject(new JSONArray(), JSON.class);
Reported by PMD.
Line: 14
assertTrue(a instanceof JSONObject);
Object b = new JSONObject().toJavaObject(JSON.class);
assertTrue(b instanceof JSONObject);
Object c = JSON.toJavaObject(new JSONArray(), JSON.class);
assertTrue(c instanceof JSONArray);
}
}
Reported by PMD.
Line: 17
assertTrue(b instanceof JSONObject);
Object c = JSON.toJavaObject(new JSONArray(), JSON.class);
assertTrue(c instanceof JSONArray);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jdk8/LocalDateTest3.java
5 issues
Line: 13
public class LocalDateTest3 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2016-05-06\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
Reported by PMD.
Line: 16
public void test_for_issue() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"2016-05-06\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public static class VO {
Reported by PMD.
Line: 17
VO vo = JSON.parseObject("{\"date\":\"2016-05-06\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public static class VO {
public LocalDate date;
Reported by PMD.
Line: 18
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public static class VO {
public LocalDate date;
Reported by PMD.
Line: 22
}
public static class VO {
public LocalDate date;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1100/Issue1178.java
5 issues
Line: 13
* Created by wenshao on 02/05/2017.
*/
public class Issue1178 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\n" +
" \"info\": {\n" +
" \"test\": \"\", \n" +
" }\n" +
"}";
Reported by PMD.
Line: 13
* Created by wenshao on 02/05/2017.
*/
public class Issue1178 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\n" +
" \"info\": {\n" +
" \"test\": \"\", \n" +
" }\n" +
"}";
Reported by PMD.
Line: 21
"}";
JSONObject jsonObject = JSON.parseObject(json);
TestModel loginResponse = JSON.toJavaObject(jsonObject, TestModel.class);
}
public static class TestModel implements Serializable {
public String info;
Reported by PMD.
Line: 25
}
public static class TestModel implements Serializable {
public String info;
}
}
Reported by PMD.
Line: 21
"}";
JSONObject jsonObject = JSON.parseObject(json);
TestModel loginResponse = JSON.toJavaObject(jsonObject, TestModel.class);
}
public static class TestModel implements Serializable {
public String info;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/jdk8/LocalDateTest4.java
5 issues
Line: 13
public class LocalDateTest4 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"20160506\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
Reported by PMD.
Line: 16
public void test_for_issue() throws Exception {
VO vo = JSON.parseObject("{\"date\":\"20160506\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public static class VO {
Reported by PMD.
Line: 17
VO vo = JSON.parseObject("{\"date\":\"20160506\"}", VO.class);
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public static class VO {
public LocalDate date;
Reported by PMD.
Line: 18
Assert.assertEquals(2016, vo.date.getYear());
Assert.assertEquals(5, vo.date.getMonthValue());
Assert.assertEquals(6, vo.date.getDayOfMonth());
}
public static class VO {
public LocalDate date;
Reported by PMD.
Line: 22
}
public static class VO {
public LocalDate date;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/guava/LinkedListMultimapTest.java
5 issues
Line: 12
* Created by wenshao on 15/01/2017.
*/
public class LinkedListMultimapTest extends TestCase {
public void test_for_multimap() throws Exception {
LinkedListMultimap map = LinkedListMultimap.create();
map.put("name", "a");
map.put("name", "b");
String json = JSON.toJSONString(map);
Reported by PMD.
Line: 14
public class LinkedListMultimapTest extends TestCase {
public void test_for_multimap() throws Exception {
LinkedListMultimap map = LinkedListMultimap.create();
map.put("name", "a");
map.put("name", "b");
String json = JSON.toJSONString(map);
assertEquals("{\"name\":[\"a\",\"b\"]}", json);
}
Reported by PMD.
Line: 15
public void test_for_multimap() throws Exception {
LinkedListMultimap map = LinkedListMultimap.create();
map.put("name", "a");
map.put("name", "b");
String json = JSON.toJSONString(map);
assertEquals("{\"name\":[\"a\",\"b\"]}", json);
}
}
Reported by PMD.
Line: 18
map.put("name", "b");
String json = JSON.toJSONString(map);
assertEquals("{\"name\":[\"a\",\"b\"]}", json);
}
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.guava;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.LinkedListMultimap;
import junit.framework.TestCase;
/**
* Created by wenshao on 15/01/2017.
Reported by PMD.