The following issues were found

src/test/java/com/alibaba/json/test/JSONParser2Test.java
21 issues
System.out.println is used
Design

Line: 56

                          f_jackson();
            // f_simple_json();

            System.out.println();
        }

        System.out.println();
        System.out.println(text);
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 59

                          System.out.println();
        }

        System.out.println();
        System.out.println(text);
    }

    public void f_ali_json() throws Exception {
        // String input = "[{\"a\":3}]";

            

Reported by PMD.

System.out.println is used
Design

Line: 60

                      }

        System.out.println();
        System.out.println(text);
    }

    public void f_ali_json() throws Exception {
        // String input = "[{\"a\":3}]";
        long startNano = System.nanoTime();

            

Reported by PMD.

System.out.println is used
Design

Line: 71

                          parser.parse();
        }
        long nano = System.nanoTime() - startNano;
        System.out.println("fast-json \t: " + NumberFormat.getInstance().format(nano));
    }

    private void f_jackson() throws Exception {
        long startNano = System.nanoTime();
        for (int i = 0; i < COUNT; ++i) {

            

Reported by PMD.

System.out.println is used
Design

Line: 83

                          // JsonNode body = node.get(1);
        }
        long nano = System.nanoTime() - startNano;
        System.out.println("jackson \t: " + NumberFormat.getInstance().format(nano));
    }
}

            

Reported by PMD.

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

Line: 30

              
public class JSONParser2Test extends TestCase {

    private String text;
    private int    COUNT = 1000 * 10;

