The following issues were found
src/test/java/com/alibaba/json/bvt/bug/Bug_for_sanxiao.java
15 issues
Line: 22
is.close();
JSONObject obj = JSON.parseObject(text);
System.out.println(obj);
Assert.assertEquals(obj.getJSONArray("segments").getJSONObject(0),
obj.getJSONArray("passengerSegmentItems").getJSONObject(0).get("segment"));
Assert.assertEquals(1428,
obj.getJSONArray("passengerSegmentItems").getJSONObject(0).getJSONObject("segment").getIntValue("agentId"));
}
Reported by PMD.
Line: 15
public class Bug_for_sanxiao extends TestCase {
public void test_0() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/Bug_for_sanxiao.json");
String text = IOUtils.toString(is);
is.close();
Reported by PMD.
Line: 17
public void test_0() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/Bug_for_sanxiao.json");
String text = IOUtils.toString(is);
is.close();
JSONObject obj = JSON.parseObject(text);
System.out.println(obj);
Reported by PMD.
Line: 17
public void test_0() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/Bug_for_sanxiao.json");
String text = IOUtils.toString(is);
is.close();
JSONObject obj = JSON.parseObject(text);
System.out.println(obj);
Reported by PMD.
Line: 17
public void test_0() throws Exception {
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/Bug_for_sanxiao.json");
String text = IOUtils.toString(is);
is.close();
JSONObject obj = JSON.parseObject(text);
System.out.println(obj);
Reported by PMD.
Line: 19
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("json/Bug_for_sanxiao.json");
String text = IOUtils.toString(is);
is.close();
JSONObject obj = JSON.parseObject(text);
System.out.println(obj);
Assert.assertEquals(obj.getJSONArray("segments").getJSONObject(0),
obj.getJSONArray("passengerSegmentItems").getJSONObject(0).get("segment"));
Reported by PMD.
Line: 23
JSONObject obj = JSON.parseObject(text);
System.out.println(obj);
Assert.assertEquals(obj.getJSONArray("segments").getJSONObject(0),
obj.getJSONArray("passengerSegmentItems").getJSONObject(0).get("segment"));
Assert.assertEquals(1428,
obj.getJSONArray("passengerSegmentItems").getJSONObject(0).getJSONObject("segment").getIntValue("agentId"));
}
Reported by PMD.
Line: 23
JSONObject obj = JSON.parseObject(text);
System.out.println(obj);
Assert.assertEquals(obj.getJSONArray("segments").getJSONObject(0),
obj.getJSONArray("passengerSegmentItems").getJSONObject(0).get("segment"));
Assert.assertEquals(1428,
obj.getJSONArray("passengerSegmentItems").getJSONObject(0).getJSONObject("segment").getIntValue("agentId"));
}
Reported by PMD.
Line: 24
JSONObject obj = JSON.parseObject(text);
System.out.println(obj);
Assert.assertEquals(obj.getJSONArray("segments").getJSONObject(0),
obj.getJSONArray("passengerSegmentItems").getJSONObject(0).get("segment"));
Assert.assertEquals(1428,
obj.getJSONArray("passengerSegmentItems").getJSONObject(0).getJSONObject("segment").getIntValue("agentId"));
}
}
Reported by PMD.
Line: 24
JSONObject obj = JSON.parseObject(text);
System.out.println(obj);
Assert.assertEquals(obj.getJSONArray("segments").getJSONObject(0),
obj.getJSONArray("passengerSegmentItems").getJSONObject(0).get("segment"));
Assert.assertEquals(1428,
obj.getJSONArray("passengerSegmentItems").getJSONObject(0).getJSONObject("segment").getIntValue("agentId"));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue_for_huangfeng.java
15 issues
Line: 10
* Created by wenshao on 16/02/2017.
*/
public class Issue_for_huangfeng extends TestCase {
public void test_for_huangfeng() throws Exception {
String json = "{\"success\":\"Y\"}";
Model model = JSON.parseObject(json, Model.class);
assertTrue(model.isSuccess());
}
Reported by PMD.
Line: 14
String json = "{\"success\":\"Y\"}";
Model model = JSON.parseObject(json, Model.class);
assertTrue(model.isSuccess());
}
public void test_for_huangfeng_t() throws Exception {
String json = "{\"success\":\"T\"}";
Reported by PMD.
Line: 14
String json = "{\"success\":\"Y\"}";
Model model = JSON.parseObject(json, Model.class);
assertTrue(model.isSuccess());
}
public void test_for_huangfeng_t() throws Exception {
String json = "{\"success\":\"T\"}";
Reported by PMD.
Line: 17
assertTrue(model.isSuccess());
}
public void test_for_huangfeng_t() throws Exception {
String json = "{\"success\":\"T\"}";
Model model = JSON.parseObject(json, Model.class);
assertTrue(model.isSuccess());
}
Reported by PMD.
Line: 21
String json = "{\"success\":\"T\"}";
Model model = JSON.parseObject(json, Model.class);
assertTrue(model.isSuccess());
}
public void test_for_huangfeng_is_t() throws Exception {
String json = "{\"isSuccess\":\"T\"}";
Reported by PMD.
Line: 21
String json = "{\"success\":\"T\"}";
Model model = JSON.parseObject(json, Model.class);
assertTrue(model.isSuccess());
}
public void test_for_huangfeng_is_t() throws Exception {
String json = "{\"isSuccess\":\"T\"}";
Reported by PMD.
Line: 24
assertTrue(model.isSuccess());
}
public void test_for_huangfeng_is_t() throws Exception {
String json = "{\"isSuccess\":\"T\"}";
Model model = JSON.parseObject(json, Model.class);
assertTrue(model.isSuccess());
}
Reported by PMD.
Line: 28
String json = "{\"isSuccess\":\"T\"}";
Model model = JSON.parseObject(json, Model.class);
assertTrue(model.isSuccess());
}
public void test_for_huangfeng_false() throws Exception {
String json = "{\"success\":\"N\"}";
Reported by PMD.
Line: 28
String json = "{\"isSuccess\":\"T\"}";
Model model = JSON.parseObject(json, Model.class);
assertTrue(model.isSuccess());
}
public void test_for_huangfeng_false() throws Exception {
String json = "{\"success\":\"N\"}";
Reported by PMD.
Line: 31
assertTrue(model.isSuccess());
}
public void test_for_huangfeng_false() throws Exception {
String json = "{\"success\":\"N\"}";
Model model = JSON.parseObject(json, Model.class);
assertFalse(model.isSuccess());
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest__nextToken.java
15 issues
Line: 9
import com.alibaba.fastjson.parser.JSONScanner;
import com.alibaba.fastjson.parser.JSONToken;
public class JSONScannerTest__nextToken extends TestCase {
public void test_next() throws Exception {
String text = "\"aaa\"";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken(JSONToken.LITERAL_INT);
Assert.assertEquals(JSONToken.LITERAL_STRING, lexer.token());
Reported by PMD.
Line: 10
import com.alibaba.fastjson.parser.JSONToken;
public class JSONScannerTest__nextToken extends TestCase {
public void test_next() throws Exception {
String text = "\"aaa\"";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken(JSONToken.LITERAL_INT);
Assert.assertEquals(JSONToken.LITERAL_STRING, lexer.token());
}
Reported by PMD.
Line: 17
Assert.assertEquals(JSONToken.LITERAL_STRING, lexer.token());
}
public void test_next_1() throws Exception {
String text = "[";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken(JSONToken.LITERAL_INT);
Assert.assertEquals(JSONToken.LBRACKET, lexer.token());
}
Reported by PMD.
Line: 24
Assert.assertEquals(JSONToken.LBRACKET, lexer.token());
}
public void test_next_2() throws Exception {
String text = "{";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken(JSONToken.LITERAL_INT);
Assert.assertEquals(JSONToken.LBRACE, lexer.token());
}
Reported by PMD.
Line: 31
Assert.assertEquals(JSONToken.LBRACE, lexer.token());
}
public void test_next_3() throws Exception {
String text = "{";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken(JSONToken.LBRACKET);
Assert.assertEquals(JSONToken.LBRACE, lexer.token());
}
Reported by PMD.
Line: 38
Assert.assertEquals(JSONToken.LBRACE, lexer.token());
}
public void test_next_4() throws Exception {
String text = "";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken(JSONToken.LBRACKET);
Assert.assertEquals(JSONToken.EOF, lexer.token());
}
Reported by PMD.
Line: 45
Assert.assertEquals(JSONToken.EOF, lexer.token());
}
public void test_next_5() throws Exception {
String text = " \n\r\t\f\b 1";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken(JSONToken.LBRACKET);
Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
}
Reported by PMD.
Line: 52
Assert.assertEquals(JSONToken.LITERAL_INT, lexer.token());
}
public void test_next_6() throws Exception {
String text = "";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken(JSONToken.EOF);
Assert.assertEquals(JSONToken.EOF, lexer.token());
}
Reported by PMD.
Line: 59
Assert.assertEquals(JSONToken.EOF, lexer.token());
}
public void test_next_7() throws Exception {
String text = "{";
JSONScanner lexer = new JSONScanner(text);
lexer.nextToken(JSONToken.EOF);
Assert.assertEquals(JSONToken.LBRACE, lexer.token());
}
Reported by PMD.
Line: 66
Assert.assertEquals(JSONToken.LBRACE, lexer.token());
}
public void test_next_8() throws Exception {
String text = "\n\r\t\f\b :{";
JSONScanner lexer = new JSONScanner(text);
lexer.nextTokenWithColon(JSONToken.LBRACE);
Assert.assertEquals(JSONToken.LBRACE, lexer.token());
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_string.java
15 issues
Line: 14
public class WriteAsArray_string extends TestCase {
public void test_0() throws Exception {
Model model = new Model();
String text = JSON.toJSONString(model, SerializerFeature.BeanToArray);
Assert.assertEquals("[null]", text);
Reported by PMD.
Line: 24
Assert.assertNull(model2.name);
}
public void test_1() throws Exception {
Model model = new Model();
model.name = "abc";
String text = JSON.toJSONString(model, SerializerFeature.BeanToArray);
Assert.assertEquals("[\"abc\"]", text);
Reported by PMD.
Line: 34
Assert.assertEquals(model.name, model2.name);
}
public void test_error_0() throws Exception {
Exception error = null;
try {
JSON.parseObject("[n", Model.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 44
Assert.assertNotNull(error);
}
public void test_error_1() throws Exception {
Exception error = null;
try {
JSON.parseObject("[nu", Model.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 54
Assert.assertNotNull(error);
}
public void test_error_2() throws Exception {
Exception error = null;
try {
JSON.parseObject("[nul", Model.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 64
Assert.assertNotNull(error);
}
public void test_error_3() throws Exception {
Exception error = null;
try {
JSON.parseObject("[null", Model.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 74
Assert.assertNotNull(error);
}
public void test_error_4() throws Exception {
Exception error = null;
try {
JSON.parseObject("[\"ab", Model.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 84
Assert.assertNotNull(error);
}
public void test_error_5() throws Exception {
Exception error = null;
try {
JSON.parseObject("[\"ab\"", Model.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
Reported by PMD.
Line: 96
public static class Model {
public String name;
}
}
Reported by PMD.
Line: 35
}
public void test_error_0() throws Exception {
Exception error = null;
try {
JSON.parseObject("[n", Model.class, Feature.SupportArrayToBean);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/AbstractSerializeTest.java
15 issues
Line: 12
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
public class AbstractSerializeTest extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest");
ObjectDeserializer serializerB = ParserConfig.getGlobalInstance().getDeserializer(B.class);
ParserConfig.getGlobalInstance().putDeserializer(A.class, serializerB);
}
Reported by PMD.
Line: 13
public class AbstractSerializeTest extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest");
ObjectDeserializer serializerB = ParserConfig.getGlobalInstance().getDeserializer(B.class);
ParserConfig.getGlobalInstance().putDeserializer(A.class, serializerB);
}
Reported by PMD.
Line: 15
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest");
ObjectDeserializer serializerB = ParserConfig.getGlobalInstance().getDeserializer(B.class);
ParserConfig.getGlobalInstance().putDeserializer(A.class, serializerB);
}
protected void tearDown() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
Reported by PMD.
Line: 16
ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest");
ObjectDeserializer serializerB = ParserConfig.getGlobalInstance().getDeserializer(B.class);
ParserConfig.getGlobalInstance().putDeserializer(A.class, serializerB);
}
protected void tearDown() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
}
Reported by PMD.
Line: 19
ParserConfig.getGlobalInstance().putDeserializer(A.class, serializerB);
}
protected void tearDown() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
}
public void test_mapping_0() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest$A\"}";
Reported by PMD.
Line: 20
}
protected void tearDown() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
}
public void test_mapping_0() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest$A\"}";
Reported by PMD.
Line: 23
ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
}
public void test_mapping_0() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest$A\"}";
B b = (B) JSON.parse(text);
Assert.assertNotNull(b);
}
Reported by PMD.
Line: 30
Assert.assertNotNull(b);
}
public void test_mapping_1() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest$A\",\"id\":123}";
B b = (B) JSON.parse(text);
Assert.assertNotNull(b);
Assert.assertEquals(123, b.getId());
Reported by PMD.
Line: 35
B b = (B) JSON.parse(text);
Assert.assertNotNull(b);
Assert.assertEquals(123, b.getId());
}
public void test_mapping_2() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest$A\",\"id\":234,\"name\":\"abc\"}";
Reported by PMD.
Line: 38
Assert.assertEquals(123, b.getId());
}
public void test_mapping_2() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest$A\",\"id\":234,\"name\":\"abc\"}";
B b = (B) JSON.parse(text);
Assert.assertNotNull(b);
Assert.assertEquals(234, b.getId());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1226.java
15 issues
Line: 12
* Created by wenshao on 16/05/2017.
*/
public class Issue1226 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"c\":\"c\"}";
TestBean tb1 = JSON.parseObject(json, TestBean.class);
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
Reported by PMD.
Line: 12
* Created by wenshao on 16/05/2017.
*/
public class Issue1226 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"c\":\"c\"}";
TestBean tb1 = JSON.parseObject(json, TestBean.class);
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
Reported by PMD.
Line: 15
public void test_for_issue() throws Exception {
String json = "{\"c\":\"c\"}";
TestBean tb1 = JSON.parseObject(json, TestBean.class);
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
assertEquals('c', tb2.getC().charValue());
String json2 = JSON.toJSONString(tb2);
Reported by PMD.
Line: 15
public void test_for_issue() throws Exception {
String json = "{\"c\":\"c\"}";
TestBean tb1 = JSON.parseObject(json, TestBean.class);
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
assertEquals('c', tb2.getC().charValue());
String json2 = JSON.toJSONString(tb2);
Reported by PMD.
Line: 18
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
assertEquals('c', tb2.getC().charValue());
String json2 = JSON.toJSONString(tb2);
JSONObject jo = JSON.parseObject(json2);
TestBean tb12 = jo.toJavaObject(TestBean.class);
Reported by PMD.
Line: 18
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
assertEquals('c', tb2.getC().charValue());
String json2 = JSON.toJSONString(tb2);
JSONObject jo = JSON.parseObject(json2);
TestBean tb12 = jo.toJavaObject(TestBean.class);
Reported by PMD.
Line: 18
assertEquals('c', tb1.getC());
TestBean2 tb2 = JSON.parseObject(json, TestBean2.class);
assertEquals('c', tb2.getC().charValue());
String json2 = JSON.toJSONString(tb2);
JSONObject jo = JSON.parseObject(json2);
TestBean tb12 = jo.toJavaObject(TestBean.class);
Reported by PMD.
Line: 23
String json2 = JSON.toJSONString(tb2);
JSONObject jo = JSON.parseObject(json2);
TestBean tb12 = jo.toJavaObject(TestBean.class);
assertEquals('c', tb12.getC());
TestBean2 tb22 = jo.toJavaObject(TestBean2.class);
assertEquals('c', tb22.getC().charValue());
}
Reported by PMD.
Line: 24
JSONObject jo = JSON.parseObject(json2);
TestBean tb12 = jo.toJavaObject(TestBean.class);
assertEquals('c', tb12.getC());
TestBean2 tb22 = jo.toJavaObject(TestBean2.class);
assertEquals('c', tb22.getC().charValue());
}
Reported by PMD.
Line: 24
JSONObject jo = JSON.parseObject(json2);
TestBean tb12 = jo.toJavaObject(TestBean.class);
assertEquals('c', tb12.getC());
TestBean2 tb22 = jo.toJavaObject(TestBean2.class);
assertEquals('c', tb22.getC().charValue());
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/serializer/ByteBufferCodec.java
15 issues
Line: 17
@Override
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
ByteBufferBean bean = parser.parseObject(ByteBufferBean.class);
return (T) bean.byteBuffer();
}
@Override
public int getFastMatchToken() {
return JSONToken.LBRACKET;
Reported by PMD.
Line: 29
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
ByteBuffer byteBuf = (ByteBuffer) object;
byte[] array = byteBuf.array();
SerializeWriter out = serializer.out;
out.write('{');
out.writeFieldName("array");
Reported by PMD.
Line: 32
byte[] array = byteBuf.array();
SerializeWriter out = serializer.out;
out.write('{');
out.writeFieldName("array");
out.writeByteArray(array);
out.writeFieldValue(',', "limit", byteBuf.limit());
out.writeFieldValue(',', "position", byteBuf.position());
Reported by PMD.
Line: 34
SerializeWriter out = serializer.out;
out.write('{');
out.writeFieldName("array");
out.writeByteArray(array);
out.writeFieldValue(',', "limit", byteBuf.limit());
out.writeFieldValue(',', "position", byteBuf.position());
out.write('}');
Reported by PMD.
Line: 35
out.write('{');
out.writeFieldName("array");
out.writeByteArray(array);
out.writeFieldValue(',', "limit", byteBuf.limit());
out.writeFieldValue(',', "position", byteBuf.position());
out.write('}');
}
Reported by PMD.
Line: 36
out.writeFieldName("array");
out.writeByteArray(array);
out.writeFieldValue(',', "limit", byteBuf.limit());
out.writeFieldValue(',', "position", byteBuf.position());
out.write('}');
}
Reported by PMD.
Line: 36
out.writeFieldName("array");
out.writeByteArray(array);
out.writeFieldValue(',', "limit", byteBuf.limit());
out.writeFieldValue(',', "position", byteBuf.position());
out.write('}');
}
Reported by PMD.
Line: 37
out.writeFieldName("array");
out.writeByteArray(array);
out.writeFieldValue(',', "limit", byteBuf.limit());
out.writeFieldValue(',', "position", byteBuf.position());
out.write('}');
}
public static class ByteBufferBean {
Reported by PMD.
Line: 37
out.writeFieldName("array");
out.writeByteArray(array);
out.writeFieldValue(',', "limit", byteBuf.limit());
out.writeFieldValue(',', "position", byteBuf.position());
out.write('}');
}
public static class ByteBufferBean {
Reported by PMD.
Line: 39
out.writeFieldValue(',', "limit", byteBuf.limit());
out.writeFieldValue(',', "position", byteBuf.position());
out.write('}');
}
public static class ByteBufferBean {
public byte[] array;
public int limit;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/autoType/AutoTypeTest0.java
15 issues
Line: 10
* Created by wenshao on 10/02/2017.
*/
public class AutoTypeTest0 extends TestCase {
public void test_0() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeTest0$Model\",\"id\":123}";
Model model = JSON.parseObject(text, Model.class);
assertEquals(123, model.id);
Model model2 = (Model) JSON.parse(text);
Reported by PMD.
Line: 10
* Created by wenshao on 10/02/2017.
*/
public class AutoTypeTest0 extends TestCase {
public void test_0() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeTest0$Model\",\"id\":123}";
Model model = JSON.parseObject(text, Model.class);
assertEquals(123, model.id);
Model model2 = (Model) JSON.parse(text);
Reported by PMD.
Line: 13
public void test_0() throws Exception {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeTest0$Model\",\"id\":123}";
Model model = JSON.parseObject(text, Model.class);
assertEquals(123, model.id);
Model model2 = (Model) JSON.parse(text);
assertEquals(123, model2.id);
}
Reported by PMD.
Line: 16
assertEquals(123, model.id);
Model model2 = (Model) JSON.parse(text);
assertEquals(123, model2.id);
}
public void test_nested() {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeTest0$ModelNested\",\"id\":123, \"nested\":{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeTest0$ModelNested\",\"id\":456, \"nested\":null}}";
Reported by PMD.
Line: 19
assertEquals(123, model2.id);
}
public void test_nested() {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeTest0$ModelNested\",\"id\":123, \"nested\":{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeTest0$ModelNested\",\"id\":456, \"nested\":null}}";
ModelNested model = JSON.parseObject(text, ModelNested.class);
assertEquals(123, model.id);
ModelNested nested1 = model.nested;
Reported by PMD.
Line: 19
assertEquals(123, model2.id);
}
public void test_nested() {
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeTest0$ModelNested\",\"id\":123, \"nested\":{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeTest0$ModelNested\",\"id\":456, \"nested\":null}}";
ModelNested model = JSON.parseObject(text, ModelNested.class);
assertEquals(123, model.id);
ModelNested nested1 = model.nested;
Reported by PMD.
Line: 23
String text = "{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeTest0$ModelNested\",\"id\":123, \"nested\":{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeTest0$ModelNested\",\"id\":456, \"nested\":null}}";
ModelNested model = JSON.parseObject(text, ModelNested.class);
assertEquals(123, model.id);
ModelNested nested1 = model.nested;
assertEquals(456, nested1.id);
assertNull(nested1.nested);
ModelNested model2 = (ModelNested) JSON.parse(text);
Reported by PMD.
Line: 25
ModelNested model = JSON.parseObject(text, ModelNested.class);
assertEquals(123, model.id);
ModelNested nested1 = model.nested;
assertEquals(456, nested1.id);
assertNull(nested1.nested);
ModelNested model2 = (ModelNested) JSON.parse(text);
assertEquals(123, model2.id);
ModelNested nested2 = model2.nested;
Reported by PMD.
Line: 26
assertEquals(123, model.id);
ModelNested nested1 = model.nested;
assertEquals(456, nested1.id);
assertNull(nested1.nested);
ModelNested model2 = (ModelNested) JSON.parse(text);
assertEquals(123, model2.id);
ModelNested nested2 = model2.nested;
assertEquals(456, nested2.id);
Reported by PMD.
Line: 29
assertNull(nested1.nested);
ModelNested model2 = (ModelNested) JSON.parse(text);
assertEquals(123, model2.id);
ModelNested nested2 = model2.nested;
assertEquals(456, nested2.id);
assertNull(nested2.nested);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_ludong.java
15 issues
Line: 1
package com.alibaba.json.bvt.bug;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import junit.framework.TestCase;
Reported by PMD.
Line: 15
public class Bug_for_ludong extends TestCase {
public void test_for_ludong() throws Exception {
String msg = "{\"changedItems\":[{\"attribute\":\"new\",\"benefitCustomer\":\"chance130320584431\",\"benefitCustomerContactor\":5809917,\"benefitCustomerId\":2001385618,\"bizStatus\":\"audit_pass\",\"creator\":\"dowjons\",\"defaultBiz\":true,\"discountRate\":100,\"domain\":\"nirvana\",\"executeAmount\":3688,\"gmtCreate\":1367856000000,\"gmtModified\":1368374400000,\"gmtSign\":1367856000000,\"id\":321600616,\"isDeleted\":\"n\",\"itemNum\":\"W1305070000053_1\",\"lastOperType\":\"finance_pass_rollback\",\"memberId\":\"3592950865\",\"modifier\":\"haiquan.zhanghq\",\"num\":12,\"oppId\":103722314,\"orderId\":315749401,\"parentId\":0,\"paymentAmount\":0,\"paymentStatus\":\"payment_none\",\"policyId\":63149,\"price\":3688,\"productCode\":\"pc060\",\"purchaseType\":\"bought\",\"quotedPrice\":3688,\"salesId\":\"tiandan\",\"salesOrgFullid\":\"/10/1/30/101/160/1001/1051/\",\"serviceSupplyCompany\":\"B50\",\"signSalesId\":\"tiandan\",\"signSalesOrgFullId\":\"/10/1/30/101/160/1001/1051/\",\"traceChange\":true,\"ultimatePrice\":3688,\"unServiceDay\":0,\"unit\":\"M\",\"unvoucherAmount\":3688,\"voucherStatus\":\"voucher_none\"}],\"context\":{\"payAmount\":3688,\"payDate\":1368442850437,\"paymentStatus\":\"payment_success\"},\"generateTime\":1368442868624,\"msgType\":\"PAYMENT\",\"orderNumber\":\"W1305070000053\"}";
OrderInternalDto dto = JSON.parseObject(msg, OrderInternalDto.class);
}
Reported by PMD.
Line: 15
public class Bug_for_ludong extends TestCase {
public void test_for_ludong() throws Exception {
String msg = "{\"changedItems\":[{\"attribute\":\"new\",\"benefitCustomer\":\"chance130320584431\",\"benefitCustomerContactor\":5809917,\"benefitCustomerId\":2001385618,\"bizStatus\":\"audit_pass\",\"creator\":\"dowjons\",\"defaultBiz\":true,\"discountRate\":100,\"domain\":\"nirvana\",\"executeAmount\":3688,\"gmtCreate\":1367856000000,\"gmtModified\":1368374400000,\"gmtSign\":1367856000000,\"id\":321600616,\"isDeleted\":\"n\",\"itemNum\":\"W1305070000053_1\",\"lastOperType\":\"finance_pass_rollback\",\"memberId\":\"3592950865\",\"modifier\":\"haiquan.zhanghq\",\"num\":12,\"oppId\":103722314,\"orderId\":315749401,\"parentId\":0,\"paymentAmount\":0,\"paymentStatus\":\"payment_none\",\"policyId\":63149,\"price\":3688,\"productCode\":\"pc060\",\"purchaseType\":\"bought\",\"quotedPrice\":3688,\"salesId\":\"tiandan\",\"salesOrgFullid\":\"/10/1/30/101/160/1001/1051/\",\"serviceSupplyCompany\":\"B50\",\"signSalesId\":\"tiandan\",\"signSalesOrgFullId\":\"/10/1/30/101/160/1001/1051/\",\"traceChange\":true,\"ultimatePrice\":3688,\"unServiceDay\":0,\"unit\":\"M\",\"unvoucherAmount\":3688,\"voucherStatus\":\"voucher_none\"}],\"context\":{\"payAmount\":3688,\"payDate\":1368442850437,\"paymentStatus\":\"payment_success\"},\"generateTime\":1368442868624,\"msgType\":\"PAYMENT\",\"orderNumber\":\"W1305070000053\"}";
OrderInternalDto dto = JSON.parseObject(msg, OrderInternalDto.class);
}
Reported by PMD.
Line: 18
public void test_for_ludong() throws Exception {
String msg = "{\"changedItems\":[{\"attribute\":\"new\",\"benefitCustomer\":\"chance130320584431\",\"benefitCustomerContactor\":5809917,\"benefitCustomerId\":2001385618,\"bizStatus\":\"audit_pass\",\"creator\":\"dowjons\",\"defaultBiz\":true,\"discountRate\":100,\"domain\":\"nirvana\",\"executeAmount\":3688,\"gmtCreate\":1367856000000,\"gmtModified\":1368374400000,\"gmtSign\":1367856000000,\"id\":321600616,\"isDeleted\":\"n\",\"itemNum\":\"W1305070000053_1\",\"lastOperType\":\"finance_pass_rollback\",\"memberId\":\"3592950865\",\"modifier\":\"haiquan.zhanghq\",\"num\":12,\"oppId\":103722314,\"orderId\":315749401,\"parentId\":0,\"paymentAmount\":0,\"paymentStatus\":\"payment_none\",\"policyId\":63149,\"price\":3688,\"productCode\":\"pc060\",\"purchaseType\":\"bought\",\"quotedPrice\":3688,\"salesId\":\"tiandan\",\"salesOrgFullid\":\"/10/1/30/101/160/1001/1051/\",\"serviceSupplyCompany\":\"B50\",\"signSalesId\":\"tiandan\",\"signSalesOrgFullId\":\"/10/1/30/101/160/1001/1051/\",\"traceChange\":true,\"ultimatePrice\":3688,\"unServiceDay\":0,\"unit\":\"M\",\"unvoucherAmount\":3688,\"voucherStatus\":\"voucher_none\"}],\"context\":{\"payAmount\":3688,\"payDate\":1368442850437,\"paymentStatus\":\"payment_success\"},\"generateTime\":1368442868624,\"msgType\":\"PAYMENT\",\"orderNumber\":\"W1305070000053\"}";
OrderInternalDto dto = JSON.parseObject(msg, OrderInternalDto.class);
}
public static class OrderInternalDto implements Serializable {
private static final long serialVersionUID = 3228508302993121205L;
Reported by PMD.
Line: 27
/* 对象生成的时间 */
private Date generateTime;
/** 订单号 */
private String orderNumber;
Reported by PMD.
Line: 27
/* 对象生成的时间 */
private Date generateTime;
/** 订单号 */
private String orderNumber;
Reported by PMD.
Line: 31
/** 订单号 */
private String orderNumber;
/** 对象的业务状态 */
private MSGTYPE msgType;
Reported by PMD.
Line: 35
/** 对象的业务状态 */
private MSGTYPE msgType;
/** 订单的瞬时状态 */
// private List<OrdOrderItemDto> instantItems;
Reported by PMD.
Line: 43
/** 发生状态变化的订单行列,比如到款只是对一个订单行发生到账行为 */
private List<OrdOrderItem> changedItems;
/** 上下文参数 */
private Map<String, Object> context;
Reported by PMD.
Line: 47
/** 上下文参数 */
private Map<String, Object> context;
public OrderInternalDto(){
this.generateTime = new Date();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/DefaultObjectDeserializerTest5.java
15 issues
Line: 15
public class DefaultObjectDeserializerTest5 extends TestCase {
public void test_error() throws Exception {
Exception error = null;
try {
JSON.parseObject("[]", new TypeReference<Map<Object, Object>>() {
});
} catch (Exception ex) {
Reported by PMD.
Line: 20
try {
JSON.parseObject("[]", new TypeReference<Map<Object, Object>>() {
});
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 26
Assert.assertNotNull(error);
}
public void test_error_2() throws Exception {
Exception error = null;
try {
JSON.parseObject(",]", new TypeReference<Map<Object, Object>>() {
});
} catch (Exception ex) {
Reported by PMD.
Line: 31
try {
JSON.parseObject(",]", new TypeReference<Map<Object, Object>>() {
});
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 37
Assert.assertNotNull(error);
}
public void test_error_3() throws Exception {
Exception error = null;
try {
JSON.parseObject("[{},{\"$ref\":0}]",
new TypeReference<List<Map<Object, Object>>>() {
});
Reported by PMD.
Line: 43
JSON.parseObject("[{},{\"$ref\":0}]",
new TypeReference<List<Map<Object, Object>>>() {
});
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 49
Assert.assertNotNull(error);
}
public void test_error_4() throws Exception {
Exception error = null;
try {
JSON.parseObject("[{},{\"$ref\":\"$[0]\",}]",
new TypeReference<List<Map<Object, Object>>>() {
});
Reported by PMD.
Line: 55
JSON.parseObject("[{},{\"$ref\":\"$[0]\",}]",
new TypeReference<List<Map<Object, Object>>>() {
});
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 61
Assert.assertNotNull(error);
}
public void test_0() throws Exception {
List<Map<Object, Object>> list = JSON.parseObject("[{},{\"$ref\":\"$[0]\"}]",
new TypeReference<List<Map<Object, Object>>>() {
});
Assert.assertSame(list.get(0), list.get(1));
}
Reported by PMD.
Line: 68
Assert.assertSame(list.get(0), list.get(1));
}
public void test_1() throws Exception {
Map<Object, Map<Object, Object>> map = JSON.parseObject("{\"1\":{},\"2\":{\"$ref\":\"$\"}}",
new TypeReference<Map<Object, Map<Object, Object>>>() {
});
Assert.assertSame(map, map.get("2"));
}
Reported by PMD.