The following issues were found

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1330_decimal.java
24 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 13

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_decimal extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"中ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 13

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_decimal extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"中ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseDecimal error, field : value") != -1);
    }

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

            

Reported by PMD.

Use assertSame(x, y) instead of assertTrue(x==y), or assertNotSame(x,y) vs assertFalse(x==y)
Design

Line: 21

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseDecimal error, field : value") != -1);
    }

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

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseDecimal error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 21

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseDecimal error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 21

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseDecimal error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 24

                      assertTrue(error.getMessage().indexOf("parseDecimal error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

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

                      assertTrue(error.getMessage().indexOf("parseDecimal error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseDecimal error, field : value") != -1);
    }

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

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/MultiFieldIntTest_writer2.java
24 issues
System.out.println is used
Design

Line: 38

                      writer.close();
        
        String text = out.toString();
        System.out.println(text);
        List<Model> results = JSON.parseObject(text, new TypeReference<List<Model>>() {});
        
        Assert.assertEquals(list.size(), results.size());
        for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);

            

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

              
public class MultiFieldIntTest_writer2 extends TestCase {
    
    public void test_for_big_writer() throws Exception {
        List<Model> list = new ArrayList<Model>();
        
        for (int i = 0; i < 1024 * 10; ++i) {
            Model model = new Model();
            model.i = 0;

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 21

                      List<Model> list = new ArrayList<Model>();
        
        for (int i = 0; i < 1024 * 10; ++i) {
            Model model = new Model();
            model.i = 0;
            model.j = 1;
            model.k = 2;
            model.v = 3;
            model.l = 4;

            

Reported by PMD.

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

Line: 43

                      
        Assert.assertEquals(list.size(), results.size());
        for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);

            

Reported by PMD.

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

Line: 43

                      
        Assert.assertEquals(list.size(), results.size());
        for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);

            

Reported by PMD.

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

Line: 44

                      Assert.assertEquals(list.size(), results.size());
        for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);
            Assert.assertEquals(list.get(i).n, results.get(i).n);

            

Reported by PMD.

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

Line: 44

                      Assert.assertEquals(list.size(), results.size());
        for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);
            Assert.assertEquals(list.get(i).n, results.get(i).n);

            

Reported by PMD.

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

Line: 45

                      for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);
            Assert.assertEquals(list.get(i).n, results.get(i).n);
        }

            

Reported by PMD.

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

Line: 45

                      for (int i = 0; i < results.size(); ++i) {
            Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);
            Assert.assertEquals(list.get(i).n, results.get(i).n);
        }

            

Reported by PMD.

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

Line: 46

                          Assert.assertEquals(list.get(i).i, results.get(i).i);
            Assert.assertEquals(list.get(i).j, results.get(i).j);
            Assert.assertEquals(list.get(i).k, results.get(i).k);
            Assert.assertEquals(list.get(i).v, results.get(i).v);
            Assert.assertEquals(list.get(i).l, results.get(i).l);
            Assert.assertEquals(list.get(i).m, results.get(i).m);
            Assert.assertEquals(list.get(i).n, results.get(i).n);
        }
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/test/DigitTest.java
24 issues
System.out.println is used
Design