    protected void setUp() throws Exception {
        // String resource = "json/Bug_0_Test.json";
        String resource = "json/Bug_0_Test.json";

            

Reported by PMD.

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

Line: 31

              public class JSONParser2Test extends TestCase {

    private String text;
    private int    COUNT = 1000 * 10;

    protected void setUp() throws Exception {
        // String resource = "json/Bug_0_Test.json";
        String resource = "json/Bug_0_Test.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);

            

Reported by PMD.

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

Line: 31

              public class JSONParser2Test extends TestCase {

    private String text;
    private int    COUNT = 1000 * 10;

    protected void setUp() throws Exception {
        // String resource = "json/Bug_0_Test.json";
        String resource = "json/Bug_0_Test.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 33

                  private String text;
    private int    COUNT = 1000 * 10;

    protected void setUp() throws Exception {
        // String resource = "json/Bug_0_Test.json";
        String resource = "json/Bug_0_Test.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        text = IOUtils.toString(is);
        is.close();

            

Reported by PMD.

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

Line: 36

                  protected void setUp() throws Exception {
        // String resource = "json/Bug_0_Test.json";
        String resource = "json/Bug_0_Test.json";
        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
        text = IOUtils.toString(is);
        is.close();

        // text =
        // "[{\"S\":321061,\"T\":\"GetAttributeResp\"},{\"ERROR\":null,\"TS\":0,\"VAL\":{\"SqlList\":[{\"BatchSizeMax\":0,\"BatchSizeTotal\":0,\"ConcurrentMax\":1,\"DataSource\":\"jdbc:wrap-jdbc:filters=default,encoding:name=ds-offer:jdbc:mysql://100.10.10.10:8066/xxx\",\"EffectedRowCount\":0,\"ErrorCount\":0,\"ExecuteCount\":5,\"FetchRowCount\":5,\"File\":null,\"ID\":2001,\"LastError\":null,\"LastTime\":1292742908178,\"MaxTimespan\":16,\"MaxTimespanOccurTime\":1292742668191,\"Name\":null,\"RunningCount\":0,\"SQL\":\"SELECT @@SQL_MODE\",\"TotalTime\":83}]}}]";

            

Reported by PMD.

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

    public void test_0() throws Exception {
        Model object = new Model();
        object.value = "<script>alert(1);</script>";
        String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
//        assertEquals("{\"value\":\"&lt;script&gt;alert(1);&lt;\\/script&gt;\"}", text);
        assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);

            

Reported by PMD.

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

Line: 13

              
public class SerializeWriterTest_BrowserSecure_5_script_model extends TestCase {

    public void test_0() throws Exception {
        Model object = new Model();
        object.value = "<script>alert(1);</script>";
        String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
//        assertEquals("{\"value\":\"&lt;script&gt;alert(1);&lt;\\/script&gt;\"}", text);
        assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      object.value = "<script>alert(1);</script>";
        String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
//        assertEquals("{\"value\":\"&lt;script&gt;alert(1);&lt;\\/script&gt;\"}", text);
        assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);
        Model object1 = JSON.parseObject(text, Model.class);
        assertEquals(object.value, object1.value);
    }

    public void test_1() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

              //        assertEquals("{\"value\":\"&lt;script&gt;alert(1);&lt;\\/script&gt;\"}", text);
        assertEquals("{\"value\":\"\\u003Cscript\\u003Ealert\\u00281\\u0029;\\u003C/script\\u003E\"}", text);
        Model object1 = JSON.parseObject(text, Model.class);
        assertEquals(object.value, object1.value);
    }

    public void test_1() throws Exception {
        Model object = new Model();
        object.value = "<";

            

Reported by PMD.

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

Line: 23

                      assertEquals(object.value, object1.value);
    }

    public void test_1() throws Exception {
        Model object = new Model();
        object.value = "<";
        String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
//        assertEquals("{\"value\":\"&lt;script&gt;alert(1);&lt;\\/script&gt;\"}", text);
        assertEquals("{\"value\":\"\\u003C\"}", 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: 23

                      assertEquals(object.value, object1.value);
    }

    public void test_1() throws Exception {
        Model object = new Model();
        object.value = "<";
        String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
//        assertEquals("{\"value\":\"&lt;script&gt;alert(1);&lt;\\/script&gt;\"}", text);
        assertEquals("{\"value\":\"\\u003C\"}", text);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                      object.value = "<";
        String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
//        assertEquals("{\"value\":\"&lt;script&gt;alert(1);&lt;\\/script&gt;\"}", text);
        assertEquals("{\"value\":\"\\u003C\"}", text);
        Model object1 = JSON.parseObject(text, Model.class);
        assertEquals(object.value, object1.value);
    }

    public void test_2() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

              //        assertEquals("{\"value\":\"&lt;script&gt;alert(1);&lt;\\/script&gt;\"}", text);
        assertEquals("{\"value\":\"\\u003C\"}", text);
        Model object1 = JSON.parseObject(text, Model.class);
        assertEquals(object.value, object1.value);
    }

    public void test_2() throws Exception {
        Model object = new Model();
        object.value = "<script>";

            

Reported by PMD.

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

Line: 33

                      assertEquals(object.value, object1.value);
    }

    public void test_2() throws Exception {
        Model object = new Model();
        object.value = "<script>";
        String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
//        assertEquals("{\"value\":\"&lt;script&gt;alert(1);&lt;\\/script&gt;\"}", text);
        assertEquals("{\"value\":\"\\u003Cscript\\u003E\"}", 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: 33

                      assertEquals(object.value, object1.value);
    }

    public void test_2() throws Exception {
        Model object = new Model();
        object.value = "<script>";
        String text = JSON.toJSONString(object, SerializerFeature.BrowserSecure);
//        assertEquals("{\"value\":\"&lt;script&gt;alert(1);&lt;\\/script&gt;\"}", text);
        assertEquals("{\"value\":\"\\u003Cscript\\u003E\"}", text);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_fushou.java
21 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 15

              
public class Bug_for_fushou extends TestCase{

	public void test_case1() {
		String text = "{\"modules\":{}}";
		L1<?> r1 = JSONObject.parseObject(text, new TypeReference<L1<L2>>() {
		});
		assertEquals(true, r1.getModules() instanceof L2);


            

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

              
public class Bug_for_fushou extends TestCase{

	public void test_case1() {
		String text = "{\"modules\":{}}";
		L1<?> r1 = JSONObject.parseObject(text, new TypeReference<L1<L2>>() {
		});
		assertEquals(true, r1.getModules() instanceof L2);


            

Reported by PMD.

Use assertTrue(x)/assertFalse(x) instead of assertEquals(true, x)/assertEquals(false, x) or assertEquals(Boolean.TRUE, x)/assertEquals(Boolean.FALSE, x).
Design

Line: 19

              		String text = "{\"modules\":{}}";
		L1<?> r1 = JSONObject.parseObject(text, new TypeReference<L1<L2>>() {
		});
		assertEquals(true, r1.getModules() instanceof L2);

		L1 r2 = JSONObject.parseObject(text, new TypeReference<L1>() {
		});
		assertEquals(true, r2.getModules() instanceof JSONObject);
		assertEquals(false, r2.getModules() instanceof L2);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

              		String text = "{\"modules\":{}}";
		L1<?> r1 = JSONObject.parseObject(text, new TypeReference<L1<L2>>() {
		});
		assertEquals(true, r1.getModules() instanceof L2);

		L1 r2 = JSONObject.parseObject(text, new TypeReference<L1>() {
		});
		assertEquals(true, r2.getModules() instanceof JSONObject);
		assertEquals(false, r2.getModules() instanceof L2);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 23

              
		L1 r2 = JSONObject.parseObject(text, new TypeReference<L1>() {
		});
		assertEquals(true, r2.getModules() instanceof JSONObject);
		assertEquals(false, r2.getModules() instanceof L2);
	}

	public void test_case2() {
		String text = "{\"modules\":{}}";

            

Reported by PMD.

Use assertTrue(x)/assertFalse(x) instead of assertEquals(true, x)/assertEquals(false, x) or assertEquals(Boolean.TRUE, x)/assertEquals(Boolean.FALSE, x).
Design

Line: 23

              
		L1 r2 = JSONObject.parseObject(text, new TypeReference<L1>() {
		});
		assertEquals(true, r2.getModules() instanceof JSONObject);
		assertEquals(false, r2.getModules() instanceof L2);
	}

	public void test_case2() {
		String text = "{\"modules\":{}}";

            

Reported by PMD.

Use assertTrue(x)/assertFalse(x) instead of assertEquals(true, x)/assertEquals(false, x) or assertEquals(Boolean.TRUE, x)/assertEquals(Boolean.FALSE, x).
Design

Line: 24

              		L1 r2 = JSONObject.parseObject(text, new TypeReference<L1>() {
		});
		assertEquals(true, r2.getModules() instanceof JSONObject);
		assertEquals(false, r2.getModules() instanceof L2);
	}

	public void test_case2() {
		String text = "{\"modules\":{}}";
		L1<?> r0 = JSONObject.parseObject(text, new TypeReference<L1>() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 24

              		L1 r2 = JSONObject.parseObject(text, new TypeReference<L1>() {
		});
		assertEquals(true, r2.getModules() instanceof JSONObject);
		assertEquals(false, r2.getModules() instanceof L2);
	}

	public void test_case2() {
		String text = "{\"modules\":{}}";
		L1<?> r0 = JSONObject.parseObject(text, new TypeReference<L1>() {

            

Reported by PMD.

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

Line: 27

              		assertEquals(false, r2.getModules() instanceof L2);
	}

	public void test_case2() {
		String text = "{\"modules\":{}}";
		L1<?> r0 = JSONObject.parseObject(text, new TypeReference<L1>() {
		});
		assertEquals(JSONObject.class, r0.getModules().getClass());


            

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

              		assertEquals(false, r2.getModules() instanceof L2);
	}

	public void test_case2() {
		String text = "{\"modules\":{}}";
		L1<?> r0 = JSONObject.parseObject(text, new TypeReference<L1>() {
		});
		assertEquals(JSONObject.class, r0.getModules().getClass());


            

Reported by PMD.

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

    public void test_list_in() throws Exception {
        JSONPath path = new JSONPath("[name in ('ljw2083')]");

        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));

            

Reported by PMD.

The String literal 'ljw2083' appears 4 times in this file; the first occurrence is on line 18
Error

Line: 18

                      JSONPath path = new JSONPath("[name in ('ljw2083')]");

        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, "yakolee"));
        entities.add(new Entity(1004, null));

        List<Object> result = (List<Object>) path.eval(entities);

            

Reported by PMD.

The String literal 'wenshao' appears 4 times in this file; the first occurrence is on line 19
Error

Line: 19

              
        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, "yakolee"));
        entities.add(new Entity(1004, null));

        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());

            

Reported by PMD.

The String literal 'yakolee' appears 4 times in this file; the first occurrence is on line 20
Error

Line: 20

                      List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));
        entities.add(new Entity(1003, "yakolee"));
        entities.add(new Entity(1004, null));

        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(0), result.get(0));

            

Reported by PMD.

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

Line: 24

                      entities.add(new Entity(1004, null));

        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
    }
    
    public void test_list_not_in() throws Exception {
        JSONPath path = new JSONPath("[name not in ('ljw2083')]");

            

Reported by PMD.

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

Line: 25

              
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(1, result.size());
        Assert.assertSame(entities.get(0), result.get(0));
    }
    
    public void test_list_not_in() throws Exception {
        JSONPath path = new JSONPath("[name not in ('ljw2083')]");
        

            

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

                      Assert.assertSame(entities.get(0), result.get(0));
    }
    
    public void test_list_not_in() throws Exception {
        JSONPath path = new JSONPath("[name not in ('ljw2083')]");
        
        List<Entity> entities = new ArrayList<Entity>();
        entities.add(new Entity(1001, "ljw2083"));
        entities.add(new Entity(1002, "wenshao"));

            

Reported by PMD.

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

Line: 38

                      entities.add(new Entity(1004, null));
        
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(3, result.size());
        Assert.assertSame(entities.get(1), result.get(0));
        Assert.assertSame(entities.get(2), result.get(1));
        Assert.assertSame(entities.get(3), result.get(2));
    }
    

            

Reported by PMD.

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

Line: 39

                      
        List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(3, result.size());
        Assert.assertSame(entities.get(1), result.get(0));
        Assert.assertSame(entities.get(2), result.get(1));
        Assert.assertSame(entities.get(3), result.get(2));
    }
    
    public void test_list_in_2() throws Exception {

            

Reported by PMD.

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

Line: 40

                      List<Object> result = (List<Object>) path.eval(entities);
        Assert.assertEquals(3, result.size());
        Assert.assertSame(entities.get(1), result.get(0));
        Assert.assertSame(entities.get(2), result.get(1));
        Assert.assertSame(entities.get(3), result.get(2));
    }
    
    public void test_list_in_2() throws Exception {
        JSONPath path = new JSONPath("[name in ('ljw2083', 'yakolee')]");

            

Reported by PMD.

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

              
public class ListStringFieldTest_dom_array_2 extends TestCase {

    public void test_list() throws Exception {
        String text = "[[\"a\",null,\"b\",\"ab\\\\c\"],[]]";

        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));

            

Reported by PMD.

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

Line: 25

                      String text = "[[\"a\",null,\"b\",\"ab\\\\c\"],[]]";

        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));


            

Reported by PMD.

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

Line: 26

              
        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));

        Assert.assertEquals(0, model.values2.size());

            

Reported by PMD.

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

Line: 27

                      Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));

        Assert.assertEquals(0, model.values2.size());
    }

            

