The following issues were found
src/test/java/com/alibaba/json/bvtVO/DataTransaction2.java
25 issues
Line: 299
String jsonString = "{'head' : {'appid':'epas','transcode' : '000000','seqno' : '111111111', 'user' : { 'id' : '00000'}, 'ret' : { 'code' : '1', 'msg' : 'txt'} }, 'body' : { param : { form:{ name : '111', sex : '1', address : 'street1', array : [ { id : '1', name : 'tom1' }, { id : '2', name : 'tom2' } ]}, limit : { start : 1, size : 25, total : 100} }, dataset : { total : 1000, rows : [ { id : 'id', name : 'name' }, { id : 'id', name : 'name' } ] } }}";
DataTransaction2 dt = DataTransaction2.fromJSON(jsonString);
System.out.println(dt.toJSON());
DataTransaction2 dt1 = JSON.parseObject(dt.toJSON(), DataTransaction2.class);
System.out.println(dt1.toJSON());
Assert.assertEquals(dt.toJSON(), dt1.toJSON());
Reported by PMD.
Line: 301
DataTransaction2 dt = DataTransaction2.fromJSON(jsonString);
System.out.println(dt.toJSON());
DataTransaction2 dt1 = JSON.parseObject(dt.toJSON(), DataTransaction2.class);
System.out.println(dt1.toJSON());
Assert.assertEquals(dt.toJSON(), dt1.toJSON());
System.out.println("=================");
System.out.println(dt.toJSON());
Reported by PMD.
Line: 305
Assert.assertEquals(dt.toJSON(), dt1.toJSON());
System.out.println("=================");
System.out.println(dt.toJSON());
dt.setRetMsgCode("-1", "错误");
dt.setDataSet("1000", new ArrayList<Map<String, Object>>());
System.out.println(dt.toJSON());
Reported by PMD.
Line: 306
Assert.assertEquals(dt.toJSON(), dt1.toJSON());
System.out.println("=================");
System.out.println(dt.toJSON());
dt.setRetMsgCode("-1", "错误");
dt.setDataSet("1000", new ArrayList<Map<String, Object>>());
System.out.println(dt.toJSON());
String text = dt.toJSON();
Reported by PMD.
Line: 309
System.out.println(dt.toJSON());
dt.setRetMsgCode("-1", "错误");
dt.setDataSet("1000", new ArrayList<Map<String, Object>>());
System.out.println(dt.toJSON());
String text = dt.toJSON();
System.out.println(text);
DataTransaction2 dt2 = JSON.parseObject(text, DataTransaction2.class);
Reported by PMD.
Line: 312
System.out.println(dt.toJSON());
String text = dt.toJSON();
System.out.println(text);
DataTransaction2 dt2 = JSON.parseObject(text, DataTransaction2.class);
System.out.println(JSON.toJSONString(dt2));
Assert.assertEquals(dt.toJSON(), dt2.toJSON());
Reported by PMD.
Line: 315
System.out.println(text);
DataTransaction2 dt2 = JSON.parseObject(text, DataTransaction2.class);
System.out.println(JSON.toJSONString(dt2));
Assert.assertEquals(dt.toJSON(), dt2.toJSON());
}
}
Reported by PMD.
Line: 1
package com.alibaba.json.bvtVO;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Reported by PMD.
Line: 32
/**
* Head
**/
class Head {
private String appid;
private String transcode;
Reported by PMD.
Line: 63
/**
* 处理结果
* */
class Ret {
private String code;
private String msg;
public String getCode() {
return code;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/PropertyFilterTest.java
25 issues
Line: 17
public class PropertyFilterTest extends TestCase {
public void test_0() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
return false;
}
Reported by PMD.
Line: 27
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 36
Assert.assertEquals("{}", text);
}
public void test_toJSONString() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
return false;
}
Reported by PMD.
Line: 47
Assert.assertEquals("{}", JSON.toJSONString(new A(), filter));
}
public void test_1() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("id".equals(name)) {
return true;
Reported by PMD.
Line: 60
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 69
Assert.assertEquals("{\"id\":0}", text);
}
public void test_2() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("name".equals(name)) {
return true;
Reported by PMD.
Line: 73
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("name".equals(name)) {
return true;
}
return false;
}
};
Reported by PMD.
Line: 82
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
A a = new A();
a.setName("chennp2008");
serializer.write(a);
Reported by PMD.
Line: 92
Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
public void test_3() throws Exception {
PropertyFilter filter = new PropertyFilter() {
public boolean apply(Object source, String name, Object value) {
if ("name".equals(name)) {
return true;
Reported by PMD.
Line: 105
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getPropertyFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "chennp2008");
serializer.write(map);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/support/moneta/MoneyNumberTest.java
25 issues
Line: 47
assertEquals(2.01f, moneyBack.getNumber().floatValue());
// short
money = Money.of(new Short("2"), Monetary.getCurrency("EUR"));
moneyJSON = JSON.toJSONString(money);
moneyBack = JSON.parseObject(moneyJSON, Money.class);
assertEquals(2, moneyBack.getNumber().shortValue());
// BigInteger
Reported by PMD.
Line: 15
* @Date :Created in 01:31 2020/7/4
*/
public class MoneyNumberTest extends TestCase {
public void test_for_issue() throws Exception {
// Integer
Money money = Money.of(5000, Monetary.getCurrency("EUR"));
String moneyJSON = JSON.toJSONString(money);
Money moneyBack = JSON.parseObject(moneyJSON, Money.class);
assertEquals(5000, moneyBack.getNumber().intValue());
Reported by PMD.
Line: 15
* @Date :Created in 01:31 2020/7/4
*/
public class MoneyNumberTest extends TestCase {
public void test_for_issue() throws Exception {
// Integer
Money money = Money.of(5000, Monetary.getCurrency("EUR"));
String moneyJSON = JSON.toJSONString(money);
Money moneyBack = JSON.parseObject(moneyJSON, Money.class);
assertEquals(5000, moneyBack.getNumber().intValue());
Reported by PMD.
Line: 17
public class MoneyNumberTest extends TestCase {
public void test_for_issue() throws Exception {
// Integer
Money money = Money.of(5000, Monetary.getCurrency("EUR"));
String moneyJSON = JSON.toJSONString(money);
Money moneyBack = JSON.parseObject(moneyJSON, Money.class);
assertEquals(5000, moneyBack.getNumber().intValue());
// Long
Reported by PMD.
Line: 20
Money money = Money.of(5000, Monetary.getCurrency("EUR"));
String moneyJSON = JSON.toJSONString(money);
Money moneyBack = JSON.parseObject(moneyJSON, Money.class);
assertEquals(5000, moneyBack.getNumber().intValue());
// Long
money = Money.of(1000L, Monetary.getCurrency("EUR"));
moneyJSON = JSON.toJSONString(money);
moneyBack = JSON.parseObject(moneyJSON, Money.class);
Reported by PMD.
Line: 20
Money money = Money.of(5000, Monetary.getCurrency("EUR"));
String moneyJSON = JSON.toJSONString(money);
Money moneyBack = JSON.parseObject(moneyJSON, Money.class);
assertEquals(5000, moneyBack.getNumber().intValue());
// Long
money = Money.of(1000L, Monetary.getCurrency("EUR"));
moneyJSON = JSON.toJSONString(money);
moneyBack = JSON.parseObject(moneyJSON, Money.class);
Reported by PMD.
Line: 20
Money money = Money.of(5000, Monetary.getCurrency("EUR"));
String moneyJSON = JSON.toJSONString(money);
Money moneyBack = JSON.parseObject(moneyJSON, Money.class);
assertEquals(5000, moneyBack.getNumber().intValue());
// Long
money = Money.of(1000L, Monetary.getCurrency("EUR"));
moneyJSON = JSON.toJSONString(money);
moneyBack = JSON.parseObject(moneyJSON, Money.class);
Reported by PMD.
Line: 26
money = Money.of(1000L, Monetary.getCurrency("EUR"));
moneyJSON = JSON.toJSONString(money);
moneyBack = JSON.parseObject(moneyJSON, Money.class);
assertEquals(1000, moneyBack.getNumber().longValue());
// Byte
money = Money.of(0x4a, Monetary.getCurrency("EUR"));
moneyJSON = JSON.toJSONString(money);
moneyBack = JSON.parseObject(moneyJSON, Money.class);
Reported by PMD.
Line: 26
money = Money.of(1000L, Monetary.getCurrency("EUR"));
moneyJSON = JSON.toJSONString(money);
moneyBack = JSON.parseObject(moneyJSON, Money.class);
assertEquals(1000, moneyBack.getNumber().longValue());
// Byte
money = Money.of(0x4a, Monetary.getCurrency("EUR"));
moneyJSON = JSON.toJSONString(money);
moneyBack = JSON.parseObject(moneyJSON, Money.class);
Reported by PMD.
Line: 26
money = Money.of(1000L, Monetary.getCurrency("EUR"));
moneyJSON = JSON.toJSONString(money);
moneyBack = JSON.parseObject(moneyJSON, Money.class);
assertEquals(1000, moneyBack.getNumber().longValue());
// Byte
money = Money.of(0x4a, Monetary.getCurrency("EUR"));
moneyJSON = JSON.toJSONString(money);
moneyBack = JSON.parseObject(moneyJSON, Money.class);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/DefaultExtJSONParser_parseArray_2.java
25 issues
Line: 24
parser.config(Feature.AllowISO8601DateFormat, false);
List<List<Integer>> list = (List<List<Integer>>) parser.parseArrayWithType(new TypeReference<List<List<Integer>>>() {
}.getType());
Assert.assertEquals(new Integer(1), list.get(0).get(0));
}
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("['1','2']");
parser.config(Feature.AllowISO8601DateFormat, false);
Reported by PMD.
Line: 32
parser.config(Feature.AllowISO8601DateFormat, false);
List<Object> list = new ArrayList<Object>();
parser.parseArray(Integer.class, list);
Assert.assertEquals(new Integer(1), list.get(0));
Assert.assertEquals(new Integer(2), list.get(1));
}
public void test_error_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("['1','2'}");
Reported by PMD.
Line: 33
List<Object> list = new ArrayList<Object>();
parser.parseArray(Integer.class, list);
Assert.assertEquals(new Integer(1), list.get(0));
Assert.assertEquals(new Integer(2), list.get(1));
}
public void test_error_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("['1','2'}");
parser.config(Feature.AllowISO8601DateFormat, false);
Reported by PMD.
Line: 19
@SuppressWarnings("deprecation")
public class DefaultExtJSONParser_parseArray_2 extends TestCase {
public void test_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[['1']]");
parser.config(Feature.AllowISO8601DateFormat, false);
List<List<Integer>> list = (List<List<Integer>>) parser.parseArrayWithType(new TypeReference<List<List<Integer>>>() {
}.getType());
Assert.assertEquals(new Integer(1), list.get(0).get(0));
Reported by PMD.
Line: 24
parser.config(Feature.AllowISO8601DateFormat, false);
List<List<Integer>> list = (List<List<Integer>>) parser.parseArrayWithType(new TypeReference<List<List<Integer>>>() {
}.getType());
Assert.assertEquals(new Integer(1), list.get(0).get(0));
}
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("['1','2']");
parser.config(Feature.AllowISO8601DateFormat, false);
Reported by PMD.
Line: 27
Assert.assertEquals(new Integer(1), list.get(0).get(0));
}
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("['1','2']");
parser.config(Feature.AllowISO8601DateFormat, false);
List<Object> list = new ArrayList<Object>();
parser.parseArray(Integer.class, list);
Assert.assertEquals(new Integer(1), list.get(0));
Reported by PMD.
Line: 36
Assert.assertEquals(new Integer(2), list.get(1));
}
public void test_error_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("['1','2'}");
parser.config(Feature.AllowISO8601DateFormat, false);
Exception error = null;
try {
Reported by PMD.
Line: 44
try {
List<Object> list = new ArrayList<Object>();
parser.parseArray(Integer.class, list);
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
Line: 50
Assert.assertNotNull(error);
}
public void test_error_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("[['1']]");
parser.config(Feature.AllowISO8601DateFormat, false);
Exception error = null;
try {
Reported by PMD.
Line: 58
try {
parser.parseArrayWithType(new TypeReference<Map<?, ?>>() {
}.getType());
} catch (Exception ex) {
error = ex;
}
Assert.assertNotNull(error);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue1013.java
25 issues
Line: 15
*/
public class Issue1013 extends TestCase {
public void test_for_issue() throws Exception {
TestDomain domain = new TestDomain();
String json = JSON.toJSONString(domain);
TestDomain domain1 = JSON.parseObject(json, TestDomain.class);
Reported by PMD.
Line: 22
TestDomain domain1 = JSON.parseObject(json, TestDomain.class);
assertEquals(domain.getList(), domain1.getList());
}
public void test_for_issue_1() throws Exception {
TestDomain domain1 = JSON.parseObject("{\"list\":[]}", TestDomain.class);
Reported by PMD.
Line: 22
TestDomain domain1 = JSON.parseObject(json, TestDomain.class);
assertEquals(domain.getList(), domain1.getList());
}
public void test_for_issue_1() throws Exception {
TestDomain domain1 = JSON.parseObject("{\"list\":[]}", TestDomain.class);
Reported by PMD.
Line: 25
assertEquals(domain.getList(), domain1.getList());
}
public void test_for_issue_1() throws Exception {
TestDomain domain1 = JSON.parseObject("{\"list\":[]}", TestDomain.class);
TestDomain domain2 = JSON.parseObject("{\"list\":[1, 2]}", TestDomain.class);
assertEquals(0, domain1.getList().size());
Reported by PMD.
Line: 25
assertEquals(domain.getList(), domain1.getList());
}
public void test_for_issue_1() throws Exception {
TestDomain domain1 = JSON.parseObject("{\"list\":[]}", TestDomain.class);
TestDomain domain2 = JSON.parseObject("{\"list\":[1, 2]}", TestDomain.class);
assertEquals(0, domain1.getList().size());
Reported by PMD.
Line: 30
TestDomain domain1 = JSON.parseObject("{\"list\":[]}", TestDomain.class);
TestDomain domain2 = JSON.parseObject("{\"list\":[1, 2]}", TestDomain.class);
assertEquals(0, domain1.getList().size());
assertEquals(Arrays.asList(1, 2), domain2.getList());
}
public void test_for_issue_2() throws Exception {
Reported by PMD.
Line: 30
TestDomain domain1 = JSON.parseObject("{\"list\":[]}", TestDomain.class);
TestDomain domain2 = JSON.parseObject("{\"list\":[1, 2]}", TestDomain.class);
assertEquals(0, domain1.getList().size());
assertEquals(Arrays.asList(1, 2), domain2.getList());
}
public void test_for_issue_2() throws Exception {
Reported by PMD.
Line: 30
TestDomain domain1 = JSON.parseObject("{\"list\":[]}", TestDomain.class);
TestDomain domain2 = JSON.parseObject("{\"list\":[1, 2]}", TestDomain.class);
assertEquals(0, domain1.getList().size());
assertEquals(Arrays.asList(1, 2), domain2.getList());
}
public void test_for_issue_2() throws Exception {
Reported by PMD.
Line: 31
TestDomain domain2 = JSON.parseObject("{\"list\":[1, 2]}", TestDomain.class);
assertEquals(0, domain1.getList().size());
assertEquals(Arrays.asList(1, 2), domain2.getList());
}
public void test_for_issue_2() throws Exception {
TestDomain domain1 = JSON.parseObject("{\"list\":null}", TestDomain.class);
Reported by PMD.
Line: 31
TestDomain domain2 = JSON.parseObject("{\"list\":[1, 2]}", TestDomain.class);
assertEquals(0, domain1.getList().size());
assertEquals(Arrays.asList(1, 2), domain2.getList());
}
public void test_for_issue_2() throws Exception {
TestDomain domain1 = JSON.parseObject("{\"list\":null}", TestDomain.class);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/date/DateTest5_iso8601.java
25 issues
Line: 11
import java.util.TimeZone;
public class DateTest5_iso8601 extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_date() throws Exception {
Reported by PMD.
Line: 16
JSON.defaultLocale = Locale.CHINA;
}
public void test_date() throws Exception {
Date date1 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12\"}", VO.class).getGmtCreate();
assertNotNull(date1);
Date date2 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19+00:00\"}", VO.class).getGmtCreate();
Date date3 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date4 = JSON.parseObject("{\"gmtCreate\":\"20180912T151019Z\"}", VO.class).getGmtCreate();
Reported by PMD.
Line: 16
JSON.defaultLocale = Locale.CHINA;
}
public void test_date() throws Exception {
Date date1 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12\"}", VO.class).getGmtCreate();
assertNotNull(date1);
Date date2 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19+00:00\"}", VO.class).getGmtCreate();
Date date3 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date4 = JSON.parseObject("{\"gmtCreate\":\"20180912T151019Z\"}", VO.class).getGmtCreate();
Reported by PMD.
Line: 17
}
public void test_date() throws Exception {
Date date1 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12\"}", VO.class).getGmtCreate();
assertNotNull(date1);
Date date2 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19+00:00\"}", VO.class).getGmtCreate();
Date date3 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date4 = JSON.parseObject("{\"gmtCreate\":\"20180912T151019Z\"}", VO.class).getGmtCreate();
Date date5 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Reported by PMD.
Line: 18
public void test_date() throws Exception {
Date date1 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12\"}", VO.class).getGmtCreate();
assertNotNull(date1);
Date date2 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19+00:00\"}", VO.class).getGmtCreate();
Date date3 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date4 = JSON.parseObject("{\"gmtCreate\":\"20180912T151019Z\"}", VO.class).getGmtCreate();
Date date5 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date6 = JSON.parseObject("{\"gmtCreate\":\"20180912\"}", VO.class).getGmtCreate();
Reported by PMD.
Line: 19
public void test_date() throws Exception {
Date date1 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12\"}", VO.class).getGmtCreate();
assertNotNull(date1);
Date date2 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19+00:00\"}", VO.class).getGmtCreate();
Date date3 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date4 = JSON.parseObject("{\"gmtCreate\":\"20180912T151019Z\"}", VO.class).getGmtCreate();
Date date5 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date6 = JSON.parseObject("{\"gmtCreate\":\"20180912\"}", VO.class).getGmtCreate();
Reported by PMD.
Line: 20
Date date1 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12\"}", VO.class).getGmtCreate();
assertNotNull(date1);
Date date2 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19+00:00\"}", VO.class).getGmtCreate();
Date date3 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date4 = JSON.parseObject("{\"gmtCreate\":\"20180912T151019Z\"}", VO.class).getGmtCreate();
Date date5 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date6 = JSON.parseObject("{\"gmtCreate\":\"20180912\"}", VO.class).getGmtCreate();
long delta_2_1 = date2.getTime() - date1.getTime();
Reported by PMD.
Line: 21
assertNotNull(date1);
Date date2 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19+00:00\"}", VO.class).getGmtCreate();
Date date3 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date4 = JSON.parseObject("{\"gmtCreate\":\"20180912T151019Z\"}", VO.class).getGmtCreate();
Date date5 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date6 = JSON.parseObject("{\"gmtCreate\":\"20180912\"}", VO.class).getGmtCreate();
long delta_2_1 = date2.getTime() - date1.getTime();
assertEquals(83419000, delta_2_1);
Reported by PMD.
Line: 22
Date date2 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19+00:00\"}", VO.class).getGmtCreate();
Date date3 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date4 = JSON.parseObject("{\"gmtCreate\":\"20180912T151019Z\"}", VO.class).getGmtCreate();
Date date5 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date6 = JSON.parseObject("{\"gmtCreate\":\"20180912\"}", VO.class).getGmtCreate();
long delta_2_1 = date2.getTime() - date1.getTime();
assertEquals(83419000, delta_2_1);
Reported by PMD.
Line: 23
Date date3 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date4 = JSON.parseObject("{\"gmtCreate\":\"20180912T151019Z\"}", VO.class).getGmtCreate();
Date date5 = JSON.parseObject("{\"gmtCreate\":\"2018-09-12T15:10:19Z\"}", VO.class).getGmtCreate();
Date date6 = JSON.parseObject("{\"gmtCreate\":\"20180912\"}", VO.class).getGmtCreate();
long delta_2_1 = date2.getTime() - date1.getTime();
assertEquals(83419000, delta_2_1);
long delta_3_1 = date3.getTime() - date1.getTime();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/CommentTest.java
25 issues
Line: 13
public class CommentTest extends TestCase {
public void test_0() throws Exception {
String text = "{ // aa" //
+ "\n}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertEquals(0, obj.size());
}
Reported by PMD.
Line: 17
String text = "{ // aa" //
+ "\n}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertEquals(0, obj.size());
}
public void test_1() throws Exception {
String text = "{ // aa" //
+ "\n\"value\":1001}";
Reported by PMD.
Line: 20
Assert.assertEquals(0, obj.size());
}
public void test_1() throws Exception {
String text = "{ // aa" //
+ "\n\"value\":1001}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertEquals(1, obj.size());
Assert.assertEquals(1001, obj.get("value"));
Reported by PMD.
Line: 24
String text = "{ // aa" //
+ "\n\"value\":1001}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertEquals(1, obj.size());
Assert.assertEquals(1001, obj.get("value"));
}
public void test_2() throws Exception {
String text = "{ /* aa */ \"value\":1001}";
Reported by PMD.
Line: 25
+ "\n\"value\":1001}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertEquals(1, obj.size());
Assert.assertEquals(1001, obj.get("value"));
}
public void test_2() throws Exception {
String text = "{ /* aa */ \"value\":1001}";
JSONObject obj = (JSONObject) JSON.parse(text);
Reported by PMD.
Line: 25
+ "\n\"value\":1001}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertEquals(1, obj.size());
Assert.assertEquals(1001, obj.get("value"));
}
public void test_2() throws Exception {
String text = "{ /* aa */ \"value\":1001}";
JSONObject obj = (JSONObject) JSON.parse(text);
Reported by PMD.
Line: 28
Assert.assertEquals(1001, obj.get("value"));
}
public void test_2() throws Exception {
String text = "{ /* aa */ \"value\":1001}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertEquals(1, obj.size());
Assert.assertEquals(1001, obj.get("value"));
}
Reported by PMD.
Line: 31
public void test_2() throws Exception {
String text = "{ /* aa */ \"value\":1001}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertEquals(1, obj.size());
Assert.assertEquals(1001, obj.get("value"));
}
public void test_3() throws Exception {
String text = "{ \"value\":/* aa */1001}";
Reported by PMD.
Line: 32
String text = "{ /* aa */ \"value\":1001}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertEquals(1, obj.size());
Assert.assertEquals(1001, obj.get("value"));
}
public void test_3() throws Exception {
String text = "{ \"value\":/* aa */1001}";
JSONObject obj = (JSONObject) JSON.parse(text);
Reported by PMD.
Line: 35
Assert.assertEquals(1001, obj.get("value"));
}
public void test_3() throws Exception {
String text = "{ \"value\":/* aa */1001}";
JSONObject obj = (JSONObject) JSON.parse(text);
Assert.assertEquals(1, obj.size());
Assert.assertEquals(1001, obj.get("value"));
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1300/Issue1330_short.java
25 issues
Line: 45
}
public static class Model {
public short value;
}
}
Reported by PMD.
Line: 11
* Created by wenshao on 30/07/2017.
*/
public class Issue1330_short extends TestCase {
public void test_for_issue() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
} catch (JSONException e) {
error = e;
Reported by PMD.
Line: 11
* Created by wenshao on 30/07/2017.
*/
public class Issue1330_short extends TestCase {
public void test_for_issue() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
} catch (JSONException e) {
error = e;
Reported by PMD.
Line: 18
} catch (JSONException e) {
error = e;
}
assertNotNull(error);
assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
}
public void test_for_issue_1() throws Exception {
Exception error = null;
Reported by PMD.
Line: 19
error = e;
}
assertNotNull(error);
assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
}
public void test_for_issue_1() throws Exception {
Exception error = null;
try {
Reported by PMD.
Line: 19
error = e;
}
assertNotNull(error);
assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
}
public void test_for_issue_1() throws Exception {
Exception error = null;
try {
Reported by PMD.
Line: 19
error = e;
}
assertNotNull(error);
assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
}
public void test_for_issue_1() throws Exception {
Exception error = null;
try {
Reported by PMD.
Line: 19
error = e;
}
assertNotNull(error);
assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
}
public void test_for_issue_1() throws Exception {
Exception error = null;
try {
Reported by PMD.
Line: 22
assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
}
public void test_for_issue_1() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"value\":[]}", Model.class);
} catch (JSONException e) {
error = e;
Reported by PMD.
Line: 22
assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
}
public void test_for_issue_1() throws Exception {
Exception error = null;
try {
JSON.parseObject("{\"value\":[]}", Model.class);
} catch (JSONException e) {
error = e;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_Next.java
25 issues
Line: 19
public static void main(String[] args) throws Exception {
Result result = JUnitCore.runClasses(Bug_for_Next.class);
for (Failure fail : result.getFailures()) {
System.out.println(fail.toString());
}
if (result.wasSuccessful()) {
System.out.println("All tests finished successfully...");
}
}
Reported by PMD.
Line: 22
System.out.println(fail.toString());
}
if (result.wasSuccessful()) {
System.out.println("All tests finished successfully...");
}
}
public void testPrimitiveArray() throws Exception {
Reported by PMD.
Line: 183
}
private void showTitle(String title) {
System.out.println("test " + title);
}
private void showMesg(String mesg) {
System.out.println(" " + mesg);
}
Reported by PMD.
Line: 187
}
private void showMesg(String mesg) {
System.out.println(" " + mesg);
}
private static String byteArrayToHexString(byte[] data) {
return byteArrayToHexString(data, 0, data.length);
}
Reported by PMD.
Line: 194
return byteArrayToHexString(data, 0, data.length);
}
private static String byteArrayToHexString(byte[] data, int offest, int len) {
if (data == null) {
return "";
}
StringBuilder sb = new StringBuilder();
Reported by PMD.
Line: 16
public class Bug_for_Next extends TestCase {
public static void main(String[] args) throws Exception {
Result result = JUnitCore.runClasses(Bug_for_Next.class);
for (Failure fail : result.getFailures()) {
System.out.println(fail.toString());
}
if (result.wasSuccessful()) {
Reported by PMD.
Line: 21
for (Failure fail : result.getFailures()) {
System.out.println(fail.toString());
}
if (result.wasSuccessful()) {
System.out.println("All tests finished successfully...");
}
}
public void testPrimitiveArray() throws Exception {
Reported by PMD.
Line: 26
}
}
public void testPrimitiveArray() throws Exception {
showTitle("1=====================================");
String text= JSON.toJSONString("testbytearray".getBytes());
showMesg("text : " + text);
byte[] byteArray = JSON.parseObject(text, byte[].class);
Reported by PMD.
Line: 26
}
}
public void testPrimitiveArray() throws Exception {
showTitle("1=====================================");
String text= JSON.toJSONString("testbytearray".getBytes());
showMesg("text : " + text);
byte[] byteArray = JSON.parseObject(text, byte[].class);
Reported by PMD.
Line: 26
}
}
public void testPrimitiveArray() throws Exception {
showTitle("1=====================================");
String text= JSON.toJSONString("testbytearray".getBytes());
showMesg("text : " + text);
byte[] byteArray = JSON.parseObject(text, byte[].class);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/TestUTF8.java
25 issues
Line: 11
public class TestUTF8 extends TestCase {
public void test_utf() throws Exception {
JSONObject obj = (JSONObject) JSON.parse("{'name':'刘大'}".getBytes("UTF-8"));
Assert.assertEquals(1, obj.size());
Assert.assertEquals("刘大", obj.get("name"));
}
Reported by PMD.
Line: 12
public class TestUTF8 extends TestCase {
public void test_utf() throws Exception {
JSONObject obj = (JSONObject) JSON.parse("{'name':'刘大'}".getBytes("UTF-8"));
Assert.assertEquals(1, obj.size());
Assert.assertEquals("刘大", obj.get("name"));
}
public void test_utf_cn() throws Exception {
Reported by PMD.
Line: 13
public void test_utf() throws Exception {
JSONObject obj = (JSONObject) JSON.parse("{'name':'刘大'}".getBytes("UTF-8"));
Assert.assertEquals(1, obj.size());
Assert.assertEquals("刘大", obj.get("name"));
}
public void test_utf_cn() throws Exception {
String content = "首先来到村委会,走进农家书屋,认真翻看各种图书和报刊。他拿起一份藏文版《人民日报》,询问村民读书读报的情况,并和正在读书的几位藏族青年亲切交谈,勉励他们好好学习,学以致用,培养致富本领。在党支部活动室,村支部书记桑杰介绍了支部建设情况。当听到全村36名党员发挥先锋模范作用";
Reported by PMD.
Line: 14
public void test_utf() throws Exception {
JSONObject obj = (JSONObject) JSON.parse("{'name':'刘大'}".getBytes("UTF-8"));
Assert.assertEquals(1, obj.size());
Assert.assertEquals("刘大", obj.get("name"));
}
public void test_utf_cn() throws Exception {
String content = "首先来到村委会,走进农家书屋,认真翻看各种图书和报刊。他拿起一份藏文版《人民日报》,询问村民读书读报的情况,并和正在读书的几位藏族青年亲切交谈,勉励他们好好学习,学以致用,培养致富本领。在党支部活动室,村支部书记桑杰介绍了支部建设情况。当听到全村36名党员发挥先锋模范作用";
JSONObject json = new JSONObject();
Reported by PMD.
Line: 17
Assert.assertEquals("刘大", obj.get("name"));
}
public void test_utf_cn() throws Exception {
String content = "首先来到村委会,走进农家书屋,认真翻看各种图书和报刊。他拿起一份藏文版《人民日报》,询问村民读书读报的情况,并和正在读书的几位藏族青年亲切交谈,勉励他们好好学习,学以致用,培养致富本领。在党支部活动室,村支部书记桑杰介绍了支部建设情况。当听到全村36名党员发挥先锋模范作用";
JSONObject json = new JSONObject();
json.put("content", content);
JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
Assert.assertEquals(1, obj.size());
Reported by PMD.
Line: 20
public void test_utf_cn() throws Exception {
String content = "首先来到村委会,走进农家书屋,认真翻看各种图书和报刊。他拿起一份藏文版《人民日报》,询问村民读书读报的情况,并和正在读书的几位藏族青年亲切交谈,勉励他们好好学习,学以致用,培养致富本领。在党支部活动室,村支部书记桑杰介绍了支部建设情况。当听到全村36名党员发挥先锋模范作用";
JSONObject json = new JSONObject();
json.put("content", content);
JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
Assert.assertEquals(1, obj.size());
Assert.assertEquals(content, obj.get("content"));
}
Reported by PMD.
Line: 21
String content = "首先来到村委会,走进农家书屋,认真翻看各种图书和报刊。他拿起一份藏文版《人民日报》,询问村民读书读报的情况,并和正在读书的几位藏族青年亲切交谈,勉励他们好好学习,学以致用,培养致富本领。在党支部活动室,村支部书记桑杰介绍了支部建设情况。当听到全村36名党员发挥先锋模范作用";
JSONObject json = new JSONObject();
json.put("content", content);
JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
Assert.assertEquals(1, obj.size());
Assert.assertEquals(content, obj.get("content"));
}
public void test_utf_de() throws Exception {
Reported by PMD.
Line: 22
JSONObject json = new JSONObject();
json.put("content", content);
JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
Assert.assertEquals(1, obj.size());
Assert.assertEquals(content, obj.get("content"));
}
public void test_utf_de() throws Exception {
String content = "Beim Griechenland-Gipfel gibt es viele Gewinner. Kanzlerin Merkel bekommt die Bankenbeteiligung, Frankreichs Präsident Sarkozy den Aufkauf von Staatsanleihen. \\nEinzig EZB-Präsident Jean-Claude Trichet gilt als Verlierer. Er zog im Machtkampf den Kürzeren";
Reported by PMD.
Line: 23
json.put("content", content);
JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
Assert.assertEquals(1, obj.size());
Assert.assertEquals(content, obj.get("content"));
}
public void test_utf_de() throws Exception {
String content = "Beim Griechenland-Gipfel gibt es viele Gewinner. Kanzlerin Merkel bekommt die Bankenbeteiligung, Frankreichs Präsident Sarkozy den Aufkauf von Staatsanleihen. \\nEinzig EZB-Präsident Jean-Claude Trichet gilt als Verlierer. Er zog im Machtkampf den Kürzeren";
JSONObject json = new JSONObject();
Reported by PMD.
Line: 26
Assert.assertEquals(content, obj.get("content"));
}
public void test_utf_de() throws Exception {
String content = "Beim Griechenland-Gipfel gibt es viele Gewinner. Kanzlerin Merkel bekommt die Bankenbeteiligung, Frankreichs Präsident Sarkozy den Aufkauf von Staatsanleihen. \\nEinzig EZB-Präsident Jean-Claude Trichet gilt als Verlierer. Er zog im Machtkampf den Kürzeren";
JSONObject json = new JSONObject();
json.put("content", content);
JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
Assert.assertEquals(1, obj.size());
Reported by PMD.