Line: 36

                          f_isDigitSwitch();
            f_isDigitProhibit();

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

    public void f_isDigitBitSet() throws Exception {

            

Reported by PMD.

System.out.println is used
Design

Line: 37

                          f_isDigitProhibit();

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

    public void f_isDigitBitSet() throws Exception {
        long startNano = System.nanoTime();

            

Reported by PMD.

System.out.println is used
Design

Line: 49

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

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

            

Reported by PMD.

System.out.println is used
Design

Line: 60

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

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

            

Reported by PMD.

System.out.println is used
Design

Line: 71

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

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

            

Reported by PMD.

System.out.println is used
Design

Line: 82

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

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

            

Reported by PMD.

System.out.println is used
Design

Line: 93

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

    private static final boolean[] digitBits = new boolean[256];
    static {
        for (char ch = '0'; ch <= '9'; ++ch) {

            

Reported by PMD.

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

Line: 25

              
public class DigitTest extends TestCase {

    private char[] text  = "[-5.041598256063065E-20,-7210028408342716000]".toCharArray();
    private int    COUNT = 1000 * 1000;

    public void test_perf() throws Exception {
        for (int i = 0; i < 50; ++i) {
            f_isDigitBitSet();

            

Reported by PMD.

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

Line: 25

              
public class DigitTest extends TestCase {

    private char[] text  = "[-5.041598256063065E-20,-7210028408342716000]".toCharArray();
    private int    COUNT = 1000 * 1000;

    public void test_perf() throws Exception {
        for (int i = 0; i < 50; ++i) {
            f_isDigitBitSet();

            

Reported by PMD.

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

Line: 26

              public class DigitTest extends TestCase {

    private char[] text  = "[-5.041598256063065E-20,-7210028408342716000]".toCharArray();
    private int    COUNT = 1000 * 1000;

    public void test_perf() throws Exception {
        for (int i = 0; i < 50; ++i) {
            f_isDigitBitSet();
            f_isDigitArray();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1330_double.java
24 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 11

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_double extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

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

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_double extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseDouble error, field : value") != -1);
    }

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

            

Reported by PMD.

Use assertSame(x, y) instead of assertTrue(x==y), or assertNotSame(x,y) vs assertFalse(x==y)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseDouble error, field : value") != -1);
    }

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

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseDouble error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseDouble error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseDouble error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 22

                      assertTrue(error.getMessage().indexOf("parseDouble error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

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

                      assertTrue(error.getMessage().indexOf("parseDouble error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseDouble error, field : value") != -1);
    }

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

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1330_byte.java
24 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 11

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_byte extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

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

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_byte extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

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

            

Reported by PMD.

Use assertSame(x, y) instead of assertTrue(x==y), or assertNotSame(x,y) vs assertFalse(x==y)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

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

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 22

                      assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

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

                      assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseByte error, field : value") != -1);
    }

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

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1330.java
24 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 11

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330 extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

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

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330 extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

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

            

Reported by PMD.

Use assertSame(x, y) instead of assertTrue(x==y), or assertNotSame(x,y) vs assertFalse(x==y)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

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

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

    public void test_for_issue_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: 22

                      assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

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

Line: 22

                      assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseInt error, field : value") != -1);
    }

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

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2500/Issue2579.java
24 issues
System.out.println is used
Design

Line: 48

              					Assert.assertEquals(i, ((MyPoint2) obj).getBatchNumber());
				}
			} catch (JSONException e) {
				System.out.println(jsonString);
				e.printStackTrace();
				Assert.assertTrue(false);
			}
		}
	}

            

Reported by PMD.

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

Line: 23

              public class Issue2579 extends TestCase {

	// 场景:走ASM
	public void test_for_issue1() throws Exception {
		run_test("MyPoint1");
	}

	// 场景:不走ASM,通过JSONType(asm=false),关闭了ASM
	public void test_for_issue2() 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: 23

              public class Issue2579 extends TestCase {

	// 场景:走ASM
	public void test_for_issue1() throws Exception {
		run_test("MyPoint1");
	}

	// 场景:不走ASM,通过JSONType(asm=false),关闭了ASM
	public void test_for_issue2() 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: 28

              	}

	// 场景:不走ASM,通过JSONType(asm=false),关闭了ASM
	public void test_for_issue2() throws Exception {
		run_test("MyPoint2");
	}

	// 场景:随机顺序组合JSON字符串测试2000次
	private void run_test(String className) {

            

Reported by PMD.

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

Line: 28

              	}

	// 场景:不走ASM,通过JSONType(asm=false),关闭了ASM
	public void test_for_issue2() throws Exception {
		run_test("MyPoint2");
	}

	// 场景:随机顺序组合JSON字符串测试2000次
	private void run_test(String className) {

            

Reported by PMD.

Prefer StringBuilder (non-synchronized) or StringBuffer (synchronized) over += for concatenating strings
Performance

Line: 39

              		String jsonString;
		for (int i = 1; i < 2000; i++) {
			jsonString = getString(i, className);
			jsonString = begin + jsonString + end;
			try {
				Object obj = JSON.parse(jsonString, Feature.SupportAutoType);
				if ("MyPoint1".equals(className)) {
					Assert.assertEquals(i, ((MyPoint1) obj).getBatchNumber());
				} else {

            

Reported by PMD.

Avoid printStackTrace(); use a logger call instead.
Design

Line: 49

              				}
			} catch (JSONException e) {
				System.out.println(jsonString);
				e.printStackTrace();
				Assert.assertTrue(false);
			}
		}
	}


            

Reported by PMD.

Avoid appending characters as strings in StringBuffer.append.
Performance

Line: 77

              			len = list.size();
			index = getRandomIndex(len);
			buffer.append(list.get(index));
			buffer.append(",");
			list.remove(index);
		}
		buffer.deleteCharAt(buffer.length() - 1);
		return buffer.toString();
	}

            

Reported by PMD.

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

Line: 90

              	}

	@SuppressWarnings("serial")
	public static class MyPoint1 extends Point {
		private UUID id;
		private int batchNumber;
		private Point point = new Point();
		private String[] strArr = { "te-st", "tes-t2" };
		private Date date = new Date();

            

Reported by PMD.

Returning 'strArr' may expose an internal array.
Design

Line: 123

              		}

		public String[] getStrArr() {
			return strArr;
		}

		public void setStrArr(String[] strArr) {
			this.strArr = strArr;
		}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1330_boolean.java
24 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 30/07/2017.
 */
public class Issue1330_boolean extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

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

Line: 11

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_boolean extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

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

            

Reported by PMD.

Use assertSame(x, y) instead of assertTrue(x==y), or assertNotSame(x,y) vs assertFalse(x==y)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

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

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

    public void test_for_issue_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: 22

                      assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

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

Line: 22

                      assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseBoolean error, field : value") != -1);
    }

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

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1330_float.java
24 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 30/07/2017.
 */
public class Issue1330_float extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

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

Line: 11

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_float extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseLong error, field : value") != -1);
    }

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

            

Reported by PMD.

Use assertSame(x, y) instead of assertTrue(x==y), or assertNotSame(x,y) vs assertFalse(x==y)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseLong error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseLong error, field : value") != -1);
    }

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

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseLong error, field : value") != -1);
    }

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

            

