The following issues were found
src/test/java/com/alibaba/json/bvt/kotlin/Issue1750.java
4 issues
Line: 23
"}";
Object obj = JSON.parseObject(json, clazz);
String result = JSON.toJSONString(obj);
System.out.println(result);
assertEquals("{\"masterId\":\"1111111111111\",\"processId\":\"222222222222222\",\"taskId\":\"33333333333333\",\"taskName\":\"44444444444444\"}", result);
}
private static class ExtClassLoader extends ClassLoader {
Reported by PMD.
Line: 11
import java.io.InputStream;
public class Issue1750 extends TestCase {
public void test_user() throws Exception {
ExtClassLoader classLoader = new ExtClassLoader();
Class clazz = classLoader.loadClass("Issue1750_ProcessBO");
String json = "{\n" +
"\t\"masterId\": \"1111111111111\",\n" +
Reported by PMD.
Line: 24
Object obj = JSON.parseObject(json, clazz);
String result = JSON.toJSONString(obj);
System.out.println(result);
assertEquals("{\"masterId\":\"1111111111111\",\"processId\":\"222222222222222\",\"taskId\":\"33333333333333\",\"taskName\":\"44444444444444\"}", result);
}
private static class ExtClassLoader extends ClassLoader {
public ExtClassLoader() throws IOException {
Reported by PMD.
Line: 34
{
byte[] bytes;
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/Issue1750_ProcessBO.clazz");
bytes = IOUtils.toByteArray(is);
is.close();
super.defineClass("Issue1750_ProcessBO", bytes, 0, bytes.length);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1400/Issue1487.java
4 issues
Line: 8
import junit.framework.TestCase;
public class Issue1487 extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
model._id = 1001L;
model.id = 1002L;
String json = JSON.toJSONString(model);
Reported by PMD.
Line: 8
import junit.framework.TestCase;
public class Issue1487 extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
model._id = 1001L;
model.id = 1002L;
String json = JSON.toJSONString(model);
Reported by PMD.
Line: 14
model.id = 1002L;
String json = JSON.toJSONString(model);
assertEquals("{\"_id\":1001,\"id\":1002}", json);
Model model1 = JSON.parseObject(json, Model.class);
assertEquals(json, JSON.toJSONString(model1));
}
public static class Model {
Reported by PMD.
Line: 16
String json = JSON.toJSONString(model);
assertEquals("{\"_id\":1001,\"id\":1002}", json);
Model model1 = JSON.parseObject(json, Model.class);
assertEquals(json, JSON.toJSONString(model1));
}
public static class Model {
private Long _id;
private Long id;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1400/Issue1478.java
4 issues
Line: 8
import junit.framework.TestCase;
public class Issue1478 extends TestCase {
public void test_for_issue() throws Exception {
Model model = new Model();
model.md5 = "xxx";
String json = JSON.toJSONString(model);
assertEquals("{\"MD5\":\"xxx\"}", json);
Reported by PMD.
Line: 13
model.md5 = "xxx";
String json = JSON.toJSONString(model);
assertEquals("{\"MD5\":\"xxx\"}", json);
}
public static class Model {
@JSONField(name = "MD5")
private String md5;
Reported by PMD.
Line: 18
public static class Model {
@JSONField(name = "MD5")
private String md5;
public String getMD5() throws Exception {
return md5;
}
}
Reported by PMD.
Line: 20
@JSONField(name = "MD5")
private String md5;
public String getMD5() throws Exception {
return md5;
}
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/naming/ListCaseTest.java
4 issues
Line: 16
public void test_0() throws Exception {
String result = "{\"code\":\"SUCCESS\",\"msg\":\"success\",\"SUCCESS\":true,\"obj\":[\"10.55.251.213\"]}";
T4QueryResult t4TaskApiResult = JSON.parseObject(result, T4QueryResult.class);
System.out.println(JSON.toJSONString(t4TaskApiResult));
}
public static class Model {
public List<String> values;
Reported by PMD.
Line: 13
* Created by wenshao on 09/02/2017.
*/
public class ListCaseTest extends TestCase {
public void test_0() throws Exception {
String result = "{\"code\":\"SUCCESS\",\"msg\":\"success\",\"SUCCESS\":true,\"obj\":[\"10.55.251.213\"]}";
T4QueryResult t4TaskApiResult = JSON.parseObject(result, T4QueryResult.class);
System.out.println(JSON.toJSONString(t4TaskApiResult));
}
Reported by PMD.
Line: 13
* Created by wenshao on 09/02/2017.
*/
public class ListCaseTest extends TestCase {
public void test_0() throws Exception {
String result = "{\"code\":\"SUCCESS\",\"msg\":\"success\",\"SUCCESS\":true,\"obj\":[\"10.55.251.213\"]}";
T4QueryResult t4TaskApiResult = JSON.parseObject(result, T4QueryResult.class);
System.out.println(JSON.toJSONString(t4TaskApiResult));
}
Reported by PMD.
Line: 24
public List<String> values;
}
public static class T4QueryResult {
@JSONField(name = "OBJ")
private List<String> obj;
@JSONField(name = "MSG")
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/AmbiguousTest.java
4 issues
Line: 12
* Created by wenshao on 16/8/31.
*/
public class AmbiguousTest extends TestCase {
public void test_for_issue() throws Exception {
String text = "{\"items\":{\"id\":101}}";
Model model = JSON.parseObject(text, Model.class);
assertEquals(1, model.items.size());
}
Reported by PMD.
Line: 15
public void test_for_issue() throws Exception {
String text = "{\"items\":{\"id\":101}}";
Model model = JSON.parseObject(text, Model.class);
assertEquals(1, model.items.size());
}
public static class Model {
public List<Item> items;
}
Reported by PMD.
Line: 15
public void test_for_issue() throws Exception {
String text = "{\"items\":{\"id\":101}}";
Model model = JSON.parseObject(text, Model.class);
assertEquals(1, model.items.size());
}
public static class Model {
public List<Item> items;
}
Reported by PMD.
Line: 19
}
public static class Model {
public List<Item> items;
}
public static class Item {
public int id;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/AsmParserTest1.java
4 issues
Line: 13
public class AsmParserTest1 extends TestCase {
public void test_asm() throws Exception {
A a = JSON.parseObject("{\"f1\":123}", A.class);
Assert.assertEquals(123, a.getF1());
Assert.assertNotNull(a.getF2());
}
Reported by PMD.
Line: 15
public void test_asm() throws Exception {
A a = JSON.parseObject("{\"f1\":123}", A.class);
Assert.assertEquals(123, a.getF1());
Assert.assertNotNull(a.getF2());
}
public static class A {
Reported by PMD.
Line: 16
public void test_asm() throws Exception {
A a = JSON.parseObject("{\"f1\":123}", A.class);
Assert.assertEquals(123, a.getF1());
Assert.assertNotNull(a.getF2());
}
public static class A {
private int f1;
Reported by PMD.
Line: 19
Assert.assertNotNull(a.getF2());
}
public static class A {
private int f1;
private List<B> f2 = new ArrayList<B>();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1400/Issue1443.java
4 issues
Line: 9
import java.util.Date;
public class Issue1443 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"date\":\"3017-08-28T00:00:00+08:00\"}";
Model model = JSON.parseObject(json, Model.class);
}
Reported by PMD.
Line: 9
import java.util.Date;
public class Issue1443 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"date\":\"3017-08-28T00:00:00+08:00\"}";
Model model = JSON.parseObject(json, Model.class);
}
Reported by PMD.
Line: 11
public class Issue1443 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"date\":\"3017-08-28T00:00:00+08:00\"}";
Model model = JSON.parseObject(json, Model.class);
}
public static class Model {
public Date date;
Reported by PMD.
Line: 11
public class Issue1443 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"date\":\"3017-08-28T00:00:00+08:00\"}";
Model model = JSON.parseObject(json, Model.class);
}
public static class Model {
public Date date;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1400/Issue1425.java
4 issues
Line: 19
SerializerFeature.DisableCircularReferenceDetect
};
System.out.println(JSON.toJSONString(dicDomain, features));
}
public static class DicDomain {
private String code;
Reported by PMD.
Line: 8
import junit.framework.TestCase;
public class Issue1425 extends TestCase {
public void test_for_issue() throws Exception {
DicDomain dicDomain = new DicDomain();
dicDomain.setCode("A001");
dicDomain.setName("测试");
SerializerFeature[] features = new SerializerFeature[]{
Reported by PMD.
Line: 8
import junit.framework.TestCase;
public class Issue1425 extends TestCase {
public void test_for_issue() throws Exception {
DicDomain dicDomain = new DicDomain();
dicDomain.setCode("A001");
dicDomain.setName("测试");
SerializerFeature[] features = new SerializerFeature[]{
Reported by PMD.
Line: 21
System.out.println(JSON.toJSONString(dicDomain, features));
}
public static class DicDomain {
private String code;
private String name;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/AutoTypeCheckHandlerTest.java
4 issues
Line: 9
import junit.framework.TestCase;
public class AutoTypeCheckHandlerTest extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig config = new ParserConfig();
String str = "{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeCheckHandlerTest$Model\"}";
JSONException error = null;
try {
Reported by PMD.
Line: 19
} catch (JSONException ex) {
error = ex;
}
assertNotNull(error);
config.addAutoTypeCheckHandler(new ParserConfig.AutoTypeCheckHandler() {
@Override
public Class<?> handler(String typeName, Class<?> expectClass, int features) {
if ("com.alibaba.json.bvt.parser.autoType.AutoTypeCheckHandlerTest$Model".equals(typeName)) {
Reported by PMD.
Line: 13
ParserConfig config = new ParserConfig();
String str = "{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeCheckHandlerTest$Model\"}";
JSONException error = null;
try {
JSON.parse(str, config);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
Line: 13
ParserConfig config = new ParserConfig();
String str = "{\"@type\":\"com.alibaba.json.bvt.parser.autoType.AutoTypeCheckHandlerTest$Model\"}";
JSONException error = null;
try {
JSON.parse(str, config);
} catch (JSONException ex) {
error = ex;
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest7.java
4 issues
Line: 15
public class JSONCreatorTest7 extends TestCase {
public void test_create() throws Exception {
Entity entity = JSON.parseObject("{\"values\":[{}]}", Entity.class);
Assert.assertEquals(1, entity.values.size());
Assert.assertEquals(Value.class, entity.values.get(0).getClass());
}
Reported by PMD.
Line: 17
public void test_create() throws Exception {
Entity entity = JSON.parseObject("{\"values\":[{}]}", Entity.class);
Assert.assertEquals(1, entity.values.size());
Assert.assertEquals(Value.class, entity.values.get(0).getClass());
}
public static class Entity {
Reported by PMD.
Line: 18
public void test_create() throws Exception {
Entity entity = JSON.parseObject("{\"values\":[{}]}", Entity.class);
Assert.assertEquals(1, entity.values.size());
Assert.assertEquals(Value.class, entity.values.get(0).getClass());
}
public static class Entity {
Reported by PMD.
Line: 18
public void test_create() throws Exception {
Entity entity = JSON.parseObject("{\"values\":[{}]}", Entity.class);
Assert.assertEquals(1, entity.values.size());
Assert.assertEquals(Value.class, entity.values.get(0).getClass());
}
public static class Entity {
Reported by PMD.