Reported by PMD.

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

Line: 28

                      Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));

        Assert.assertEquals(0, model.values2.size());
    }


            

Reported by PMD.

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

Line: 29

                      Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));

        Assert.assertEquals(0, model.values2.size());
    }

    public void test_list2() throws Exception {

            

Reported by PMD.

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

Line: 31

                      Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));

        Assert.assertEquals(0, model.values2.size());
    }

    public void test_list2() throws Exception {
        String text = "{\"values\":[\"a\",null,\"b\",\"ab\\\\c\"],\"values2\":[]}";


            

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

                      Assert.assertEquals(0, model.values2.size());
    }

    public void test_list2() throws Exception {
        String text = "{\"values\":[\"a\",null,\"b\",\"ab\\\\c\"],\"values2\":[]}";

        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));

            

Reported by PMD.

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

Line: 38

                      String text = "{\"values\":[\"a\",null,\"b\",\"ab\\\\c\"],\"values2\":[]}";

        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));


            

Reported by PMD.

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

Line: 39

              
        Model model = JSON.parseObject(text, Model.class);
        Assert.assertEquals(4, model.values.size());
        Assert.assertEquals("a", model.values.get(0));
        Assert.assertEquals(null, model.values.get(1));
        Assert.assertEquals("b", model.values.get(2));
        Assert.assertEquals("ab\\c", model.values.get(3));

        Assert.assertEquals(0, model.values2.size());

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2600/Issue2689.java
21 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

              
public class Issue2689 extends TestCase
{
    public void test_0() throws Exception {
        Exception error = null;
        try {
            JSON.parse("{\"val\":\"\\x~\"");
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      } catch (JSONException ex) {
            error = ex;
        }
        assertTrue(
                error.getMessage().startsWith("invalid escape character"));
    }

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

            

Reported by PMD.

The String literal 'invalid escape character' appears 4 times in this file; the first occurrence is on line 17
Error

Line: 17

