The following issues were found

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

              import java.lang.reflect.Constructor;

public class Issue1524 extends TestCase {
    public void test_user() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazz = classLoader.loadClass("DataClass");

        Constructor constructor = clazz.getConstructor(String.class, String.class);
        Object object = constructor.newInstance("ccc", "ddd");

            

Reported by PMD.

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

Line: 12

              import java.lang.reflect.Constructor;

public class Issue1524 extends TestCase {
    public void test_user() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazz = classLoader.loadClass("DataClass");

        Constructor constructor = clazz.getConstructor(String.class, String.class);
        Object object = constructor.newInstance("ccc", "ddd");

            

Reported by PMD.

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

Line: 16

                      ExtClassLoader classLoader = new ExtClassLoader();
        Class clazz = classLoader.loadClass("DataClass");

        Constructor constructor = clazz.getConstructor(String.class, String.class);
        Object object = constructor.newInstance("ccc", "ddd");
        String json = JSON.toJSONString(object);
        assertEquals("{\"Id\":\"ccc\",\"Name\":\"ddd\"}", json);

        Object object2 = JSON.parseObject(json, clazz);

            

Reported by PMD.

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

Line: 17

                      Class clazz = classLoader.loadClass("DataClass");

        Constructor constructor = clazz.getConstructor(String.class, String.class);
        Object object = constructor.newInstance("ccc", "ddd");
        String json = JSON.toJSONString(object);
        assertEquals("{\"Id\":\"ccc\",\"Name\":\"ddd\"}", json);

        Object object2 = JSON.parseObject(json, clazz);
        String json2 = JSON.toJSONString(object2);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      Constructor constructor = clazz.getConstructor(String.class, String.class);
        Object object = constructor.newInstance("ccc", "ddd");
        String json = JSON.toJSONString(object);
        assertEquals("{\"Id\":\"ccc\",\"Name\":\"ddd\"}", json);

        Object object2 = JSON.parseObject(json, clazz);
        String json2 = JSON.toJSONString(object2);
        assertEquals("{\"Id\":\"ccc\",\"Name\":\"ddd\"}", json2);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 23

              
        Object object2 = JSON.parseObject(json, clazz);
        String json2 = JSON.toJSONString(object2);
        assertEquals("{\"Id\":\"ccc\",\"Name\":\"ddd\"}", json2);
    }

    public static class ExtClassLoader extends ClassLoader {

