The following issues were found
src/test/java/com/alibaba/json/bvt/date/DateFormatPriorityTest.java
38 issues
Line: 24
public class DateFormatPriorityTest extends TestCase {
Calendar calendar;
protected void setUp() {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
Reported by PMD.
Line: 26
public class DateFormatPriorityTest extends TestCase {
Calendar calendar;
protected void setUp() {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
calendar = Calendar.getInstance(JSON.defaultTimeZone);
calendar.set(1995, Calendar.OCTOBER, 26);
Reported by PMD.
Line: 34
calendar.set(1995, Calendar.OCTOBER, 26);
}
public void test_for_fastJsonConfig() throws IOException {
FastJsonConfig config = new FastJsonConfig();
config.setDateFormat("yyyy-MM.dd");
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
converter.setFastJsonConfig(config);
Reported by PMD.
Line: 63
};
VO vo = new VO();
vo.setDate(calendar.getTime());
converter.write(vo, VO.class, MediaType.APPLICATION_JSON_UTF8, out);
byte[] bytes = byteOut.toByteArray();
String jsonString = new String(bytes, "UTF-8");
Reported by PMD.
Line: 72
Assert.assertEquals("{\"date\":\"1995-10.26\"}", jsonString);
}
public void test_for_toJSONStringWithDateFormat() {
VO vo = new VO();
vo.setDate(calendar.getTime());
String jsonString = JSON.toJSONStringWithDateFormat(vo, "yyyy.MM.dd");
Reported by PMD.
Line: 74
public void test_for_toJSONStringWithDateFormat() {
VO vo = new VO();
vo.setDate(calendar.getTime());
String jsonString = JSON.toJSONStringWithDateFormat(vo, "yyyy.MM.dd");
assertEquals("{\"date\":\"1995.10.26\"}", jsonString);
}
Reported by PMD.
Line: 78
String jsonString = JSON.toJSONStringWithDateFormat(vo, "yyyy.MM.dd");
assertEquals("{\"date\":\"1995.10.26\"}", jsonString);
}
public void test_for_Annotation() {
VO2 vo2 = new VO2();
vo2.setDate(calendar.getTime());
Reported by PMD.
Line: 81
assertEquals("{\"date\":\"1995.10.26\"}", jsonString);
}
public void test_for_Annotation() {
VO2 vo2 = new VO2();
vo2.setDate(calendar.getTime());
String jsonString = JSON.toJSONString(vo2);
Reported by PMD.
Line: 83
public void test_for_Annotation() {
VO2 vo2 = new VO2();
vo2.setDate(calendar.getTime());
String jsonString = JSON.toJSONString(vo2);
assertEquals("{\"date\":\"1995.10-26\"}", jsonString);
}
Reported by PMD.
Line: 87
String jsonString = JSON.toJSONString(vo2);
assertEquals("{\"date\":\"1995.10-26\"}", jsonString);
}
public void test_for_DEFFAULT_DATE_FORMAT() {
String defaultDateFormat = JSON.DEFFAULT_DATE_FORMAT;
Reported by PMD.
src/test/java/com/derbysoft/spitfire/fastjson/TestFastJson.java
38 issues
Line: 70
public void f_test() throws Exception {
String text = JSON.toJSONString(createTest(), SerializerFeature.WriteClassName);
System.out.println(text.length());
System.out.println(text);
System.out.println("serialize finished");
GenericRS<HotelAvailRS> o = (GenericRS<HotelAvailRS>) JSON.parseObject(text, GenericRS.class);
System.out.println(o);
Reported by PMD.
Line: 71
String text = JSON.toJSONString(createTest(), SerializerFeature.WriteClassName);
System.out.println(text.length());
System.out.println(text);
System.out.println("serialize finished");
GenericRS<HotelAvailRS> o = (GenericRS<HotelAvailRS>) JSON.parseObject(text, GenericRS.class);
System.out.println(o);
}
Reported by PMD.
Line: 72
String text = JSON.toJSONString(createTest(), SerializerFeature.WriteClassName);
System.out.println(text.length());
System.out.println(text);
System.out.println("serialize finished");
GenericRS<HotelAvailRS> o = (GenericRS<HotelAvailRS>) JSON.parseObject(text, GenericRS.class);
System.out.println(o);
}
Reported by PMD.
Line: 75
System.out.println("serialize finished");
GenericRS<HotelAvailRS> o = (GenericRS<HotelAvailRS>) JSON.parseObject(text, GenericRS.class);
System.out.println(o);
}
public void testFP() throws IOException {
Generic<String> q = new Generic<String>();
for (int x = 0; x < STAYS_COUNT; ++x) {
Reported by PMD.
Line: 88
}
stopWatch.stop();
System.out.println("JSON serialize:" + stopWatch.getTime());
stopWatch.reset();
stopWatch.start();
for (int i = 0; i < TIMES; ++i) {
javaSerialize(q);
Reported by PMD.
Line: 96
javaSerialize(q);
}
stopWatch.stop();
System.out.println("JAVA serialize:" + stopWatch.getTime());
System.out.println();
}
}
private <T> void jsonSerialize(T t) throws IOException {
Reported by PMD.
Line: 97
}
stopWatch.stop();
System.out.println("JAVA serialize:" + stopWatch.getTime());
System.out.println();
}
}
private <T> void jsonSerialize(T t) throws IOException {
// String text = JSON.toJSONString(t, SerializerFeature.WriteClassName, SerializerFeature.PrettyFormat);
Reported by PMD.
Line: 147
}
stopWatch.stop();
System.out.println("JSON serialize:" + stopWatch.getTime());
stopWatch.reset();
stopWatch.start();
for (int i = 0; i < TIMES; ++i) {
javaSerialize(obj);
Reported by PMD.
Line: 155
javaSerialize(obj);
}
stopWatch.stop();
System.out.println("JAVA serialize:" + stopWatch.getTime());
System.out.println();
}
}
public void testDeserializePerformance() throws IOException, ClassNotFoundException {
Reported by PMD.
Line: 156
}
stopWatch.stop();
System.out.println("JAVA serialize:" + stopWatch.getTime());
System.out.println();
}
}
public void testDeserializePerformance() throws IOException, ClassNotFoundException {
Object obj = createTest();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/ParserSpecialCharTest.java
37 issues
Line: 9
import com.alibaba.fastjson.JSON;
public class ParserSpecialCharTest extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals("\0", JSON.parseObject("{\"value\":\"\\0\"}", VO.class).getValue());
}
Reported by PMD.
Line: 11
public class ParserSpecialCharTest extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals("\0", JSON.parseObject("{\"value\":\"\\0\"}", VO.class).getValue());
}
public void test_1() throws Exception {
Assert.assertEquals("\1", JSON.parseObject("{\"value\":\"\\1\"}", VO.class).getValue());
Reported by PMD.
Line: 12
public class ParserSpecialCharTest extends TestCase {
public void test_0() throws Exception {
Assert.assertEquals("\0", JSON.parseObject("{\"value\":\"\\0\"}", VO.class).getValue());
}
public void test_1() throws Exception {
Assert.assertEquals("\1", JSON.parseObject("{\"value\":\"\\1\"}", VO.class).getValue());
}
Reported by PMD.
Line: 15
Assert.assertEquals("\0", JSON.parseObject("{\"value\":\"\\0\"}", VO.class).getValue());
}
public void test_1() throws Exception {
Assert.assertEquals("\1", JSON.parseObject("{\"value\":\"\\1\"}", VO.class).getValue());
}
public void test_2() throws Exception {
Assert.assertEquals("\2", JSON.parseObject("{\"value\":\"\\2\"}", VO.class).getValue());
Reported by PMD.
Line: 16
}
public void test_1() throws Exception {
Assert.assertEquals("\1", JSON.parseObject("{\"value\":\"\\1\"}", VO.class).getValue());
}
public void test_2() throws Exception {
Assert.assertEquals("\2", JSON.parseObject("{\"value\":\"\\2\"}", VO.class).getValue());
}
Reported by PMD.
Line: 19
Assert.assertEquals("\1", JSON.parseObject("{\"value\":\"\\1\"}", VO.class).getValue());
}
public void test_2() throws Exception {
Assert.assertEquals("\2", JSON.parseObject("{\"value\":\"\\2\"}", VO.class).getValue());
}
public void test_3() throws Exception {
Assert.assertEquals("\3", JSON.parseObject("{\"value\":\"\\3\"}", VO.class).getValue());
Reported by PMD.
Line: 20
}
public void test_2() throws Exception {
Assert.assertEquals("\2", JSON.parseObject("{\"value\":\"\\2\"}", VO.class).getValue());
}
public void test_3() throws Exception {
Assert.assertEquals("\3", JSON.parseObject("{\"value\":\"\\3\"}", VO.class).getValue());
}
Reported by PMD.
Line: 23
Assert.assertEquals("\2", JSON.parseObject("{\"value\":\"\\2\"}", VO.class).getValue());
}
public void test_3() throws Exception {
Assert.assertEquals("\3", JSON.parseObject("{\"value\":\"\\3\"}", VO.class).getValue());
}
public void test_4() throws Exception {
Assert.assertEquals("\4", JSON.parseObject("{\"value\":\"\\4\"}", VO.class).getValue());
Reported by PMD.
Line: 24
}
public void test_3() throws Exception {
Assert.assertEquals("\3", JSON.parseObject("{\"value\":\"\\3\"}", VO.class).getValue());
}
public void test_4() throws Exception {
Assert.assertEquals("\4", JSON.parseObject("{\"value\":\"\\4\"}", VO.class).getValue());
}
Reported by PMD.
Line: 27
Assert.assertEquals("\3", JSON.parseObject("{\"value\":\"\\3\"}", VO.class).getValue());
}
public void test_4() throws Exception {
Assert.assertEquals("\4", JSON.parseObject("{\"value\":\"\\4\"}", VO.class).getValue());
}
public void test_5() throws Exception {
Assert.assertEquals("\5", JSON.parseObject("{\"value\":\"\\5\"}", VO.class).getValue());
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_field_access_filter_in_int.java
37 issues
Line: 14
public class JSONPath_field_access_filter_in_int extends TestCase {
public void test_list_in() throws Exception {
JSONPath path = new JSONPath("[id in (1001)]");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
Reported by PMD.
Line: 18
JSONPath path = new JSONPath("[id in (1001)]");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, "yakolee"));
entities.add(new Entity(1004, null));
List<Object> result = (List<Object>) path.eval(entities);
Reported by PMD.
Line: 19
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, "yakolee"));
entities.add(new Entity(1004, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Reported by PMD.
Line: 20
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, "yakolee"));
entities.add(new Entity(1004, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Assert.assertSame(entities.get(0), result.get(0));
Reported by PMD.
Line: 24
entities.add(new Entity(1004, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Assert.assertSame(entities.get(0), result.get(0));
}
public void test_list_not_in() throws Exception {
JSONPath path = new JSONPath("[id not in (1001)]");
Reported by PMD.
Line: 25
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(1, result.size());
Assert.assertSame(entities.get(0), result.get(0));
}
public void test_list_not_in() throws Exception {
JSONPath path = new JSONPath("[id not in (1001)]");
Reported by PMD.
Line: 28
Assert.assertSame(entities.get(0), result.get(0));
}
public void test_list_not_in() throws Exception {
JSONPath path = new JSONPath("[id not in (1001)]");
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
Reported by PMD.
Line: 38
entities.add(new Entity(1004, null));
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(3, result.size());
Assert.assertSame(entities.get(1), result.get(0));
Assert.assertSame(entities.get(2), result.get(1));
Assert.assertSame(entities.get(3), result.get(2));
}
Reported by PMD.
Line: 39
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(3, result.size());
Assert.assertSame(entities.get(1), result.get(0));
Assert.assertSame(entities.get(2), result.get(1));
Assert.assertSame(entities.get(3), result.get(2));
}
public void test_list_nin() throws Exception {
Reported by PMD.
Line: 40
List<Object> result = (List<Object>) path.eval(entities);
Assert.assertEquals(3, result.size());
Assert.assertSame(entities.get(1), result.get(0));
Assert.assertSame(entities.get(2), result.get(1));
Assert.assertSame(entities.get(3), result.get(2));
}
public void test_list_nin() throws Exception {
JSONPath path = new JSONPath("[id nin (1001)]");
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_16.java
37 issues
Line: 18
public class JSONPath_16 extends TestCase {
public void test_for_jsonpath() throws Exception {
String str = "[{\"id\":1001,\"salary\":4000,\"name\":\"jobs\",\"valid\":false},{\"id\":1001,\"salary\":5000}]";
System.out.println(str);
assertEquals(2
, JSONPath.extract(str, "$.size()"));
assertEquals("array"
, JSONPath.extract(str, "$.type()"));
Reported by PMD.
Line: 16
import java.util.concurrent.TimeUnit;
public class JSONPath_16 extends TestCase {
public void test_for_jsonpath() throws Exception {
String str = "[{\"id\":1001,\"salary\":4000,\"name\":\"jobs\",\"valid\":false},{\"id\":1001,\"salary\":5000}]";
System.out.println(str);
assertEquals(2
, JSONPath.extract(str, "$.size()"));
Reported by PMD.
Line: 16
import java.util.concurrent.TimeUnit;
public class JSONPath_16 extends TestCase {
public void test_for_jsonpath() throws Exception {
String str = "[{\"id\":1001,\"salary\":4000,\"name\":\"jobs\",\"valid\":false},{\"id\":1001,\"salary\":5000}]";
System.out.println(str);
assertEquals(2
, JSONPath.extract(str, "$.size()"));
Reported by PMD.
Line: 19
public void test_for_jsonpath() throws Exception {
String str = "[{\"id\":1001,\"salary\":4000,\"name\":\"jobs\",\"valid\":false},{\"id\":1001,\"salary\":5000}]";
System.out.println(str);
assertEquals(2
, JSONPath.extract(str, "$.size()"));
assertEquals("array"
, JSONPath.extract(str, "$.type()"));
Reported by PMD.
Line: 22
assertEquals(2
, JSONPath.extract(str, "$.size()"));
assertEquals("array"
, JSONPath.extract(str, "$.type()"));
assertEquals("object"
, JSONPath.extract(str, "$[0].type()"));
Reported by PMD.
Line: 25
assertEquals("array"
, JSONPath.extract(str, "$.type()"));
assertEquals("object"
, JSONPath.extract(str, "$[0].type()"));
assertEquals("number"
, JSONPath.extract(str, "$[0].id.type()"));
Reported by PMD.
Line: 28
assertEquals("object"
, JSONPath.extract(str, "$[0].type()"));
assertEquals("number"
, JSONPath.extract(str, "$[0].id.type()"));
assertEquals("string"
, JSONPath.extract(str, "$[0].name.type()"));
Reported by PMD.
Line: 31
assertEquals("number"
, JSONPath.extract(str, "$[0].id.type()"));
assertEquals("string"
, JSONPath.extract(str, "$[0].name.type()"));
assertEquals("boolean"
, JSONPath.extract(str, "$[0].valid.type()"));
Reported by PMD.
Line: 34
assertEquals("string"
, JSONPath.extract(str, "$[0].name.type()"));
assertEquals("boolean"
, JSONPath.extract(str, "$[0].valid.type()"));
assertEquals("null"
, JSONPath.extract(str, "$[0].xx.type()"));
}
Reported by PMD.
Line: 37
assertEquals("boolean"
, JSONPath.extract(str, "$[0].valid.type()"));
assertEquals("null"
, JSONPath.extract(str, "$[0].xx.type()"));
}
public void test_for_jsonpath_type() throws Exception {
JSONObject root = new JSONObject();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/basicType/IntegerNullTest.java
37 issues
Line: 14
* Created by wenshao on 10/08/2017.
*/
public class IntegerNullTest extends TestCase {
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
Reported by PMD.
Line: 14
* Created by wenshao on 10/08/2017.
*/
public class IntegerNullTest extends TestCase {
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
Reported by PMD.
Line: 16
public class IntegerNullTest extends TestCase {
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
public void test_null_quote() throws Exception {
Reported by PMD.
Line: 17
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
public void test_null_quote() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
Reported by PMD.
Line: 18
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
public void test_null_quote() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
assertNotNull(model);
Reported by PMD.
Line: 21
assertNull(model.v2);
}
public void test_null_quote() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
Reported by PMD.
Line: 21
assertNull(model.v2);
}
public void test_null_quote() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
Reported by PMD.
Line: 23
public void test_null_quote() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
public void test_null_1() throws Exception {
Reported by PMD.
Line: 24
public void test_null_quote() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
Reported by PMD.
Line: 25
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/basicType/LongNullTest.java
37 issues
Line: 14
* Created by wenshao on 10/08/2017.
*/
public class LongNullTest extends TestCase {
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
Reported by PMD.
Line: 14
* Created by wenshao on 10/08/2017.
*/
public class LongNullTest extends TestCase {
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
Reported by PMD.
Line: 16
public class LongNullTest extends TestCase {
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
public void test_null_quote() throws Exception {
Reported by PMD.
Line: 17
public void test_null() throws Exception {
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
public void test_null_quote() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
Reported by PMD.
Line: 18
Model model = JSON.parseObject("{\"v1\":null,\"v2\":null}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
public void test_null_quote() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
assertNotNull(model);
Reported by PMD.
Line: 21
assertNull(model.v2);
}
public void test_null_quote() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
Reported by PMD.
Line: 21
assertNull(model.v2);
}
public void test_null_quote() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
Reported by PMD.
Line: 23
public void test_null_quote() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
public void test_null_1() throws Exception {
Reported by PMD.
Line: 24
public void test_null_quote() throws Exception {
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
Reported by PMD.
Line: 25
Model model = JSON.parseObject("{\"v1\":\"null\",\"v2\":\"null\"}", Model.class);
assertNotNull(model);
assertNull(model.v1);
assertNull(model.v2);
}
public void test_null_1() throws Exception {
Model model = JSON.parseObject("{\"v1\":null ,\"v2\":null }", Model.class);
assertNotNull(model);
Reported by PMD.
src/test/java/com/alibaba/json/test/epubview/TestKlutz.java
37 issues
Line: 54
//gson();
jackson();
System.out.println("=======================");
}
}
private String jackson() throws Exception {
String s = mapper.writeValueAsString(book);
Reported by PMD.
Line: 67
book_jackson = mapper.readValue(s, EpubViewBook.class);
//s = mapper.writeValueAsString(epubViewBook);
}
System.out.println("Jackson:" + (System.currentTimeMillis() - startTime) + ", " + s.length());
System.out.println(s);
return s;
}
private String gson() throws Exception {
Reported by PMD.
Line: 68
//s = mapper.writeValueAsString(epubViewBook);
}
System.out.println("Jackson:" + (System.currentTimeMillis() - startTime) + ", " + s.length());
System.out.println(s);
return s;
}
private String gson() throws Exception {
String s = gson.toJson(book);
Reported by PMD.
Line: 82
EpubViewBook epubViewBook = gson.fromJson(s, EpubViewBook.class);
s = gson.toJson(epubViewBook);
}
System.out.println("Gson:" + (System.currentTimeMillis() - startTime) + ", " + s.length());
return s;
}
private String fastjson() {
String s = JSON.toJSONString(book, SerializerFeature.DisableCircularReferenceDetect);
Reported by PMD.
Line: 96
book_fastjson = JSON.parseObject(s, EpubViewBook.class, Feature.DisableCircularReferenceDetect);
//s = JSON.toJSONString(epubViewBook, SerializerFeature.DisableCircularReferenceDetect);
}
System.out.println("Fastjson:" + (System.currentTimeMillis() - startTime) + ", " + s.length());
System.out.println(s);
return s;
}
}
Reported by PMD.
Line: 97
//s = JSON.toJSONString(epubViewBook, SerializerFeature.DisableCircularReferenceDetect);
}
System.out.println("Fastjson:" + (System.currentTimeMillis() - startTime) + ", " + s.length());
System.out.println(s);
return s;
}
}
Reported by PMD.
Line: 20
public class TestKlutz extends TestCase {
private EpubViewBook book;
ObjectMapper mapper = new ObjectMapper();
Gson gson = new Gson();
private EpubViewBook book_jackson;
Reported by PMD.
Line: 22
private EpubViewBook book;
ObjectMapper mapper = new ObjectMapper();
Gson gson = new Gson();
private EpubViewBook book_jackson;
private EpubViewBook book_fastjson;
Reported by PMD.
Line: 23
private EpubViewBook book;
ObjectMapper mapper = new ObjectMapper();
Gson gson = new Gson();
private EpubViewBook book_jackson;
private EpubViewBook book_fastjson;
private int LOOP_COUNT = 1000 * 1;
Reported by PMD.
Line: 23
private EpubViewBook book;
ObjectMapper mapper = new ObjectMapper();
Gson gson = new Gson();
private EpubViewBook book_jackson;
private EpubViewBook book_fastjson;
private int LOOP_COUNT = 1000 * 1;
Reported by PMD.
src/main/java/com/alibaba/fastjson/support/spring/FastJsonHttpMessageConverter.java
36 issues
Line: 262
private Object readType(Type type, HttpInputMessage inputMessage) {
try {
InputStream in = inputMessage.getBody();
return JSON.parseObject(in,
fastJsonConfig.getCharset(),
type,
fastJsonConfig.getParserConfig(),
fastJsonConfig.getParseProcess(),
Reported by PMD.
Line: 281
protected void writeInternal(Object object, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
ByteArrayOutputStream outnew = new ByteArrayOutputStream();
try {
HttpHeaders headers = outputMessage.getHeaders();
//获取全局配置的filter
SerializeFilter[] globalFilters = fastJsonConfig.getSerializeFilters();
List<SerializeFilter> allFilters = new ArrayList<SerializeFilter>(Arrays.asList(globalFilters));
Reported by PMD.
Line: 295
if (value instanceof FastJsonContainer) {
FastJsonContainer fastJsonContainer = (FastJsonContainer) value;
PropertyPreFilters filters = fastJsonContainer.getFilters();
allFilters.addAll(filters.getFilters());
value = fastJsonContainer.getValue();
}
//revise 2017-10-23 ,
Reported by PMD.
Line: 296
if (value instanceof FastJsonContainer) {
FastJsonContainer fastJsonContainer = (FastJsonContainer) value;
PropertyPreFilters filters = fastJsonContainer.getFilters();
allFilters.addAll(filters.getFilters());
value = fastJsonContainer.getValue();
}
//revise 2017-10-23 ,
// 保持原有的MappingFastJsonValue对象的contentType不做修改 保持旧版兼容。
Reported by PMD.
Line: 297
FastJsonContainer fastJsonContainer = (FastJsonContainer) value;
PropertyPreFilters filters = fastJsonContainer.getFilters();
allFilters.addAll(filters.getFilters());
value = fastJsonContainer.getValue();
}
//revise 2017-10-23 ,
// 保持原有的MappingFastJsonValue对象的contentType不做修改 保持旧版兼容。
// 但是新的JSONPObject将返回标准的contentType:application/javascript ,不对是否有function进行判断
Reported by PMD.
Line: 317
value, //
fastJsonConfig.getSerializeConfig(), //
//fastJsonConfig.getSerializeFilters(), //
allFilters.toArray(new SerializeFilter[allFilters.size()]),
fastJsonConfig.getDateFormat(), //
JSON.DEFAULT_GENERATE_FEATURE, //
fastJsonConfig.getSerializerFeatures());
if (isJsonp) {
Reported by PMD.
Line: 323
fastJsonConfig.getSerializerFeatures());
if (isJsonp) {
headers.setContentType(APPLICATION_JAVASCRIPT);
}
if (fastJsonConfig.isWriteContentLength()) {
headers.setContentLength(len);
}
Reported by PMD.
Line: 327
}
if (fastJsonConfig.isWriteContentLength()) {
headers.setContentLength(len);
}
outnew.writeTo(outputMessage.getBody());
} catch (JSONException ex) {
Reported by PMD.
Line: 341
private Object strangeCodeForJackson(Object obj) {
if (obj != null) {
String className = obj.getClass().getName();
if ("com.fasterxml.jackson.databind.node.ObjectNode".equals(className)) {
return obj.toString();
}
}
return obj;
Reported by PMD.
Line: 381
if (type instanceof TypeVariable) {
ResolvableType resolvedTypeVariable = resolveVariable((TypeVariable) type, ResolvableType.forClass(contextClass));
if (resolvedTypeVariable != ResolvableType.NONE) {
return resolvedTypeVariable.resolve();
}
} else if (type instanceof ParameterizedType && resolvedType.hasUnresolvableGenerics()) {
ParameterizedType parameterizedType = (ParameterizedType) type;
Class<?>[] generics = new Class[parameterizedType.getActualTypeArguments().length];
Type[] typeArguments = parameterizedType.getActualTypeArguments();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_reverse_test.java
36 issues
Line: 11
public class JSONPath_reverse_test extends TestCase
{
public void test_reserve() throws Exception {
JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");
assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
Reported by PMD.
Line: 11
public class JSONPath_reverse_test extends TestCase
{
public void test_reserve() throws Exception {
JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");
assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
Reported by PMD.
Line: 14
public void test_reserve() throws Exception {
JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");
assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
|| text.equals("[\"ljw\",[\"ljw\",50,1001]]")
|| text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
Reported by PMD.
Line: 14
public void test_reserve() throws Exception {
JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");
assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
|| text.equals("[\"ljw\",[\"ljw\",50,1001]]")
|| text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
Reported by PMD.
Line: 14
public void test_reserve() throws Exception {
JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");
assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
|| text.equals("[\"ljw\",[\"ljw\",50,1001]]")
|| text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
Reported by PMD.
Line: 15
JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");
assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
|| text.equals("[\"ljw\",[\"ljw\",50,1001]]")
|| text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
|| text.equals("[\"ljw\",[1001,50,\"ljw\"]]")
Reported by PMD.
Line: 15
JSONObject object = JSON.parseObject("{\"id\":1001,\"name\":\"ljw\",\"age\":50}");
assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
|| text.equals("[\"ljw\",[\"ljw\",50,1001]]")
|| text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
|| text.equals("[\"ljw\",[1001,50,\"ljw\"]]")
Reported by PMD.
Line: 17
assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
|| text.equals("[\"ljw\",[\"ljw\",50,1001]]")
|| text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
|| text.equals("[\"ljw\",[1001,50,\"ljw\"]]")
|| text.equals("[\"ljw\",[1001,\"ljw\",50]]")
|| text.equals("[\"ljw\",[50,\"ljw\",1001]]"));
Reported by PMD.
Line: 17
assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
|| text.equals("[\"ljw\",[\"ljw\",50,1001]]")
|| text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
|| text.equals("[\"ljw\",[1001,50,\"ljw\"]]")
|| text.equals("[\"ljw\",[1001,\"ljw\",50]]")
|| text.equals("[\"ljw\",[50,\"ljw\",1001]]"));
Reported by PMD.
Line: 17
assertEquals("[1001,\"ljw\"]", JSONPath.reserveToArray(object, "id", "name").toString());
assertEquals("[\"ljw\",1001]", JSONPath.reserveToArray(object, "name", "id").toString());
String text = JSON.toJSONString(JSONPath.reserveToArray(object, "name", "*"), SerializerFeature.MapSortField);
assertTrue(text.equals("[\"ljw\",[\"ljw\",1001,50]]")
|| text.equals("[\"ljw\",[\"ljw\",50,1001]]")
|| text.equals("[\"ljw\",[50,1001,\"ljw\"]]")
|| text.equals("[\"ljw\",[1001,50,\"ljw\"]]")
|| text.equals("[\"ljw\",[1001,\"ljw\",50]]")
|| text.equals("[\"ljw\",[50,\"ljw\",1001]]"));
Reported by PMD.