The following issues were found
src/test/java/com/alibaba/json/bvt/Issue213Test.java
3 issues
Line: 12
public class Issue213Test extends TestCase {
public void test_0() throws Exception {
String text = "\t\t\t\t\t\t \u00A020:00-21:30</span><br />\r\n\r\n</p>\r\n<p>\r\n\t\r\n</p>\r\n<p>\r\n\t<br />\r\n</p>\r\n\t\t\t";
Product e = new Product();
e.setIntro(text);
byte[] r = JSON.toJSONBytes(e);
JSON.parseObject(r, Product.class);
Reported by PMD.
Line: 12
public class Issue213Test extends TestCase {
public void test_0() throws Exception {
String text = "\t\t\t\t\t\t \u00A020:00-21:30</span><br />\r\n\r\n</p>\r\n<p>\r\n\t\r\n</p>\r\n<p>\r\n\t<br />\r\n</p>\r\n\t\t\t";
Product e = new Product();
e.setIntro(text);
byte[] r = JSON.toJSONBytes(e);
JSON.parseObject(r, Product.class);
Reported by PMD.
Line: 20
JSON.parseObject(r, Product.class);
}
public static class Product implements Serializable {
private static final long serialVersionUID = 5515785177596600948L;
private String studyTargets;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/EnumerationTest.java
3 issues
Line: 15
public class EnumerationTest extends TestCase {
public void test_enumeration() throws Exception {
Assert.assertEquals("[]", JSON.toJSONString(new Vector().elements()));
Assert.assertEquals("[null]", JSON.toJSONString(new Vector(Collections.singleton(null)).elements()));
Assert.assertEquals("{\"value\":[]}", JSON.toJSONString(new VO(), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
}
Reported by PMD.
Line: 16
public class EnumerationTest extends TestCase {
public void test_enumeration() throws Exception {
Assert.assertEquals("[]", JSON.toJSONString(new Vector().elements()));
Assert.assertEquals("[null]", JSON.toJSONString(new Vector(Collections.singleton(null)).elements()));
Assert.assertEquals("{\"value\":[]}", JSON.toJSONString(new VO(), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
}
Reported by PMD.
Line: 17
public void test_enumeration() throws Exception {
Assert.assertEquals("[]", JSON.toJSONString(new Vector().elements()));
Assert.assertEquals("[null]", JSON.toJSONString(new Vector(Collections.singleton(null)).elements()));
Assert.assertEquals("{\"value\":[]}", JSON.toJSONString(new VO(), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
}
private static class VO {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/JSONBytesTest2.java
3 issues
Line: 11
public class JSONBytesTest2 extends TestCase {
public void test_codec() throws Exception {
String text="𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𢴈𢵌𢵧𢺳𣲷𤓓𤶸𤷪𥄫𦉘𦟌𦧲𦧺𧨾𨅝𨈇𨋢𨳊𨳍𨳒𩶘";
byte[] bytes = JSON.toJSONBytes(text);
String text2 = (String) JSON.parse(bytes);
Reported by PMD.
Line: 17
byte[] bytes = JSON.toJSONBytes(text);
String text2 = (String) JSON.parse(bytes);
Assert.assertEquals(text.length(), text2.length());
for (int i = 0; i < text.length(); ++i) {
char c1 = text.charAt(i);
char c2 = text2.charAt(i);
Assert.assertEquals(c1, c2);
Reported by PMD.
Line: 17
byte[] bytes = JSON.toJSONBytes(text);
String text2 = (String) JSON.parse(bytes);
Assert.assertEquals(text.length(), text2.length());
for (int i = 0; i < text.length(); ++i) {
char c1 = text.charAt(i);
char c2 = text2.charAt(i);
Assert.assertEquals(c1, c2);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/EmptyArrayAsNullTest.java
3 issues
Line: 11
*/
public class EmptyArrayAsNullTest extends TestCase {
public void test_emtpyAsNull() throws Exception {
String text = "{\"value\":[]}";
Model model = JSON.parseObject(text, Model.class);
assertNull(model.value);
}
Reported by PMD.
Line: 15
String text = "{\"value\":[]}";
Model model = JSON.parseObject(text, Model.class);
assertNull(model.value);
}
public static class Model {
public Value value;
}
Reported by PMD.
Line: 19
}
public static class Model {
public Value value;
}
public static class Value {
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/DefaultJSONParserTest_ref.java
3 issues
Line: 28
public class DefaultJSONParserTest_ref extends TestCase {
public void test_ref() {
Map obj = JSON.parseObject("{\"id\":{},\"value\":{\"$ref\":\"$\"}}", Map.class);
Assert.assertTrue(obj == obj.get("value"));
}
Reported by PMD.
Line: 30
public void test_ref() {
Map obj = JSON.parseObject("{\"id\":{},\"value\":{\"$ref\":\"$\"}}", Map.class);
Assert.assertTrue(obj == obj.get("value"));
}
}
Reported by PMD.
Line: 30
public void test_ref() {
Map obj = JSON.parseObject("{\"id\":{},\"value\":{\"$ref\":\"$\"}}", Map.class);
Assert.assertTrue(obj == obj.get("value"));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/JSONObjectTest6.java
3 issues
Line: 9
public class JSONObjectTest6 extends TestCase {
public void test() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("value", 123);
Model model = jsonObject.toJavaObject(Model.class);
assertEquals(123, model.value);
Reported by PMD.
Line: 14
jsonObject.put("value", 123);
Model model = jsonObject.toJavaObject(Model.class);
assertEquals(123, model.value);
}
public static class Model {
public int value;
}
Reported by PMD.
Line: 18
}
public static class Model {
public int value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/CurrencyTest.java
3 issues
Line: 16
VO vo = new VO();
vo.setValue(Currency.getInstance(Locale.CHINA));
String text = JSON.toJSONString(vo);
System.out.println(text);
JSON.parseObject(text, VO.class);
}
public static class VO {
Reported by PMD.
Line: 12
public class CurrencyTest extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.setValue(Currency.getInstance(Locale.CHINA));
String text = JSON.toJSONString(vo);
System.out.println(text);
JSON.parseObject(text, VO.class);
Reported by PMD.
Line: 12
public class CurrencyTest extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.setValue(Currency.getInstance(Locale.CHINA));
String text = JSON.toJSONString(vo);
System.out.println(text);
JSON.parseObject(text, VO.class);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/JSONObjectTest_getObj_2.java
3 issues
Line: 16
public class JSONObjectTest_getObj_2 extends TestCase {
public void test_get_empty() throws Exception {
JSONObject obj = new JSONObject();
obj.put("value", "");
Assert.assertEquals("", obj.get("value"));
Assert.assertNull(obj.getObject("value", Model.class));
}
Reported by PMD.
Line: 23
Assert.assertNull(obj.getObject("value", Model.class));
}
public void test_get_null() throws Exception {
TypeUtils.cast("null", getType(), ParserConfig.getGlobalInstance());
TypeUtils.cast("", getType(), ParserConfig.getGlobalInstance());
}
public static class Model {
Reported by PMD.
Line: 23
Assert.assertNull(obj.getObject("value", Model.class));
}
public void test_get_null() throws Exception {
TypeUtils.cast("null", getType(), ParserConfig.getGlobalInstance());
TypeUtils.cast("", getType(), ParserConfig.getGlobalInstance());
}
public static class Model {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/CircularReferenceTest.java
3 issues
Line: 12
public class CircularReferenceTest extends TestCase {
public void test_0() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream objectOut = new ObjectOutputStream(out);
Category p = new Category();
p.setId(1);
Reported by PMD.
Line: 12
public class CircularReferenceTest extends TestCase {
public void test_0() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream objectOut = new ObjectOutputStream(out);
Category p = new Category();
p.setId(1);
Reported by PMD.
Line: 23
Category child = new Category();
child.setId(2);
child.setName("child");
p.getChildren().add(child);
child.setParent(p);
}
objectOut.writeObject(p);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue944.java
3 issues
Line: 13
* Created by wenshao on 19/12/2016.
*/
public class Issue944 extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
model.id = 1001;
String text = JSON.toJSONString(model, SerializerFeature.SkipTransientField);
Reported by PMD.
Line: 19
String text = JSON.toJSONString(model, SerializerFeature.SkipTransientField);
assertEquals("{}", text);
}
public static class Model {
private int id;
Reported by PMD.
Line: 23
}
public static class Model {
private int id;
@Transient
public int getId() {
return id;
}
Reported by PMD.