        public ExtClassLoader() throws IOException {

            

Reported by PMD.

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

Line: 33

              
            {
                byte[] bytes;
                InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/issue1526/DataClass.clazz");
                bytes = IOUtils.toByteArray(is);
                is.close();

                super.defineClass("DataClass", bytes, 0, bytes.length);
            }

            

Reported by PMD.

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

              import junit.framework.TestCase;

public class BigDecimalKeyFieldTest extends TestCase {
    public void test_for_bigdecimal_key() throws Exception {
        Map<?, ?> obj = JSON.parseObject("{1234.56:\"abc\"}", HashMap.class);
        Map.Entry<?, ?> entry = obj.entrySet().iterator().next();
        Assert.assertEquals("abc", entry.getValue());
        Assert.assertEquals(new BigDecimal("1234.56"), entry.getKey());
    }

            

Reported by PMD.

Avoid using implementation types like 'HashMap'; use the interface instead
Design

Line: 15

              
public class BigDecimalKeyFieldTest extends TestCase {
    public void test_for_bigdecimal_key() throws Exception {
        Map<?, ?> obj = JSON.parseObject("{1234.56:\"abc\"}", HashMap.class);
        Map.Entry<?, ?> entry = obj.entrySet().iterator().next();
        Assert.assertEquals("abc", entry.getValue());
        Assert.assertEquals(new BigDecimal("1234.56"), entry.getKey());
    }
}

            

Reported by PMD.

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

Line: 16

              public class BigDecimalKeyFieldTest extends TestCase {
    public void test_for_bigdecimal_key() throws Exception {
        Map<?, ?> obj = JSON.parseObject("{1234.56:\"abc\"}", HashMap.class);
        Map.Entry<?, ?> entry = obj.entrySet().iterator().next();
        Assert.assertEquals("abc", entry.getValue());
        Assert.assertEquals(new BigDecimal("1234.56"), entry.getKey());
    }
}

            

Reported by PMD.

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

Line: 16

              public class BigDecimalKeyFieldTest extends TestCase {
    public void test_for_bigdecimal_key() throws Exception {
        Map<?, ?> obj = JSON.parseObject("{1234.56:\"abc\"}", HashMap.class);
        Map.Entry<?, ?> entry = obj.entrySet().iterator().next();
        Assert.assertEquals("abc", entry.getValue());
        Assert.assertEquals(new BigDecimal("1234.56"), entry.getKey());
    }
}

            

Reported by PMD.

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

Line: 16

              public class BigDecimalKeyFieldTest extends TestCase {
    public void test_for_bigdecimal_key() throws Exception {
        Map<?, ?> obj = JSON.parseObject("{1234.56:\"abc\"}", HashMap.class);
        Map.Entry<?, ?> entry = obj.entrySet().iterator().next();
        Assert.assertEquals("abc", entry.getValue());
        Assert.assertEquals(new BigDecimal("1234.56"), entry.getKey());
    }
}

            

Reported by PMD.

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

Line: 17

                  public void test_for_bigdecimal_key() throws Exception {
        Map<?, ?> obj = JSON.parseObject("{1234.56:\"abc\"}", HashMap.class);
        Map.Entry<?, ?> entry = obj.entrySet().iterator().next();
        Assert.assertEquals("abc", entry.getValue());
        Assert.assertEquals(new BigDecimal("1234.56"), entry.getKey());
    }
}

            

Reported by PMD.

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

Line: 18

                      Map<?, ?> obj = JSON.parseObject("{1234.56:\"abc\"}", HashMap.class);
        Map.Entry<?, ?> entry = obj.entrySet().iterator().next();
        Assert.assertEquals("abc", entry.getValue());
        Assert.assertEquals(new BigDecimal("1234.56"), entry.getKey());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/ClassConstructorTest1.java
7 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: 9

              import org.springframework.util.Assert;

public class ClassConstructorTest1 extends TestCase {
    public void test_error() throws Exception {
        String modelJSON = "{\"age\":12, \"name\":\"nanqi\"}";
        Model model = JSON.parseObject(modelJSON, Model.class);
//        Assert.notNull(model.getName());
        //skip
    }

            

Reported by PMD.

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

Line: 9

              import org.springframework.util.Assert;

public class ClassConstructorTest1 extends TestCase {
    public void test_error() throws Exception {
        String modelJSON = "{\"age\":12, \"name\":\"nanqi\"}";
        Model model = JSON.parseObject(modelJSON, Model.class);
//        Assert.notNull(model.getName());
        //skip
    }

            

Reported by PMD.

Avoid unused local variables such as 'model'.
Design

Line: 11

              public class ClassConstructorTest1 extends TestCase {
    public void test_error() throws Exception {
        String modelJSON = "{\"age\":12, \"name\":\"nanqi\"}";
        Model model = JSON.parseObject(modelJSON, Model.class);
//        Assert.notNull(model.getName());
        //skip
    }

    public static class Model {

            

Reported by PMD.

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

Line: 16

                      //skip
    }

    public static class Model {
        public Model(int age) {
            this.age = age;
        }

        private String name;

            

Reported by PMD.

Avoid unused imports such as 'org.junit.Test'
Design

Line: 5

              
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import org.junit.Test;
import org.springframework.util.Assert;

public class ClassConstructorTest1 extends TestCase {
    public void test_error() throws Exception {
        String modelJSON = "{\"age\":12, \"name\":\"nanqi\"}";

            

Reported by PMD.

Avoid unused imports such as 'org.springframework.util.Assert'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import org.junit.Test;
import org.springframework.util.Assert;

public class ClassConstructorTest1 extends TestCase {
    public void test_error() throws Exception {
        String modelJSON = "{\"age\":12, \"name\":\"nanqi\"}";
        Model model = JSON.parseObject(modelJSON, Model.class);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'model' (lines '11'-'14').
Error

Line: 11

              public class ClassConstructorTest1 extends TestCase {
    public void test_error() throws Exception {
        String modelJSON = "{\"age\":12, \"name\":\"nanqi\"}";
        Model model = JSON.parseObject(modelJSON, Model.class);
//        Assert.notNull(model.getName());
        //skip
    }

    public static class Model {

            

Reported by PMD.

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

    public void test_parse() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("1");
        Assert.assertEquals(Integer.valueOf(1), parser.parse());

        Exception error = null;
        try {

            

Reported by PMD.

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

Line: 23

                      Exception error = null;
        try {
            parser.parse();
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }


            

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

                      Assert.assertNotNull(error);
    }

    public void test_parse_str() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("\"1\"");
        parser.config(Feature.AllowISO8601DateFormat, true);
        Assert.assertEquals("1", parser.parse());

    }

            

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

              
    }

    public void test_parseArray() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("[1]");
        parser.config(Feature.AllowArbitraryCommas, false);
        List<String> list = new ArrayList<String>();
        parser.parseArray(String.class, list);
        Assert.assertEquals(1, list.size());

            

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

                      Assert.assertEquals(1, list.size());
    }

    public void test_parseArray_error() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("[1,2}");
        parser.config(Feature.AllowArbitraryCommas, false);
        List<String> list = new ArrayList<String>();

        Exception error = null;

            

Reported by PMD.

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

Line: 20

                      DefaultJSONParser parser = new DefaultJSONParser("1");
        Assert.assertEquals(Integer.valueOf(1), parser.parse());

        Exception error = null;
        try {
            parser.parse();
        } catch (Exception ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '49'-'53').
Error

Line: 49

                      parser.config(Feature.AllowArbitraryCommas, false);
        List<String> list = new ArrayList<String>();

        Exception error = null;
        try {
            parser.parseArray(String.class, list);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

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

              import junit.framework.TestCase;

public class FastMatchCheckTest extends TestCase {
    public void test_match() throws Exception {
        Assert.assertEquals(JSONToken.LBRACKET, AtomicCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, SqlDateDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LBRACKET, ObjectArrayCodec.instance.getFastMatchToken());

            

Reported by PMD.

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

Line: 17

              
public class FastMatchCheckTest extends TestCase {
    public void test_match() throws Exception {
        Assert.assertEquals(JSONToken.LBRACKET, AtomicCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, SqlDateDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LBRACKET, ObjectArrayCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_STRING, CharacterCodec.instance.getFastMatchToken());

            

Reported by PMD.

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

Line: 18

              public class FastMatchCheckTest extends TestCase {
    public void test_match() throws Exception {
        Assert.assertEquals(JSONToken.LBRACKET, AtomicCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, SqlDateDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LBRACKET, ObjectArrayCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_STRING, CharacterCodec.instance.getFastMatchToken());
    }

            

Reported by PMD.

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

Line: 19

                  public void test_match() throws Exception {
        Assert.assertEquals(JSONToken.LBRACKET, AtomicCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, SqlDateDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LBRACKET, ObjectArrayCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_STRING, CharacterCodec.instance.getFastMatchToken());
    }
}

            

Reported by PMD.

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

Line: 20

                      Assert.assertEquals(JSONToken.LBRACKET, AtomicCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, SqlDateDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LBRACKET, ObjectArrayCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_STRING, CharacterCodec.instance.getFastMatchToken());
    }
}

            

Reported by PMD.

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

Line: 21

                      Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, SqlDateDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LBRACKET, ObjectArrayCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_STRING, CharacterCodec.instance.getFastMatchToken());
    }
}

            

Reported by PMD.

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

Line: 22

                      Assert.assertEquals(JSONToken.LITERAL_INT, NumberDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_INT, SqlDateDeserializer.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LBRACKET, ObjectArrayCodec.instance.getFastMatchToken());
        Assert.assertEquals(JSONToken.LITERAL_STRING, CharacterCodec.instance.getFastMatchToken());
    }
}

            

Reported by PMD.

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

    public void test_e() throws Exception {
        StringBuffer buf = new StringBuffer();
        buf.append("{\"type\":'");
        for (int i = 0; i < 100; ++i) {
            buf.append('a');
        }

            

Reported by PMD.

StringBuffer constructor is initialized with size 16, but has at least 17 characters appended.
Performance

Line: 12

              public class JSONLexerTest_14 extends TestCase {

    public void test_e() throws Exception {
        StringBuffer buf = new StringBuffer();
        buf.append("{\"type\":'");
        for (int i = 0; i < 100; ++i) {
            buf.append('a');
        }
        buf.append("\\t");

            

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

                      for (int i = 0; i < 100; ++i) {
            buf.append('a');
        }
        buf.append("\\t");
        buf.append("'}");
        VO vo = JSON.parseObject(buf.toString(), VO.class);
        String type = vo.getType();
        for (int i = 0; i < 100; ++i) {
            Assert.assertEquals('a', type.charAt(i));

            

Reported by PMD.

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

Line: 17

                      for (int i = 0; i < 100; ++i) {
            buf.append('a');
        }
        buf.append("\\t");
        buf.append("'}");
        VO vo = JSON.parseObject(buf.toString(), VO.class);
        String type = vo.getType();
        for (int i = 0; i < 100; ++i) {
            Assert.assertEquals('a', type.charAt(i));

            

Reported by PMD.

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

Line: 20

                      buf.append("\\t");
        buf.append("'}");
        VO vo = JSON.parseObject(buf.toString(), VO.class);
        String type = vo.getType();
        for (int i = 0; i < 100; ++i) {
            Assert.assertEquals('a', type.charAt(i));
        }
        Assert.assertEquals('\t', type.charAt(100));
        Assert.assertEquals(101, type.length());

            

Reported by PMD.

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

Line: 24

                      for (int i = 0; i < 100; ++i) {
            Assert.assertEquals('a', type.charAt(i));
        }
        Assert.assertEquals('\t', type.charAt(100));
        Assert.assertEquals(101, type.length());
    }


    public static class VO {

            

Reported by PMD.

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

Line: 25

                          Assert.assertEquals('a', type.charAt(i));
        }
        Assert.assertEquals('\t', type.charAt(100));
        Assert.assertEquals(101, type.length());
    }


    public static class VO {
        public VO(){

            

Reported by PMD.

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

Line: 14

              
public class JSONReaderTest_array_array_2 extends TestCase {

    String text = "[[],[],[],[],[], [],[],[],[],[]]";

    public void test_read() throws Exception {

        JSONReader reader = new JSONReader(new StringReader(text));
        reader.startArray();

            

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

              
    String text = "[[],[],[],[],[], [],[],[],[],[]]";

    public void test_read() throws Exception {

        JSONReader reader = new JSONReader(new StringReader(text));
        reader.startArray();

        int count = 0;

            

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

                      reader.close();
    }

    public void test_read_1() throws Exception {
        JSONReader reader = new JSONReader(new JSONScanner(text));
        reader.startArray();

        int count = 0;
        while (reader.hasNext()) {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '21'-'25').
Error

Line: 21

                      JSONReader reader = new JSONReader(new StringReader(text));
        reader.startArray();

        int count = 0;
        while (reader.hasNext()) {
            reader.startArray();
            reader.endArray();
            count++;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '25'-'25').
Error

Line: 25

                      while (reader.hasNext()) {
            reader.startArray();
            reader.endArray();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endArray();
        reader.close();

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '37'-'41').
Error

Line: 37

                      JSONReader reader = new JSONReader(new JSONScanner(text));
        reader.startArray();

        int count = 0;
        while (reader.hasNext()) {
            reader.startArray();
            reader.endArray();
            count++;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '41'-'41').
Error

Line: 41

                      while (reader.hasNext()) {
            reader.startArray();
            reader.endArray();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endArray();
        reader.close();

            

Reported by PMD.

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

Line: 14

              
public class JSONReaderTest_array_object_2 extends TestCase {

    String text = "[{},{},{},{},{} ,{},{},{},{},{}]";

    public void test_read() throws Exception {

        JSONReader reader = new JSONReader(new StringReader(text));
        reader.startArray();

            

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

              
    String text = "[{},{},{},{},{} ,{},{},{},{},{}]";

    public void test_read() throws Exception {

        JSONReader reader = new JSONReader(new StringReader(text));
        reader.startArray();

        int count = 0;

            

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

                      reader.close();
    }

    public void test_read_1() throws Exception {
        JSONReader reader = new JSONReader(new JSONScanner(text));
        reader.startArray();

        int count = 0;
        while (reader.hasNext()) {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '21'-'25').
Error

Line: 21

                      JSONReader reader = new JSONReader(new StringReader(text));
        reader.startArray();

        int count = 0;
        while (reader.hasNext()) {
            reader.startObject();
            reader.endObject();
            count++;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '25'-'25').
Error

Line: 25

                      while (reader.hasNext()) {
            reader.startObject();
            reader.endObject();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endArray();
        reader.close();

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '37'-'41').
Error

Line: 37

                      JSONReader reader = new JSONReader(new JSONScanner(text));
        reader.startArray();

        int count = 0;
        while (reader.hasNext()) {
            reader.startObject();
            reader.endObject();
            count++;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '41'-'41').
Error

Line: 41

                      while (reader.hasNext()) {
            reader.startObject();
            reader.endObject();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endArray();
        reader.close();

            

Reported by PMD.

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

    public void test_bool() throws Exception {
        Model model = JSON.parseObject("[true,false]", Model.class, Feature.SupportArrayToBean);
        Assert.assertEquals(true, model.v1);
        Assert.assertEquals(false, 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: 19

                      Assert.assertEquals(false, model.v2);
    }
    
    public void test_bool_space() throws Exception {
        Model model = JSON.parseObject("[true ,false ]", Model.class, Feature.SupportArrayToBean);
        Assert.assertEquals(true, model.v1);
        Assert.assertEquals(false, 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: 25

                      Assert.assertEquals(false, model.v2);
    }

    public void test_bool_num() throws Exception {
        Model model = JSON.parseObject("[1,0]", Model.class, Feature.SupportArrayToBean);
        Assert.assertEquals(true, model.v1);
        Assert.assertEquals(false, 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: 31

                      Assert.assertEquals(false, model.v2);
    }

    public void test_bool_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[t,0]", Model.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 43

              
    public static class Model {

        public boolean v1;
        public boolean v2;
    }
}

            

Reported by PMD.

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

Line: 44

                  public static class Model {

        public boolean v1;
        public boolean v2;
    }
}

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '32'-'36').
Error

Line: 32

                  }

    public void test_bool_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[t,0]", Model.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

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

    public void test_enum() throws Exception {
        Model model = JSON.parseObject("[\"A\",\"B\"]", Model.class, Feature.SupportArrayToBean);
        Assert.assertEquals(Type.A, model.v1);
        Assert.assertEquals(Type.B, 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: 19

                      Assert.assertEquals(Type.B, model.v2);
    }
    
    public void test_enum_space() throws Exception {
        Model model = JSON.parseObject("[\"A\" ,\"B\" ]", Model.class, Feature.SupportArrayToBean);
        Assert.assertEquals(Type.A, model.v1);
        Assert.assertEquals(Type.B, 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: 25

                      Assert.assertEquals(Type.B, model.v2);
    }

    public void test_enum_num() throws Exception {
        Model model = JSON.parseObject("[1,0]", Model.class, Feature.SupportArrayToBean);
        Assert.assertEquals(Type.B, model.v1);
        Assert.assertEquals(Type.A, 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: 31

                      Assert.assertEquals(Type.A, model.v2);
    }

    public void test_enum_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[t,0]", Model.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 43

              
    public static class Model {

        public Type v1;
        public Type v2;
    }
    
    public static enum Type {
        A, B, C

            

Reported by PMD.

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

Line: 44

                  public static class Model {

        public Type v1;
        public Type v2;
    }
    
    public static enum Type {
        A, B, C
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '32'-'36').
Error

Line: 32

                  }

    public void test_enum_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[t,0]", Model.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.