                          error = ex;
        }
        assertTrue(
                error.getMessage().startsWith("invalid escape character"));
    }

    public void test_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

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

Line: 17

                          error = ex;
        }
        assertTrue(
                error.getMessage().startsWith("invalid escape character"));
    }

    public void test_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

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

Line: 17

                          error = ex;
        }
        assertTrue(
                error.getMessage().startsWith("invalid escape character"));
    }

    public void test_1() throws Exception {
        Exception error = null;
        try {

            

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

                              error.getMessage().startsWith("invalid escape character"));
    }

    public void test_1() throws Exception {
        Exception error = null;
        try {
            JSON.parse("{\"val\":'\\x~'");
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

                      } catch (JSONException ex) {
            error = ex;
        }
        assertTrue(
                error.getMessage().startsWith("invalid escape character"));
    }

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

            

Reported by PMD.

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

Line: 28

                          error = ex;
        }
        assertTrue(
                error.getMessage().startsWith("invalid escape character"));
    }

    public void test_2() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

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

Line: 28

                          error = ex;
        }
        assertTrue(
                error.getMessage().startsWith("invalid escape character"));
    }

    public void test_2() throws Exception {
        Exception error = null;
        try {

            

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

                              error.getMessage().startsWith("invalid escape character"));
    }

    public void test_2() throws Exception {
        Exception error = null;
        try {
            JSON.parse("{\"val\":'\\x1'");
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvtVO/DataTransaction.java
21 issues
System.out.println is used
Design

Line: 316

              
        dt.getBody().getParam().setForm(m2);

        System.out.println(dt.toJSON());

        DataTransaction dt2 = DataTransaction.fromJSON(dt.toJSON());
        System.out.println(dt2.toJSON());
    }
}

            

