The following issues were found

src/test/java/com/alibaba/json/bvt/bug/StackTraceElementTest2.java
2 issues
JUnit tests should include assert() or fail()
Design

Line: 9

              

public class StackTraceElementTest2 extends TestCase {
    public void test_stackTrace2() throws Exception {
        String text = "{\"@type\":\"java.lang.StackTraceElement\",\"className\":\"java.lang.Thread\",\"fileName\":\"Thread.java\",\"lineNumber\":1503,\"methodName\":\"getStackTrace\",\"nativeMethod\":false}";
        JSON.parseObject(text, StackTraceElement.class);
    }
}

            

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

              

public class StackTraceElementTest2 extends TestCase {
    public void test_stackTrace2() throws Exception {
        String text = "{\"@type\":\"java.lang.StackTraceElement\",\"className\":\"java.lang.Thread\",\"fileName\":\"Thread.java\",\"lineNumber\":1503,\"methodName\":\"getStackTrace\",\"nativeMethod\":false}";
        JSON.parseObject(text, StackTraceElement.class);
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_qianbi.java
2 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: 7

              import junit.framework.TestCase;

public class Bug_for_qianbi extends TestCase {
    public void test_for_bug() throws Exception {
        String json = "\n" +
                "[{\"a\":\"1A18810QBYZN5T3M3CH6K3\",\"r\":[\"44304\",\"103467\"]},{\"a\":\"1A188104CTUW5TXFGCJPDW\",\"r\":[\"24391\",\"56132\",\"44304\",\"15567\"]},{\"a\":\"1A18812GJ9P37TOGKPT8BQ\",\"r\":[\"24539\",\"44304\",\"56259\"]} ,{\"a\":\"1A188104CTUW5TXFGCJPDW\",\"r\":[\"24391\",\"44304\",\"15567\"]}]";

        JSON.parse(json);
    }

            

Reported by PMD.

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

Line: 7

              import junit.framework.TestCase;

public class Bug_for_qianbi extends TestCase {
    public void test_for_bug() throws Exception {
        String json = "\n" +
                "[{\"a\":\"1A18810QBYZN5T3M3CH6K3\",\"r\":[\"44304\",\"103467\"]},{\"a\":\"1A188104CTUW5TXFGCJPDW\",\"r\":[\"24391\",\"56132\",\"44304\",\"15567\"]},{\"a\":\"1A18812GJ9P37TOGKPT8BQ\",\"r\":[\"24539\",\"44304\",\"56259\"]} ,{\"a\":\"1A188104CTUW5TXFGCJPDW\",\"r\":[\"24391\",\"44304\",\"15567\"]}]";

        JSON.parse(json);
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/Bug89.java
2 issues
In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions
Design

Line: 15

                      try {
            String s = "{\"a\":з」∠)_,\"}";
            JSON.parseObject(s);
            fail("Expect JSONException");
        } catch (JSONException e) {
            // good
        }
    }
}

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 16

                          String s = "{\"a\":з」∠)_,\"}";
            JSON.parseObject(s);
            fail("Expect JSONException");
        } catch (JSONException e) {
            // good
        }
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_sankun.java
2 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 10

              

public class Bug_for_sankun extends TestCase {
    public void test_sankun() throws Exception {
        PushMsg bean = new PushMsg();
        JSON.toJSONString(bean);
    }
}

            

Reported by PMD.

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

Line: 10

              

public class Bug_for_sankun extends TestCase {
    public void test_sankun() throws Exception {
        PushMsg bean = new PushMsg();
        JSON.toJSONString(bean);
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_smoothrat2.java
2 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 10

              
public class Bug_for_smoothrat2 extends TestCase {

    public void test_0() throws Exception {
        long millis = System.currentTimeMillis();
        
        java.sql.Time time = new java.sql.Time(millis);
        Entity entity = new Entity();
        

            

Reported by PMD.

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

Line: 22

                      Assert.assertEquals("{\"value\":" + millis + "}", text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(time, entity2.getValue());
        
    }

    public static class Entity {


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/ServiceLoaderTest.java
2 issues
JUnit tests should include assert() or fail()
Design

Line: 9

              

public class ServiceLoaderTest extends TestCase {
    public void test_0() throws Exception {
        new ServiceLoader();
    }
}

            

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

              

public class ServiceLoaderTest extends TestCase {
    public void test_0() throws Exception {
        new ServiceLoader();
    }
}

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/serializer/JSONAwareSerializer.java
2 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 39

                      }

        JSONAware aware = (JSONAware) object;
        out.write(aware.toJSONString());
    }
}

            

Reported by PMD.

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

Line: 39

                      }

        JSONAware aware = (JSONAware) object;
        out.write(aware.toJSONString());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/BuilderTest.java
2 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 9

              import com.alibaba.fastjson.JSON;

public class BuilderTest extends TestCase {
	public void test_builder() throws Exception {
		RainbowStats rainbowStats = JSON.parseObject("{\"id\":33}", RainbowStats.class);
		Assert.assertEquals(33, rainbowStats.getId());
	}
	
	private static class RainbowStats {

            

Reported by PMD.

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

Line: 11

              public class BuilderTest extends TestCase {
	public void test_builder() throws Exception {
		RainbowStats rainbowStats = JSON.parseObject("{\"id\":33}", RainbowStats.class);
		Assert.assertEquals(33, rainbowStats.getId());
	}
	
	private static class RainbowStats {
		private int id;
		private String name;

            

Reported by PMD.

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

    public void test_get() throws Exception {
        JSONObject obj = JSON.parseObject("{id:123}");
        Assert.assertEquals(123, obj.getObject("id", Object.class));
    }

    public static interface VO {

            

Reported by PMD.

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

Line: 15

              
    public void test_get() throws Exception {
        JSONObject obj = JSON.parseObject("{id:123}");
        Assert.assertEquals(123, obj.getObject("id", Object.class));
    }

    public static interface VO {
        @JSONField()
        int getId();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_typeReference.java
2 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 12

              

public class Bug_for_typeReference extends TestCase {
    public void test_0 () throws Exception {
        String text = "[]";
        JSON.parseObject(text, new TypeReference<List<String>>(){}.getType());
    }
}

            

Reported by PMD.

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

Line: 12

              

public class Bug_for_typeReference extends TestCase {
    public void test_0 () throws Exception {
        String text = "[]";
        JSON.parseObject(text, new TypeReference<List<String>>(){}.getType());
    }
}

            

Reported by PMD.