The following issues were found

src/test/java/com/alibaba/json/bvt/date/DateFormatPriorityTest.java
38 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

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.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

A Calendar is used to create a Date or DateTime, this is expensive.
Performance

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

A Calendar is used to create a Date or DateTime, this is expensive.
Performance

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.

JUnit assertions should include a message
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

A Calendar is used to create a Date or DateTime, this is expensive.
Performance

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.

JUnit assertions should include a message
Design

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
System.out.println is used
Design

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.

System.out.println is used
Design

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.

System.out.println is used
Design

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.

System.out.println is used
Design

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.

System.out.println is used
Design

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.

System.out.println is used
Design

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.

System.out.println is used
Design

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.

System.out.println is used
Design

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.

System.out.println is used
Design

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.

System.out.println is used
Design

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
This class has too many methods, consider refactoring it.
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

Potential violation of Law of Demeter (method chain calls)
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

Potential violation of Law of Demeter (method chain calls)
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

Potential violation of Law of Demeter (method chain calls)
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

Potential violation of Law of Demeter (method chain calls)
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

The String literal 'ljw2083' appears 7 times in this file; the first occurrence is on line 18
Error

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.

The String literal 'wenshao' appears 7 times in this file; the first occurrence is on line 19
Error

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.

The String literal 'yakolee' appears 7 times in this file; the first occurrence is on line 20
Error

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.

Potential violation of Law of Demeter (object not created locally)
Design

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.

Potential violation of Law of Demeter (object not created locally)
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

Potential violation of Law of Demeter (object not created locally)
Design

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.

Potential violation of Law of Demeter (object not created locally)
Design

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.

Potential violation of Law of Demeter (object not created locally)
Design

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
System.out.println is used
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

Unit tests should not contain more than 1 assert(s).
Design

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.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

Line: 22

                      assertEquals(2
                , JSONPath.extract(str, "$.size()"));

        assertEquals("array"
                , JSONPath.extract(str, "$.type()"));

        assertEquals("object"
                , JSONPath.extract(str, "$[0].type()"));


            

Reported by PMD.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

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
Unit tests should not contain more than 1 assert(s).
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

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.

Unit tests should not contain more than 1 assert(s).
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

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
Unit tests should not contain more than 1 assert(s).
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

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.

Unit tests should not contain more than 1 assert(s).
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

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.

JUnit assertions should include a message
Design

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
System.out.println is used
Design

Line: 54

                          //gson();
            jackson();

            System.out.println("=======================");
        }
    }

    private String jackson() throws Exception {
        String s = mapper.writeValueAsString(book);

            

Reported by PMD.

System.out.println is used
Design

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.

System.out.println is used
Design

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.

System.out.println is used
Design

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.

System.out.println is used
Design

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.

System.out.println is used
Design

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.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

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.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 22

              
    private EpubViewBook book;
    
    ObjectMapper mapper = new ObjectMapper();
    Gson gson = new Gson();
    
    private EpubViewBook book_jackson;
    private EpubViewBook book_fastjson;
    

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

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.

Field gson has the same name as a method
Error

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
Ensure that resources like this InputStream object are closed after use
Error

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.

Consider using a try-with-resources statement instead of explicitly closing the resource
Design

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.

Potential violation of Law of Demeter (object not created locally)
Design

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.

Potential violation of Law of Demeter (object not created locally)
Design

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.

Potential violation of Law of Demeter (object not created locally)
Design

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.

This call to Collection.toArray() may be optimizable
Performance

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.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 323

                                  fastJsonConfig.getSerializerFeatures());

            if (isJsonp) {
                headers.setContentType(APPLICATION_JAVASCRIPT);
            }

            if (fastJsonConfig.isWriteContentLength()) {
                headers.setContentLength(len);
            }

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 327

                          }

            if (fastJsonConfig.isWriteContentLength()) {
                headers.setContentLength(len);
            }

            outnew.writeTo(outputMessage.getBody());

        } catch (JSONException ex) {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

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.

Potential violation of Law of Demeter (object not created locally)
Design

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
Unit tests should not contain more than 1 assert(s).
Design

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.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

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.

JUnit assertions should include a message
Design

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.

Potential violation of Law of Demeter (method chain calls)
Design

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.

The String literal 'name' appears 5 times in this file; the first occurrence is on line 14
Error

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.

JUnit assertions should include a message
Design

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.

Potential violation of Law of Demeter (method chain calls)
Design

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.

Position literals first in String comparisons
Design

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.

Potential violation of Law of Demeter (object not created locally)
Design

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.

JUnit assertions should include a message
Design

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.