The following issues were found

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

              
public class LocaleTest extends TestCase {

    public void test_0() throws Exception {
        String input = JSON.toJSONString(Locale.US);
        Assert.assertEquals(Locale.US, JSON.parseObject(input, Locale.class));
    }

    public void test_1() throws Exception {

            

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(Locale.US, JSON.parseObject(input, Locale.class));
    }

    public void test_1() throws Exception {
        Locale l1 = new Locale("l1");
        String input = JSON.toJSONString(l1);
        Assert.assertEquals(l1, JSON.parseObject(input, Locale.class));
    }


            

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(l1, JSON.parseObject(input, Locale.class));
    }

    public void test_2() throws Exception {
        Locale l1 = new Locale("l1", "l2", "l3");
        String input = JSON.toJSONString(l1);
        Assert.assertEquals(l1, JSON.parseObject(input, Locale.class));
    }


            

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

                      Assert.assertEquals(l1, JSON.parseObject(input, Locale.class));
    }

    public void test_null() throws Exception {
        String input = "null";
        DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);

        MiscCodec deser = new MiscCodec();


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/InterfaceParseTest.java
4 issues
Do not use the short type
Performance

Line: 25

                      
        void setI(int value);
        void setC(char value);
        void setS(short value);
        void setL(long value);
    }
}

            

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

              

public class InterfaceParseTest extends TestCase {
    public void test_interface() throws Exception {
        VO vo = JSON.parseObject("{\"text\":\"abc\",\"b\":true}", VO.class);
        Assert.assertEquals("abc", vo.getText());
        Assert.assertEquals(Boolean.TRUE, vo.getB());
    }
    

            

Reported by PMD.

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

Line: 12

              public class InterfaceParseTest extends TestCase {
    public void test_interface() throws Exception {
        VO vo = JSON.parseObject("{\"text\":\"abc\",\"b\":true}", VO.class);
        Assert.assertEquals("abc", vo.getText());
        Assert.assertEquals(Boolean.TRUE, vo.getB());
    }
    
    public static interface VO {
        void setText(String val);

            

Reported by PMD.

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

Line: 13

                  public void test_interface() throws Exception {
        VO vo = JSON.parseObject("{\"text\":\"abc\",\"b\":true}", VO.class);
        Assert.assertEquals("abc", vo.getText());
        Assert.assertEquals(Boolean.TRUE, vo.getB());
    }
    
    public static interface VO {
        void setText(String val);
        String getText();

            

Reported by PMD.

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

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

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

            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'39').
Error

Line: 14

              public class PropertyFilterClassLevelTest extends TestCase {

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

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


            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'39').
Error

Line: 14

              public class PropertyFilterClassLevelTest extends TestCase {

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

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


            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'39').
Error

Line: 14

              public class PropertyFilterClassLevelTest extends TestCase {

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

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


            

Reported by PMD.

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

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

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

            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'39').
Error

Line: 14

              public class PropertyFilterClassLevelTest_private extends TestCase {

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

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


            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'39').
Error

Line: 14

              public class PropertyFilterClassLevelTest_private extends TestCase {

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

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


            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'39').
Error

Line: 14

              public class PropertyFilterClassLevelTest_private extends TestCase {

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

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


            

Reported by PMD.

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

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

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

            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'39').
Error

Line: 14

              public class ValueClassLevelTest extends TestCase {

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

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


            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'39').
Error

Line: 14

              public class ValueClassLevelTest extends TestCase {

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

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


            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'39').
Error

Line: 14

              public class ValueClassLevelTest extends TestCase {

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

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


            

Reported by PMD.

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

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

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

            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'39').
Error

Line: 14

              public class ValueClassLevelTest_private extends TestCase {

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

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


            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'39').
Error

Line: 14

              public class ValueClassLevelTest_private extends TestCase {

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

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


            

Reported by PMD.

Found 'DU'-anomaly for variable 'array' (lines '14'-'39').
Error

Line: 14

              public class ValueClassLevelTest_private extends TestCase {

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

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


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/prettyFormat/ArrayListFieldTest.java
4 issues
System.out.println is used
Design

Line: 21

                      
        
        String text = JSON.toJSONString(vo, SerializerFeature.PrettyFormat, SerializerFeature.UseSingleQuotes);
        System.out.println(text);
    }

    public static class VO {

        private final List<Entity> entries = new ArrayList<Entity>();

            

Reported by PMD.

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

Line: 13

              
public class ArrayListFieldTest extends TestCase {

