The following issues were found

src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest4.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 com.alibaba.fastjson.annotation.JSONField;

public class JSONFieldTest4 extends TestCase {
	public void test_jsonField() throws Exception {
		VO vo = new VO();

		vo.setId(123);
		vo.setFlag(true);


            

Reported by PMD.

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

Line: 20

              		Assert.assertEquals("{\"id\":123}", text);
	}

	public static class VO {
		private int id;

		@JSONField(serialize = false)
		private boolean m_flag;
		

            

Reported by PMD.

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

Line: 24

              		private int id;

		@JSONField(serialize = false)
		private boolean m_flag;
		
		@JSONField(serialize = false)
		private int m_id2;

		public int getId() {

            

Reported by PMD.

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

Line: 27

              		private boolean m_flag;
		
		@JSONField(serialize = false)
		private int m_id2;

		public int getId() {
			return id;
		}


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/typeRef/TypeReferenceTest11.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: 12

               * Created by wenshao on 2016/10/11.
 */
public class TypeReferenceTest11 extends TestCase {
    public void test_same() throws Exception {
        Type type1 = getType(Integer.class);
        Type type2 = getType(Integer.class);

        assertEquals(type1, type2);
        assertSame(type1, type2);

            

Reported by PMD.

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

Line: 12

               * Created by wenshao on 2016/10/11.
 */
public class TypeReferenceTest11 extends TestCase {
    public void test_same() throws Exception {
        Type type1 = getType(Integer.class);
        Type type2 = getType(Integer.class);

        assertEquals(type1, type2);
        assertSame(type1, type2);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      Type type1 = getType(Integer.class);
        Type type2 = getType(Integer.class);

        assertEquals(type1, type2);
        assertSame(type1, type2);
    }

    <T> Type getType(Type type) {
        return new TypeReference<Response<T>>(type) {}.getType();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      Type type2 = getType(Integer.class);

        assertEquals(type1, type2);
        assertSame(type1, type2);
    }

    <T> Type getType(Type type) {
        return new TypeReference<Response<T>>(type) {}.getType();
    }

            

Reported by PMD.

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

              
public class MapTest extends TestCase {

    public void test_no_sort() throws Exception {
        JSONObject obj = new JSONObject(true);
        obj.put("name", "jobs");
        obj.put("id", 33);
        String text = toJSONString(obj);
        Assert.assertEquals("{'name':'jobs','id':33}", 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: 27

                      Assert.assertEquals("{'name':'jobs','id':33}", text);
    }
    
    public void test_null() throws Exception {
        JSONObject obj = new JSONObject(true);
        obj.put("name", null);
        String text = JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue);
        Assert.assertEquals("{\"name\":null}", 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: 52

                      }
    }

    public void test_onJSONField() {
        Map<String, String> map = new HashMap();
        map.put("Ariston", null);
        MapNullValue mapNullValue = new MapNullValue();
        mapNullValue.setMap( map );
        String json = JSON.toJSONString( mapNullValue );

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 58

                      MapNullValue mapNullValue = new MapNullValue();
        mapNullValue.setMap( map );
        String json = JSON.toJSONString( mapNullValue );
        assertEquals("{\"map\":{\"Ariston\":null}}", json);
    }

    class MapNullValue {
        @JSONField(serialzeFeatures = {SerializerFeature.WriteMapNullValue})
        private Map map;

            

Reported by PMD.

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

               * Created by wenshao on 01/04/2017.
 */
public class MaxBufSizeTest2 extends TestCase {
    public void test_max_buf() throws Exception {
        char[] chars = new char[4096];
        Arrays.fill(chars, '0');


        JSONObject jsonObject = new JSONObject();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

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

    public String toJSONString(Object obj) {

        SerializeWriter out = new SerializeWriter();

            

Reported by PMD.

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

Line: 3

              package com.alibaba.json.bvt.serializer;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.SerializeWriter;
import junit.framework.TestCase;


            

Reported by PMD.

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

Line: 24

                      JSONObject jsonObject = new JSONObject();
        jsonObject.put("val", new String(chars));

        Throwable error = null;
        try {
            toJSONString(jsonObject);
        } catch (JSONException e) {
            error = e;
        }

            

Reported by PMD.

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

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

        JSONSerializer.write(out, new Object[] { "a12", "b34" });

        Assert.assertEquals("[\"a12\",\"b34\"]", out.toString());

            

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("[\"a12\",\"b34\"]", out.toString());
    }

    public void test_1() throws Exception {
        SerializeWriter out = new SerializeWriter(1);

        JSONSerializer.write(out, new Object[] {});

        Assert.assertEquals("[]", out.toString());

            

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.assertEquals("[]", out.toString());
    }

    public void test_2() throws Exception {
        SerializeWriter out = new SerializeWriter(1);

        JSONSerializer.write(out, new Object[] { null, null });

        Assert.assertEquals("[null,null]", out.toString());

            

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

                      Assert.assertEquals("[null,null]", out.toString());
    }

    public void test_3() throws Exception {
        Assert.assertEquals("[null,null]", JSON.toJSONString(new Object[] { null, null }, false));
    }
}

            

Reported by PMD.

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

    public void test_root() throws Exception {
        Object obj = new Object();
        Assert.assertSame(obj, new JSONPath("$").eval(obj));
    }

    public void test_null() 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: 19

                      Assert.assertSame(obj, new JSONPath("$").eval(obj));
    }

    public void test_null() throws Exception {
        Assert.assertNull(new JSONPath("$").extract(null));
    }

    public void test_map() throws Exception {
        Map<String, Object> map = new HashMap<String, 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: 23

                      Assert.assertNull(new JSONPath("$").extract(null));
    }

    public void test_map() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("val", new Object());
        Assert.assertSame(map.get("val"), new JSONPath("$.val").eval(map));
    }
    

            

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.assertSame(map.get("val"), new JSONPath("$.val").eval(map));
    }
    
    public void test_entity() throws Exception {
        Entity entity = new Entity();
        entity.setValue(new Object());
        Assert.assertSame(entity.getValue(), new JSONPath("$.value").eval(entity));
    }


            

Reported by PMD.

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

              
public class PatternTest extends TestCase {

    public void test_file() throws Exception {
        Pattern p = Pattern.compile("a*b");

        String text = JSON.toJSONString(p);

        Assert.assertEquals(JSON.toJSONString(p.pattern()), text);

            

Reported by PMD.

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

Line: 17

              
        String text = JSON.toJSONString(p);

        Assert.assertEquals(JSON.toJSONString(p.pattern()), text);

        Pattern p1 = JSON.parseObject(text, Pattern.class);
        Assert.assertEquals(p.pattern(), p1.pattern());
    }
}

            

Reported by PMD.

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

Line: 20

                      Assert.assertEquals(JSON.toJSONString(p.pattern()), text);

        Pattern p1 = JSON.parseObject(text, Pattern.class);
        Assert.assertEquals(p.pattern(), p1.pattern());
    }
}

            

Reported by PMD.

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

Line: 20

                      Assert.assertEquals(JSON.toJSONString(p.pattern()), text);

        Pattern p1 = JSON.parseObject(text, Pattern.class);
        Assert.assertEquals(p.pattern(), p1.pattern());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/taobao/ItemUpdateDOTest.java
4 issues
System.out.println is used
Design

Line: 18

                              SerializerFeature.IgnoreNonFieldGetter, SerializerFeature.WriteClassName,
                SerializerFeature.WriteMapNullValue);

        System.out.println(JSON.toJSONString("\u000B"));
    }

