The following issues were found
src/test/java/com/alibaba/json/bvt/fullSer/ToJavaObjectTest2.java
5 issues
Line: 15
* Created by wenshao on 04/02/2017.
*/
public class ToJavaObjectTest2 extends TestCase {
public void test_for_toJavaObject() throws Exception {
JSONObject obj = JSON.parseObject("{\"model\":{\"id\":123}}");
Map<String, Model> models = obj.toJavaObject(new TypeReference<Map<String, Model>>(){}.getType());
assertEquals(123, models.get("model").id);
}
Reported by PMD.
Line: 18
public void test_for_toJavaObject() throws Exception {
JSONObject obj = JSON.parseObject("{\"model\":{\"id\":123}}");
Map<String, Model> models = obj.toJavaObject(new TypeReference<Map<String, Model>>(){}.getType());
assertEquals(123, models.get("model").id);
}
public static class Model {
public int id;
}
Reported by PMD.
Line: 18
public void test_for_toJavaObject() throws Exception {
JSONObject obj = JSON.parseObject("{\"model\":{\"id\":123}}");
Map<String, Model> models = obj.toJavaObject(new TypeReference<Map<String, Model>>(){}.getType());
assertEquals(123, models.get("model").id);
}
public static class Model {
public int id;
}
Reported by PMD.
Line: 22
}
public static class Model {
public int id;
}
}
Reported by PMD.
Line: 8
import com.alibaba.fastjson.TypeReference;
import junit.framework.TestCase;
import java.util.List;
import java.util.Map;
/**
* Created by wenshao on 04/02/2017.
*/
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2300/Issue2397.java
5 issues
Line: 13
public class Issue2397 extends TestCase {
public void test_for_bug(){
String jsonStr = "{\"items\":[{\"id\":1,\"name\":\"kata\"}]}";
TestReply testReply = JSON.parseObject(jsonStr, new TypeReference<TestReply>() {
});
Assert.assertEquals(testReply.getItems().get(0).getId() , 1);
Reported by PMD.
Line: 18
TestReply testReply = JSON.parseObject(jsonStr, new TypeReference<TestReply>() {
});
Assert.assertEquals(testReply.getItems().get(0).getId() , 1);
}
public static class SuperBaseReply<T> {
private List<T> items;
Reported by PMD.
Line: 18
TestReply testReply = JSON.parseObject(jsonStr, new TypeReference<TestReply>() {
});
Assert.assertEquals(testReply.getItems().get(0).getId() , 1);
}
public static class SuperBaseReply<T> {
private List<T> items;
Reported by PMD.
Line: 37
}
public static class Msg implements Serializable {
private int id;
private String name;
public int getId() {
return id;
Reported by PMD.
Line: 37
}
public static class Msg implements Serializable {
private int id;
private String name;
public int getId() {
return id;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3200/Issue3266.java
5 issues
Line: 9
import junit.framework.TestCase;
public class Issue3266 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.type = Color.Black;
String str = JSON.toJSONString(vo);
assertEquals("{\"type\":1003}", str);
Reported by PMD.
Line: 14
vo.type = Color.Black;
String str = JSON.toJSONString(vo);
assertEquals("{\"type\":1003}", str);
VO vo2 = JSON.parseObject(str, VO.class);
}
Reported by PMD.
Line: 16
String str = JSON.toJSONString(vo);
assertEquals("{\"type\":1003}", str);
VO vo2 = JSON.parseObject(str, VO.class);
}
public static class VO {
public Color type;
Reported by PMD.
Line: 21
}
public static class VO {
public Color type;
}
public enum Color {
Red(1001),
White(1002),
Reported by PMD.
Line: 16
String str = JSON.toJSONString(vo);
assertEquals("{\"type\":1003}", str);
VO vo2 = JSON.parseObject(str, VO.class);
}
public static class VO {
public Color type;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3200/Issue3266_mixedin.java
5 issues
Line: 9
import junit.framework.TestCase;
public class Issue3266_mixedin extends TestCase {
public void test_for_issue() throws Exception {
JSON.addMixInAnnotations(Color.class, ColorMixedIn.class);
VO vo = new VO();
vo.type = Color.Black;
Reported by PMD.
Line: 16
vo.type = Color.Black;
String str = JSON.toJSONString(vo);
assertEquals("{\"type\":1003}", str);
VO vo2 = JSON.parseObject(str, VO.class);
}
public static class VO {
Reported by PMD.
Line: 18
String str = JSON.toJSONString(vo);
assertEquals("{\"type\":1003}", str);
VO vo2 = JSON.parseObject(str, VO.class);
}
public static class VO {
public Color type;
}
Reported by PMD.
Line: 22
}
public static class VO {
public Color type;
}
public enum Color {
Red(1001),
White(1002),
Reported by PMD.
Line: 18
String str = JSON.toJSONString(vo);
assertEquals("{\"type\":1003}", str);
VO vo2 = JSON.parseObject(str, VO.class);
}
public static class VO {
public Color type;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/bug/Bug0.java
5 issues
Line: 13
public class Bug0 extends TestCase {
public void test_0() throws Exception {
String text = "{a:1,b:2}";
JSONObject json = JSON.parseObject(text, JSONObject.class);
Assert.assertEquals(1, json.getIntValue("a"));
Assert.assertEquals(2, json.getIntValue("b"));
}
Reported by PMD.
Line: 16
public void test_0() throws Exception {
String text = "{a:1,b:2}";
JSONObject json = JSON.parseObject(text, JSONObject.class);
Assert.assertEquals(1, json.getIntValue("a"));
Assert.assertEquals(2, json.getIntValue("b"));
}
public void test_array_exception() throws Exception {
String text = "[1, 2]}";
Reported by PMD.
Line: 17
String text = "{a:1,b:2}";
JSONObject json = JSON.parseObject(text, JSONObject.class);
Assert.assertEquals(1, json.getIntValue("a"));
Assert.assertEquals(2, json.getIntValue("b"));
}
public void test_array_exception() throws Exception {
String text = "[1, 2]}";
Exception error = null;
Reported by PMD.
Line: 20
Assert.assertEquals(2, json.getIntValue("b"));
}
public void test_array_exception() throws Exception {
String text = "[1, 2]}";
Exception error = null;
try {
JSON.parseObject(text, JSONArray.class);
} catch (JSONException ex) {
Reported by PMD.
Line: 22
public void test_array_exception() throws Exception {
String text = "[1, 2]}";
Exception error = null;
try {
JSON.parseObject(text, JSONArray.class);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_2200/Issue2289.java
5 issues
Line: 9
import junit.framework.TestCase;
public class Issue2289 extends TestCase {
public void test_for_issue() throws Exception {
B b = new B();
b.id = 123;
JSONSerializer jsonSerializer = new JSONSerializer();
Reported by PMD.
Line: 18
jsonSerializer.writeAs(b, A.class);
String str = jsonSerializer.toString();
assertEquals("{}", str);
}
public static class A {
}
Reported by PMD.
Line: 26
}
public static class B extends A {
public int id;
}
}
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.issue_2200;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import junit.framework.TestCase;
public class Issue2289 extends TestCase {
public void test_for_issue() throws Exception {
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import junit.framework.TestCase;
public class Issue2289 extends TestCase {
public void test_for_issue() throws Exception {
B b = new B();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_3200/Issue3281.java
5 issues
Line: 19
* @Description:补充测试用例
*/
public class Issue3281 extends TestCase {
public void test_for_issue() {
ModelState modelBack = JSON.parseObject("{\"counterMap\":{\"0\":0,\"100\":0,\"200\":0,\"300\":0,\"400\":0," +
"\"500\":0,\"600\":0,\"700\":0,\"800\":0,\"900\":0,\"1000\":0},\"formatDate\":null," +
"\"modelName\":\"test\",\"modelScores\":{\"Test1-1000\":{\"max\":1.0997832999999515,\"min\":0.0," +
"\"recording\":false}},\"modelVersion\":\"1\",\"pit\":1592470429399,\"useCaseName\":\"test\"," +
"\"variableName\":\"v2\"}", ModelState.class);
Reported by PMD.
Line: 25
"\"modelName\":\"test\",\"modelScores\":{\"Test1-1000\":{\"max\":1.0997832999999515,\"min\":0.0," +
"\"recording\":false}},\"modelVersion\":\"1\",\"pit\":1592470429399,\"useCaseName\":\"test\"," +
"\"variableName\":\"v2\"}", ModelState.class);
Assert.assertNotNull(modelBack.getCounterMap());
Assert.assertNotNull(modelBack.getModelScores());
}
@Builder
@Data
Reported by PMD.
Line: 26
"\"recording\":false}},\"modelVersion\":\"1\",\"pit\":1592470429399,\"useCaseName\":\"test\"," +
"\"variableName\":\"v2\"}", ModelState.class);
Assert.assertNotNull(modelBack.getCounterMap());
Assert.assertNotNull(modelBack.getModelScores());
}
@Builder
@Data
@AllArgsConstructor
Reported by PMD.
Line: 33
@Data
@AllArgsConstructor
public static class ModelState {
private HashMap<String, Long> counterMap;
private Date formatDate;
private HashMap<String, TGigest> modelScores;
Reported by PMD.
Line: 37
private Date formatDate;
private HashMap<String, TGigest> modelScores;
private String modelName;
private Long modelVersion;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1300/Issue_for_zuojian.java
5 issues
Line: 10
import java.util.Date;
public class Issue_for_zuojian extends TestCase {
public void test_for_issue() throws Exception {
JSON.DEFFAULT_DATE_FORMAT = "yyyyMMddHHmmssSSSZ";
String json = "{\"value\":\"20180131022733000-0800\"}";
JSON.parseObject(json, Model.class);
JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
}
Reported by PMD.
Line: 10
import java.util.Date;
public class Issue_for_zuojian extends TestCase {
public void test_for_issue() throws Exception {
JSON.DEFFAULT_DATE_FORMAT = "yyyyMMddHHmmssSSSZ";
String json = "{\"value\":\"20180131022733000-0800\"}";
JSON.parseObject(json, Model.class);
JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
}
Reported by PMD.
Line: 17
JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
}
public void test_for_issue_1() throws Exception {
JSON.DEFFAULT_DATE_FORMAT = "yyyyMMddHHmmssSSSZ";
String json = "{\"value\":\"20180131022733000-0800\"}";
JSONObject object = JSON.parseObject(json);
object.getObject("value", Date.class);
Reported by PMD.
Line: 17
JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
}
public void test_for_issue_1() throws Exception {
JSON.DEFFAULT_DATE_FORMAT = "yyyyMMddHHmmssSSSZ";
String json = "{\"value\":\"20180131022733000-0800\"}";
JSONObject object = JSON.parseObject(json);
object.getObject("value", Date.class);
Reported by PMD.
Line: 22
String json = "{\"value\":\"20180131022733000-0800\"}";
JSONObject object = JSON.parseObject(json);
object.getObject("value", Date.class);
JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
}
public static class Model {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ObjectFieldTest.java
5 issues
Line: 12
public class ObjectFieldTest extends TestCase {
public void test_codec_null() throws Exception {
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
{
Reported by PMD.
Line: 24
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue(), v.getValue());
}
{
V0 v = new V0();
v.setValue(Integer.valueOf(123));
String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
Reported by PMD.
Line: 34
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue(), v.getValue());
}
}
public void test_codec_null_1() throws Exception {
Reported by PMD.
Line: 38
}
}
public void test_codec_null_1() throws Exception {
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
{
V0 v = new V0();
Reported by PMD.
Line: 56
V0 v1 = JSON.parseObject(text, V0.class);
Assert.assertEquals(v1.getValue(), v.getValue());
}
}
public static class V0 {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_Exception.java
5 issues
Line: 11
public void test_exception() throws Exception {
RuntimeException ex = new RuntimeException("e1");
String text = JSON.toJSONString(ex);
System.out.println(text);
RuntimeException ex2 = (RuntimeException) JSON.parse(text);
}
}
Reported by PMD.
Line: 8
import com.alibaba.fastjson.JSON;
public class Bug_for_Exception extends TestCase {
public void test_exception() throws Exception {
RuntimeException ex = new RuntimeException("e1");
String text = JSON.toJSONString(ex);
System.out.println(text);
RuntimeException ex2 = (RuntimeException) JSON.parse(text);
Reported by PMD.
Line: 8
import com.alibaba.fastjson.JSON;
public class Bug_for_Exception extends TestCase {
public void test_exception() throws Exception {
RuntimeException ex = new RuntimeException("e1");
String text = JSON.toJSONString(ex);
System.out.println(text);
RuntimeException ex2 = (RuntimeException) JSON.parse(text);
Reported by PMD.
Line: 13
String text = JSON.toJSONString(ex);
System.out.println(text);
RuntimeException ex2 = (RuntimeException) JSON.parse(text);
}
}
Reported by PMD.
Line: 13
String text = JSON.toJSONString(ex);
System.out.println(text);
RuntimeException ex2 = (RuntimeException) JSON.parse(text);
}
}
Reported by PMD.