    public void test_prettyFormat() throws Exception {
        VO vo = new VO();
        vo.getEntries().add(new Entity(123, "aaa"));
        vo.getEntries().add(new Entity(234, "bbb"));
        vo.getEntries().add(new Entity(3, "ccc"));
        

            

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

              
public class ArrayListFieldTest extends TestCase {

    public void test_prettyFormat() throws Exception {
        VO vo = new VO();
        vo.getEntries().add(new Entity(123, "aaa"));
        vo.getEntries().add(new Entity(234, "bbb"));
        vo.getEntries().add(new Entity(3, "ccc"));
        

            

Reported by PMD.

The class 'Entity' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=4, WMC=6)
Design

Line: 34

              
    }

    public static class Entity {

        private int    id;
        private String name;

        public Entity(){

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/support/hsf/HSFJSONUtilsTest_2.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

              import java.lang.reflect.Method;

public class HSFJSONUtilsTest_2 extends TestCase {
    public void test_for_hsf() throws Exception {
        final Method method = HSFJSONUtilsTest_2.class.getMethod("f", VeryComplexDO.class);

        String json = "{\n" +
                "\t\"argsTypes\":[\"com.alibaba.json.bvt.support.hsf.HSFJSONUtilsTest_2.VeryComplexDO\"],\n" +
                "\t\"argsObjs\":[\n" +

            

Reported by PMD.

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

Line: 11

              import java.lang.reflect.Method;

public class HSFJSONUtilsTest_2 extends TestCase {
    public void test_for_hsf() throws Exception {
        final Method method = HSFJSONUtilsTest_2.class.getMethod("f", VeryComplexDO.class);

        String json = "{\n" +
                "\t\"argsTypes\":[\"com.alibaba.json.bvt.support.hsf.HSFJSONUtilsTest_2.VeryComplexDO\"],\n" +
                "\t\"argsObjs\":[\n" +

            

Reported by PMD.

Avoid unused imports such as 'net.minidev.json.JSONUtil'
Design

Line: 6

              import com.alibaba.fastjson.support.hsf.HSFJSONUtils;
import com.alibaba.fastjson.support.hsf.MethodLocator;
import junit.framework.TestCase;
import net.minidev.json.JSONUtil;

import java.lang.reflect.Method;

public class HSFJSONUtilsTest_2 extends TestCase {
    public void test_for_hsf() throws Exception {

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 35

              
        HSFJSONUtils.parseInvocationArguments(json, new MethodLocator() {

            public Method findMethod(String[] types) {
                return method;
            }
        });

    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/util/IOUtilsTest.java
4 issues
JUnit tests should include assert() or fail()
Design

Line: 9

              import java.io.StringReader;

public class IOUtilsTest extends TestCase {
    public void test_readAll() throws Exception {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < 1024 * 64; ++i) {
            buf.append("a");
        }


            

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

              import java.io.StringReader;

public class IOUtilsTest extends TestCase {
    public void test_readAll() throws Exception {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < 1024 * 64; ++i) {
            buf.append("a");
        }


            

Reported by PMD.

Avoid appending characters as strings in StringBuffer.append.
Performance

Line: 12

                  public void test_readAll() throws Exception {
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < 1024 * 64; ++i) {
            buf.append("a");
        }

        StringReader reader = new StringReader(buf.toString());
        IOUtils.readAll(reader);
    }

            

Reported by PMD.

Ensure that resources like this StringReader object are closed after use
Error

Line: 15

                          buf.append("a");
        }

        StringReader reader = new StringReader(buf.toString());
        IOUtils.readAll(reader);
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/util/GenericFieldInfoTest2.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

               * Created by wenshao on 30/05/2017.
 */
public class GenericFieldInfoTest2 extends TestCase {
    public void test_generic() throws Exception {
        A4 a = JSON.parseObject("{\"data\":[]3}", A4.class);
        assertTrue(a.data instanceof List);
    }



            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

              public class GenericFieldInfoTest2 extends TestCase {
    public void test_generic() throws Exception {
        A4 a = JSON.parseObject("{\"data\":[]3}", A4.class);
        assertTrue(a.data instanceof List);
    }


    public static class A <T> {
        public T data;

            

Reported by PMD.

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

Line: 20

              

    public static class A <T> {
        public T data;
    }

    public static class A1 <T> extends A<T> {

    }

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.TypeReference'
Design

Line: 4

              package com.alibaba.json.bvt.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import junit.framework.TestCase;

import java.util.List;

/**

            

Reported by PMD.