Reported by PMD.

System.out.println is used
Design

Line: 319

                      System.out.println(dt.toJSON());

        DataTransaction dt2 = DataTransaction.fromJSON(dt.toJSON());
        System.out.println(dt2.toJSON());
    }
}

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 1

              package com.alibaba.json.bvtVO;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;

            

Reported by PMD.

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

Line: 19

              
    private static final long serialVersionUID = 1L;

    private Head              head             = new Head();

    private Body              body             = new Body();

    public DataTransaction(){


            

Reported by PMD.

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

Line: 19

              
    private static final long serialVersionUID = 1L;

    private Head              head             = new Head();

    private Body              body             = new Body();

    public DataTransaction(){


            

Reported by PMD.

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

Line: 21

              
    private Head              head             = new Head();

    private Body              body             = new Body();

    public DataTransaction(){

    }


            

Reported by PMD.

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

Line: 21

              
    private Head              head             = new Head();

    private Body              body             = new Body();

    public DataTransaction(){

    }


            

Reported by PMD.

The class 'Head' is suspected to be a Data Class (WOC=16.667%, NOPA=0, NOAM=10, WMC=12)
Design

Line: 30

                  /**
     * Head
     **/
    public static class Head {

        private String appid;

        private String transcode;


            

Reported by PMD.

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

Line: 61

                      /**
         * 处理结果
         */
        public static class Ret {

            private String code;
            private String msg;

            public String getCode() {

            

Reported by PMD.

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

Line: 135

                  /**
     * Body
     */
    public static class Body {

        private Param   param = new Param();

        private DataSet dataset;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest_long.java
21 issues
System.out.println is used
Design

Line: 16

              public class JSONScannerTest_long extends TestCase {

    public void ftest_parse_long() throws Exception {
        System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner("1293770846476");
        lexer.scanNumber();
        Assert.assertEquals(new Long(1293770846476L), (Long) lexer.integerValue());
        Assert.assertEquals(1293770846476L, lexer.longValue());
    }

            

Reported by PMD.

Avoid instantiating Long objects.Call Long.valueOf() instead
Performance

Line: 19

                      System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner("1293770846476");
        lexer.scanNumber();
        Assert.assertEquals(new Long(1293770846476L), (Long) lexer.integerValue());
        Assert.assertEquals(1293770846476L, lexer.longValue());
    }

    public void ftest_parse_long_1() throws Exception {
        System.out.println(System.currentTimeMillis());

            

Reported by PMD.

System.out.println is used
Design

Line: 24

                  }

    public void ftest_parse_long_1() throws Exception {
        System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner(Long.toString(Long.MAX_VALUE));
        lexer.scanNumber();
        Assert.assertEquals(new Long(Long.MAX_VALUE), (Long) lexer.integerValue());
        Assert.assertEquals(Long.MAX_VALUE, lexer.longValue());
    }

            

Reported by PMD.

Avoid instantiating Long objects.Call Long.valueOf() instead
Performance

Line: 27

                      System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner(Long.toString(Long.MAX_VALUE));
        lexer.scanNumber();
        Assert.assertEquals(new Long(Long.MAX_VALUE), (Long) lexer.integerValue());
        Assert.assertEquals(Long.MAX_VALUE, lexer.longValue());
    }

    public void test_parse_long_2() throws Exception {
        System.out.println(System.currentTimeMillis());

            

Reported by PMD.

System.out.println is used
Design

Line: 32

                  }

    public void test_parse_long_2() throws Exception {
        System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner(Long.toString(Long.MIN_VALUE));
        lexer.scanNumber();
        Assert.assertEquals(new Long(Long.MIN_VALUE), (Long) lexer.integerValue());
        Assert.assertEquals(Long.MIN_VALUE, lexer.longValue());
    }

            

Reported by PMD.

Avoid instantiating Long objects.Call Long.valueOf() instead
Performance

Line: 35

                      System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner(Long.toString(Long.MIN_VALUE));
        lexer.scanNumber();
        Assert.assertEquals(new Long(Long.MIN_VALUE), (Long) lexer.integerValue());
        Assert.assertEquals(Long.MIN_VALUE, lexer.longValue());
    }

    public void test_error_0() {
        Exception error = null;

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 15

               */
public class JSONScannerTest_long extends TestCase {

    public void ftest_parse_long() throws Exception {
        System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner("1293770846476");
        lexer.scanNumber();
        Assert.assertEquals(new Long(1293770846476L), (Long) lexer.integerValue());
        Assert.assertEquals(1293770846476L, lexer.longValue());

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 23

                      Assert.assertEquals(1293770846476L, lexer.longValue());
    }

    public void ftest_parse_long_1() throws Exception {
        System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner(Long.toString(Long.MAX_VALUE));
        lexer.scanNumber();
        Assert.assertEquals(new Long(Long.MAX_VALUE), (Long) lexer.integerValue());
        Assert.assertEquals(Long.MAX_VALUE, lexer.longValue());

            

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(Long.MAX_VALUE, lexer.longValue());
    }

    public void test_parse_long_2() throws Exception {
        System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner(Long.toString(Long.MIN_VALUE));
        lexer.scanNumber();
        Assert.assertEquals(new Long(Long.MIN_VALUE), (Long) lexer.integerValue());
        Assert.assertEquals(Long.MIN_VALUE, lexer.longValue());

            

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

                      Assert.assertEquals(Long.MIN_VALUE, lexer.longValue());
    }

    public void test_error_0() {
        Exception error = null;
        try {
            JSONScanner lexer = new JSONScanner("--");
            lexer.scanNumber();
            lexer.longValue();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/comparing_json_modules/Floating_point_Test.java
21 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 24/03/2017.
 */
public class Floating_point_Test extends TestCase {
    public void test_2_1() throws Exception {
        assertEquals("0.0", JSON.toJSONString(0.0));
    }

    public void test_2_2() throws Exception {
        assertEquals("-0.0", JSON.toJSONString(-0.0F));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

               */
public class Floating_point_Test extends TestCase {
    public void test_2_1() throws Exception {
        assertEquals("0.0", JSON.toJSONString(0.0));
    }

    public void test_2_2() throws Exception {
        assertEquals("-0.0", JSON.toJSONString(-0.0F));
    }

            

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

                      assertEquals("0.0", JSON.toJSONString(0.0));
    }

    public void test_2_2() throws Exception {
        assertEquals("-0.0", JSON.toJSONString(-0.0F));
    }

    public void test_2_3() throws Exception {
        assertEquals("1.0", JSON.toJSONString(1.0));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                  }

    public void test_2_2() throws Exception {
        assertEquals("-0.0", JSON.toJSONString(-0.0F));
    }

    public void test_2_3() throws Exception {
        assertEquals("1.0", JSON.toJSONString(1.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: 19

                      assertEquals("-0.0", JSON.toJSONString(-0.0F));
    }

    public void test_2_3() throws Exception {
        assertEquals("1.0", JSON.toJSONString(1.0));
    }

    public void test_2_4() throws Exception {
        assertEquals("0.1", JSON.toJSONString(0.1));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                  }

    public void test_2_3() throws Exception {
        assertEquals("1.0", JSON.toJSONString(1.0));
    }

    public void test_2_4() throws Exception {
        assertEquals("0.1", JSON.toJSONString(0.1));
    }

            

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

                      assertEquals("1.0", JSON.toJSONString(1.0));
    }

    public void test_2_4() throws Exception {
        assertEquals("0.1", JSON.toJSONString(0.1));
    }

    public void test_2_5() throws Exception {
        assertEquals("3.141592653589793", JSON.toJSONString(Math.PI));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 24

                  }

    public void test_2_4() throws Exception {
        assertEquals("0.1", JSON.toJSONString(0.1));
    }

    public void test_2_5() throws Exception {
        assertEquals("3.141592653589793", JSON.toJSONString(Math.PI));
    }

            

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

                      assertEquals("0.1", JSON.toJSONString(0.1));
    }

    public void test_2_5() throws Exception {
        assertEquals("3.141592653589793", JSON.toJSONString(Math.PI));
    }

    public void test_2_6() throws Exception {
        double doubeValue = Math.pow(Math.PI, 100);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                  }

    public void test_2_5() throws Exception {
        assertEquals("3.141592653589793", JSON.toJSONString(Math.PI));
    }

    public void test_2_6() throws Exception {
        double doubeValue = Math.pow(Math.PI, 100);
        assertEquals("5.187848314319592E49", JSON.toJSONString(doubeValue));

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest_int.java
21 issues
System.out.println is used
Design

Line: 16

              public class JSONScannerTest_int extends TestCase {

    public void ftest_parse_long() throws Exception {
        System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner("1293770846");
        lexer.scanNumber();
        Assert.assertEquals(new Integer(1293770846), (Integer) lexer.integerValue());
        Assert.assertEquals(1293770846, lexer.intValue());
    }

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 19

                      System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner("1293770846");
        lexer.scanNumber();
        Assert.assertEquals(new Integer(1293770846), (Integer) lexer.integerValue());
        Assert.assertEquals(1293770846, lexer.intValue());
    }

    public void ftest_parse_long_1() throws Exception {
        System.out.println(System.currentTimeMillis());

            

Reported by PMD.

System.out.println is used
Design

Line: 24

                  }

    public void ftest_parse_long_1() throws Exception {
        System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner(Integer.toString(Integer.MAX_VALUE));
        lexer.scanNumber();
        Assert.assertEquals(new Integer(Integer.MAX_VALUE), (Integer) lexer.integerValue());
        Assert.assertEquals(Integer.MAX_VALUE, lexer.intValue());
    }

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 27

                      System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner(Integer.toString(Integer.MAX_VALUE));
        lexer.scanNumber();
        Assert.assertEquals(new Integer(Integer.MAX_VALUE), (Integer) lexer.integerValue());
        Assert.assertEquals(Integer.MAX_VALUE, lexer.intValue());
    }

    public void test_parse_long_2() throws Exception {
        System.out.println(System.currentTimeMillis());

            

Reported by PMD.

System.out.println is used
Design

Line: 32

                  }

    public void test_parse_long_2() throws Exception {
        System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner(Long.toString(Integer.MIN_VALUE));
        lexer.scanNumber();
        Assert.assertEquals(new Integer(Integer.MIN_VALUE), (Integer) lexer.integerValue());
        Assert.assertEquals(Integer.MIN_VALUE, lexer.intValue());
    }

            

Reported by PMD.

Avoid instantiating Integer objects. Call Integer.valueOf() instead.
Performance

Line: 35

                      System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner(Long.toString(Integer.MIN_VALUE));
        lexer.scanNumber();
        Assert.assertEquals(new Integer(Integer.MIN_VALUE), (Integer) lexer.integerValue());
        Assert.assertEquals(Integer.MIN_VALUE, lexer.intValue());
    }

    public void test_error_0() {
        Exception error = null;

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 15

               */
public class JSONScannerTest_int extends TestCase {

    public void ftest_parse_long() throws Exception {
        System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner("1293770846");
        lexer.scanNumber();
        Assert.assertEquals(new Integer(1293770846), (Integer) lexer.integerValue());
        Assert.assertEquals(1293770846, lexer.intValue());

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 23

                      Assert.assertEquals(1293770846, lexer.intValue());
    }

    public void ftest_parse_long_1() throws Exception {
        System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner(Integer.toString(Integer.MAX_VALUE));
        lexer.scanNumber();
        Assert.assertEquals(new Integer(Integer.MAX_VALUE), (Integer) lexer.integerValue());
        Assert.assertEquals(Integer.MAX_VALUE, lexer.intValue());

            

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(Integer.MAX_VALUE, lexer.intValue());
    }

    public void test_parse_long_2() throws Exception {
        System.out.println(System.currentTimeMillis());
        JSONScanner lexer = new JSONScanner(Long.toString(Integer.MIN_VALUE));
        lexer.scanNumber();
        Assert.assertEquals(new Integer(Integer.MIN_VALUE), (Integer) lexer.integerValue());
        Assert.assertEquals(Integer.MIN_VALUE, lexer.intValue());

            

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

                      Assert.assertEquals(Integer.MIN_VALUE, lexer.intValue());
    }

    public void test_error_0() {
        Exception error = null;
        try {
            JSONScanner lexer = new JSONScanner("--");
            lexer.scanNumber();
            lexer.intValue();

            

Reported by PMD.