The following issues were found
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_list_obj_first_public.java
17 issues
Line: 16
public class WriteAsArray_list_obj_first_public extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.setId(123);
vo.setName("wenshao");
vo.getFvalues().add(new A());
Reported by PMD.
Line: 26
Assert.assertEquals("[[[0]],123,\"wenshao\"]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getFvalues().size(), vo2.getFvalues().size());
Assert.assertEquals(vo.getFvalues().get(0).getClass(), vo2.getFvalues().get(0).getClass());
Assert.assertEquals(vo.getFvalues().get(0).getValue(), vo2.getFvalues().get(0).getValue());
}
Reported by PMD.
Line: 27
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getFvalues().size(), vo2.getFvalues().size());
Assert.assertEquals(vo.getFvalues().get(0).getClass(), vo2.getFvalues().get(0).getClass());
Assert.assertEquals(vo.getFvalues().get(0).getValue(), vo2.getFvalues().get(0).getValue());
}
Reported by PMD.
Line: 28
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getFvalues().size(), vo2.getFvalues().size());
Assert.assertEquals(vo.getFvalues().get(0).getClass(), vo2.getFvalues().get(0).getClass());
Assert.assertEquals(vo.getFvalues().get(0).getValue(), vo2.getFvalues().get(0).getValue());
}
public static class VO {
Reported by PMD.
Line: 28
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getFvalues().size(), vo2.getFvalues().size());
Assert.assertEquals(vo.getFvalues().get(0).getClass(), vo2.getFvalues().get(0).getClass());
Assert.assertEquals(vo.getFvalues().get(0).getValue(), vo2.getFvalues().get(0).getValue());
}
public static class VO {
Reported by PMD.
Line: 28
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getFvalues().size(), vo2.getFvalues().size());
Assert.assertEquals(vo.getFvalues().get(0).getClass(), vo2.getFvalues().get(0).getClass());
Assert.assertEquals(vo.getFvalues().get(0).getValue(), vo2.getFvalues().get(0).getValue());
}
public static class VO {
Reported by PMD.
Line: 29
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getFvalues().size(), vo2.getFvalues().size());
Assert.assertEquals(vo.getFvalues().get(0).getClass(), vo2.getFvalues().get(0).getClass());
Assert.assertEquals(vo.getFvalues().get(0).getValue(), vo2.getFvalues().get(0).getValue());
}
public static class VO {
Reported by PMD.
Line: 29
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getFvalues().size(), vo2.getFvalues().size());
Assert.assertEquals(vo.getFvalues().get(0).getClass(), vo2.getFvalues().get(0).getClass());
Assert.assertEquals(vo.getFvalues().get(0).getValue(), vo2.getFvalues().get(0).getValue());
}
public static class VO {
Reported by PMD.
Line: 29
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getFvalues().size(), vo2.getFvalues().size());
Assert.assertEquals(vo.getFvalues().get(0).getClass(), vo2.getFvalues().get(0).getClass());
Assert.assertEquals(vo.getFvalues().get(0).getValue(), vo2.getFvalues().get(0).getValue());
}
public static class VO {
Reported by PMD.
Line: 29
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getFvalues().size(), vo2.getFvalues().size());
Assert.assertEquals(vo.getFvalues().get(0).getClass(), vo2.getFvalues().get(0).getClass());
Assert.assertEquals(vo.getFvalues().get(0).getValue(), vo2.getFvalues().get(0).getValue());
}
public static class VO {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/deny/DenyTest10.java
17 issues
Line: 41
}
public void test_uuid() throws Exception {
System.out.println(UUID.randomUUID());
Object obj = JSON.parseObject("{\"@type\":\"java.util.UUID\",\"val\":\"290c580d-efa3-432b-8475-2655e336232a\"}", Object.class, config);
assertEquals(UUID.class, obj.getClass());
}
}
Reported by PMD.
Line: 14
import java.util.concurrent.ConcurrentHashMap;
public class DenyTest10 extends TestCase {
ParserConfig config = new ParserConfig();
protected void setUp() throws Exception {
assertFalse(config.isAutoTypeSupport());
Properties properties = new Properties();
Reported by PMD.
Line: 16
public class DenyTest10 extends TestCase {
ParserConfig config = new ParserConfig();
protected void setUp() throws Exception {
assertFalse(config.isAutoTypeSupport());
Properties properties = new Properties();
properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
// -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.DenyTest9
Reported by PMD.
Line: 17
ParserConfig config = new ParserConfig();
protected void setUp() throws Exception {
assertFalse(config.isAutoTypeSupport());
Properties properties = new Properties();
properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
// -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.DenyTest9
config.configFromPropety(properties);
Reported by PMD.
Line: 25
config.configFromPropety(properties);
}
public void test_hashMap() throws Exception {
Object obj = JSON.parseObject("{\"@type\":\"java.util.HashMap\"}", Object.class, config);
assertEquals(HashMap.class, obj.getClass());
}
public void test_hashMap_weekHashMap() throws Exception {
Reported by PMD.
Line: 27
public void test_hashMap() throws Exception {
Object obj = JSON.parseObject("{\"@type\":\"java.util.HashMap\"}", Object.class, config);
assertEquals(HashMap.class, obj.getClass());
}
public void test_hashMap_weekHashMap() throws Exception {
Object obj = JSON.parseObject("{\"@type\":\"java.util.WeakHashMap\"}", Object.class, config);
assertEquals(WeakHashMap.class, obj.getClass());
Reported by PMD.
Line: 27
public void test_hashMap() throws Exception {
Object obj = JSON.parseObject("{\"@type\":\"java.util.HashMap\"}", Object.class, config);
assertEquals(HashMap.class, obj.getClass());
}
public void test_hashMap_weekHashMap() throws Exception {
Object obj = JSON.parseObject("{\"@type\":\"java.util.WeakHashMap\"}", Object.class, config);
assertEquals(WeakHashMap.class, obj.getClass());
Reported by PMD.
Line: 27
public void test_hashMap() throws Exception {
Object obj = JSON.parseObject("{\"@type\":\"java.util.HashMap\"}", Object.class, config);
assertEquals(HashMap.class, obj.getClass());
}
public void test_hashMap_weekHashMap() throws Exception {
Object obj = JSON.parseObject("{\"@type\":\"java.util.WeakHashMap\"}", Object.class, config);
assertEquals(WeakHashMap.class, obj.getClass());
Reported by PMD.
Line: 30
assertEquals(HashMap.class, obj.getClass());
}
public void test_hashMap_weekHashMap() throws Exception {
Object obj = JSON.parseObject("{\"@type\":\"java.util.WeakHashMap\"}", Object.class, config);
assertEquals(WeakHashMap.class, obj.getClass());
}
public void test_hashMap_concurrentHashMap() throws Exception {
Reported by PMD.
Line: 32
public void test_hashMap_weekHashMap() throws Exception {
Object obj = JSON.parseObject("{\"@type\":\"java.util.WeakHashMap\"}", Object.class, config);
assertEquals(WeakHashMap.class, obj.getClass());
}
public void test_hashMap_concurrentHashMap() throws Exception {
Object obj = JSON.parseObject("{\"@type\":\"java.util.concurrent.ConcurrentHashMap\"}", Object.class, config);
assertEquals(ConcurrentHashMap.class, obj.getClass());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_calenar_test.java
17 issues
Line: 12
import java.util.Map;
public class JSONPath_calenar_test extends TestCase {
public void test_map() throws Exception {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2017);
calendar.set(Calendar.MONTH, 6);
calendar.set(Calendar.DAY_OF_MONTH, 30);
Reported by PMD.
Line: 12
import java.util.Map;
public class JSONPath_calenar_test extends TestCase {
public void test_map() throws Exception {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2017);
calendar.set(Calendar.MONTH, 6);
calendar.set(Calendar.DAY_OF_MONTH, 30);
Reported by PMD.
Line: 14
public class JSONPath_calenar_test extends TestCase {
public void test_map() throws Exception {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2017);
calendar.set(Calendar.MONTH, 6);
calendar.set(Calendar.DAY_OF_MONTH, 30);
calendar.set(Calendar.HOUR_OF_DAY, 16);
calendar.set(Calendar.MINUTE, 8);
Reported by PMD.
Line: 15
public void test_map() throws Exception {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2017);
calendar.set(Calendar.MONTH, 6);
calendar.set(Calendar.DAY_OF_MONTH, 30);
calendar.set(Calendar.HOUR_OF_DAY, 16);
calendar.set(Calendar.MINUTE, 8);
calendar.set(Calendar.SECOND, 43);
Reported by PMD.
Line: 16
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2017);
calendar.set(Calendar.MONTH, 6);
calendar.set(Calendar.DAY_OF_MONTH, 30);
calendar.set(Calendar.HOUR_OF_DAY, 16);
calendar.set(Calendar.MINUTE, 8);
calendar.set(Calendar.SECOND, 43);
Reported by PMD.
Line: 18
calendar.set(Calendar.MONTH, 6);
calendar.set(Calendar.DAY_OF_MONTH, 30);
calendar.set(Calendar.HOUR_OF_DAY, 16);
calendar.set(Calendar.MINUTE, 8);
calendar.set(Calendar.SECOND, 43);
assertEquals(2017, JSONPath.eval(calendar, "/year"));
assertEquals(6, JSONPath.eval(calendar, "/month"));
Reported by PMD.
Line: 19
calendar.set(Calendar.DAY_OF_MONTH, 30);
calendar.set(Calendar.HOUR_OF_DAY, 16);
calendar.set(Calendar.MINUTE, 8);
calendar.set(Calendar.SECOND, 43);
assertEquals(2017, JSONPath.eval(calendar, "/year"));
assertEquals(6, JSONPath.eval(calendar, "/month"));
assertEquals(30, JSONPath.eval(calendar, "/day"));
Reported by PMD.
Line: 20
calendar.set(Calendar.HOUR_OF_DAY, 16);
calendar.set(Calendar.MINUTE, 8);
calendar.set(Calendar.SECOND, 43);
assertEquals(2017, JSONPath.eval(calendar, "/year"));
assertEquals(6, JSONPath.eval(calendar, "/month"));
assertEquals(30, JSONPath.eval(calendar, "/day"));
Reported by PMD.
Line: 22
calendar.set(Calendar.MINUTE, 8);
calendar.set(Calendar.SECOND, 43);
assertEquals(2017, JSONPath.eval(calendar, "/year"));
assertEquals(6, JSONPath.eval(calendar, "/month"));
assertEquals(30, JSONPath.eval(calendar, "/day"));
assertEquals(16, JSONPath.eval(calendar, "/hour"));
assertEquals(8, JSONPath.eval(calendar, "/minute"));
Reported by PMD.
Line: 23
calendar.set(Calendar.SECOND, 43);
assertEquals(2017, JSONPath.eval(calendar, "/year"));
assertEquals(6, JSONPath.eval(calendar, "/month"));
assertEquals(30, JSONPath.eval(calendar, "/day"));
assertEquals(16, JSONPath.eval(calendar, "/hour"));
assertEquals(8, JSONPath.eval(calendar, "/minute"));
assertEquals(43, JSONPath.eval(calendar, "/second"));
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/JSONLexerAllowCommentTest.java
17 issues
Line: 22
String jsonWithComment = "{ /*tes****\n\r\n*t*/\"a\":1 /*****test88888*****/ /*test*/ , /*test*/ //test\n //est\n \"b\":2}";
JSONObject object = JSON.parseObject(jsonWithComment, Feature.AllowComment, Feature.OrderedField);
System.out.println(object.toJSONString());
Assert.assertEquals("{\"a\":1,\"b\":2}",object.toJSONString());
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner(jsonWithComment,
Feature.AllowComment.getMask() | Feature.OrderedField.getMask()));
Reported by PMD.
Line: 30
JSONObject object1 = parser.parseObject();
Assert.assertEquals("{\"a\":1,\"b\":2}",object1.toJSONString());
System.out.println(object1.toJSONString());
}
public void test_1() throws IOException {
String resource = "json/json_with_comment.json";
Reported by PMD.
Line: 42
is.close();
JSONObject object = JSON.parseObject(text, Feature.AllowComment, Feature.OrderedField);
System.out.println(object.toJSONString());
Assert
.assertEquals(
"{\"hello\":\"asafsadf\",\"test\":1,\"array\":[\"10000sfsaf\",100,{\"nihao\":{\"test\":\"sdfasdf\"}}],\"object\":{\"teset\":1000}}",
object.toJSONString());
Reported by PMD.
Line: 18
import com.alibaba.fastjson.parser.JSONReaderScanner;
public class JSONLexerAllowCommentTest extends TestCase {
public void test_0() throws Exception {
String jsonWithComment = "{ /*tes****\n\r\n*t*/\"a\":1 /*****test88888*****/ /*test*/ , /*test*/ //test\n //est\n \"b\":2}";
JSONObject object = JSON.parseObject(jsonWithComment, Feature.AllowComment, Feature.OrderedField);
System.out.println(object.toJSONString());
Assert.assertEquals("{\"a\":1,\"b\":2}",object.toJSONString());
Reported by PMD.
Line: 22
String jsonWithComment = "{ /*tes****\n\r\n*t*/\"a\":1 /*****test88888*****/ /*test*/ , /*test*/ //test\n //est\n \"b\":2}";
JSONObject object = JSON.parseObject(jsonWithComment, Feature.AllowComment, Feature.OrderedField);
System.out.println(object.toJSONString());
Assert.assertEquals("{\"a\":1,\"b\":2}",object.toJSONString());
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner(jsonWithComment,
Feature.AllowComment.getMask() | Feature.OrderedField.getMask()));
Reported by PMD.
Line: 23
String jsonWithComment = "{ /*tes****\n\r\n*t*/\"a\":1 /*****test88888*****/ /*test*/ , /*test*/ //test\n //est\n \"b\":2}";
JSONObject object = JSON.parseObject(jsonWithComment, Feature.AllowComment, Feature.OrderedField);
System.out.println(object.toJSONString());
Assert.assertEquals("{\"a\":1,\"b\":2}",object.toJSONString());
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner(jsonWithComment,
Feature.AllowComment.getMask() | Feature.OrderedField.getMask()));
JSONObject object1 = parser.parseObject();
Reported by PMD.
Line: 26
Assert.assertEquals("{\"a\":1,\"b\":2}",object.toJSONString());
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner(jsonWithComment,
Feature.AllowComment.getMask() | Feature.OrderedField.getMask()));
JSONObject object1 = parser.parseObject();
Assert.assertEquals("{\"a\":1,\"b\":2}",object1.toJSONString());
System.out.println(object1.toJSONString());
Reported by PMD.
Line: 26
Assert.assertEquals("{\"a\":1,\"b\":2}",object.toJSONString());
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner(jsonWithComment,
Feature.AllowComment.getMask() | Feature.OrderedField.getMask()));
JSONObject object1 = parser.parseObject();
Assert.assertEquals("{\"a\":1,\"b\":2}",object1.toJSONString());
System.out.println(object1.toJSONString());
Reported by PMD.
Line: 29
Feature.AllowComment.getMask() | Feature.OrderedField.getMask()));
JSONObject object1 = parser.parseObject();
Assert.assertEquals("{\"a\":1,\"b\":2}",object1.toJSONString());
System.out.println(object1.toJSONString());
}
public void test_1() throws IOException {
Reported by PMD.
Line: 30
JSONObject object1 = parser.parseObject();
Assert.assertEquals("{\"a\":1,\"b\":2}",object1.toJSONString());
System.out.println(object1.toJSONString());
}
public void test_1() throws IOException {
String resource = "json/json_with_comment.json";
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/SerializeWriterTest_BrowserSecure_4_script.java
17 issues
Line: 14
public class SerializeWriterTest_BrowserSecure_4_script extends TestCase {
public void test_0() throws Exception {
JSONObject object = new JSONObject();
object.put("value", "<script>alert(1);</script>");
String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);
Reported by PMD.
Line: 14
public class SerializeWriterTest_BrowserSecure_4_script extends TestCase {
public void test_0() throws Exception {
JSONObject object = new JSONObject();
object.put("value", "<script>alert(1);</script>");
String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);
Reported by PMD.
Line: 19
object.put("value", "<script>alert(1);</script>");
String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);
JSONObject object1 = JSON.parseObject(text);
assertEquals(object.get("value"), object1.get("value"));
}
public void test_1() throws Exception {
Reported by PMD.
Line: 21
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);
JSONObject object1 = JSON.parseObject(text);
assertEquals(object.get("value"), object1.get("value"));
}
public void test_1() throws Exception {
String text = JSON.toJSONString("<", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003C\"", text);
Reported by PMD.
Line: 21
// assertEquals("{\"value\":\"<script>alert(1);<\\/script>\"}", text);
assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);
JSONObject object1 = JSON.parseObject(text);
assertEquals(object.get("value"), object1.get("value"));
}
public void test_1() throws Exception {
String text = JSON.toJSONString("<", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003C\"", text);
Reported by PMD.
Line: 24
assertEquals(object.get("value"), object1.get("value"));
}
public void test_1() throws Exception {
String text = JSON.toJSONString("<", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003C\"", text);
}
public void test_2() throws Exception {
Reported by PMD.
Line: 26
public void test_1() throws Exception {
String text = JSON.toJSONString("<", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003C\"", text);
}
public void test_2() throws Exception {
String text = JSON.toJSONString("<script>", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003Cscript\\u003E\"", text);
Reported by PMD.
Line: 29
assertEquals("\"\\u003C\"", text);
}
public void test_2() throws Exception {
String text = JSON.toJSONString("<script>", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003Cscript\\u003E\"", text);
}
public void test_3() throws Exception {
Reported by PMD.
Line: 31
public void test_2() throws Exception {
String text = JSON.toJSONString("<script>", SerializerFeature.BrowserSecure);
assertEquals("\"\\u003Cscript\\u003E\"", text);
}
public void test_3() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 500; i++) {
Reported by PMD.
Line: 34
assertEquals("\"\\u003Cscript\\u003E\"", text);
}
public void test_3() throws Exception {
StringBuilder buf = new StringBuilder();
for (int i = 0; i < 500; i++) {
buf.append("<script>");
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/joda/JodaTest_2_LocalDateTimeTest3_private.java
17 issues
Line: 12
public class JodaTest_2_LocalDateTimeTest3_private extends TestCase {
public void test_for_issue() throws Exception {
String text = "{\"date\":\"20111203\"}";
VO vo = JSON.parseObject(text, VO.class);
assertEquals(2011, vo.date.getYear());
assertEquals(12, vo.date.getMonthOfYear());
Reported by PMD.
Line: 12
public class JodaTest_2_LocalDateTimeTest3_private extends TestCase {
public void test_for_issue() throws Exception {
String text = "{\"date\":\"20111203\"}";
VO vo = JSON.parseObject(text, VO.class);
assertEquals(2011, vo.date.getYear());
assertEquals(12, vo.date.getMonthOfYear());
Reported by PMD.
Line: 16
String text = "{\"date\":\"20111203\"}";
VO vo = JSON.parseObject(text, VO.class);
assertEquals(2011, vo.date.getYear());
assertEquals(12, vo.date.getMonthOfYear());
assertEquals(03, vo.date.getDayOfMonth());
assertEquals(0, vo.date.getHourOfDay());
assertEquals(0, vo.date.getMinuteOfHour());
assertEquals(0, vo.date.getSecondOfMinute());
Reported by PMD.
Line: 16
String text = "{\"date\":\"20111203\"}";
VO vo = JSON.parseObject(text, VO.class);
assertEquals(2011, vo.date.getYear());
assertEquals(12, vo.date.getMonthOfYear());
assertEquals(03, vo.date.getDayOfMonth());
assertEquals(0, vo.date.getHourOfDay());
assertEquals(0, vo.date.getMinuteOfHour());
assertEquals(0, vo.date.getSecondOfMinute());
Reported by PMD.
Line: 17
VO vo = JSON.parseObject(text, VO.class);
assertEquals(2011, vo.date.getYear());
assertEquals(12, vo.date.getMonthOfYear());
assertEquals(03, vo.date.getDayOfMonth());
assertEquals(0, vo.date.getHourOfDay());
assertEquals(0, vo.date.getMinuteOfHour());
assertEquals(0, vo.date.getSecondOfMinute());
Reported by PMD.
Line: 17
VO vo = JSON.parseObject(text, VO.class);
assertEquals(2011, vo.date.getYear());
assertEquals(12, vo.date.getMonthOfYear());
assertEquals(03, vo.date.getDayOfMonth());
assertEquals(0, vo.date.getHourOfDay());
assertEquals(0, vo.date.getMinuteOfHour());
assertEquals(0, vo.date.getSecondOfMinute());
Reported by PMD.
Line: 18
assertEquals(2011, vo.date.getYear());
assertEquals(12, vo.date.getMonthOfYear());
assertEquals(03, vo.date.getDayOfMonth());
assertEquals(0, vo.date.getHourOfDay());
assertEquals(0, vo.date.getMinuteOfHour());
assertEquals(0, vo.date.getSecondOfMinute());
assertEquals(text, JSON.toJSONString(vo));
Reported by PMD.
Line: 18
assertEquals(2011, vo.date.getYear());
assertEquals(12, vo.date.getMonthOfYear());
assertEquals(03, vo.date.getDayOfMonth());
assertEquals(0, vo.date.getHourOfDay());
assertEquals(0, vo.date.getMinuteOfHour());
assertEquals(0, vo.date.getSecondOfMinute());
assertEquals(text, JSON.toJSONString(vo));
Reported by PMD.
Line: 19
assertEquals(2011, vo.date.getYear());
assertEquals(12, vo.date.getMonthOfYear());
assertEquals(03, vo.date.getDayOfMonth());
assertEquals(0, vo.date.getHourOfDay());
assertEquals(0, vo.date.getMinuteOfHour());
assertEquals(0, vo.date.getSecondOfMinute());
assertEquals(text, JSON.toJSONString(vo));
}
Reported by PMD.
Line: 19
assertEquals(2011, vo.date.getYear());
assertEquals(12, vo.date.getMonthOfYear());
assertEquals(03, vo.date.getDayOfMonth());
assertEquals(0, vo.date.getHourOfDay());
assertEquals(0, vo.date.getMinuteOfHour());
assertEquals(0, vo.date.getSecondOfMinute());
assertEquals(text, JSON.toJSONString(vo));
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/FeatureParserTest.java
17 issues
Line: 18
parser.config(Feature.AllowSingleQuotes, true);
JSONObject json = (JSONObject) parser.parse();
Assert.assertEquals(1, json.size());
Assert.assertEquals(new Integer(3), (Integer) json.getInteger("a"));
}
public void test_AllowSingleQuotes_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{'a':'3'}");
parser.config(Feature.AllowSingleQuotes, true);
Reported by PMD.
Line: 34
parser.config(Feature.AllowUnQuotedFieldNames, true);
JSONObject json = (JSONObject) parser.parse();
Assert.assertEquals(1, json.size());
Assert.assertEquals(new Integer(3), (Integer) json.getInteger("a"));
}
public void test_error_0() throws Exception {
JSONException error = null;
try {
Reported by PMD.
Line: 13
public class FeatureParserTest extends TestCase {
public void test_AllowSingleQuotes_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{'a':3}");
parser.config(Feature.AllowSingleQuotes, true);
JSONObject json = (JSONObject) parser.parse();
Assert.assertEquals(1, json.size());
Assert.assertEquals(new Integer(3), (Integer) json.getInteger("a"));
Reported by PMD.
Line: 17
DefaultJSONParser parser = new DefaultJSONParser("{'a':3}");
parser.config(Feature.AllowSingleQuotes, true);
JSONObject json = (JSONObject) parser.parse();
Assert.assertEquals(1, json.size());
Assert.assertEquals(new Integer(3), (Integer) json.getInteger("a"));
}
public void test_AllowSingleQuotes_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{'a':'3'}");
Reported by PMD.
Line: 18
parser.config(Feature.AllowSingleQuotes, true);
JSONObject json = (JSONObject) parser.parse();
Assert.assertEquals(1, json.size());
Assert.assertEquals(new Integer(3), (Integer) json.getInteger("a"));
}
public void test_AllowSingleQuotes_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{'a':'3'}");
parser.config(Feature.AllowSingleQuotes, true);
Reported by PMD.
Line: 21
Assert.assertEquals(new Integer(3), (Integer) json.getInteger("a"));
}
public void test_AllowSingleQuotes_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{'a':'3'}");
parser.config(Feature.AllowSingleQuotes, true);
JSONObject json = (JSONObject) parser.parse();
Assert.assertEquals(1, json.size());
Assert.assertEquals("3", (String) json.get("a"));
Reported by PMD.
Line: 25
DefaultJSONParser parser = new DefaultJSONParser("{'a':'3'}");
parser.config(Feature.AllowSingleQuotes, true);
JSONObject json = (JSONObject) parser.parse();
Assert.assertEquals(1, json.size());
Assert.assertEquals("3", (String) json.get("a"));
}
public void test_AllowUnQuotedFieldNames_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{a:3}");
Reported by PMD.
Line: 26
parser.config(Feature.AllowSingleQuotes, true);
JSONObject json = (JSONObject) parser.parse();
Assert.assertEquals(1, json.size());
Assert.assertEquals("3", (String) json.get("a"));
}
public void test_AllowUnQuotedFieldNames_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{a:3}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
Reported by PMD.
Line: 29
Assert.assertEquals("3", (String) json.get("a"));
}
public void test_AllowUnQuotedFieldNames_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{a:3}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
JSONObject json = (JSONObject) parser.parse();
Assert.assertEquals(1, json.size());
Assert.assertEquals(new Integer(3), (Integer) json.getInteger("a"));
Reported by PMD.
Line: 33
DefaultJSONParser parser = new DefaultJSONParser("{a:3}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
JSONObject json = (JSONObject) parser.parse();
Assert.assertEquals(1, json.size());
Assert.assertEquals(new Integer(3), (Integer) json.getInteger("a"));
}
public void test_error_0() throws Exception {
JSONException error = null;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/exception/RuntimeExceptionTest.java
17 issues
Line: 11
public class RuntimeExceptionTest extends TestCase {
public void test_0() throws Exception {
RuntimeException ex = new RuntimeException();
JSONObject json = JSON.parseObject(JSON.toJSONString(ex));
// Assert.assertEquals(RuntimeException.class.getName(), json.get("@type"));
Reported by PMD.
Line: 14
public void test_0() throws Exception {
RuntimeException ex = new RuntimeException();
JSONObject json = JSON.parseObject(JSON.toJSONString(ex));
// Assert.assertEquals(RuntimeException.class.getName(), json.get("@type"));
String jsonString = JSON.toJSONString(ex);
Exception ex1 = JSON.parseObject(jsonString, Exception.class);
Reported by PMD.
Line: 20
String jsonString = JSON.toJSONString(ex);
Exception ex1 = JSON.parseObject(jsonString, Exception.class);
Assert.assertEquals(ex.getMessage(), ex1.getMessage());
Assert.assertEquals(ex.getStackTrace().length, ex1.getStackTrace().length);
for (int i = 0; i < ex.getStackTrace().length; ++i) {
Assert.assertEquals(ex.getStackTrace()[i].getClassName(), ex1.getStackTrace()[i].getClassName());
Assert.assertEquals(ex.getStackTrace()[i].getFileName(), ex1.getStackTrace()[i].getFileName());
Reported by PMD.
Line: 21
Exception ex1 = JSON.parseObject(jsonString, Exception.class);
Assert.assertEquals(ex.getMessage(), ex1.getMessage());
Assert.assertEquals(ex.getStackTrace().length, ex1.getStackTrace().length);
for (int i = 0; i < ex.getStackTrace().length; ++i) {
Assert.assertEquals(ex.getStackTrace()[i].getClassName(), ex1.getStackTrace()[i].getClassName());
Assert.assertEquals(ex.getStackTrace()[i].getFileName(), ex1.getStackTrace()[i].getFileName());
Assert.assertEquals(ex.getStackTrace()[i].getLineNumber(), ex1.getStackTrace()[i].getLineNumber());
Reported by PMD.
Line: 21
Exception ex1 = JSON.parseObject(jsonString, Exception.class);
Assert.assertEquals(ex.getMessage(), ex1.getMessage());
Assert.assertEquals(ex.getStackTrace().length, ex1.getStackTrace().length);
for (int i = 0; i < ex.getStackTrace().length; ++i) {
Assert.assertEquals(ex.getStackTrace()[i].getClassName(), ex1.getStackTrace()[i].getClassName());
Assert.assertEquals(ex.getStackTrace()[i].getFileName(), ex1.getStackTrace()[i].getFileName());
Assert.assertEquals(ex.getStackTrace()[i].getLineNumber(), ex1.getStackTrace()[i].getLineNumber());
Reported by PMD.
Line: 21
Exception ex1 = JSON.parseObject(jsonString, Exception.class);
Assert.assertEquals(ex.getMessage(), ex1.getMessage());
Assert.assertEquals(ex.getStackTrace().length, ex1.getStackTrace().length);
for (int i = 0; i < ex.getStackTrace().length; ++i) {
Assert.assertEquals(ex.getStackTrace()[i].getClassName(), ex1.getStackTrace()[i].getClassName());
Assert.assertEquals(ex.getStackTrace()[i].getFileName(), ex1.getStackTrace()[i].getFileName());
Assert.assertEquals(ex.getStackTrace()[i].getLineNumber(), ex1.getStackTrace()[i].getLineNumber());
Reported by PMD.
Line: 23
Assert.assertEquals(ex.getMessage(), ex1.getMessage());
Assert.assertEquals(ex.getStackTrace().length, ex1.getStackTrace().length);
for (int i = 0; i < ex.getStackTrace().length; ++i) {
Assert.assertEquals(ex.getStackTrace()[i].getClassName(), ex1.getStackTrace()[i].getClassName());
Assert.assertEquals(ex.getStackTrace()[i].getFileName(), ex1.getStackTrace()[i].getFileName());
Assert.assertEquals(ex.getStackTrace()[i].getLineNumber(), ex1.getStackTrace()[i].getLineNumber());
Assert.assertEquals(ex.getStackTrace()[i].getMethodName(), ex1.getStackTrace()[i].getMethodName());
}
Reported by PMD.
Line: 24
Assert.assertEquals(ex.getStackTrace().length, ex1.getStackTrace().length);
for (int i = 0; i < ex.getStackTrace().length; ++i) {
Assert.assertEquals(ex.getStackTrace()[i].getClassName(), ex1.getStackTrace()[i].getClassName());
Assert.assertEquals(ex.getStackTrace()[i].getFileName(), ex1.getStackTrace()[i].getFileName());
Assert.assertEquals(ex.getStackTrace()[i].getLineNumber(), ex1.getStackTrace()[i].getLineNumber());
Assert.assertEquals(ex.getStackTrace()[i].getMethodName(), ex1.getStackTrace()[i].getMethodName());
}
Reported by PMD.
Line: 24
Assert.assertEquals(ex.getStackTrace().length, ex1.getStackTrace().length);
for (int i = 0; i < ex.getStackTrace().length; ++i) {
Assert.assertEquals(ex.getStackTrace()[i].getClassName(), ex1.getStackTrace()[i].getClassName());
Assert.assertEquals(ex.getStackTrace()[i].getFileName(), ex1.getStackTrace()[i].getFileName());
Assert.assertEquals(ex.getStackTrace()[i].getLineNumber(), ex1.getStackTrace()[i].getLineNumber());
Assert.assertEquals(ex.getStackTrace()[i].getMethodName(), ex1.getStackTrace()[i].getMethodName());
}
Reported by PMD.
Line: 25
for (int i = 0; i < ex.getStackTrace().length; ++i) {
Assert.assertEquals(ex.getStackTrace()[i].getClassName(), ex1.getStackTrace()[i].getClassName());
Assert.assertEquals(ex.getStackTrace()[i].getFileName(), ex1.getStackTrace()[i].getFileName());
Assert.assertEquals(ex.getStackTrace()[i].getLineNumber(), ex1.getStackTrace()[i].getLineNumber());
Assert.assertEquals(ex.getStackTrace()[i].getMethodName(), ex1.getStackTrace()[i].getMethodName());
}
Assert.assertEquals(ex1.getClass(), ex.getClass());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_list_obj_public.java
17 issues
Line: 16
public class WriteAsArray_list_obj_public extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.setId(123);
vo.setName("wenshao");
vo.getValues().add(new A());
Reported by PMD.
Line: 26
Assert.assertEquals("[123,\"wenshao\",[[0]]]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
Assert.assertEquals(vo.getValues().get(0).getClass(), vo2.getValues().get(0).getClass());
Assert.assertEquals(vo.getValues().get(0).getValue(), vo2.getValues().get(0).getValue());
}
Reported by PMD.
Line: 27
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
Assert.assertEquals(vo.getValues().get(0).getClass(), vo2.getValues().get(0).getClass());
Assert.assertEquals(vo.getValues().get(0).getValue(), vo2.getValues().get(0).getValue());
}
Reported by PMD.
Line: 28
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
Assert.assertEquals(vo.getValues().get(0).getClass(), vo2.getValues().get(0).getClass());
Assert.assertEquals(vo.getValues().get(0).getValue(), vo2.getValues().get(0).getValue());
}
public static class VO {
Reported by PMD.
Line: 28
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
Assert.assertEquals(vo.getValues().get(0).getClass(), vo2.getValues().get(0).getClass());
Assert.assertEquals(vo.getValues().get(0).getValue(), vo2.getValues().get(0).getValue());
}
public static class VO {
Reported by PMD.
Line: 28
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
Assert.assertEquals(vo.getValues().get(0).getClass(), vo2.getValues().get(0).getClass());
Assert.assertEquals(vo.getValues().get(0).getValue(), vo2.getValues().get(0).getValue());
}
public static class VO {
Reported by PMD.
Line: 29
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
Assert.assertEquals(vo.getValues().get(0).getClass(), vo2.getValues().get(0).getClass());
Assert.assertEquals(vo.getValues().get(0).getValue(), vo2.getValues().get(0).getValue());
}
public static class VO {
Reported by PMD.
Line: 29
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
Assert.assertEquals(vo.getValues().get(0).getClass(), vo2.getValues().get(0).getClass());
Assert.assertEquals(vo.getValues().get(0).getValue(), vo2.getValues().get(0).getValue());
}
public static class VO {
Reported by PMD.
Line: 29
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
Assert.assertEquals(vo.getValues().get(0).getClass(), vo2.getValues().get(0).getClass());
Assert.assertEquals(vo.getValues().get(0).getValue(), vo2.getValues().get(0).getValue());
}
public static class VO {
Reported by PMD.
Line: 29
Assert.assertEquals(vo.getId(), vo2.getId());
Assert.assertEquals(vo.getName(), vo2.getName());
Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
Assert.assertEquals(vo.getValues().get(0).getClass(), vo2.getValues().get(0).getClass());
Assert.assertEquals(vo.getValues().get(0).getValue(), vo2.getValues().get(0).getValue());
}
public static class VO {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/DefaultExtJSONParserTest_3.java
17 issues
Line: 15
public class DefaultExtJSONParserTest_3 extends TestCase {
public void test_0() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v1:3}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
}
Reported by PMD.
Line: 19
DefaultJSONParser parser = new DefaultJSONParser("{v1:3}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
}
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v1:'3'}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
Reported by PMD.
Line: 22
Assert.assertEquals(3, a.getV1());
}
public void test_1() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v1:'3'}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
Reported by PMD.
Line: 27
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
}
public void test_2() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v1:\"3\"}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
Reported by PMD.
Line: 30
Assert.assertEquals(3, a.getV1());
}
public void test_2() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v1:\"3\"}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
Reported by PMD.
Line: 35
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3, a.getV1());
}
public void test_3() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{o1:{}}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
Reported by PMD.
Line: 38
Assert.assertEquals(3, a.getV1());
}
public void test_3() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{o1:{}}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(true, a.getO1() != null);
Reported by PMD.
Line: 43
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(true, a.getO1() != null);
}
public void test_4() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v5:'3'}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
Reported by PMD.
Line: 46
Assert.assertEquals(true, a.getO1() != null);
}
public void test_4() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v5:'3'}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3L, a.getV5().longValue());
Reported by PMD.
Line: 51
parser.config(Feature.AllowUnQuotedFieldNames, true);
parser.config(Feature.AllowSingleQuotes, true);
A a = parser.parseObject(A.class);
Assert.assertEquals(3L, a.getV5().longValue());
}
public void test_5() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser("{v5:\"3\"}");
parser.config(Feature.AllowUnQuotedFieldNames, true);
Reported by PMD.