The following issues were found

src/test/java/com/alibaba/json/bvt/parser/ReadOnlyAtomicBooleanTest.java
4 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 ReadOnlyAtomicBooleanTest extends TestCase {

    public void test_readOnly() throws Exception {
        Model model = new Model();
        model.value.set(true);

        String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":true}", text);

            

Reported by PMD.

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

Line: 15

              
    public void test_readOnly() throws Exception {
        Model model = new Model();
        model.value.set(true);

        String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":true}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());

            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":true}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());
    }

    public static class Model {
        private final AtomicBoolean value = new AtomicBoolean();


            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":true}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());
    }

    public static class Model {
        private final AtomicBoolean value = new AtomicBoolean();


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/ReadOnlyAtomicIntegerTest.java
4 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 ReadOnlyAtomicIntegerTest extends TestCase {

    public void test_readOnly() throws Exception {
        Model model = new Model();
        model.value.set(1001);

        String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);

            

Reported by PMD.

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

Line: 15

              
    public void test_readOnly() throws Exception {
        Model model = new Model();
        model.value.set(1001);

        String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());

            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());
    }

    public static class Model {
        private final AtomicInteger value = new AtomicInteger();


            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());
    }

    public static class Model {
        private final AtomicInteger value = new AtomicInteger();


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/ReadOnlyAtomicLongTest.java
4 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 ReadOnlyAtomicLongTest extends TestCase {

    public void test_readOnly() throws Exception {
        Model model = new Model();
        model.value.set(1001);

        String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);

            

Reported by PMD.

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

Line: 15

              
    public void test_readOnly() throws Exception {
        Model model = new Model();
        model.value.set(1001);

        String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());

            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());
    }

    public static class Model {
        private final AtomicLong value = new AtomicLong();


            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());
    }

    public static class Model {
        private final AtomicLong value = new AtomicLong();


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/ReadOnlyMapTest_final_field.java
4 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 ReadOnlyMapTest_final_field extends TestCase {

    public void test_readOnlyNullList() throws Exception {
        String text = "{\"values\":{\"a\":{}}}";
        Entity entity = JSON.parseObject(text, Entity.class);
        Assert.assertNotNull(entity);
        Assert.assertNotNull(entity.values.get("a"));
        Assert.assertTrue(entity.values.get("a") instanceof A);

            

Reported by PMD.

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

Line: 18

                      String text = "{\"values\":{\"a\":{}}}";
        Entity entity = JSON.parseObject(text, Entity.class);
        Assert.assertNotNull(entity);
        Assert.assertNotNull(entity.values.get("a"));
        Assert.assertTrue(entity.values.get("a") instanceof A);
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 19

                      Entity entity = JSON.parseObject(text, Entity.class);
        Assert.assertNotNull(entity);
        Assert.assertNotNull(entity.values.get("a"));
        Assert.assertTrue(entity.values.get("a") instanceof A);
    }

    public static class Entity {

        public final Map<String, A> values = new HashMap<String, A>();

            

Reported by PMD.

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

Line: 24

              
    public static class Entity {

        public final Map<String, A> values = new HashMap<String, A>();

    }

    public static class A {


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/TestInitStringFieldAsEmpty.java
4 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 TestInitStringFieldAsEmpty extends TestCase {

    public void test_private() throws Exception {
        VO1 vo1 = JSON.parseObject("{}", VO1.class, Feature.InitStringFieldAsEmpty);
        Assert.assertEquals("", vo1.getValue());
    }

    public void test_public() throws Exception {

            

Reported by PMD.

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

Line: 13

              
    public void test_private() throws Exception {
        VO1 vo1 = JSON.parseObject("{}", VO1.class, Feature.InitStringFieldAsEmpty);
        Assert.assertEquals("", vo1.getValue());
    }

    public void test_public() throws Exception {
        VO2 vo2 = JSON.parseObject("{}", VO2.class, Feature.InitStringFieldAsEmpty);
        Assert.assertEquals("", vo2.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: 16

                      Assert.assertEquals("", vo1.getValue());
    }

    public void test_public() throws Exception {
        VO2 vo2 = JSON.parseObject("{}", VO2.class, Feature.InitStringFieldAsEmpty);
        Assert.assertEquals("", vo2.getValue());
    }
    
    private static class VO1 {

            

Reported by PMD.

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

Line: 18

              
    public void test_public() throws Exception {
        VO2 vo2 = JSON.parseObject("{}", VO2.class, Feature.InitStringFieldAsEmpty);
        Assert.assertEquals("", vo2.getValue());
    }
    
    private static class VO1 {

        private String value;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/fullSer/EmtpyLinkedHashMapTest.java
4 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 EmtpyLinkedHashMapTest extends TestCase {
    public void test_0() throws Exception {
        Map map = (Map) JSON.parseObject("{\"@type\":\"java.util.LinkedHashMap\"}", Object.class);
    }
}

            

Reported by PMD.

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

Line: 10

              import junit.framework.TestCase;

public class EmtpyLinkedHashMapTest extends TestCase {
    public void test_0() throws Exception {
        Map map = (Map) JSON.parseObject("{\"@type\":\"java.util.LinkedHashMap\"}", Object.class);
    }
}

            

Reported by PMD.

Avoid unused local variables such as 'map'.
Design

Line: 11

              
public class EmtpyLinkedHashMapTest extends TestCase {
    public void test_0() throws Exception {
        Map map = (Map) JSON.parseObject("{\"@type\":\"java.util.LinkedHashMap\"}", Object.class);
    }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'map' (lines '11'-'12').
Error

Line: 11

              
public class EmtpyLinkedHashMapTest extends TestCase {
    public void test_0() throws Exception {
        Map map = (Map) JSON.parseObject("{\"@type\":\"java.util.LinkedHashMap\"}", Object.class);
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/feature/FeaturesTest7.java
4 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 FeaturesTest7 extends TestCase {

    public void test_0() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.setAsmEnable(false);
        
        String text = JSON.toJSONString(new Entity(), config);
        Assert.assertEquals("{\"value\":\"SECONDS\"}", text);

            

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

                      Assert.assertEquals("{\"value\":\"SECONDS\"}", text);
    }
    
    public void test_1() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.setAsmEnable(true);
        
        String text = JSON.toJSONString(new Entity(), config);
        Assert.assertEquals("{\"value\":\"SECONDS\"}", text);

            

Reported by PMD.

Private field 'value' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 31

              
    public static class Entity {

        private TimeUnit value = TimeUnit.SECONDS;

        @JSONField(serialzeFeatures = { SerializerFeature.WriteEnumUsingToString })
        public TimeUnit getValue() {
            return value;
        }

            

Reported by PMD.

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

Line: 31

              
    public static class Entity {

        private TimeUnit value = TimeUnit.SECONDS;

        @JSONField(serialzeFeatures = { SerializerFeature.WriteEnumUsingToString })
        public TimeUnit getValue() {
            return value;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/TypeUtilsTest_castToBytes.java
4 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 TypeUtilsTest_castToBytes extends TestCase {

    public void test_castToDate() throws Exception {
        Assert.assertArrayEquals(new byte[0], TypeUtils.castToBytes(new byte[0]));
    }

    public void test_castToDate_error() throws Exception {
        Exception error = null;

            

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.assertArrayEquals(new byte[0], TypeUtils.castToBytes(new byte[0]));
    }

    public void test_castToDate_error() throws Exception {
        Exception error = null;
        try {
            TypeUtils.castToBytes(new int[0]);
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

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

Line: 19

                      Exception error = null;
        try {
            TypeUtils.castToBytes(new int[0]);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
}

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '16'-'20').
Error

Line: 16

                  }

    public void test_castToDate_error() throws Exception {
        Exception error = null;
        try {
            TypeUtils.castToBytes(new int[0]);
        } catch (Exception ex) {
            error = ex;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/TypeUtilsTest_loadClass.java
4 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 TypeUtilsTest_loadClass extends TestCase {

    public void test_loadClass() throws Exception {
        Assert.assertSame(Entity.class,
                          TypeUtils.loadClass("com.alibaba.json.bvt.parser.TypeUtilsTest_loadClass$Entity",
                                              Entity.class.getClassLoader()));

        Assert.assertSame(Entity.class,

            

Reported by PMD.

In J2EE, getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead.
Error

Line: 14

                  public void test_loadClass() throws Exception {
        Assert.assertSame(Entity.class,
                          TypeUtils.loadClass("com.alibaba.json.bvt.parser.TypeUtilsTest_loadClass$Entity",
                                              Entity.class.getClassLoader()));

        Assert.assertSame(Entity.class,
                          TypeUtils.loadClass("com.alibaba.json.bvt.parser.TypeUtilsTest_loadClass$Entity", null));
    }


            

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

                                        TypeUtils.loadClass("com.alibaba.json.bvt.parser.TypeUtilsTest_loadClass$Entity", null));
    }

    public void test_error() throws Exception {
        Assert.assertNull(TypeUtils.loadClass("com.alibaba.json.bvt.parser.TypeUtilsTest_loadClass.Entity",
                                              Entity.class.getClassLoader()));
    }

    public static class Entity {

            

Reported by PMD.

In J2EE, getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassLoader() instead.
Error

Line: 22

              
    public void test_error() throws Exception {
        Assert.assertNull(TypeUtils.loadClass("com.alibaba.json.bvt.parser.TypeUtilsTest_loadClass.Entity",
                                              Entity.class.getClassLoader()));
    }

    public static class Entity {

    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/UTF8ByteArrayLexerTest_symbol.java
4 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 UTF8ByteArrayLexerTest_symbol extends TestCase {

    public void test_utf8() throws Exception {
        byte[] bytes = "{\"name\":\"温家宝\", \"name\":\"xx\"}".getBytes("UTF-8");

        JSONObject json = JSON.parseObject(bytes, JSONObject.class);
    }
}

            

Reported by PMD.

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

Line: 10

              
public class UTF8ByteArrayLexerTest_symbol extends TestCase {

    public void test_utf8() throws Exception {
        byte[] bytes = "{\"name\":\"温家宝\", \"name\":\"xx\"}".getBytes("UTF-8");

        JSONObject json = JSON.parseObject(bytes, JSONObject.class);
    }
}

            

Reported by PMD.

Avoid unused local variables such as 'json'.
Design

Line: 13

                  public void test_utf8() throws Exception {
        byte[] bytes = "{\"name\":\"温家宝\", \"name\":\"xx\"}".getBytes("UTF-8");

        JSONObject json = JSON.parseObject(bytes, JSONObject.class);
    }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'json' (lines '13'-'14').
Error

Line: 13

                  public void test_utf8() throws Exception {
        byte[] bytes = "{\"name\":\"温家宝\", \"name\":\"xx\"}".getBytes("UTF-8");

        JSONObject json = JSON.parseObject(bytes, JSONObject.class);
    }
}

            

Reported by PMD.