The following issues were found

src/test/java/com/alibaba/json/bvt/serializer/filters/PropertyFilterTest2.java
3 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: 12

              
public class PropertyFilterTest2 extends TestCase {

    public void test_0() throws Exception {
        class VO {
            public int    id;
            public String name;
        }


            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '18'-'31').
Error

Line: 18

                          public String name;
        }

        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                return "id".equals(name);
            }
        };

            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '18'-'31').
Error

Line: 18

                          public String name;
        }

        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                return "id".equals(name);
            }
        };

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/features/JSONDirectTest.java
3 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: 11

              import junit.framework.TestCase;

public class JSONDirectTest extends TestCase {
    public void test_feature() throws Exception {
        Model model = new Model();
        model.id = 1001;
        model.value = "{}";
        
        String json = JSON.toJSONString(model);

            

Reported by PMD.

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

Line: 22

                  }

    public static class Model {
        public int id;
        @JSONField(jsonDirect=true)
        public String value;
    }
}

            

Reported by PMD.

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

Line: 24

                  public static class Model {
        public int id;
        @JSONField(jsonDirect=true)
        public String value;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/JSONFieldSetterTest.java
3 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: 11

               * Created by wenshao on 05/04/2017.
 */
public class JSONFieldSetterTest extends TestCase {
    public void test_for_setter() throws Exception {
        Model model = JSON.parseObject("{\"id\":123}", Model.class);
        assertEquals(123, model._id);
    }

    public static class Model {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

              public class JSONFieldSetterTest extends TestCase {
    public void test_for_setter() throws Exception {
        Model model = JSON.parseObject("{\"id\":123}", Model.class);
        assertEquals(123, model._id);
    }

    public static class Model {
        private int _id;


            

Reported by PMD.

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

Line: 17

                  }

    public static class Model {
        private int _id;

        @JSONField(name = "id")
        public void id(int id) {
            this._id = id;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/TestPivateStaticClass.java
3 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: 10

              
public class TestPivateStaticClass extends TestCase {

    public void test_inner() throws Exception {
        VO vo = new VO();
        String text = JSON.toJSONString(vo);
        Assert.assertEquals("{\"value\":234}", text);
        
        VO v1 = JSON.parseObject(text, VO.class);

            

Reported by PMD.

Avoid unused local variables such as 'v1'.
Design

Line: 15

                      String text = JSON.toJSONString(vo);
        Assert.assertEquals("{\"value\":234}", text);
        
        VO v1 = JSON.parseObject(text, VO.class);
    }

    private static class VO {

        private int value = 234;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'v1' (lines '15'-'16').
Error

Line: 15

                      String text = JSON.toJSONString(vo);
        Assert.assertEquals("{\"value\":234}", text);
        
        VO v1 = JSON.parseObject(text, VO.class);
    }

    private static class VO {

        private int value = 234;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/features/JSONDirectTest_private.java
3 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: 11

              import junit.framework.TestCase;

public class JSONDirectTest_private extends TestCase {
    public void test_feature() throws Exception {
        Model model = new Model();
        model.id = 1001;
        model.value = "{}";
        
        String json = JSON.toJSONString(model);

            

Reported by PMD.

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

Line: 22

                  }

    private static class Model {
        public int id;
        @JSONField(jsonDirect=true)
        public String value;
    }
}

            

Reported by PMD.

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

Line: 24

                  private static class Model {
        public int id;
        @JSONField(jsonDirect=true)
        public String value;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/TestSpecial.java
3 issues
System.out.println is used
Design

Line: 16

                  public void test_0 () throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("name", "\n\r\t");
        System.out.println(JSON.toJSONString(map, SerializerFeature.WriteTabAsSpecial));
    }
}

            

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: 12

              import com.alibaba.fastjson.serializer.SerializerFeature;

public class TestSpecial extends TestCase {
    @SuppressWarnings("deprecation")
    public void test_0 () throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("name", "\n\r\t");
        System.out.println(JSON.toJSONString(map, SerializerFeature.WriteTabAsSpecial));
    }

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 13

              
public class TestSpecial extends TestCase {
    @SuppressWarnings("deprecation")
    public void test_0 () throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("name", "\n\r\t");
        System.out.println(JSON.toJSONString(map, SerializerFeature.WriteTabAsSpecial));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/deny/DenyTest13.java
3 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: 11

               * Created by wenshao on 29/01/2017.
 */
public class DenyTest13 extends TestCase {
    public void test_deny() throws Exception {
        String text = "{\"value\":{\"@type\":\"java.lang.Thread\"}}";
        Exception error = null;
        try {
            JSON.parseObject(text, Model.class);
        } catch (JSONException ex) {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      } catch (JSONException ex) {
            error = ex;
        }
        assertNotNull(error);
    }

    public static class Model {
        public Object value;
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '13'-'17').
Error

Line: 13

              public class DenyTest13 extends TestCase {
    public void test_deny() throws Exception {
        String text = "{\"value\":{\"@type\":\"java.lang.Thread\"}}";
        Exception error = null;
        try {
            JSON.parseObject(text, Model.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterClassLevelTest_private.java
3 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 NameFilterClassLevelTest_private extends TestCase {

    public void test_0() throws Exception {
        Object[] array = { new ModelA(), new ModelB() };

        SerializeConfig config = new SerializeConfig();
        config.addFilter(ModelA.class, //
                         new PascalNameFilter());

            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '15'-'33').
Error

Line: 15

              public class NameFilterClassLevelTest_private extends TestCase {

    public void test_0() throws Exception {
        Object[] array = { new ModelA(), new ModelB() };

        SerializeConfig config = new SerializeConfig();
        config.addFilter(ModelA.class, //
                         new PascalNameFilter());
        config.addFilter(ModelB.class, //

            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '15'-'33').
Error

Line: 15

              public class NameFilterClassLevelTest_private extends TestCase {

    public void test_0() throws Exception {
        Object[] array = { new ModelA(), new ModelB() };

        SerializeConfig config = new SerializeConfig();
        config.addFilter(ModelA.class, //
                         new PascalNameFilter());
        config.addFilter(ModelB.class, //

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/TestSpecial4.java
3 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: 11

              
public class TestSpecial4 extends TestCase {

    public void test_0() throws Exception {
        StringBuilder buf = new StringBuilder();
        buf.append('\r');
        buf.append('\r');
        for (int i = 0; i < 1000; ++i) {
            buf.append('\u2028');

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 13

              
    public void test_0() throws Exception {
        StringBuilder buf = new StringBuilder();
        buf.append('\r');
        buf.append('\r');
        for (int i = 0; i < 1000; ++i) {
            buf.append('\u2028');
        }


            

Reported by PMD.

StringBuffer (or StringBuilder).append is called 2 consecutive times with literals. Use a single append with a single combined String.
Performance

Line: 13

              
    public void test_0() throws Exception {
        StringBuilder buf = new StringBuilder();
        buf.append('\r');
        buf.append('\r');
        for (int i = 0; i < 1000; ++i) {
            buf.append('\u2028');
        }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterClassLevelTest.java
3 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 NameFilterClassLevelTest extends TestCase {

    public void test_0() throws Exception {
        Object[] array = { new ModelA(), new ModelB() };

        SerializeConfig config = new SerializeConfig();
        config.addFilter(ModelA.class, //
                         new PascalNameFilter());

            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '15'-'33').
Error

Line: 15

              public class NameFilterClassLevelTest extends TestCase {

    public void test_0() throws Exception {
        Object[] array = { new ModelA(), new ModelB() };

        SerializeConfig config = new SerializeConfig();
        config.addFilter(ModelA.class, //
                         new PascalNameFilter());
        config.addFilter(ModelB.class, //

            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '15'-'33').
Error

Line: 15

              public class NameFilterClassLevelTest extends TestCase {

    public void test_0() throws Exception {
        Object[] array = { new ModelA(), new ModelB() };

        SerializeConfig config = new SerializeConfig();
        config.addFilter(ModelA.class, //
                         new PascalNameFilter());
        config.addFilter(ModelB.class, //

            

Reported by PMD.