Reported by PMD.

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

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseLong error, field : value") != -1);
    }

    public void test_for_issue_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: 22

                      assertTrue(error.getMessage().indexOf("parseLong error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

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

Line: 22

                      assertTrue(error.getMessage().indexOf("parseLong error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseLong error, field : value") != -1);
    }

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

            

Reported by PMD.

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

              
public class DefaultJSONParserTest extends TestCase {

	public void test_double() {
		DefaultJSONParser parser = new DefaultJSONParser("3.4");
		parser.config(Feature.UseBigDecimal, false);
		Assert.assertEquals("3.4", parser.getInput());
		Assert.assertEquals(false, parser.isEnabled(Feature.UseBigDecimal));
		Object result = 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: 38

              		Assert.assertEquals(3.4D, result);
	}

	public void test_double_in_object() {
		DefaultJSONParser parser = new DefaultJSONParser("{\"double\":3.4}");
		parser.config(Feature.UseBigDecimal, false);
		Assert.assertEquals("{\"double\":3.4}", parser.getInput());
		Object result = parser.parse();
		Assert.assertEquals(3.4D, ((Map) result).get("double"));

            

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

              		Assert.assertEquals(3.4D, ((Map) result).get("double"));
	}

	public void test_error() {
		Exception error = null;
		try {
			DefaultJSONParser parser = new DefaultJSONParser("{\"name\":3]");
			parser.parse();
		} catch (Exception ex) {

            

Reported by PMD.

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

Line: 51

              		try {
			DefaultJSONParser parser = new DefaultJSONParser("{\"name\":3]");
			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: 57

              		Assert.assertNotNull(error);
	}

	public void test_error2() {
		Exception error = null;
		try {
			DefaultJSONParser parser = new DefaultJSONParser("ttr");
			parser.parse();
		} catch (Exception ex) {

            

Reported by PMD.

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

Line: 62

              		try {
			DefaultJSONParser parser = new DefaultJSONParser("ttr");
			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: 68

              		Assert.assertNotNull(error);
	}

	public void test_error3() {
		Exception error = null;
		try {
			DefaultJSONParser parser = new DefaultJSONParser("33");
			parser.parseObject(new HashMap());
		} catch (Exception ex) {

            

Reported by PMD.

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

Line: 73

              		try {
			DefaultJSONParser parser = new DefaultJSONParser("33");
			parser.parseObject(new HashMap());
		} 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: 79

              		Assert.assertNotNull(error);
	}

	public void test_error4() {
		Exception error = null;
		try {
			DefaultJSONParser parser = new DefaultJSONParser("]");
			parser.parse();
		} catch (Exception ex) {

            

Reported by PMD.

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

Line: 84

              		try {
			DefaultJSONParser parser = new DefaultJSONParser("]");
			parser.parse();
		} catch (Exception ex) {
			error = ex;
		}
		Assert.assertNotNull(error);
	}


            

Reported by PMD.