The following issues were found

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

Line: 14

              
public class JSONPath_list_multi extends TestCase {

    List list = new ArrayList();

    public JSONPath_list_multi(){
        list.add(new Object());
        list.add(new Object());
        list.add(new Object());

            

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

                      list.add(new Object());
    }

    public void test_list_multi() throws Exception {
        List<Object> result = (List<Object>) new JSONPath("$[2,4,5,8,100]").eval(list);
        Assert.assertEquals(5, result.size());
        Assert.assertSame(list.get(2), result.get(0));
        Assert.assertSame(list.get(4), result.get(1));
        Assert.assertSame(list.get(5), result.get(2));

            

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

                      Assert.assertNull(result.get(4));
    }

    public void test_list_multi_negative() throws Exception {
        List<Object> result = (List<Object>) new JSONPath("$[-1,-2,-100]").eval(list);
        Assert.assertEquals(3, result.size());
        Assert.assertSame(list.get(9), result.get(0));
        Assert.assertSame(list.get(8), result.get(1));
        Assert.assertNull(result.get(2));

            

Reported by PMD.

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

    public void test() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"20129401\"", VO.class);
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

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

Line: 17

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


            

Reported by PMD.

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

Line: 14

              public class DateParseTest12 extends TestCase {

    public void test() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"20129401\"", VO.class);
        } catch (Exception ex) {
            error = ex;
        }

            

Reported by PMD.

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

              import junit.framework.TestCase;

public class writeJSONStringToTest extends TestCase {
    public void test_writeJSONStringTo() throws Exception {
        Model model = new Model();
        model.id = 1001;
        model.name = "中文名称";
        
        ByteArrayOutputStream os = new ByteArrayOutputStream();

            

Reported by PMD.

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

Line: 27

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

            

Reported by PMD.

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

Line: 28

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

            

Reported by PMD.

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

    public void test_writer() throws Exception {
        StringWriter out = new StringWriter();
        JSONWriter writer = new JSONWriter(out);

        writer.startObject();
        writer.writeKey("value");

            

Reported by PMD.

Avoid unused imports such as 'java.util.Collections'
Design

Line: 4

              package com.alibaba.json.bvt.stream;

import java.io.StringWriter;
import java.util.Collections;

import junit.framework.TestCase;

import org.junit.Assert;


            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.serializer.SerializerFeature'
Design

Line: 11

              import org.junit.Assert;

import com.alibaba.fastjson.JSONWriter;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class JSONWriterTest_5 extends TestCase {

    public void test_writer() throws Exception {
        StringWriter out = new StringWriter();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/FieldDeserializerTest.java
3 issues
Avoid throwing raw exception types.
Design

Line: 30

                      }

        public void setValue(V1 value) {
            throw new RuntimeException();
        }

    }

    private static class V1 {

            

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

              
public class FieldDeserializerTest extends TestCase {

    public void test_deser() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{'value':{}}", Entity.class);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 12

              public class FieldDeserializerTest extends TestCase {

    public void test_deser() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{'value':{}}", Entity.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

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

    public void test_0() throws Exception {
        StringWriter out = new StringWriter();

        SerializeWriter writer = new SerializeWriter(out, 10);
        Assert.assertEquals(10, writer.getBufferLength());


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 19

                      Assert.assertEquals(10, writer.getBufferLength());

        for (char ch = 'a'; ch <= 'z'; ++ch) {
            char[] chars = new char[] { ch, ch, ch };
            writer.write(chars, 0, chars.length);
        }
        writer.close();

        String text = out.toString();

            

Reported by PMD.

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

Line: 25

                      writer.close();

        String text = out.toString();
        Assert.assertEquals(26 * 3, text.length());

        for (int i = 0; i < 26; ++i) {
            Assert.assertEquals(text.charAt(i * 3), (char) ('a' + i));
            Assert.assertEquals(text.charAt(i * 3 + 1), (char) ('a' + i));
            Assert.assertEquals(text.charAt(i * 3 + 2), (char) ('a' + i));

            

Reported by PMD.

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

    public void test_includes() throws Exception {
        VO vo = new VO();
        vo.setId(123);
        vo.setName("wenshao");
        vo.setPassword("ooxxx");


            

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

                      Assert.assertEquals("{\"id\":123,\"name\":\"wenshao\"}", text);
    }
    
    public void test_excludes() throws Exception {
        VO vo = new VO();
        vo.setId(123);
        vo.setName("wenshao");
        vo.setPassword("ooxxx");
        vo.setInfo("fofo");

            

Reported by PMD.

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

Line: 34

                      Assert.assertEquals("{\"id\":123,\"info\":\"fofo\",\"name\":\"wenshao\"}", text);
    }

    public static class VO {

        private int    id;
        private String name;
        private String password;
        private String info;

            

Reported by PMD.

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

    public void test() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"2012040125000a\"}", VO.class);
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

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

Line: 17

                      Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"2012040125000a\"}", VO.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }


            

Reported by PMD.

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

Line: 14

              public class DateParseTest13 extends TestCase {

    public void test() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"date\":\"2012040125000a\"}", VO.class);
        } catch (Exception ex) {
            error = ex;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/support/jaxrs/mock/service/FastJsonRestfulServiceTestImpl.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: 29

              @Service("fastJsonRestful")
public class FastJsonRestfulServiceTestImpl implements FastJsonRestfulServiceTest {

	@Override
	public JSONObject test1(FastJsonTestVO vo) {

		JSONObject jsonObj = new JSONObject();
		
		jsonObj.put("id", vo.getId());

            

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

              		return jsonObj;
	}

	@Override
	public JSONObject test2(List<FastJsonParentTestVO> vos) {

		JSONObject jsonObj = new JSONObject();
		
		for (FastJsonParentTestVO fastJsonParentTestVO : vos) {

            

Reported by PMD.

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

Line: 48

              		
		for (FastJsonParentTestVO fastJsonParentTestVO : vos) {
			
			jsonObj.put(fastJsonParentTestVO.getName(), fastJsonParentTestVO.getSonList().size());
		}
		
		return jsonObj;
	}
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/deny/DenyTest12.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 DenyTest12 extends TestCase {
    public void test_deny() throws Exception {
        String text = "{\"value\":{\"@type\":\"java.lang.Thread\"}}";

        Exception error = null;
        try {
            JSON.parseObject(text, Model.class);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

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

    public static class Model {
        public Value value;
    }

            

Reported by PMD.

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

Line: 14

                  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.