The following issues were found
src/test/java/com/alibaba/json/bvt/serializer/JSONObjectOrderTest.java
3 issues
Line: 10
public class JSONObjectOrderTest extends TestCase {
public void test_for_order() throws Exception {
System.out.println(JSON.VERSION);
JSONObject jsonObj = new JSONObject(true);
jsonObj.put("code","code");
jsonObj.put("msg","msg");
jsonObj.put("data", "data");
String jsonStr = JSON.toJSONString(jsonObj, SerializerFeature.MapSortField);
Reported by PMD.
Line: 9
import junit.framework.TestCase;
public class JSONObjectOrderTest extends TestCase {
public void test_for_order() throws Exception {
System.out.println(JSON.VERSION);
JSONObject jsonObj = new JSONObject(true);
jsonObj.put("code","code");
jsonObj.put("msg","msg");
jsonObj.put("data", "data");
Reported by PMD.
Line: 16
jsonObj.put("msg","msg");
jsonObj.put("data", "data");
String jsonStr = JSON.toJSONString(jsonObj, SerializerFeature.MapSortField);
assertEquals("{\"code\":\"code\",\"msg\":\"msg\",\"data\":\"data\"}", jsonStr);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/generic/GenericArrayTest4.java
3 issues
Line: 12
public class GenericArrayTest4 extends TestCase {
public void test_generic() throws Exception {
VO vo = new VO();
vo.values = new Pair[] {null, null};
String text = JSON.toJSONString(vo);
// VO vo1 = JSON.parseObject(text, new TypeReference<VO<Number, String>>(){} );
Reported by PMD.
Line: 26
}
public static class A<T extends Number, S> {
public Pair<? extends T, ? extends S>[] values;
}
public static class VO extends A<Number, String> {
}
Reported by PMD.
Line: 6
import org.junit.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import junit.framework.TestCase;
public class GenericArrayTest4 extends TestCase {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest5.java
3 issues
Line: 11
public class JSONFieldTest5 extends TestCase {
public void test_jsonField() throws Exception {
VO vo = new VO();
vo.setID(123);
String text = JSON.toJSONString(vo);
Reported by PMD.
Line: 19
String text = JSON.toJSONString(vo);
Assert.assertEquals("{\"iD\":123}", text);
Assert.assertEquals(123, JSON.parseObject(text, VO.class).getID());
}
public static class VO {
private int id;
Reported by PMD.
Line: 24
public static class VO {
private int id;
public int getID() {
return id;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/UnicodeTest.java
3 issues
Line: 12
public class UnicodeTest extends TestCase {
public void test_unicode() throws Exception {
String text = JSON.toJSONString(Collections.singletonMap("v", "\u0018"));
System.out.println(text);
}
}
Reported by PMD.
Line: 10
import junit.framework.TestCase;
public class UnicodeTest extends TestCase {
public void test_unicode() throws Exception {
String text = JSON.toJSONString(Collections.singletonMap("v", "\u0018"));
System.out.println(text);
}
}
Reported by PMD.
Line: 10
import junit.framework.TestCase;
public class UnicodeTest extends TestCase {
public void test_unicode() throws Exception {
String text = JSON.toJSONString(Collections.singletonMap("v", "\u0018"));
System.out.println(text);
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/taobao/SpecialStringTest.java
3 issues
Line: 10
import junit.framework.TestCase;
public class SpecialStringTest extends TestCase {
public void test_for_special() throws Exception {
VO vo = new VO();
vo.value = "{\"aurl\"";
String text = JSON.toJSONString(vo);
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo1.value, vo.value);
Reported by PMD.
Line: 18
Assert.assertEquals(vo1.value, vo.value);
}
public void test_for_special_1() throws Exception {
VO vo = new VO();
vo.value = "{\"aurl\":\"http://a.m.taobao.com/i529666038203.htm\",\"eurl\":\"http://click.mz.simba.taobao.com/ecpm?e=FKzStLpktUcmgME64bmjnBsQmLP5zomMI9WwdvViswDtdMUS1TLPryFiqQmsaUcblU3hrUulblXi4Nf5jVnFI3mESrWAJFi8UK7RDtIZydUyXElRAMLwo3HZWQvTKXBpyitB%2BgALy7j45JkIPnsiapEFjIWbdXJAnae9i5WIlhTnQ%2FthEaQ9IuT5J4gzB5T%2FcKP7YijzmvIZWnX1fL8Wv2yOkjnv1RfOuAwHNITyYhs0036Nbzw1rue9DcuU1VaInAsdAQs%2BcFbs41NPY6%2FbqjqRHfjhCyty&u=http%3A%2F%2Fa.m.taobao.com%2Fi529666038203.htm&k=289\",\"tbgoodslink\":\"http://i.mmcdn.cn/simba/img/TB120WTMpXXXXazXXXXSutbFXXX.jpg\",\"tmpl\":\"\"}";
String text = JSON.toJSONString(vo);
VO vo1 = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo1.value, vo.value);
Reported by PMD.
Line: 27
}
public static class VO {
public String value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/taobao/LongObjectAsStringTest.java
3 issues
Line: 10
import junit.framework.TestCase;
public class LongObjectAsStringTest extends TestCase {
public void test_0 () throws Exception {
VO vo = JSON.parseObject("{\"value\":\"1001\"}", VO.class);
Assert.assertEquals(1001, vo.value.intValue());
}
public static class VO {
Reported by PMD.
Line: 12
public class LongObjectAsStringTest extends TestCase {
public void test_0 () throws Exception {
VO vo = JSON.parseObject("{\"value\":\"1001\"}", VO.class);
Assert.assertEquals(1001, vo.value.intValue());
}
public static class VO {
public Long value;
}
Reported by PMD.
Line: 16
}
public static class VO {
public Long value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/IntFieldTest.java
3 issues
Line: 11
public class IntFieldTest extends TestCase {
public void test_model() throws Exception {
Model model = new Model();
model.id = -1001;
String text = JSON.toJSONString(model);
Assert.assertEquals("{\"id\":-1001}", text);
Reported by PMD.
Line: 19
Assert.assertEquals("{\"id\":-1001}", text);
}
public void test_model_max() throws Exception {
Model model = new Model();
model.id = Integer.MIN_VALUE;
String text = JSON.toJSONString(model);
Assert.assertEquals("{\"id\":-2147483648}", text);
Reported by PMD.
Line: 29
public static class Model {
public int id;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumFieldsTest2.java
3 issues
Line: 12
public class EnumFieldsTest2 extends TestCase {
public void test_enum() throws Exception {
Model model = new Model();
model.t1 = Type.A;
model.t2 = null;
String text = JSON.toJSONString(model, SerializerFeature.WriteMapNullValue);
Reported by PMD.
Line: 15
public void test_enum() throws Exception {
Model model = new Model();
model.t1 = Type.A;
model.t2 = null;
String text = JSON.toJSONString(model, SerializerFeature.WriteMapNullValue);
Assert.assertEquals("{\"t1\":\"A\",\"t2\":null}", text);
}
Reported by PMD.
Line: 21
Assert.assertEquals("{\"t1\":\"A\",\"t2\":null}", text);
}
public static class Model {
private Type t1;
private Type t2;
public Type getT1() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/MaxBufSizeTest.java
3 issues
Line: 11
* Created by wenshao on 01/04/2017.
*/
public class MaxBufSizeTest extends TestCase {
public void test_max_buf() throws Exception {
SerializeWriter writer = new SerializeWriter();
Throwable error = null;
try {
writer.setMaxBufSize(1);
Reported by PMD.
Line: 20
} catch (JSONException e) {
error = e;
}
assertNotNull(error);
}
}
Reported by PMD.
Line: 14
public void test_max_buf() throws Exception {
SerializeWriter writer = new SerializeWriter();
Throwable error = null;
try {
writer.setMaxBufSize(1);
} catch (JSONException e) {
error = e;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_containsValue_2.java
3 issues
Line: 10
import junit.framework.TestCase;
public class JSONPath_containsValue_2 extends TestCase {
public void test_root() throws Exception {
Model model = new Model();
model.value = 1001;
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001));
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001L));
Reported by PMD.
Line: 14
Model model = new Model();
model.value = 1001;
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001));
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001L));
Assert.assertTrue(JSONPath.containsValue(model, "/value", (short) 1001));
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001F));
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001D));
Reported by PMD.
Line: 28
}
public static class Model {
public int value;
}
}
Reported by PMD.