The following issues were found
src/test/java/com/alibaba/json/bvt/issue_1100/Issue969.java
14 issues
Line: 17
* Created by wenshao on 08/05/2017.
*/
public class Issue969 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
jsonArray.add(new Model());
jsonObject.put("models", jsonArray);
Reported by PMD.
Line: 17
* Created by wenshao on 08/05/2017.
*/
public class Issue969 extends TestCase {
public void test_for_issue() throws Exception {
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
jsonArray.add(new Model());
jsonObject.put("models", jsonArray);
Reported by PMD.
Line: 22
JSONArray jsonArray = new JSONArray();
jsonArray.add(new Model());
jsonObject.put("models", jsonArray);
List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){});
assertEquals(1, list.size());
assertEquals(Model.class, list.get(0).getClass());
Reported by PMD.
Line: 26
List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){});
assertEquals(1, list.size());
assertEquals(Model.class, list.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
JSONObject jsonObject = new JSONObject();
Reported by PMD.
Line: 27
List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){});
assertEquals(1, list.size());
assertEquals(Model.class, list.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
JSONObject jsonObject = new JSONObject();
Reported by PMD.
Line: 27
List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){});
assertEquals(1, list.size());
assertEquals(Model.class, list.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
JSONObject jsonObject = new JSONObject();
Reported by PMD.
Line: 30
assertEquals(Model.class, list.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
jsonArray.add(new Model());
jsonObject.put("models", jsonArray);
Reported by PMD.
Line: 30
assertEquals(Model.class, list.get(0).getClass());
}
public void test_for_issue_1() throws Exception {
JSONObject jsonObject = new JSONObject();
JSONArray jsonArray = new JSONArray();
jsonArray.add(new Model());
jsonObject.put("models", jsonArray);
Reported by PMD.
Line: 39
List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){}.getType());
assertEquals(1, list.size());
assertEquals(Model.class, list.get(0).getClass());
}
public static class Model {
Reported by PMD.
Line: 40
List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){}.getType());
assertEquals(1, list.size());
assertEquals(Model.class, list.get(0).getClass());
}
public static class Model {
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest17.java
14 issues
Line: 29
Family[] familyArray = new Family[] { fA, fB };
String text = JSON.toJSONString(familyArray, true);
System.out.println(text);
JSONArray array = JSON.parseArray(text);
Assert.assertSame(array.getJSONObject(0).get("master"), array.getJSONObject(0).getJSONArray("members").get(0));
Reported by PMD.
Line: 11
public class RefTest17 extends TestCase {
public void test_0() throws Exception {
Person pA = new Person("a");
Person pB = new Person("b");
Family fA = new Family();
Reported by PMD.
Line: 33
JSONArray array = JSON.parseArray(text);
Assert.assertSame(array.getJSONObject(0).get("master"), array.getJSONObject(0).getJSONArray("members").get(0));
Family family = array.getObject(0, Family.class);
Assert.assertNotNull(family.getMembers()[0]);
Assert.assertNotNull(family.getMembers()[1]);
}
Reported by PMD.
Line: 33
JSONArray array = JSON.parseArray(text);
Assert.assertSame(array.getJSONObject(0).get("master"), array.getJSONObject(0).getJSONArray("members").get(0));
Family family = array.getObject(0, Family.class);
Assert.assertNotNull(family.getMembers()[0]);
Assert.assertNotNull(family.getMembers()[1]);
}
Reported by PMD.
Line: 33
JSONArray array = JSON.parseArray(text);
Assert.assertSame(array.getJSONObject(0).get("master"), array.getJSONObject(0).getJSONArray("members").get(0));
Family family = array.getObject(0, Family.class);
Assert.assertNotNull(family.getMembers()[0]);
Assert.assertNotNull(family.getMembers()[1]);
}
Reported by PMD.
Line: 33
JSONArray array = JSON.parseArray(text);
Assert.assertSame(array.getJSONObject(0).get("master"), array.getJSONObject(0).getJSONArray("members").get(0));
Family family = array.getObject(0, Family.class);
Assert.assertNotNull(family.getMembers()[0]);
Assert.assertNotNull(family.getMembers()[1]);
}
Reported by PMD.
Line: 33
JSONArray array = JSON.parseArray(text);
Assert.assertSame(array.getJSONObject(0).get("master"), array.getJSONObject(0).getJSONArray("members").get(0));
Family family = array.getObject(0, Family.class);
Assert.assertNotNull(family.getMembers()[0]);
Assert.assertNotNull(family.getMembers()[1]);
}
Reported by PMD.
Line: 35
Assert.assertSame(array.getJSONObject(0).get("master"), array.getJSONObject(0).getJSONArray("members").get(0));
Family family = array.getObject(0, Family.class);
Assert.assertNotNull(family.getMembers()[0]);
Assert.assertNotNull(family.getMembers()[1]);
}
public static class Family {
Reported by PMD.
Line: 36
Assert.assertSame(array.getJSONObject(0).get("master"), array.getJSONObject(0).getJSONArray("members").get(0));
Family family = array.getObject(0, Family.class);
Assert.assertNotNull(family.getMembers()[0]);
Assert.assertNotNull(family.getMembers()[1]);
}
public static class Family {
Reported by PMD.
Line: 37
Family family = array.getObject(0, Family.class);
Assert.assertNotNull(family.getMembers()[0]);
Assert.assertNotNull(family.getMembers()[1]);
}
public static class Family {
private Person master;
Reported by PMD.
src/main/java/com/alibaba/fastjson/parser/deserializer/TimeDeserializer.java
14 issues
Line: 13
import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.util.TypeUtils;
public class TimeDeserializer implements ObjectDeserializer {
public final static TimeDeserializer instance = new TimeDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
Reported by PMD.
Line: 13
import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.fastjson.util.TypeUtils;
public class TimeDeserializer implements ObjectDeserializer {
public final static TimeDeserializer instance = new TimeDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
Reported by PMD.
Line: 18
public final static TimeDeserializer instance = new TimeDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
Reported by PMD.
Line: 18
public final static TimeDeserializer instance = new TimeDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
Reported by PMD.
Line: 18
public final static TimeDeserializer instance = new TimeDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
Reported by PMD.
Line: 18
public final static TimeDeserializer instance = new TimeDeserializer();
@SuppressWarnings("unchecked")
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
Reported by PMD.
Line: 21
public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
JSONLexer lexer = parser.lexer;
if (lexer.token() == JSONToken.COMMA) {
lexer.nextToken(JSONToken.LITERAL_STRING);
if (lexer.token() != JSONToken.LITERAL_STRING) {
throw new JSONException("syntax error");
}
Reported by PMD.
Line: 58
return (T) new java.sql.Time(((Number) val).longValue());
} else if (val instanceof String) {
String strVal = (String) val;
if (strVal.length() == 0) {
return null;
}
long longVal;
JSONScanner dateLexer = new JSONScanner(strVal);
Reported by PMD.
Line: 65
long longVal;
JSONScanner dateLexer = new JSONScanner(strVal);
if (dateLexer.scanISO8601DateIfMatch()) {
longVal = dateLexer.getCalendar().getTimeInMillis();
} else {
boolean isDigit = true;
for (int i = 0; i< strVal.length(); ++i) {
char ch = strVal.charAt(i);
if (ch < '0' || ch > '9') {
Reported by PMD.
Line: 68
longVal = dateLexer.getCalendar().getTimeInMillis();
} else {
boolean isDigit = true;
for (int i = 0; i< strVal.length(); ++i) {
char ch = strVal.charAt(i);
if (ch < '0' || ch > '9') {
isDigit = false;
break;
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/parser/deserializer/ResolveFieldDeserializer.java
14 issues
Line: 16
@SuppressWarnings("rawtypes")
public final class ResolveFieldDeserializer extends FieldDeserializer {
private final int index;
private final List list;
private final DefaultJSONParser parser;
private final Object key;
private final Map map;
Reported by PMD.
Line: 17
public final class ResolveFieldDeserializer extends FieldDeserializer {
private final int index;
private final List list;
private final DefaultJSONParser parser;
private final Object key;
private final Map map;
Reported by PMD.
Line: 18
private final int index;
private final List list;
private final DefaultJSONParser parser;
private final Object key;
private final Map map;
private final Collection collection;
Reported by PMD.
Line: 20
private final List list;
private final DefaultJSONParser parser;
private final Object key;
private final Map map;
private final Collection collection;
public ResolveFieldDeserializer(DefaultJSONParser parser, List list, int index){
Reported by PMD.
Line: 21
private final DefaultJSONParser parser;
private final Object key;
private final Map map;
private final Collection collection;
public ResolveFieldDeserializer(DefaultJSONParser parser, List list, int index){
super(null, null);
Reported by PMD.
Line: 23
private final Object key;
private final Map map;
private final Collection collection;
public ResolveFieldDeserializer(DefaultJSONParser parser, List list, int index){
super(null, null);
this.parser = parser;
this.index = index;
Reported by PMD.
Line: 40
public ResolveFieldDeserializer(Map map, Object index){
super(null, null);
this.parser = null;
this.index = -1;
this.list = null;
this.key = index;
this.map = map;
Reported by PMD.
Line: 42
this.parser = null;
this.index = -1;
this.list = null;
this.key = index;
this.map = map;
collection = null;
Reported by PMD.
Line: 53
public ResolveFieldDeserializer(Collection collection){
super(null, null);
this.parser = null;
this.index = -1;
this.list = null;
key = null;
map = null;
Reported by PMD.
Line: 55
this.parser = null;
this.index = -1;
this.list = null;
key = null;
map = null;
this.collection = collection;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue869.java
14 issues
Line: 15
* Created by wenshao on 2016/10/19.
*/
public class Issue869 extends TestCase {
public void test_for_issue() throws Exception {
List<DoublePoint> doublePointList = new ArrayList<DoublePoint>();
{
DoublePoint doublePoint = new DoublePoint();
doublePoint.startPoint = new Point(22, 35);
doublePoint.endPoint = doublePoint.startPoint;
Reported by PMD.
Line: 31
}
String json = JSON.toJSONString(doublePointList);
assertEquals("[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"x\":22,\"y\":35}},{\"endPoint\":{\"x\":16,\"y\":18},\"startPoint\":{\"x\":16,\"y\":18}}]", json);
}
public void test_for_issue_parse() throws Exception {
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
Reported by PMD.
Line: 34
assertEquals("[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"x\":22,\"y\":35}},{\"endPoint\":{\"x\":16,\"y\":18},\"startPoint\":{\"x\":16,\"y\":18}}]", json);
}
public void test_for_issue_parse() throws Exception {
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
Reported by PMD.
Line: 34
assertEquals("[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"x\":22,\"y\":35}},{\"endPoint\":{\"x\":16,\"y\":18},\"startPoint\":{\"x\":16,\"y\":18}}]", json);
}
public void test_for_issue_parse() throws Exception {
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
Reported by PMD.
Line: 38
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
Reported by PMD.
Line: 39
String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
Reported by PMD.
Line: 40
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
public Point startPoint;
Reported by PMD.
Line: 40
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
public Point startPoint;
Reported by PMD.
Line: 40
List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
public Point startPoint;
Reported by PMD.
Line: 41
assertNotNull(doublePointList.get(0));
assertNotNull(doublePointList.get(1));
assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
}
public static class DoublePoint{
public Point startPoint;
public Point endPoint;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest_unwrapped_5.java
14 issues
Line: 13
public class JSONFieldTest_unwrapped_5 extends TestCase {
public void test_jsonField() throws Exception {
Health vo = new Health();
vo.id = 123;
vo.details.put("latitude", 37);
vo.details.put("longitude", 127);
Reported by PMD.
Line: 13
public class JSONFieldTest_unwrapped_5 extends TestCase {
public void test_jsonField() throws Exception {
Health vo = new Health();
vo.id = 123;
vo.details.put("latitude", 37);
vo.details.put("longitude", 127);
Reported by PMD.
Line: 16
public void test_jsonField() throws Exception {
Health vo = new Health();
vo.id = 123;
vo.details.put("latitude", 37);
vo.details.put("longitude", 127);
String text = JSON.toJSONString(vo);
Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text);
Reported by PMD.
Line: 17
Health vo = new Health();
vo.id = 123;
vo.details.put("latitude", 37);
vo.details.put("longitude", 127);
String text = JSON.toJSONString(vo);
Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text);
Health vo2 = JSON.parseObject(text, Health.class);
Reported by PMD.
Line: 23
Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text);
Health vo2 = JSON.parseObject(text, Health.class);
assertNotNull(vo2.details);
assertEquals(37, vo2.details.get("latitude"));
assertEquals(127, vo2.details.get("longitude"));
}
Reported by PMD.
Line: 24
Health vo2 = JSON.parseObject(text, Health.class);
assertNotNull(vo2.details);
assertEquals(37, vo2.details.get("latitude"));
assertEquals(127, vo2.details.get("longitude"));
}
public void test_null() throws Exception {
Reported by PMD.
Line: 24
Health vo2 = JSON.parseObject(text, Health.class);
assertNotNull(vo2.details);
assertEquals(37, vo2.details.get("latitude"));
assertEquals(127, vo2.details.get("longitude"));
}
public void test_null() throws Exception {
Reported by PMD.
Line: 25
Health vo2 = JSON.parseObject(text, Health.class);
assertNotNull(vo2.details);
assertEquals(37, vo2.details.get("latitude"));
assertEquals(127, vo2.details.get("longitude"));
}
public void test_null() throws Exception {
Health vo = new Health();
Reported by PMD.
Line: 25
Health vo2 = JSON.parseObject(text, Health.class);
assertNotNull(vo2.details);
assertEquals(37, vo2.details.get("latitude"));
assertEquals(127, vo2.details.get("longitude"));
}
public void test_null() throws Exception {
Health vo = new Health();
Reported by PMD.
Line: 29
}
public void test_null() throws Exception {
Health vo = new Health();
vo.id = 123;
vo.details = null;
String text = JSON.toJSONString(vo);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/ref/RefTest23.java
14 issues
Line: 31
"\t},\n" +
"\t\"aaaa\\\"\":{\"$ref\":\"$.bbbb\\\\\\\"\"}\n" +
"}";
System.out.println(json);
JSONObject root = JSON.parseObject(json);
assertSame(root.get("bbbb\\"), root.get("aaaa\\"));
}
}
Reported by PMD.
Line: 11
* Created by wenshao on 16/8/23.
*/
public class RefTest23 extends TestCase {
public void test_ref() throws Exception {
String json = "{\"$ref\":\"tmall/item\",\"id\":123}";
JSONObject root = JSON.parseObject(json);
assertEquals("tmall/item", root.get("$ref"));
assertEquals(123, root.get("id"));
}
Reported by PMD.
Line: 11
* Created by wenshao on 16/8/23.
*/
public class RefTest23 extends TestCase {
public void test_ref() throws Exception {
String json = "{\"$ref\":\"tmall/item\",\"id\":123}";
JSONObject root = JSON.parseObject(json);
assertEquals("tmall/item", root.get("$ref"));
assertEquals(123, root.get("id"));
}
Reported by PMD.
Line: 14
public void test_ref() throws Exception {
String json = "{\"$ref\":\"tmall/item\",\"id\":123}";
JSONObject root = JSON.parseObject(json);
assertEquals("tmall/item", root.get("$ref"));
assertEquals(123, root.get("id"));
}
public void test_ref_1() throws Exception {
String json = "{\"$ref\":123}";
Reported by PMD.
Line: 14
public void test_ref() throws Exception {
String json = "{\"$ref\":\"tmall/item\",\"id\":123}";
JSONObject root = JSON.parseObject(json);
assertEquals("tmall/item", root.get("$ref"));
assertEquals(123, root.get("id"));
}
public void test_ref_1() throws Exception {
String json = "{\"$ref\":123}";
Reported by PMD.
Line: 15
String json = "{\"$ref\":\"tmall/item\",\"id\":123}";
JSONObject root = JSON.parseObject(json);
assertEquals("tmall/item", root.get("$ref"));
assertEquals(123, root.get("id"));
}
public void test_ref_1() throws Exception {
String json = "{\"$ref\":123}";
JSONObject root = JSON.parseObject(json);
Reported by PMD.
Line: 15
String json = "{\"$ref\":\"tmall/item\",\"id\":123}";
JSONObject root = JSON.parseObject(json);
assertEquals("tmall/item", root.get("$ref"));
assertEquals(123, root.get("id"));
}
public void test_ref_1() throws Exception {
String json = "{\"$ref\":123}";
JSONObject root = JSON.parseObject(json);
Reported by PMD.
Line: 18
assertEquals(123, root.get("id"));
}
public void test_ref_1() throws Exception {
String json = "{\"$ref\":123}";
JSONObject root = JSON.parseObject(json);
assertEquals(123, root.get("$ref"));
}
Reported by PMD.
Line: 21
public void test_ref_1() throws Exception {
String json = "{\"$ref\":123}";
JSONObject root = JSON.parseObject(json);
assertEquals(123, root.get("$ref"));
}
public void test_ref_2() throws Exception {
String json = "{\n" +
"\t\"bbbb\\\"\":{\n" +
Reported by PMD.
Line: 21
public void test_ref_1() throws Exception {
String json = "{\"$ref\":123}";
JSONObject root = JSON.parseObject(json);
assertEquals(123, root.get("$ref"));
}
public void test_ref_2() throws Exception {
String json = "{\n" +
"\t\"bbbb\\\"\":{\n" +
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/LocaleFieldTest.java
14 issues
Line: 13
* Created by wenshao on 14/03/2017.
*/
public class LocaleFieldTest extends TestCase {
public void test_local_str() throws Exception {
Model model = new Model();
model.locale = Locale.CHINA;
String json = JSON.toJSONString(model);
Reported by PMD.
Line: 13
* Created by wenshao on 14/03/2017.
*/
public class LocaleFieldTest extends TestCase {
public void test_local_str() throws Exception {
Model model = new Model();
model.locale = Locale.CHINA;
String json = JSON.toJSONString(model);
Reported by PMD.
Line: 20
String json = JSON.toJSONString(model);
JSONObject jsonObject = JSON.parseObject(json);
jsonObject.toJavaObject(Model.class);
}
public void test_local_obj() throws Exception {
String json = "{\"locale\":{\"displayCountry\":\"China\",\"displayVariant\":\"\",\"displayLanguage\":\"Chinese\",\"language\":\"zh\",\"displayName\":\"Chinese (China)\",\"variant\":\"\",\"ISO3Language\":\"zho\",\"ISO3Country\":\"CHN\",\"country\":\"CN\"}}";
Reported by PMD.
Line: 23
jsonObject.toJavaObject(Model.class);
}
public void test_local_obj() throws Exception {
String json = "{\"locale\":{\"displayCountry\":\"China\",\"displayVariant\":\"\",\"displayLanguage\":\"Chinese\",\"language\":\"zh\",\"displayName\":\"Chinese (China)\",\"variant\":\"\",\"ISO3Language\":\"zho\",\"ISO3Country\":\"CHN\",\"country\":\"CN\"}}";
JSONObject jsonObject = JSON.parseObject(json);
Model model2 = jsonObject.toJavaObject(Model.class);
assertEquals("CN", model2.locale.getCountry());
Reported by PMD.
Line: 23
jsonObject.toJavaObject(Model.class);
}
public void test_local_obj() throws Exception {
String json = "{\"locale\":{\"displayCountry\":\"China\",\"displayVariant\":\"\",\"displayLanguage\":\"Chinese\",\"language\":\"zh\",\"displayName\":\"Chinese (China)\",\"variant\":\"\",\"ISO3Language\":\"zho\",\"ISO3Country\":\"CHN\",\"country\":\"CN\"}}";
JSONObject jsonObject = JSON.parseObject(json);
Model model2 = jsonObject.toJavaObject(Model.class);
assertEquals("CN", model2.locale.getCountry());
Reported by PMD.
Line: 27
String json = "{\"locale\":{\"displayCountry\":\"China\",\"displayVariant\":\"\",\"displayLanguage\":\"Chinese\",\"language\":\"zh\",\"displayName\":\"Chinese (China)\",\"variant\":\"\",\"ISO3Language\":\"zho\",\"ISO3Country\":\"CHN\",\"country\":\"CN\"}}";
JSONObject jsonObject = JSON.parseObject(json);
Model model2 = jsonObject.toJavaObject(Model.class);
assertEquals("CN", model2.locale.getCountry());
assertEquals("zh", model2.locale.getLanguage());
assertEquals(Locale.CHINA.getDisplayCountry(), model2.locale.getDisplayCountry());
}
Reported by PMD.
Line: 28
JSONObject jsonObject = JSON.parseObject(json);
Model model2 = jsonObject.toJavaObject(Model.class);
assertEquals("CN", model2.locale.getCountry());
assertEquals("zh", model2.locale.getLanguage());
assertEquals(Locale.CHINA.getDisplayCountry(), model2.locale.getDisplayCountry());
}
public static class Model {
Reported by PMD.
Line: 28
JSONObject jsonObject = JSON.parseObject(json);
Model model2 = jsonObject.toJavaObject(Model.class);
assertEquals("CN", model2.locale.getCountry());
assertEquals("zh", model2.locale.getLanguage());
assertEquals(Locale.CHINA.getDisplayCountry(), model2.locale.getDisplayCountry());
}
public static class Model {
Reported by PMD.
Line: 29
JSONObject jsonObject = JSON.parseObject(json);
Model model2 = jsonObject.toJavaObject(Model.class);
assertEquals("CN", model2.locale.getCountry());
assertEquals("zh", model2.locale.getLanguage());
assertEquals(Locale.CHINA.getDisplayCountry(), model2.locale.getDisplayCountry());
}
public static class Model {
public Locale locale;
Reported by PMD.
Line: 29
JSONObject jsonObject = JSON.parseObject(json);
Model model2 = jsonObject.toJavaObject(Model.class);
assertEquals("CN", model2.locale.getCountry());
assertEquals("zh", model2.locale.getLanguage());
assertEquals(Locale.CHINA.getDisplayCountry(), model2.locale.getDisplayCountry());
}
public static class Model {
public Locale locale;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/feature/DisableFieldSmartMatchTest.java
14 issues
Line: 12
* Created by wenshao on 17/03/2017.
*/
public class DisableFieldSmartMatchTest extends TestCase {
public void test_feature() throws Exception {
assertEquals(123, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class).personId);
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
}
Reported by PMD.
Line: 12
* Created by wenshao on 17/03/2017.
*/
public class DisableFieldSmartMatchTest extends TestCase {
public void test_feature() throws Exception {
assertEquals(123, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class).personId);
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
}
Reported by PMD.
Line: 13
*/
public class DisableFieldSmartMatchTest extends TestCase {
public void test_feature() throws Exception {
assertEquals(123, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class).personId);
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
}
public void test_feature2() throws Exception {
Reported by PMD.
Line: 13
*/
public class DisableFieldSmartMatchTest extends TestCase {
public void test_feature() throws Exception {
assertEquals(123, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class).personId);
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
}
public void test_feature2() throws Exception {
Reported by PMD.
Line: 14
public class DisableFieldSmartMatchTest extends TestCase {
public void test_feature() throws Exception {
assertEquals(123, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class).personId);
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
}
public void test_feature2() throws Exception {
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask2.class).personId);
Reported by PMD.
Line: 14
public class DisableFieldSmartMatchTest extends TestCase {
public void test_feature() throws Exception {
assertEquals(123, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class).personId);
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
}
public void test_feature2() throws Exception {
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask2.class).personId);
Reported by PMD.
Line: 15
public void test_feature() throws Exception {
assertEquals(123, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class).personId);
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
}
public void test_feature2() throws Exception {
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask2.class).personId);
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask2.class).personId);
Reported by PMD.
Line: 15
public void test_feature() throws Exception {
assertEquals(123, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class).personId);
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
}
public void test_feature2() throws Exception {
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask2.class).personId);
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask2.class).personId);
Reported by PMD.
Line: 18
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
}
public void test_feature2() throws Exception {
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask2.class).personId);
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask2.class).personId);
}
public static class Model_for_disableFieldSmartMatchMask {
Reported by PMD.
Line: 18
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask.class, Feature.DisableFieldSmartMatch).personId);
}
public void test_feature2() throws Exception {
assertEquals(0, JSON.parseObject("{\"person_id\":123}", Model_for_disableFieldSmartMatchMask2.class).personId);
assertEquals(123, JSON.parseObject("{\"personId\":123}", Model_for_disableFieldSmartMatchMask2.class).personId);
}
public static class Model_for_disableFieldSmartMatchMask {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest5.java
14 issues
Line: 20
model.a = b;
String str = JSON.toJSONString(model);
System.out.println(str);
assertEquals("{\"a\":{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest5$B\",\"id\":1001,\"value\":2017}}", str);
Model model2 = JSON.parseObject(str, Model.class);
assertTrue(model2.a instanceof B);
}
Reported by PMD.
Line: 34
model.a = a;
String str = JSON.toJSONString(model);
System.out.println(str);
assertEquals("{\"a\":{\"id\":1001}}", str);
Model model2 = JSON.parseObject(str, Model.class);
assertSame(A.class, model2.a.getClass());
}
Reported by PMD.
Line: 12
* Created by wenshao on 14/08/2017.
*/
public class WriteClassNameTest5 extends TestCase {
public void test_for_writeClassName() throws Exception {
Model model = new Model();
B b = new B();
b.id = 1001;
b.value = 2017;
model.a = b;
Reported by PMD.
Line: 12
* Created by wenshao on 14/08/2017.
*/
public class WriteClassNameTest5 extends TestCase {
public void test_for_writeClassName() throws Exception {
Model model = new Model();
B b = new B();
b.id = 1001;
b.value = 2017;
model.a = b;
Reported by PMD.
Line: 21
String str = JSON.toJSONString(model);
System.out.println(str);
assertEquals("{\"a\":{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest5$B\",\"id\":1001,\"value\":2017}}", str);
Model model2 = JSON.parseObject(str, Model.class);
assertTrue(model2.a instanceof B);
}
Reported by PMD.
Line: 24
assertEquals("{\"a\":{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest5$B\",\"id\":1001,\"value\":2017}}", str);
Model model2 = JSON.parseObject(str, Model.class);
assertTrue(model2.a instanceof B);
}
public void test_for_writeClassName_no() throws Exception {
Model model = new Model();
A a = new A();
Reported by PMD.
Line: 27
assertTrue(model2.a instanceof B);
}
public void test_for_writeClassName_no() throws Exception {
Model model = new Model();
A a = new A();
a.id = 1001;
model.a = a;
Reported by PMD.
Line: 27
assertTrue(model2.a instanceof B);
}
public void test_for_writeClassName_no() throws Exception {
Model model = new Model();
A a = new A();
a.id = 1001;
model.a = a;
Reported by PMD.
Line: 35
String str = JSON.toJSONString(model);
System.out.println(str);
assertEquals("{\"a\":{\"id\":1001}}", str);
Model model2 = JSON.parseObject(str, Model.class);
assertSame(A.class, model2.a.getClass());
}
Reported by PMD.
Line: 38
assertEquals("{\"a\":{\"id\":1001}}", str);
Model model2 = JSON.parseObject(str, Model.class);
assertSame(A.class, model2.a.getClass());
}
public static class Model {
@JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
public A a;
Reported by PMD.