    public static class Model {
        private long f0 = 1;
        private long f1;

            

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 ItemUpdateDOTest extends TestCase {

    public void test_1() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.setAsmEnable(false);
        Model item = new Model();
        JSON.toJSONString(item, config, SerializerFeature.IgnoreErrorGetter,
                SerializerFeature.IgnoreNonFieldGetter, SerializerFeature.WriteClassName,

            

Reported by PMD.

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

Line: 10

              
public class ItemUpdateDOTest extends TestCase {

    public void test_1() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.setAsmEnable(false);
        Model item = new Model();
        JSON.toJSONString(item, config, SerializerFeature.IgnoreErrorGetter,
                SerializerFeature.IgnoreNonFieldGetter, SerializerFeature.WriteClassName,

            

Reported by PMD.

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

Line: 21

                      System.out.println(JSON.toJSONString("\u000B"));
    }

    public static class Model {
        private long f0 = 1;
        private long f1;

        public long getF0() {
            return f0;

            

Reported by PMD.

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

              
public class SerializeConfigTest extends TestCase {

    public void test_0() throws Exception {
        SerializeConfig config = new SerializeConfig();

        Method method = SerializeConfig.class.getDeclaredMethod("createJavaBeanSerializer", Class.class);
        method.setAccessible(true);
        Exception error = null;

            

Reported by PMD.

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

Line: 21

                      SerializeConfig config = new SerializeConfig();

        Method method = SerializeConfig.class.getDeclaredMethod("createJavaBeanSerializer", Class.class);
        method.setAccessible(true);
        Exception error = null;
        try {
            method.invoke(config, int.class);
        } catch (InvocationTargetException ex) {
            error = ex;

            

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.assertNotNull(error);
    }

    public void test_1() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.setTypeKey("%type");
        Assert.assertEquals("%type", config.getTypeKey());

        Assert.assertEquals("{\"%type\":\"java.util.LinkedHashMap\"}",

            

Reported by PMD.

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

Line: 22

              
        Method method = SerializeConfig.class.getDeclaredMethod("createJavaBeanSerializer", Class.class);
        method.setAccessible(true);
        Exception error = null;
        try {
            method.invoke(config, int.class);
        } catch (InvocationTargetException ex) {
            error = ex;
        }

            

Reported by PMD.

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

    public void test_0() throws Exception {
        A a = new A();
        DefaultJSONParser parser = new DefaultJSONParser("{\"id\":123}", ParserConfig.getGlobalInstance());
        parser.parseObject(a);
    }


            

Reported by PMD.

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

Line: 13

              
public class DefaultObjectDeserializerTest11 extends TestCase {

    public void test_0() throws Exception {
        A a = new A();
        DefaultJSONParser parser = new DefaultJSONParser("{\"id\":123}", ParserConfig.getGlobalInstance());
        parser.parseObject(a);
    }


            

Reported by PMD.

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

Line: 5

              
import junit.framework.TestCase;

import org.junit.Assert;

import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.json.bvt.parser.deser.DefaultObjectDeserializerTest4.Entity;


            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.json.bvt.parser.deser.DefaultObjectDeserializerTest4.Entity'
Design

Line: 9

              
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.json.bvt.parser.deser.DefaultObjectDeserializerTest4.Entity;

public class DefaultObjectDeserializerTest11 extends TestCase {

    public void test_0() throws Exception {
        A a = new A();

            

Reported by PMD.