The following issues were found

src/test/java/com/alibaba/json/bvt/JSONTest_Bytes_1.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: 13

              
public class JSONTest_Bytes_1 extends TestCase {

    public void test_bytes() throws Exception {
        Assert.assertEquals("\"abc\"", new String(JSON.toJSONBytes("abc", SerializeConfig.getGlobalInstance())));
        Assert.assertEquals("'abc'",
                            new String(JSON.toJSONBytes("abc", SerializeConfig.getGlobalInstance(),
                                                        SerializerFeature.UseSingleQuotes)));
    }

            

Reported by PMD.

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

Line: 14

              public class JSONTest_Bytes_1 extends TestCase {

    public void test_bytes() throws Exception {
        Assert.assertEquals("\"abc\"", new String(JSON.toJSONBytes("abc", SerializeConfig.getGlobalInstance())));
        Assert.assertEquals("'abc'",
                            new String(JSON.toJSONBytes("abc", SerializeConfig.getGlobalInstance(),
                                                        SerializerFeature.UseSingleQuotes)));
    }


            

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

                                                                      SerializerFeature.UseSingleQuotes)));
    }

    public void test_bytes_2() throws Exception {
        Assert.assertEquals("\"abc\"", new String(JSON.toJSONBytes("abc")));
        Assert.assertEquals("'abc'", new String(JSON.toJSONBytes("abc", SerializerFeature.UseSingleQuotes)));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/taobao/IntegerAsStringTest.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

              import junit.framework.TestCase;

public class IntegerAsStringTest extends TestCase {
    public void test_0 () throws Exception {
        VO vo = JSON.parseObject("{\"value\":\"1001\"}", VO.class);
        Assert.assertEquals(1001, vo.value.intValue());
    }
    
    public static class VO {

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 12

              public class IntegerAsStringTest extends TestCase {
    public void test_0 () throws Exception {
        VO vo = JSON.parseObject("{\"value\":\"1001\"}", VO.class);
        Assert.assertEquals(1001, vo.value.intValue());
    }
    
    public static class VO {
        public Integer value;
    }

            

Reported by PMD.

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

Line: 16

                  }
    
    public static class VO {
        public Integer value;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/number/NumberEmtpyObjectTest.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

               * Created by wenshao on 24/04/2017.
 */
public class NumberEmtpyObjectTest extends TestCase {
    public void test_for_emptyObj() throws Exception {
        Model model = JSON.parseObject("{\"val\":{}}", Model.class);
        assertNull(model.val);
    }

    public static class Model {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

              public class NumberEmtpyObjectTest extends TestCase {
    public void test_for_emptyObj() throws Exception {
        Model model = JSON.parseObject("{\"val\":{}}", Model.class);
        assertNull(model.val);
    }

    public static class Model {
        public Number val;
    }

            

Reported by PMD.

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

Line: 16

                  }

    public static class Model {
        public Number val;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/DupSetterTest3.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: 20

              
public class DupSetterTest3 extends TestCase {

    public void testEnum() {
        VO enumTest = new VO();
        enumTest.status = 3;
        String json = JSONObject.toJSONString(enumTest);
        JSONObject.parseObject(json, VO.class);
    }

            

Reported by PMD.

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

Line: 20

              
public class DupSetterTest3 extends TestCase {

    public void testEnum() {
        VO enumTest = new VO();
        enumTest.status = 3;
        String json = JSONObject.toJSONString(enumTest);
        JSONObject.parseObject(json, VO.class);
    }

            

Reported by PMD.

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

Line: 29

              
    public static class VO {

        public Integer status;

        @JSONField(name = "status")
        public Integer status2;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/DupSetterTest.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: 19

              
public class DupSetterTest extends TestCase {

    public void testEnum() {
        VO enumTest = new VO();
        enumTest.setStatus(3);
        String json = JSONObject.toJSONString(enumTest);
        JSONObject.parseObject(json, VO.class);
    }

            

Reported by PMD.

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

Line: 19

              
public class DupSetterTest extends TestCase {

    public void testEnum() {
        VO enumTest = new VO();
        enumTest.setStatus(3);
        String json = JSONObject.toJSONString(enumTest);
        JSONObject.parseObject(json, VO.class);
    }

            

Reported by PMD.

Perhaps 'code' could be replaced by a local variable.
Design

Line: 46

                  public static enum Status {
                               ENABLE(1);

        private Integer code;

        Status(Integer code){
            this.code = code;
        }
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/DoubleFormatTest2.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 09/01/2017.
 */
public class DoubleFormatTest2 extends TestCase {
    public void test_format() throws Exception {
        Model model = new Model();
        model.value = 123.45678D;

        String str = JSON.toJSONString(model);
        assertEquals("{\"value\":123.46}", str);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      model.value = 123.45678D;

        String str = JSON.toJSONString(model);
        assertEquals("{\"value\":123.46}", str);
    }

    public static class Model {
        @JSONField(format = "0.00")
        public Double value;

            

Reported by PMD.

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

Line: 21

              
    public static class Model {
        @JSONField(format = "0.00")
        public Double value;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/DoubleFormatTest.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 09/01/2017.
 */
public class DoubleFormatTest extends TestCase {
    public void test_format() throws Exception {
        Model model = new Model();
        model.value = 123.45678D;

        String str = JSON.toJSONString(model);
        assertEquals("{\"value\":123.46}", str);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      model.value = 123.45678D;

        String str = JSON.toJSONString(model);
        assertEquals("{\"value\":123.46}", str);
    }

    public static class Model {
        @JSONField(format = "0.00")
        public double value;

            

Reported by PMD.

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

Line: 21

              
    public static class Model {
        @JSONField(format = "0.00")
        public double value;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/ReferenceDeserializerTest.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: 15

              
public class ReferenceDeserializerTest extends TestCase {

    public void test_0() throws Exception {
        ParserConfig config = new ParserConfig();
        config.putDeserializer(MyRef.class, ReferenceCodec.instance);
        Exception error = null;
        try {
            JSON.parseObject("{\"ref\":{}}", VO.class, config, 0);

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 21

                      Exception error = null;
        try {
            JSON.parseObject("{\"ref\":{}}", VO.class, config, 0);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '18'-'22').
Error

Line: 18

                  public void test_0() throws Exception {
        ParserConfig config = new ParserConfig();
        config.putDeserializer(MyRef.class, ReferenceCodec.instance);
        Exception error = null;
        try {
            JSON.parseObject("{\"ref\":{}}", VO.class, config, 0);
        } catch (Exception ex) {
            error = ex;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/DupTest.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

               * Created by wenshao on 13/02/2017.
 */
public class DupTest extends TestCase {
    public void test_dup() throws Exception {
        String json = "{\"id\":1001,\"_id\":1002}";

        Model model = JSON.parseObject(json, Model.class);
        assertEquals(1001, model.id);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                      String json = "{\"id\":1001,\"_id\":1002}";

        Model model = JSON.parseObject(json, Model.class);
        assertEquals(1001, model.id);
    }

    public static class Model {
        public int id;
    }

            

Reported by PMD.

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

Line: 18

                  }

    public static class Model {
        public int id;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/arraymapping/ArrayMapping_double.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 ArrayMapping_double extends TestCase {
    public void test_float() throws Exception {
        Model model = JSON.parseObject("[123.45,\"wenshao\"]", Model.class, Feature.SupportArrayToBean);
        Assert.assertTrue(123.45D == model.id);
        Assert.assertEquals("wenshao", model.name);
    }
    

            

Reported by PMD.

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

Line: 18

                  }
    
    public static class Model {
        public double id;
        public String name;
        
    }
}

            

Reported by PMD.

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

Line: 19

                  
    public static class Model {
        public double id;
        public String name;
        
    }
}

            

Reported by PMD.